public virtual List <ConnectionPoint> GetConnectionPoints()
        {
            List <ConnectionPoint> connectionPoints = new List <ConnectionPoint>();

            if (HasCornerConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.TopLeft, DisplayRectangle.TopLeftCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.TopRight, DisplayRectangle.TopRightCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomLeft, DisplayRectangle.BottomLeftCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomRight, DisplayRectangle.BottomRightCorner()));
            }

            if (HasCenterConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.LeftMiddle, DisplayRectangle.LeftMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.RightMiddle, DisplayRectangle.RightMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.TopMiddle, DisplayRectangle.TopMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomMiddle, DisplayRectangle.BottomMiddle()));
            }

            if (HasLeftRightConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.LeftMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.RightMiddle()));
            }

            if (HasTopBottomConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.TopMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomMiddle()));
            }

            return(connectionPoints);
        }
        public virtual List <ShapeAnchor> GetAnchors()
        {
            // draw anchors
            List <ShapeAnchor> anchors = new List <ShapeAnchor>();
            AnchorBox          r;
            int anchorSize = 6;

            if (HasCornerAnchors) // tai cac canh
            {
                Point newPoint = new Point();
                newPoint = DisplayRectangle.TopLeft();
                r        = new AnchorBox(DisplayRectangle.TopLeft(), anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopLeft, r, Cursors.SizeNWSE));

                newPoint = DisplayRectangle.TopRight();
                newPoint.Offset(-anchorWidthHeight, 0);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopRight, r, Cursors.SizeNESW));

                newPoint = DisplayRectangle.BottomLeft();
                newPoint.Offset(0, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomLeft, r, Cursors.SizeNESW));

                newPoint = DisplayRectangle.BottomRight();
                newPoint.Offset(-anchorWidthHeight, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomRight, r, Cursors.SizeNWSE));
            }

            if (HasCenterAnchors || HasLeftRightAnchors) // tai trai va phai
            {
                Point newPoint = DisplayRectangle.LeftMiddle();
                newPoint.Offset(0, -anchorWidthHeight / 2);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.LeftMiddle, r, Cursors.SizeWE));

                newPoint = DisplayRectangle.RightMiddle();
                newPoint.Offset(-anchorWidthHeight, -anchorWidthHeight / 2);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.RightMiddle, r, Cursors.SizeWE));
            }

            if (HasCenterAnchors || HasTopBottomAnchors) // tai vi tri tren va duoi
            {
                Point newPoint = new Point();
                newPoint = DisplayRectangle.TopMiddle();
                newPoint.Offset(-anchorWidthHeight / 2, 0);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopMiddle, r, Cursors.SizeNS));
                newPoint = DisplayRectangle.BottomMiddle();
                newPoint.Offset(-anchorWidthHeight / 2, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomMiddle, r, Cursors.SizeNS));
            }

            return(anchors);
        }
Exemple #3
0
        public override List <ConnectionPoint> GetConnectionPoints()
        {
            List <ConnectionPoint> connectionPoints = new List <ConnectionPoint>();

            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.TopMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.BottomLeftCorner()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomRightCorner()));

            return(connectionPoints);
        }
Exemple #4
0
        public override void Draw(Graphics gr)
        {
            Pen pen = (Pen)BorderPen.Clone();

            if (ShowLineAsSelected)
            {
                pen.Color = pen.Color.ToArgb() == Color.Red.ToArgb() ? Color.Blue : Color.Red;
            }

            gr.DrawLine(pen, DisplayRectangle.TopMiddle(), DisplayRectangle.BottomMiddle());
            pen.Dispose();

            base.Draw(gr);
        }
Exemple #5
0
 public override void Draw()
 {
     if (ShowConnectorAsSelected)
     {
         verticalLine.Stroke = new SolidColorBrush(Colors.Red);
     }
     else
     {
         verticalLine.Stroke = new SolidColorBrush(Colors.Black);
     }
     verticalLine.X1 = DisplayRectangle.TopMiddle().X;
     verticalLine.Y1 = DisplayRectangle.TopMiddle().Y;
     verticalLine.X2 = DisplayRectangle.BottomMiddle().X;
     verticalLine.Y2 = DisplayRectangle.BottomMiddle().Y;
     base.Draw();
 }
Exemple #6
0
        public virtual List <ShapeAnchor> GetAnchors()
        {
            List <ShapeAnchor> anchors = new List <ShapeAnchor>();
            Rectangle          r;
            Size anchorSize = new Size(anchorWidthHeight, anchorWidthHeight);

            if (HasCornerAnchors)
            {
                r = new Rectangle(DisplayRectangle.TopLeftCorner(), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.TopLeft, r, Cursors.SizeNWSE));
                r = new Rectangle(DisplayRectangle.TopRightCorner().Move(-anchorWidthHeight, 0), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.TopRight, r, Cursors.SizeNESW));
                r = new Rectangle(DisplayRectangle.BottomLeftCorner().Move(0, -anchorWidthHeight), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.BottomLeft, r, Cursors.SizeNESW));
                r = new Rectangle(DisplayRectangle.BottomRightCorner().Move(-anchorWidthHeight, -anchorWidthHeight), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.BottomRight, r, Cursors.SizeNWSE));
            }

            if (HasCenterAnchors || HasLeftRightAnchors)
            {
                r = new Rectangle(DisplayRectangle.LeftMiddle().Move(0, -anchorWidthHeight / 2), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.LeftMiddle, r, Cursors.SizeWE));
                r = new Rectangle(DisplayRectangle.RightMiddle().Move(-anchorWidthHeight, -anchorWidthHeight / 2), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.RightMiddle, r, Cursors.SizeWE));
            }

            if (HasCenterAnchors || HasTopBottomAnchors)
            {
                r = new Rectangle(DisplayRectangle.TopMiddle().Move(-anchorWidthHeight / 2, 0), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.TopMiddle, r, Cursors.SizeNS));
                r = new Rectangle(DisplayRectangle.BottomMiddle().Move(-anchorWidthHeight / 2, -anchorWidthHeight), anchorSize);
                anchors.Add(new ShapeAnchor(GripType.BottomMiddle, r, Cursors.SizeNS));
            }

            return(anchors);
        }
        public virtual void DrawText(Graphics gr)
        {
            SizeF size  = gr.MeasureString(Text, TextFont);
            Brush brush = new SolidBrush(TextColor);
            Point textpos;

            // TextRenderer is terrible when font is bolded.  Not sure why.
            // Would be great to use this, but the rendering is so bad, I won't.

            // Some info here:
            // http://stackoverflow.com/questions/9038125/asp-net-textrenderer-drawtext-awful-text-images
            //gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; // <-- important!
            //gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            //gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            //gr.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            //gr.TextContrast = 0;
            //TextFormatFlags flags = TextFormatFlags.Right | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;
            //TextRenderer.DrawText(gr, Text, TextFont, DisplayRectangle, TextColor, flags);

            switch (TextAlign)
            {
            case ContentAlignment.TopLeft:
                textpos = DisplayRectangle.TopLeftCorner().Move(5, 5);
                break;

            case ContentAlignment.TopCenter:
                textpos = DisplayRectangle.TopMiddle().Move((int)(-size.Width / 2), 5);
                break;

            case ContentAlignment.TopRight:
                textpos = DisplayRectangle.TopRightCorner().Move((int)(-(size.Width + 5)), 5);
                break;

            case ContentAlignment.MiddleLeft:
                textpos = DisplayRectangle.LeftMiddle().Move(5, (int)(-size.Height / 2));
                break;

            case ContentAlignment.MiddleCenter:
                textpos = DisplayRectangle.Center().Move((int)(-size.Width / 2), (int)(-size.Height / 2));
                break;

            case ContentAlignment.MiddleRight:
                textpos = DisplayRectangle.RightMiddle().Move((int)(-(size.Width + 5)), (int)(-size.Height / 2));
                break;

            case ContentAlignment.BottomLeft:
                textpos = DisplayRectangle.BottomLeftCorner().Move(5, (int)-(size.Height + 5));
                break;

            case ContentAlignment.BottomCenter:
                textpos = DisplayRectangle.BottomMiddle().Move((int)(-size.Width / 2), (int)-(size.Height + 5));
                break;

            case ContentAlignment.BottomRight:
                textpos = DisplayRectangle.BottomRightCorner().Move((int)(-(size.Width + 5)), (int)-(size.Height + 5));
                break;

            default:            // middle center
                textpos = DisplayRectangle.Center().Move((int)(-size.Width / 2), (int)(-size.Height / 2));
                break;
            }

            gr.DrawString(Text, TextFont, brush, textpos);
            brush.Dispose();
        }