Beispiel #1
0
        public virtual IShapeHandle CreateBoundingHandle(Shapes.DiagramShape obj, Shapes.DiagramShape selectedObj)
        {
            IShapeHandle handle1 = obj.CreateBoundingHandle();

            if (handle1 == null)
            {
                return(null);
            }
            handle1.SelectedObject = selectedObj;
            Shapes.DiagramShape obj1 = handle1.DiagramShape;
            if (obj1 == null)
            {
                return(null);
            }
            obj1.Selectable = false;
            Shapes.DiagramGraph shape1 = obj1 as Shapes.DiagramGraph;
            if (shape1 != null)
            {
                Color       color1 = Color.LightGray;
                DiagramView view1  = this.View;
                if (view1 != null)
                {
                    if (this.Focused)
                    {
                        if ((this.Primary != null) && (this.Primary.SelectionObject == obj))
                        {
                            color1 = view1.PrimarySelectionColor;
                        }
                        else
                        {
                            color1 = view1.SecondarySelectionColor;
                        }
                    }
                    else
                    {
                        color1 = view1.NoFocusSelectionColor;
                    }
                }
                float single1 = view1.BoundingHandlePenWidth;
                float single2 = (single1 == 0f) ? 0f : (single1 / view1.WorldScale.Width);
                if (((this.myBoundingHandlePen == null) || (Shapes.DiagramGraph.GoPenInfo.GetPenColor(this.myBoundingHandlePen, color1) != color1)) || (this.myBoundingHandlePen.Width != single2))
                {
                    this.myBoundingHandlePen = new Pen(color1, single2);
                }
                shape1.Pen   = this.myBoundingHandlePen;
                shape1.Brush = null;
            }
            this.AddHandle(obj, handle1);
            return(handle1);
        }
Beispiel #2
0
        public virtual IShapeHandle CreateResizeHandle(Shapes.DiagramShape obj, Shapes.DiagramShape selectedObj, PointF loc, int handleid, bool filled)
        {
            IShapeHandle handle1 = obj.CreateResizeHandle(handleid);

            if (handle1 == null)
            {
                return(null);
            }
            handle1.HandleID       = handleid;
            handle1.SelectedObject = selectedObj;
            Shapes.DiagramShape obj1 = handle1.DiagramShape;
            if (obj1 == null)
            {
                return(null);
            }
            DiagramView view1 = this.View;
            SizeF       ef1   = obj1.Size;

            if ((ef1.Width <= 0f) || (ef1.Height <= 0f))
            {
                if (view1 != null)
                {
                    ef1 = view1.ResizeHandleSize;
                }
                else
                {
                    ef1 = new SizeF(6f, 6f);
                }
            }
            if (view1 != null)
            {
                ef1.Width  /= view1.WorldScale.Width;
                ef1.Height /= view1.WorldScale.Height;
            }
            obj1.Bounds = new RectangleF(loc.X - (ef1.Width / 2f), loc.Y - (ef1.Height / 2f), ef1.Width, ef1.Height);
            if (handleid == 0)
            {
                obj1.Selectable = false;
            }
            else
            {
                obj1.Selectable = true;
            }
            Shapes.DiagramGraph shape1 = obj1 as Shapes.DiagramGraph;
            if (shape1 != null)
            {
                Color color1 = Color.LightGray;
                if (view1 != null)
                {
                    if (this.Focused)
                    {
                        if ((this.Primary != null) && (this.Primary.SelectionObject == obj))
                        {
                            color1 = view1.PrimarySelectionColor;
                        }
                        else
                        {
                            color1 = view1.SecondarySelectionColor;
                        }
                    }
                    else
                    {
                        color1 = view1.NoFocusSelectionColor;
                    }
                }
                if (filled)
                {
                    float single1 = view1.ResizeHandlePenWidth;
                    float single2 = (single1 == 0f) ? 0f : (single1 / view1.WorldScale.Width);
                    if (((this.myResizeHandlePen == null) || (Shapes.DiagramGraph.GoPenInfo.GetPenColor(this.myResizeHandlePen, this.myResizeHandlePenColor) != this.myResizeHandlePenColor)) || (this.myResizeHandlePen.Width != single2))
                    {
                        this.myResizeHandlePen = new Pen(this.myResizeHandlePenColor, single2);
                    }
                    shape1.Pen = this.myResizeHandlePen;
                    if ((this.myResizeHandleBrush == null) || (this.myResizeHandleBrush.Color != color1))
                    {
                        this.myResizeHandleBrush = new SolidBrush(color1);
                    }
                    shape1.Brush = this.myResizeHandleBrush;
                }
                else
                {
                    float single3 = view1.ResizeHandlePenWidth;
                    float single4 = (single3 == 0f) ? 0f : ((single3 + 1f) / view1.WorldScale.Width);
                    if (((this.myResizeHandlePen == null) || (Shapes.DiagramGraph.GoPenInfo.GetPenColor(this.myResizeHandlePen, color1) != color1)) || (this.myResizeHandlePen.Width != single4))
                    {
                        this.myResizeHandlePen = new Pen(color1, single4);
                    }
                    shape1.Pen   = this.myResizeHandlePen;
                    shape1.Brush = null;
                }
            }
            this.AddHandle(obj, handle1);
            return(handle1);
        }
Beispiel #3
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            PointF     tf9;
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;

            PointF[] tfArray1 = this.getPoints();
            PointF   tf1      = DiagramGraph.ExpandPointOnEdge(tfArray1[0], ef1, single1);
            PointF   tf2      = DiagramGraph.ExpandPointOnEdge(tfArray1[1], ef1, single1);
            PointF   tf3      = DiagramGraph.ExpandPointOnEdge(tfArray1[2], ef1, single1);
            PointF   tf4      = DiagramGraph.ExpandPointOnEdge(tfArray1[3], ef1, single1);
            PointF   tf5      = DiagramGraph.ExpandPointOnEdge(tfArray1[4], ef1, single1);
            PointF   tf6      = DiagramGraph.ExpandPointOnEdge(tfArray1[5], ef1, single1);
            PointF   tf7      = DiagramGraph.ExpandPointOnEdge(tfArray1[6], ef1, single1);
            PointF   tf8      = DiagramGraph.ExpandPointOnEdge(tfArray1[7], ef1, single1);
            float    single2  = p1.X;
            float    single3  = p1.Y;
            float    single4  = 1E+21f;
            PointF   tf10     = new PointF();

            if (StrokeGraph.NearestIntersectionOnLine(tf1, tf2, p1, p2, out tf9))
            {
                float single5 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single5 < single4)
                {
                    single4 = single5;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf2, tf3, p1, p2, out tf9))
            {
                float single6 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single6 < single4)
                {
                    single4 = single6;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf3, tf4, p1, p2, out tf9))
            {
                float single7 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single7 < single4)
                {
                    single4 = single7;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf4, tf5, p1, p2, out tf9))
            {
                float single8 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single8 < single4)
                {
                    single4 = single8;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf5, tf6, p1, p2, out tf9))
            {
                float single9 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single9 < single4)
                {
                    single4 = single9;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf6, tf7, p1, p2, out tf9))
            {
                float single10 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single10 < single4)
                {
                    single4 = single10;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf7, tf8, p1, p2, out tf9))
            {
                float single11 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single11 < single4)
                {
                    single4 = single11;
                    tf10    = tf9;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf8, tf1, p1, p2, out tf9))
            {
                float single12 = ((tf9.X - single2) * (tf9.X - single2)) + ((tf9.Y - single3) * (tf9.Y - single3));
                if (single12 < single4)
                {
                    single4 = single12;
                    tf10    = tf9;
                }
            }
            result = tf10;
            return(single4 < 1E+21f);
        }