Esempio n. 1
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);
        }