Example #1
0
        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);
        }
Example #2
0
        public override List <ConnectionPoint> GetConnectionPoints()
        {
            List <ConnectionPoint> connectionPoints = new List <ConnectionPoint>();

            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.LeftMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.RightMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.TopRightCorner()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomRightCorner()));

            return(connectionPoints);
        }
Example #3
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);
        }
Example #4
0
        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();
        }