Пример #1
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);
        }
Пример #2
0
        public virtual DiagramSelection ComputeEffectiveSelection(Shapes.IDiagramShapeCollection coll, bool move)
        {
            Hashtable hashtable1 = new Hashtable();

            Shapes.DiagramShapeCollection collection1 = null;
            DiagramSelection selection1 = new DiagramSelection(null);

            Shapes.DiagramShapeCollection collection2 = null;
            foreach (Shapes.DiagramShape obj1 in coll)
            {
                Shapes.DiagramShape obj2 = obj1.DraggingObject;
                if (((obj2 != null) && !(move ? !obj2.CanMove() : !obj2.CanCopy())) && !this.alreadyDragged(hashtable1, obj2))
                {
                    if ((collection1 != null) && (obj2 is Shapes.GroupShape))
                    {
                        CollectionEnumerator enumerator2 = collection1.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            Shapes.DiagramShape obj3 = enumerator2.Current;
                            if (obj3.IsChildOf(obj2))
                            {
                                hashtable1.Remove(7);
                                if (collection2 == null)
                                {
                                    collection2 = new Shapes.DiagramShapeCollection();
                                }
                                collection2.Add(obj3);
                                selection1.Remove(obj3);
                            }
                        }
                        if ((collection2 != null) && !collection2.IsEmpty)
                        {
                            enumerator2 = collection2.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                Shapes.DiagramShape obj4 = enumerator2.Current;
                                collection1.Remove(obj4);
                            }
                            collection2.Clear();
                        }
                    }
                    hashtable1.Add(obj2, obj2);
                    if (!obj2.IsTopLevel)
                    {
                        if (collection1 == null)
                        {
                            collection1 = new Shapes.DiagramShapeCollection();
                        }
                        collection1.Add(obj2);
                    }
                    selection1.Add(obj2);
                }
            }
            Shapes.DiagramShape[] objArray1 = selection1.CopyArray();
            for (int num1 = 0; num1 < objArray1.Length; num1++)
            {
                Shapes.DiagramShape obj5  = objArray1[num1];
                Shapes.IDiagramNode node1 = obj5 as Shapes.IDiagramNode;
                if (node1 != null)
                {
                    foreach (Shapes.IDiagramLine link1 in node1.DestinationLinks)
                    {
                        if (!this.alreadyDragged(hashtable1, link1.DiagramShape) && ((link1.ToPort == null) || this.alreadyDragged(hashtable1, link1.ToPort.DiagramShape)))
                        {
                            hashtable1.Add(link1.DiagramShape, link1.DiagramShape);
                            selection1.Add(link1.DiagramShape);
                        }
                    }
                    foreach (Shapes.IDiagramLine link2 in node1.SourceLinks)
                    {
                        if (!this.alreadyDragged(hashtable1, link2.DiagramShape) && ((link2.FromPort == null) || this.alreadyDragged(hashtable1, link2.FromPort.DiagramShape)))
                        {
                            hashtable1.Add(link2.DiagramShape, link2.DiagramShape);
                            selection1.Add(link2.DiagramShape);
                        }
                    }
                }
            }
            return(selection1);
        }
Пример #3
0
 public virtual DiagramSelection ComputeEffectiveSelection(Shapes.IDiagramShapeCollection coll, bool move)
 {
     Hashtable hashtable1 = new Hashtable();
     Shapes.DiagramShapeCollection collection1 = null;
     DiagramSelection selection1 = new DiagramSelection(null);
     Shapes.DiagramShapeCollection collection2 = null;
     foreach (Shapes.DiagramShape obj1 in coll)
     {
         Shapes.DiagramShape obj2 = obj1.DraggingObject;
         if (((obj2 != null) && !(move ? !obj2.CanMove() : !obj2.CanCopy())) && !this.alreadyDragged(hashtable1, obj2))
         {
             if ((collection1 != null) && (obj2 is Shapes.GroupShape))
             {
                 CollectionEnumerator enumerator2 = collection1.GetEnumerator();
                 while (enumerator2.MoveNext())
                 {
                     Shapes.DiagramShape obj3 = enumerator2.Current;
                     if (obj3.IsChildOf(obj2))
                     {
                         hashtable1.Remove(7);
                         if (collection2 == null)
                         {
                             collection2 = new Shapes.DiagramShapeCollection();
                         }
                         collection2.Add(obj3);
                         selection1.Remove(obj3);
                     }
                 }
                 if ((collection2 != null) && !collection2.IsEmpty)
                 {
                     enumerator2 = collection2.GetEnumerator();
                     while (enumerator2.MoveNext())
                     {
                         Shapes.DiagramShape obj4 = enumerator2.Current;
                         collection1.Remove(obj4);
                     }
                     collection2.Clear();
                 }
             }
             hashtable1.Add(obj2, obj2);
             if (!obj2.IsTopLevel)
             {
                 if (collection1 == null)
                 {
                     collection1 = new Shapes.DiagramShapeCollection();
                 }
                 collection1.Add(obj2);
             }
             selection1.Add(obj2);
         }
     }
     Shapes.DiagramShape[] objArray1 = selection1.CopyArray();
     for (int num1 = 0; num1 < objArray1.Length; num1++)
     {
         Shapes.DiagramShape obj5 = objArray1[num1];
         Shapes.IDiagramNode node1 = obj5 as Shapes.IDiagramNode;
         if (node1 != null)
         {
             foreach (Shapes.IDiagramLine link1 in node1.DestinationLinks)
             {
                 if (!this.alreadyDragged(hashtable1, link1.DiagramShape) && ((link1.ToPort == null) || this.alreadyDragged(hashtable1, link1.ToPort.DiagramShape)))
                 {
                     hashtable1.Add(link1.DiagramShape, link1.DiagramShape);
                     selection1.Add(link1.DiagramShape);
                 }
             }
             foreach (Shapes.IDiagramLine link2 in node1.SourceLinks)
             {
                 if (!this.alreadyDragged(hashtable1, link2.DiagramShape) && ((link2.FromPort == null) || this.alreadyDragged(hashtable1, link2.FromPort.DiagramShape)))
                 {
                     hashtable1.Add(link2.DiagramShape, link2.DiagramShape);
                     selection1.Add(link2.DiagramShape);
                 }
             }
         }
     }
     return selection1;
 }
Пример #4
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;
 }
Пример #5
0
 public virtual void DeleteSelection(DiagramSelection sel)
 {
     if (sel == null)
     {
         sel = this.Selection;
     }
     if (((sel != this.Selection) || this.CanDeleteObjects()) && !sel.IsEmpty)
     {
         string text1 = null;
         try
         {
             this.StartTransaction();
             CancelEventArgs args1 = new CancelEventArgs();
             this.RaiseSelectionDeleting(args1);
             if (args1.Cancel)
             {
                 return;
             }
             Shapes.DiagramShape[] objArray1 = sel.CopyArray();
             int num1 = objArray1.Length;
             for (int num2 = num1 - 1; num2 >= 0; num2--)
             {
                 Shapes.DiagramShape obj1 = objArray1[num2];
                 if ((obj1 != null) && obj1.CanDelete())
                 {
                     obj1.Remove();
                     sel.Remove(obj1);
                 }
             }
             text1 = "Delete Selection";
             this.RaiseSelectionDeleted();
         }
         finally
         {
             this.FinishTransaction(text1);
         }
     }
 }
Пример #6
0
 public virtual void CopySelection(DiagramSelection sel, SizeF offset, bool grid)
 {
     if (sel == null)
     {
         sel = this.Selection;
     }
     if (((sel != this.Selection) || this.CanCopyObjects()) && !sel.IsEmpty)
     {
         DiagramDocument document1 = this.Document;
         string text1 = null;
         try
         {
             this.StartTransaction();
             CopyDictionary dictionary1 = document1.CreateCopyDictionary();
             document1.CopyFromCollection(sel, true, true, offset, dictionary1);
             this.Selection.Clear();
             IDictionaryEnumerator enumerator1 = dictionary1.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 Shapes.DiagramShape obj1 = enumerator1.Value as Shapes.DiagramShape;
                 if (((obj1 != null) && obj1.IsTopLevel) && (obj1.Document == document1))
                 {
                     this.Selection.Add(obj1);
                 }
             }
             if (grid)
             {
                 Shapes.DiagramShape obj2 = null;
                 CollectionEnumerator enumerator2 = this.Selection.GetEnumerator();
                 while (enumerator2.MoveNext())
                 {
                     Shapes.DiagramShape obj3 = enumerator2.Current;
                     if (!(obj3 is Shapes.IDiagramLine))
                     {
                         obj2 = obj3;
                         break;
                     }
                 }
                 SizeF ef1 = offset;
                 if (obj2 != null)
                 {
                     PointF tf1 = obj2.Location;
                     PointF tf2 = this.FindNearestGridPoint(tf1);
                     ef1.Width = tf2.X - tf1.X;
                     ef1.Height = tf2.Y - tf1.Y;
                     enumerator2 = this.Selection.GetEnumerator();
                     while (enumerator2.MoveNext())
                     {
                         Shapes.DiagramShape obj4 = enumerator2.Current;
                         if (obj4 is Shapes.IDiagramLine)
                         {
                             obj4.Position = new PointF(obj4.Left + ef1.Width, obj4.Top + ef1.Height);
                         }
                     }
                 }
                 enumerator2 = this.Selection.GetEnumerator();
                 while (enumerator2.MoveNext())
                 {
                     Shapes.DiagramShape obj5 = enumerator2.Current;
                     if (!(obj5 is Shapes.IDiagramLine))
                     {
                         PointF tf3 = obj5.Location;
                         PointF tf4 = this.FindNearestGridPoint(tf3);
                         obj5.DoMove(this, tf3, tf4);
                     }
                 }
             }
             text1 = "Copy Selection";
         }
         finally
         {
             this.FinishTransaction(text1);
         }
     }
 }
Пример #7
0
 public virtual void MoveSelection(DiagramSelection sel, SizeF offset, bool grid)
 {
     if (sel == null)
     {
         sel = this.Selection;
     }
     if (((sel != this.Selection) || this.CanMoveObjects()) && !sel.IsEmpty)
     {
         string text1 = null;
         try
         {
             this.StartTransaction();
             Shapes.DiagramShape obj1 = null;
             CollectionEnumerator enumerator1 = sel.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 Shapes.DiagramShape obj2 = enumerator1.Current;
                 if (!(obj2 is Shapes.IDiagramLine))
                 {
                     obj1 = obj2;
                     break;
                 }
             }
             SizeF ef1 = offset;
             if (obj1 != null)
             {
                 PointF tf1 = obj1.Location;
                 PointF tf2 = new PointF(tf1.X + offset.Width, tf1.Y + offset.Height);
                 if (grid)
                 {
                     tf2 = this.FindNearestGridPoint(tf2);
                 }
                 ef1.Width = tf2.X - tf1.X;
                 ef1.Height = tf2.Y - tf1.Y;
             }
             enumerator1 = sel.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 Shapes.DiagramShape obj3 = enumerator1.Current;
                 if (obj3 is Shapes.IDiagramLine)
                 {
                     obj3.DoMove(this, obj3.Position, new PointF(obj3.Left + ef1.Width, obj3.Top + ef1.Height));
                 }
             }
             enumerator1 = sel.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 Shapes.DiagramShape obj4 = enumerator1.Current;
                 if (!(obj4 is Shapes.IDiagramLine))
                 {
                     PointF tf3 = obj4.Location;
                     PointF tf4 = new PointF(tf3.X + offset.Width, tf3.Y + offset.Height);
                     if (grid)
                     {
                         tf4 = this.FindNearestGridPoint(tf4);
                     }
                     obj4.DoMove(this, tf3, tf4);
                 }
             }
             text1 = "Move Selection";
         }
         finally
         {
             this.FinishTransaction(text1);
         }
     }
 }