示例#1
0
        public static void DrawBorder(DrawingContext dc, CoreRectRange Range, double BorderWidth, Brush BorderColor, int BorderStyle)
        {
            Brush lb          = Brushes.CadetBlue;
            Pen   lp          = new Pen(BorderColor, BorderWidth);
            Point TopLeft     = Range.TopLeft;
            Point TopRight    = new Point(Range.BottomRight.X, Range.TopLeft.Y);
            Point BottomRight = Range.BottomRight;
            Point BottomLeft  = new Point(Range.TopLeft.X, Range.BottomRight.Y);

            switch (BorderStyle)
            {
            case BorderStyle_StraightLine:
                DrawLine(dc, TopLeft, TopRight, BorderWidth, BorderColor, LineStyle_StraightLine);
                DrawLine(dc, TopLeft, BottomLeft, BorderWidth, BorderColor, LineStyle_StraightLine);
                DrawLine(dc, BottomRight, TopRight, BorderWidth, BorderColor, LineStyle_StraightLine);
                DrawLine(dc, BottomRight, BottomLeft, BorderWidth, BorderColor, LineStyle_StraightLine);
                break;

            case BorderStyle_MultipleSegment:
                DrawLine(dc, TopLeft, TopRight, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                DrawLine(dc, TopLeft, BottomLeft, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                DrawLine(dc, BottomRight, TopRight, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                DrawLine(dc, BottomRight, BottomLeft, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                break;
            }
        }
 public ClassUMLObject(CoreRectRange Range)
     : base(Range)
 {
     TitleText = "UMLClass(" + ID + ")";
     MemberText = "Members:";
     MethodText = "Methods:";
 }
示例#3
0
        public static void DrawText(DrawingContext dc, String Text, CoreRectRange Range, Brush TextColor, int FontSize)
        {
            FormattedText formattedText = new FormattedText(Text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), FontSize, TextColor);

            formattedText.MaxTextHeight = Range.Height;
            formattedText.MaxTextWidth  = Range.Width;
            dc.DrawText(formattedText, Range.TopLeft);
        }
 public void SetChildrens(List<BaseUMLObject> Objects)
 {
     Childrens = Objects;
     List<CoreRectRange> Ranges = new List<CoreRectRange>();
     foreach (BaseUMLObject obj in Objects)
     {
         Ranges.Add(obj.getRange());
     }
     Range = new CoreRectRange(Ranges);
 }
示例#5
0
        //enum GraphicDetail {DrawID,DrawText,DrawBorder,DrawBorder,DrawObject}


        public BaseUMLObject(CoreRectRange _Range)
            : base()
        {
            Range = _Range;
            Ports = new List<ConnectionPort>();
            Ports.Add(new ConnectionPort(this,ConnectionPort.Location.TopConnectionPort));
            Ports.Add(new ConnectionPort(this, ConnectionPort.Location.RightConnectionPort));
            Ports.Add(new ConnectionPort(this, ConnectionPort.Location.LeftConnectionPort));
            Ports.Add(new ConnectionPort(this, ConnectionPort.Location.BottomConnectionPort));
        }
示例#6
0
 public virtual void Move(Point Location, int Type = Move_Normal)
 {
     if (Type == Move_Normal)
     {
         Range = new CoreRectRange(Location.X, Location.Y, Location.X + Range.Width, Location.Y+Range.Height);
     }
     else if(Type == Move_Relative)
     {
         Point p = new Point(Range.TopLeft.X + Location.X, Range.TopLeft.Y + Location.Y);
         Range = new CoreRectRange(p.X,p.Y , p.X+Range.Width, p.Y+Range.Height);
     }
 }
 public override void Draw(DrawingContext dc)
 {
     double BorderWidth = 1;
     foreach (BaseUMLObject obj in Childrens)
         obj.Draw(dc);
     CoreDraw.DrawBorder(dc, Range, BorderWidth, Brushes.Red, CoreDraw.BorderStyle_MultipleSegment);
     CoreRectRange TextRange = new CoreRectRange(Range.TopLeft.X + BorderWidth * 1.5, Range.TopLeft.Y + BorderWidth * 1.5 - 30, Range.BottomRight.X - BorderWidth * 1.5, Range.TopLeft.Y + Range.Height / 3 - BorderWidth * 1.5 - 30);
     CoreDraw.DrawText(dc, "UMLGroup(" + ID + ")", TextRange, Brushes.Black, 12);
     if (Selected)
         foreach (ConnectionPort Port in Ports)
             Port.Draw(dc);
     return;
 }
 public GroupUMLObject(CoreRectRange Range) : base(Range)
 {
     
 }
 public override void Draw(DrawingContext dc)
 {
     const double BorderWidth = 3;
     double Width = Range.Width;
     double Height = Range.Height;
     Point Title_Top_LeftPoint = new Point(Range.TopLeft.X, Range.TopLeft.Y);
     Point Title_Top_RightPoint = new Point(Range.BottomRight.X, Range.TopLeft.Y);
     Point Title_Member_LeftPoint = new Point(Range.TopLeft.X,Range.TopLeft.Y+Height*0.25);
     Point Title_Member_RightPoint = new Point(Range.BottomRight.X,Range.TopLeft.Y+Height*0.25);
     Point Member_Method_LeftPoint = new Point(Range.TopLeft.X,Range.TopLeft.Y+Height*0.65);
     Point Member_Method_RightPoint = new Point(Range.BottomRight.X,Range.TopLeft.Y+Height*0.65);
     Point Method_Bottom_LeftPoint = new Point(Range.TopLeft.X, Range.TopLeft.Y + Height);
     Point Method_Bottom_RightPoint = new Point(Range.BottomRight.X, Range.TopLeft.Y + Height);
     //畫出整個外觀
     CoreDraw.DrawRect(dc, Range, Brushes.AliceBlue);
     //畫出第一條分隔線
     CoreDraw.DrawLine(dc, Title_Member_LeftPoint, Title_Member_RightPoint, BorderWidth, Brushes.Black, CoreDraw.LineStyle_StraightLine);
     //畫出第二條分隔線
     CoreDraw.DrawLine(dc, Member_Method_LeftPoint, Member_Method_RightPoint, BorderWidth, Brushes.Black, CoreDraw.LineStyle_StraightLine);
     //畫出Title
     CoreRectRange TitleRange = new CoreRectRange(Title_Top_LeftPoint.X + BorderWidth , Title_Top_LeftPoint.Y + BorderWidth , Title_Member_RightPoint.X - BorderWidth, Title_Member_RightPoint.Y - BorderWidth );
     //CoreDraw.DrawBorder(dc, TitleRange, 2, Brushes.Red, CoreDraw.BorderStyle_StraightLine);
     CoreDraw.DrawText(dc, TitleText, TitleRange, Brushes.Black, 12);
     //畫出Member
     CoreRectRange MembersRange = new CoreRectRange(Title_Member_LeftPoint.X + BorderWidth, Title_Member_LeftPoint.Y + BorderWidth , Member_Method_RightPoint.X - BorderWidth , Member_Method_RightPoint.Y - BorderWidth );
     //CoreDraw.DrawBorder(dc, MembersRange, 2, Brushes.Red, CoreDraw.BorderStyle_StraightLine);
     CoreDraw.DrawText(dc, MemberText, MembersRange, Brushes.Black, 12);
     //畫出Methods
     CoreRectRange Methodsange = new CoreRectRange(Member_Method_LeftPoint.X + BorderWidth , Member_Method_LeftPoint.Y + BorderWidth , Method_Bottom_RightPoint.X - BorderWidth , Method_Bottom_RightPoint.Y - BorderWidth );
     //CoreDraw.DrawBorder(dc, Methodsange, 2, Brushes.Red, CoreDraw.BorderStyle_StraightLine);
     CoreDraw.DrawText(dc, MethodText, Methodsange, Brushes.Black, 12);
     //劃出外框
     CoreDraw.DrawBorder(dc, Range, BorderWidth, Brushes.Black, CoreDraw.BorderStyle_StraightLine);
     //畫出選擇點
     if (Selected)
         foreach (ConnectionPort Port in Ports)
             Port.Draw(dc);
     return;
 }
 public override bool Inside(CoreRectRange r)
 {
     if (Range.TopLeft.X > r.TopLeft.X && Range.TopLeft.Y > r.TopLeft.Y && Range.BottomRight.X < r.BottomRight.X && Range.BottomRight.Y < r.BottomRight.Y)
         return true;
     return false;
 }
示例#11
0
 public static void DrawRect(DrawingContext dc, CoreRectRange Range, Brush RectColor)
 {
     dc.DrawRectangle(RectColor, new Pen(), new Rect(Range.TopLeft, Range.BottomRight));
 }
示例#12
0
        public static void DrawBorder(DrawingContext dc, CoreRectRange Range, double BorderWidth, Brush BorderColor, int BorderStyle)
        {
            Brush lb = Brushes.CadetBlue;
            Pen lp = new Pen(BorderColor, BorderWidth);
            Point TopLeft = Range.TopLeft;
            Point TopRight = new Point(Range.BottomRight.X, Range.TopLeft.Y);
            Point BottomRight = Range.BottomRight;
            Point BottomLeft = new Point(Range.TopLeft.X, Range.BottomRight.Y);
            switch(BorderStyle)
            {
                case BorderStyle_StraightLine:
                    DrawLine(dc, TopLeft, TopRight, BorderWidth, BorderColor, LineStyle_StraightLine);
                    DrawLine(dc, TopLeft, BottomLeft, BorderWidth, BorderColor, LineStyle_StraightLine);
                    DrawLine(dc, BottomRight, TopRight, BorderWidth, BorderColor, LineStyle_StraightLine);
                    DrawLine(dc, BottomRight, BottomLeft, BorderWidth, BorderColor, LineStyle_StraightLine);
                    break;
                
                case BorderStyle_MultipleSegment:
                    DrawLine(dc, TopLeft, TopRight, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                    DrawLine(dc, TopLeft, BottomLeft, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                    DrawLine(dc, BottomRight, TopRight, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                    DrawLine(dc, BottomRight, BottomLeft, BorderWidth, BorderColor, LineStyle_MultipleSegment);
                    break;
            }

        }
示例#13
0
 public static void DrawRect(DrawingContext dc, CoreRectRange Range, Brush RectColor)
 {
     dc.DrawRectangle(RectColor, new Pen(), new Rect(Range.TopLeft, Range.BottomRight));
 }
示例#14
0
 public CoreRectRange getRange()
 {
     Point Center = getCenter();
     CoreRectRange Range = new CoreRectRange(Center.X - Width / 2, Center.Y - Height / 2, Center.X + Width / 2, Center.Y + Height / 2);
     return Range;
 }
 public override bool Inside(CoreRectRange r)
 {
     return false;
 }
 public UseCaseUMLObject(CoreRectRange Range)
     : base(Range)
 {
     Name = "UMLUseCase(" + ID + ")";
 }
示例#17
0
 public static void DrawText(DrawingContext dc, String Text, CoreRectRange Range, Brush TextColor, int FontSize)
 {
     FormattedText formattedText = new FormattedText(Text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), FontSize, TextColor);
     formattedText.MaxTextHeight = Range.Height;
     formattedText.MaxTextWidth = Range.Width;
     dc.DrawText(formattedText, Range.TopLeft);
 }
 public override void Draw(DrawingContext dc)
 {
     const double BorderWidth = 3;
     double Width = Range.Width;
     double Height = Range.Height;
     Point Center = new Point((Range.TopLeft.X + Range.BottomRight.X) / 2, (Range.TopLeft.Y + Range.BottomRight.Y) / 2);
     double a = Math.Max(Range.Height, Range.Width) / 2;  //長邊半徑
     double b = Math.Min(Range.Height, Range.Width) / 2;  //短邊半徑
     double c = 2 * b * b / a;  //計算正焦距
     //s+w=2a, (2c)^2+w^2=s^2 我們現在要求垂直於左焦點的線長w*2,以及c*2為內接四邊形的長和寬
     //s^2-w^2=(2c)^2 --> (s+w)(s-w)=(2c)^2 --> (s-w)=(2c)^2/(s+w) --> (s-w)=(2c)^2/(2a) --> (s-w)=2c^2/a --> 2w = 2*a - ((2*c*c)/a)
     double w = (2 * a - ((2 * c * c) / a)) / 2;
     Point InsideRectTopLeft = new Point(Center.X - c, Center.Y - w);
     Point InsideRectBottomRight = new Point(Center.X + c, Center.Y + w);
     //畫出整個外觀
     CoreDraw.DrawEllipse(dc, Center, Width, Height, Brushes.AliceBlue);
     //畫出Title
     CoreRectRange TitleRange = new CoreRectRange(InsideRectTopLeft, InsideRectBottomRight);
     //CoreDraw.DrawBorder(dc, TitleRange, 2, Brushes.Red, CoreDraw.BorderStyle_StraightLine);
     CoreDraw.DrawText(dc, Name, TitleRange, Brushes.Black, 12);
     //劃出外框
     CoreDraw.DrawEllipseBorder(dc, Center, Width, Height, BorderWidth, Brushes.Black);
     //畫出選擇點
     if (Selected)
         foreach (ConnectionPort Port in Ports)
             Port.Draw(dc);
     return;
 }
示例#19
0
 public abstract bool Inside(CoreRectRange r);