예제 #1
0
 public virtual IShapeHandle FindHandleByID(Shapes.DiagramShape obj, int id)
 {
     if (this.myHandles != null)
     {
         object obj1 = this.myHandles[obj];
         if (obj1 == null)
         {
             return(null);
         }
         if (obj1 is ArrayList)
         {
             ArrayList list1 = (ArrayList)obj1;
             foreach (IShapeHandle handle1 in list1)
             {
                 if (handle1.HandleID == id)
                 {
                     return(handle1);
                 }
             }
             return(null);
         }
         IShapeHandle handle2 = (IShapeHandle)obj1;
         if (handle2.HandleID == id)
         {
             return(handle2);
         }
     }
     return(null);
 }
예제 #2
0
 public void Remove(Shapes.DiagramShape obj)
 {
     if (obj != null)
     {
         DiagramLayer layer1 = obj.Layer;
         if (layer1 != null)
         {
             if (layer1 != this)
             {
                 throw new ArgumentException("Cannot remove an object from a layer if it does not belong to that layer.");
             }
             Shapes.GroupShape group1 = obj.Parent;
             if (group1 != null)
             {
                 group1.Remove(obj);
             }
             else
             {
                 this.removeFromLayer(obj, false);
             }
         }
     }
     if (this.ShapeRemoved != null)
     {
         this.ShapeRemoved(this, new SelectionEventArgs(obj));
     }
 }
예제 #3
0
        public Shapes.IDiagramShapeCollection AddCollection(Shapes.IDiagramShapeCollection coll, bool reparentLinks)
        {
            Shapes.DiagramShapeCollection collection1 = new Shapes.DiagramShapeCollection();
            foreach (Shapes.DiagramShape obj1 in coll)
            {
                collection1.Add(obj1);
            }
            CollectionEnumerator enumerator2 = collection1.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                Shapes.DiagramShape obj2 = enumerator2.Current;
                bool flag1 = obj2.Layer != null;
                if (flag1)
                {
                    Shapes.GroupShape.setAllNoClear(obj2, true);
                    obj2.Remove();
                }
                this.Add(obj2);
                if (flag1)
                {
                    Shapes.GroupShape.setAllNoClear(obj2, false);
                }
            }
            if (reparentLinks && this.IsInDocument)
            {
                Shapes.SubGraphNode.ReparentAllLinksToSubGraphs(collection1, true, this.Document.LinksLayer);
            }
            return(collection1);
        }
예제 #4
0
        private void removeFromSelection(Shapes.DiagramShape obj)
        {
            Shapes.DiagramShape obj1 = this.Primary;
            this.myObjTable.Remove(obj);
            base.Remove(obj);
            DiagramView view1 = this.View;

            if (view1 != null)
            {
                if (obj.IsInDocument)
                {
                    obj.OnLostSelection(this);
                }
                view1.RaiseShapeLostSelection(obj);
                if ((obj1 == obj) && obj1.IsInDocument)
                {
                    obj1 = this.Primary;
                    if (obj1 != null)
                    {
                        obj1.OnLostSelection(this);
                        view1.RaiseShapeLostSelection(obj1);
                        obj1.OnGotSelection(this);
                        view1.RaiseShapeSelected(obj1);
                    }
                }
            }
        }
예제 #5
0
 public void Add(Shapes.DiagramShape obj)
 {
     if (obj != null)
     {
         if (obj.Layer != null)
         {
             if (obj.Layer.LayerCollectionContainer != this.LayerCollectionContainer)
             {
                 throw new ArgumentException("Cannot add an object to a layer when it is already part of a different document's or view's layer.");
             }
             if (obj.Parent != null)
             {
                 throw new ArgumentException("Cannot add an object to a layer when it is part of a group.");
             }
             DiagramLayer layer1 = obj.Layer;
             if (layer1 != this)
             {
                 this.changeLayer(obj, layer1, false);
             }
         }
         else
         {
             if (obj.Parent != null)
             {
                 obj.Parent.Remove(obj);
             }
             this.addToLayer(obj, false);
         }
     }
     if (this.ShapeAdded != null)
     {
         this.ShapeAdded(this, new SelectionEventArgs(obj));
     }
 }
예제 #6
0
        public virtual DiagramSelection CreateDragSelection()
        {
            DiagramSelection selection1 = new DiagramSelection(null);

            Shapes.RectangleGraph rectangle1 = new Shapes.RectangleGraph();
            rectangle1.Bounds  = base.CurrentObject.Bounds;
            rectangle1.Visible = false;
            base.View.Layers.Default.Add(rectangle1);
            selection1.Add(rectangle1);
            Shapes.DiagramShapeCollection collection1 = new Shapes.DiagramShapeCollection();
            CollectionEnumerator          enumerator1 = ((this.EffectiveSelection != null) ? this.EffectiveSelection : base.Selection).GetEnumerator();

            while (enumerator1.MoveNext())
            {
                Shapes.DiagramShape obj1 = enumerator1.Current;
                collection1.Add(obj1.DraggingObject);
            }
            RectangleF ef1     = DiagramDocument.ComputeBounds(collection1, base.View);
            float      single1 = base.View.WorldScale.Width;

            if (((ef1.Width * single1) > 2000f) || ((ef1.Height * single1) > 2000f))
            {
                single1 *= System.Math.Min((float)(2000f / (ef1.Width * single1)), (float)(2000f / (ef1.Height * single1)));
            }
            Bitmap bitmap1 = base.View.GetBitmapFromCollection(collection1, ef1, single1, false);

            Shapes.DiagramImage image1 = new Shapes.DiagramImage();
            image1.Image  = bitmap1;
            image1.Bounds = new RectangleF(ef1.X, ef1.Y, ((float)bitmap1.Width) / single1, ((float)bitmap1.Height) / single1);
            base.View.Layers.Default.Add(image1);
            selection1.Add(image1);
            return(selection1);
        }
예제 #7
0
        public virtual void AddHandle(Shapes.DiagramShape obj, IShapeHandle handle)
        {
            if (this.myHandles == null)
            {
                this.myHandles = new Hashtable();
            }
            object obj1 = this.myHandles[obj];

            if (obj1 == null)
            {
                this.myHandles[obj] = handle;
            }
            else if (obj1 is ArrayList)
            {
                ArrayList list1 = (ArrayList)obj1;
                list1.Add(handle);
            }
            else
            {
                ArrayList list2 = new ArrayList();
                list2.Add(obj1);
                list2.Add(handle);
                this.myHandles[obj] = list2;
            }
            if (this.View != null)
            {
                this.View.Layers.Default.Add(handle.DiagramShape);
            }
        }
예제 #8
0
 protected virtual Shapes.IDiagramLine CreateTemporaryLink(Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort)
 {
     Shapes.IDiagramLine link1 = (Shapes.IDiagramLine)Activator.CreateInstance(base.View.LineType);
     if ((link1 == null) || (link1.DiagramShape == null))
     {
         return(null);
     }
     link1.FromPort = fromPort;
     link1.ToPort   = toPort;
     Shapes.DiagramShape obj1 = link1.DiagramShape;
     if (obj1 is Shapes.LineGraph)
     {
         Shapes.LineGraph link2 = (Shapes.LineGraph)obj1;
         if (this.myOrthogonalSet)
         {
             link2.Orthogonal = this.Orthogonal;
         }
         link2.AdjustingStyle = Shapes.LineAdjustingStyle.Calculate;
     }
     else if (obj1 is Shapes.TextLine)
     {
         Shapes.TextLine link3 = (Shapes.TextLine)obj1;
         if (this.myOrthogonalSet)
         {
             link3.Orthogonal = this.Orthogonal;
         }
         link3.AdjustingStyle = Shapes.LineAdjustingStyle.Calculate;
     }
     base.View.Layers.Default.Add(obj1);
     return(link1);
 }
예제 #9
0
 public virtual void DoNoRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort)
 {
     Shapes.DiagramShape obj1 = oldlink.DiagramShape;
     if ((obj1 != null) && (obj1.Layer != null))
     {
         if (obj1.Movable)
         {
             oldlink.FromPort       = fromPort;
             oldlink.ToPort         = toPort;
             base.TransactionResult = "Relink";
             base.View.RaiseLinkRelinked(oldlink.DiagramShape);
             return;
         }
         if (obj1.CanDelete())
         {
             CancelEventArgs args1 = new CancelEventArgs();
             base.View.RaiseSelectionDeleting(args1);
             if (!args1.Cancel)
             {
                 obj1.Remove();
                 base.View.RaiseSelectionDeleted();
                 base.TransactionResult = "Relink";
                 return;
             }
             this.DoCancelMouse();
         }
         else
         {
             this.DoCancelMouse();
         }
     }
     base.TransactionResult = null;
 }
예제 #10
0
 public virtual void DoLinking(PointF dc)
 {
     if (this.EndPort != null)
     {
         Shapes.DiagramShape obj1 = this.EndPort.DiagramShape;
         if (obj1 != null)
         {
             RectangleF          ef1;
             Shapes.IDiagramPort port1 = this.PickNearestPort(dc);
             GoTemporaryPort     port2 = obj1 as GoTemporaryPort;
             if (port2 != null)
             {
                 port2.Target = port1 as Shapes.DiagramPort;
             }
             if ((port1 != null) && (port1.DiagramShape != null))
             {
                 ef1 = port1.DiagramShape.Bounds;
             }
             else
             {
                 ef1 = new RectangleF(dc.X, dc.Y, 0f, 0f);
             }
             obj1.Bounds = ef1;
         }
     }
 }
예제 #11
0
        public override bool CanStart()
        {
            if ((!base.View.CanMoveObjects() && !base.View.CanCopyObjects()) && !base.View.AllowDragOut)
            {
                return(false);
            }
            if (base.LastInput.IsContextButton)
            {
                return(false);
            }
            Size  size1  = base.DragSize;
            Point point1 = base.FirstInput.ViewPoint;
            Point point2 = base.LastInput.ViewPoint;

            if ((System.Math.Abs((int)(point1.X - point2.X)) <= (size1.Width / 2)) && (System.Math.Abs((int)(point1.Y - point2.Y)) <= (size1.Height / 2)))
            {
                return(false);
            }
            Shapes.DiagramShape obj1 = base.View.PickObject(true, false, base.FirstInput.DocPoint, true);
            if (obj1 == null)
            {
                return(false);
            }
            if (!obj1.CanMove() && !obj1.CanCopy())
            {
                return(false);
            }
            return(true);
        }
예제 #12
0
        public override void Start()
        {
            IShapeHandle handle1 = this.PickResizeHandle(base.FirstInput.DocPoint);

            if (handle1 != null)
            {
                Shapes.DiagramShape obj1 = handle1.HandledObject;
                if (obj1 != null)
                {
                    base.CurrentObject = obj1;
                    base.StartTransaction();
                    if (base.Selection.GetHandleCount(obj1) > 0)
                    {
                        this.mySelectedObject = handle1.SelectedObject;
                        if (this.HidesSelectionHandles || !handle1.SelectedObject.ResizesRealtime)
                        {
                            this.mySelectionHidden = true;
                            obj1.RemoveSelectionHandles(base.Selection);
                        }
                    }
                    this.ResizeHandle   = handle1;
                    this.OriginalBounds = obj1.Bounds;
                    this.OriginalPoint  = handle1.DiagramShape.GetSpotLocation(1);
                }
            }
        }
예제 #13
0
 public bool Contains(Shapes.DiagramShape obj)
 {
     if (obj != null)
     {
         return(obj.Layer == this);
     }
     return(false);
 }
예제 #14
0
 public void Clear()
 {
     for (int num1 = this.myObjects.Count; num1 > 0; num1 = System.Math.Min(num1, this.myObjects.Count))
     {
         Shapes.DiagramShape obj1 = (Shapes.DiagramShape) this.myObjects[--num1];
         this.Remove(obj1);
     }
 }
예제 #15
0
 public override bool Contains(Shapes.DiagramShape obj)
 {
     if (obj == null)
     {
         return(false);
     }
     return(this.myObjTable.ContainsKey(obj));
 }
예제 #16
0
        internal void addToLayer(Shapes.DiagramShape obj, bool undoing)
        {
            this.myObjects.Add(obj);
            obj.SetLayer(this, obj, undoing);
            this.InsertIntoCache(obj);
            RectangleF ef1 = obj.Bounds;

            this.LayerCollectionContainer.RaiseChanged(0x386, 0, obj, 0, null, DiagramLayer.NullRect, 0, this, ef1);
        }
예제 #17
0
 public override bool CanStart()
 {
     if (base.FirstInput.IsContextButton)
     {
         return(false);
     }
     Shapes.DiagramShape obj1 = base.View.PickObject(true, false, base.FirstInput.DocPoint, true);
     return(obj1 == null);
 }
예제 #18
0
 public override void Start()
 {
     base.Start();
     Shapes.DiagramShape obj1 = base.CurrentObject;
     if ((obj1 != null) && (base.Selection.GetHandleCount(obj1) > 0))
     {
         this.mySelectionHidden = true;
         obj1.RemoveSelectionHandles(base.Selection);
     }
     this.StartRelink(base.Link, base.OriginalEndPort, base.LastInput.DocPoint);
 }
예제 #19
0
 private bool alreadyDragged(Hashtable draggeds, Shapes.DiagramShape o)
 {
     for (Shapes.DiagramShape obj1 = o; obj1 != null; obj1 = obj1.Parent)
     {
         if (draggeds.Contains(obj1))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #20
0
        internal void changeLayer(Shapes.DiagramShape obj, DiagramLayer oldLayer, bool undoing)
        {
            oldLayer.RemoveFromCache(obj);
            int num1 = Shapes.DiagramShapeCollection.fastRemove(oldLayer.myObjects, obj);

            this.myObjects.Add(obj);
            obj.SetLayer(this, obj, undoing);
            this.InsertIntoCache(obj);
            RectangleF ef1 = obj.Bounds;

            this.LayerCollectionContainer.RaiseChanged(0x388, 0, obj, num1, oldLayer, ef1, -1, this, ef1);
        }
예제 #21
0
 private Shapes.IDiagramPort pickNearestPort1(Shapes.DiagramShape obj, PointF dc, Shapes.IDiagramPort bestPort, ref float bestDist)
 {
     Shapes.IDiagramPort port1 = obj as Shapes.IDiagramPort;
     if (port1 != null)
     {
         PointF tf1     = this.PortPoint(port1, dc);
         float  single1 = dc.X - tf1.X;
         float  single2 = dc.Y - tf1.Y;
         float  single3 = (single1 * single1) + (single2 * single2);
         if (single3 <= bestDist)
         {
             object obj1 = null;
             if (this.ValidPortsCache != null)
             {
                 obj1 = this.ValidPortsCache[port1];
             }
             if (obj1 == ToolLinking.Valid)
             {
                 bestPort = port1;
                 bestDist = single3;
             }
             else if (obj1 != ToolLinking.Invalid)
             {
                 if ((this.Forwards && this.IsValidLink(this.OriginalStartPort, port1)) || (!this.Forwards && this.IsValidLink(port1, this.OriginalStartPort)))
                 {
                     if (this.ValidPortsCache != null)
                     {
                         this.ValidPortsCache[port1] = ToolLinking.Valid;
                     }
                     bestPort = port1;
                     bestDist = single3;
                 }
                 else if (this.ValidPortsCache != null)
                 {
                     this.ValidPortsCache[port1] = ToolLinking.Invalid;
                 }
             }
         }
     }
     Shapes.GroupShape group1 = obj as Shapes.GroupShape;
     if (group1 != null)
     {
         Shapes.GroupEnumerator enumerator2 = group1.GetEnumerator();
         Shapes.GroupEnumerator enumerator1 = enumerator2.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             Shapes.DiagramShape obj2 = enumerator1.Current;
             bestPort = this.pickNearestPort1(obj2, dc, bestPort, ref bestDist);
         }
     }
     return(bestPort);
 }
예제 #22
0
 public virtual Shapes.DiagramShape Copy(Shapes.DiagramShape obj)
 {
     if (obj == null)
     {
         return(null);
     }
     Shapes.DiagramShape obj1 = this[obj] as Shapes.DiagramShape;
     if (obj1 == null)
     {
         obj1 = obj.CopyObject(this);
     }
     return(obj1);
 }
예제 #23
0
 public virtual IActionObject PickActionObject()
 {
     for (Shapes.DiagramShape obj1 = base.View.PickObject(true, false, base.LastInput.DocPoint, false); obj1 != null; obj1 = obj1.Parent)
     {
         IActionObject obj2 = obj1 as IActionObject;
         if ((obj2 != null) && obj2.ActionEnabled)
         {
             base.CurrentObject = obj1;
             return(obj2);
         }
     }
     return(null);
 }
예제 #24
0
 public virtual Shapes.DiagramShape Select(Shapes.DiagramShape obj)
 {
     if (obj == null)
     {
         return(null);
     }
     if ((this.Primary != obj) || (this.Count != 1))
     {
         this.Clear();
         this.Add(obj);
     }
     return(obj);
 }
예제 #25
0
        internal void InsertIntoCache(Shapes.DiagramShape obj)
        {
            RectangleF ef1 = obj.Bounds;

            foreach (GoLayerCache cache1 in this.Caches)
            {
                RectangleF ef2 = obj.ExpandPaintBounds(ef1, cache1.View);
                if (Shapes.DiagramShape.IntersectsRect(cache1.Rect, ef2))
                {
                    cache1.Objects.Add(obj);
                }
            }
        }
예제 #26
0
        public void RemoveAllSelectionHandles()
        {
            CollectionEnumerator enumerator1 = this.Backwards.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                Shapes.DiagramShape obj2 = enumerator1.Current.SelectionObject;
                if (obj2 != null)
                {
                    obj2.RemoveSelectionHandles(this);
                }
            }
        }
예제 #27
0
 public override bool DoMouseOver(InputEventArgs evt)
 {
     if ((this.OverviewRect != null) && this.OverviewRect.ContainsPoint(evt.DocPoint))
     {
         this.Cursor = Cursors.SizeAll;
     }
     else
     {
         this.Cursor = this.DefaultCursor;
     }
     Shapes.DiagramShape obj1 = this.Document.PickObject(evt.DocPoint, false);
     this.DoToolTipObject(obj1);
     return(true);
 }
예제 #28
0
 public virtual void Toggle(Shapes.DiagramShape obj)
 {
     if (obj != null)
     {
         if (this.Contains(obj))
         {
             this.Remove(obj);
         }
         else
         {
             this.Add(obj);
         }
     }
 }
예제 #29
0
 public override void Remove(Shapes.DiagramShape obj)
 {
     if (obj != null)
     {
         if (this.Contains(obj))
         {
             this.removeFromSelection(obj);
         }
         else
         {
             this.RemoveHandles(obj);
         }
     }
 }
예제 #30
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);
        }