开发者

WPF: How to draw UML interface relationship arrow?

I want to draw the following arrow type:

WPF: How to draw UML interface relationship arrow?

How can I do that?

I have already a similar arrow:

private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            double theta = Math.Atan2(Y1 - Y2, X1 - X2);
            double sint = Math.Sin(theta);
            double cost = Math.Cos(theta);

            Point pt1 = new Point(X1, this.Y1);
            Point pt2 = new Point(X2, this.Y2);

            Point pt3 = new Point(
                X2 + (HeadWidth * cost - HeadHeight * sint),
                Y2 + (HeadWidth * sint + HeadHeight * cost));

            Point pt4 = new Point(
                X2 + (HeadWidth * cost + HeadHeight * sint),
                Y2 - (HeadHeight * cost - HeadWidth * sint));

            context.BeginFigure(pt1, true, false);
            context.LineTo(pt2, true, true);
            context.LineTo(pt3, true, true);
            context.LineTo(pt4, true, true);
            context.LineTo(pt2, t开发者_StackOverflow社区rue, true);
        }

How can I change so that this isn't an arrow but a circle?


Use an Ellipse shape and a vertical Line (with HorizontalAlignment set to center) in a vertical StackPanel. That is:

  <StackPanel>   
    <Ellipse HorizontalAlignment="Center" Height="10" Width="10" 
             Stroke="Black" />
    <Line HorizontalAlignment="Center" X1="0" Y1="0" X2="0" Y2="10" 
             Stroke="Black" />
    <Rectangle Width="40" Height="20" Stroke="Black"/>
  </StackPanel>

I also threw a Rectangle in there to represent the class that implements the interface.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜