Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsState st = e.Graphics.Save();
            ActiveDrawing ei = PortOwner as ActiveDrawing;
            Point         p0 = ei.Center;
            Point         p1 = this.Center;
            double        a;

            if (p0.Y == p1.Y)
            {
                if (p1.X > p0.X)
                {
                    a = -Math.PI / 2.0;
                }
                else
                {
                    a = Math.PI / 2.0;
                }
            }
            else
            {
                a = -Math.Atan2((double)(p1.X - p0.X), ((double)(p1.Y - p0.Y)));
            }
            //move to the center of this port icon. (0,0) co-ordinates is at the left-top of the port icon.
            e.Graphics.TranslateTransform(this.Size.Width / 2, this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            //rotate
            e.Graphics.RotateTransform((float)(a * 180.0 / Math.PI));
            //move to the left-top corner
            e.Graphics.TranslateTransform(-this.Size.Width / 2, -this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            //do the drawing
            VplDrawing.DrawOutArrow(e.Graphics, _drawBrush, this.Size, enumPositionType.Bottom);
            //restore the transformations
            e.Graphics.Restore(st);
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsState st = e.Graphics.Save();
            ActiveDrawing ei = PortOwner as ActiveDrawing;
            Point         p0 = ei.Center;
            Point         p1 = this.Center;
            double        a;

            if (p0.Y == p1.Y)
            {
                if (p1.X > p0.X)
                {
                    a = -Math.PI / 2.0;
                }
                else
                {
                    a = Math.PI / 2.0;
                }
            }
            else
            {
                a = -Math.Atan2((double)(p1.X - p0.X), ((double)(p1.Y - p0.Y)));
            }
            e.Graphics.TranslateTransform(this.Size.Width / 2, this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            e.Graphics.RotateTransform((float)(a * 180.0 / Math.PI));
            e.Graphics.TranslateTransform(-this.Size.Width / 2, -this.Size.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            VplDrawing.DrawInArrow(e.Graphics, _drawBrush, this.Size, enumPositionType.Bottom);
            e.Graphics.Restore(st);
        }
 protected override void OnPaint(PaintEventArgs e)
 {
     VplDrawing.DrawInArrow(e.Graphics, _drawBrush, this.Size, this.PositionType);
 }