Ejemplo n.º 1
0
 public override RectangleF ExpandPaintBounds(RectangleF rect, DiagramView view)
 {
     rect = base.ExpandPaintBounds(rect, view);
     if (((this.Style != DiagramPortStyle.None) && (base.Parent != null)) && base.Parent.Shadowed)
     {
         SizeF ef1 = this.GetShadowOffset(view);
         if (ef1.Width < 0f)
         {
             rect.X     += ef1.Width;
             rect.Width -= ef1.Width;
         }
         else
         {
             rect.Width += ef1.Width;
         }
         if (ef1.Height < 0f)
         {
             rect.Y      += ef1.Height;
             rect.Height -= ef1.Height;
             return(rect);
         }
         rect.Height += ef1.Height;
     }
     return(rect);
 }
Ejemplo n.º 2
0
 protected sealed override void Dispose(bool disposing)
 {
     if (disposing && !base.IsDisposed)
     {
         // HACK: BUG: UNDONE: TODO: BUGBUG: MSBUG: DIRTY_HACK: Don't dispose the DiagramClientView if it is in the process of disassociating.
         // Bad things happen if we do.
         if (!myDisassociating)
         {
             DiagramView       designer       = Designer;
             DiagramClientView designerClient = designer.DiagramClientView;
             Diagram           diagram        = designer.Diagram;
             if (diagram != null)
             {
                 diagram.Disassociate(designer);
             }
             designerClient.DiagramDisassociating -= DiagramDisassociating;
             designerClient.Dispose();
             designer.Dispose();
         }
         else
         {
             base.Controls.Clear();
         }
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 3
0
        // SCRIPT evaluate python script in nodes signed with stamp in node link [F9]
        private void Evaluate(Diagram.Diagram diagram, DiagramView diagramView)
        {
            Nodes nodes = null;

            if (diagramView.selectedNodes.Count() > 0)
            {
                nodes = new Nodes(diagramView.selectedNodes);
            }
            else
            {
                nodes = new Nodes(diagram.GetAllNodes());
            }
            // remove nodes whit link other then [ ! | eval | evaluate | !#num_order | eval#num_order |  evaluate#num_order]
            // higest number is executed first
            Regex regex = new Regex(@"^\s*(eval(uate)|!){1}(#\w+){0,1}\s*$");
            nodes.RemoveAll(n => !regex.Match(n.link).Success);

            nodes.OrderByLink();
            nodes.Reverse();

            String clipboard = Os.GetTextFormClipboard();

#if !DEBUG
            Job.DoJob(
                new DoWorkEventHandler(
                    delegate (object o, DoWorkEventArgs args)
                    {
#endif
                        this.Evaluate(diagram, diagramView, nodes, clipboard);
#if !DEBUG
                    }
                )
            );
#endif
        }
Ejemplo n.º 4
0
 public Tools(Diagram.Diagram diagram, DiagramView diagramView, Node node, string clipboard = "")
 {
     this.diagram     = diagram;
     this.diagramView = diagramView;
     this.node        = node;
     this.clipboard   = clipboard;
 }
        /// <summary>
        /// Set this mouse action as the active action on the
        /// diagram of the given shape.
        /// </summary>
        /// <param name="attachToShape">The shape the constraint is being attached to.</param>
        /// <param name="constraint">The constraint being connected.</param>
        /// <param name="clientView">The active DiagramClientView</param>
        public void ChainMouseAction(FactTypeShape attachToShape, UniquenessConstraint constraint, DiagramClientView clientView)
        {
            DiagramView activeView = Diagram.ActiveDiagramView;

            if (activeView != null)
            {
                // Move on to the selection action
                clientView.ActiveMouseAction = this;

                // Now emulate a mouse click in the middle of the added constraint. The click
                // actions provide a starting point for the connect action, so a mouse move
                // provides a drag line.
                Point emulateClickPoint = clientView.WorldToDevice(attachToShape.GetAbsoluteConstraintAttachPoint(constraint, FactSetConstraint.GetLink(constraint, attachToShape.AssociatedFactType)));
                DiagramMouseEventArgs mouseEventArgs = new DiagramMouseEventArgs(new MouseEventArgs(MouseButtons.Left, 1, emulateClickPoint.X, emulateClickPoint.Y, 0), clientView);
                MouseDown(mouseEventArgs);
                Click(new DiagramPointEventArgs(emulateClickPoint.X, emulateClickPoint.Y, PointRelativeTo.Client, clientView));
                MouseUp(mouseEventArgs);
                attachToShape.Invalidate(true);

                // An extra move lets us chain when the mouse is not on the design surface,
                // such as when we are being activated via the task list.
                MouseMove(mouseEventArgs);

                ORMDiagram.SelectToolboxItem(activeView, ResourceStrings.ToolboxInternalUniquenessConstraintItemId);
                FactTypeShape.ActiveInternalUniquenessConstraintConnectAction = this;
            }
        }
Ejemplo n.º 6
0
        public override bool CanExecute(object parameter = null)
        {
            if (Current.MainWindow == null || Current.MainWindow.DiagramTabManager == null || Current.Project == null)
            {
                return(false);
            }
            IList <DiagramView> topDiagramViews = Current.MainWindow.DiagramTabManager.GetTopDiagramViews();

            /* there must be two diagrams, each with one selected component, both components must be of the
             * same type and they must be linked already */
            if (Current.Project.UsesVersioning && topDiagramViews.Count == 2)
            {
                DiagramView diagramView1 = topDiagramViews[0];
                DiagramView diagramView2 = topDiagramViews[1];

                if (Current.Project.VersionManager.AreItemsLinked(diagramView1.Diagram, diagramView2.Diagram))
                {
                    IEnumerable <Component> selectedComponents1 = diagramView1.GetSelectedComponents();
                    IEnumerable <Component> selectedComponents2 = diagramView2.GetSelectedComponents();
                    if (selectedComponents1.Count() == 1 && selectedComponents2.Count() == 1)
                    {
                        Component component1 = selectedComponents1.First();
                        Component component2 = selectedComponents2.First();
                        if (component1.GetType() == component2.GetType() && component1.Version != component2.Version &&
                            Current.Project.VersionManager.AreItemsLinked(component1, component2))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
 public static void DrawLine(Graphics g, DiagramView view, System.Drawing.Pen pen, float x1, float y1, float x2, float y2)
 {
     if (pen != null)
     {
         g.DrawLine(pen, x1, y1, x2, y2);
     }
 }
Ejemplo n.º 8
0
        public override Rectangle ComputeRubberBandBox()
        {
            int         num3;
            int         num4;
            Point       point1 = base.FirstInput.ViewPoint;
            Point       point2 = base.LastInput.ViewPoint;
            int         num1   = point2.X - point1.X;
            int         num2   = point2.Y - point1.Y;
            DiagramView view1  = this.ZoomedView;

            if (((view1 == null) || (view1.DisplayRectangle.Height == 0)) || (num2 == 0))
            {
                return(new Rectangle(System.Math.Min(point2.X, point1.X), System.Math.Min(point2.Y, point1.Y), System.Math.Abs((int)(point2.X - point1.X)), System.Math.Abs((int)(point2.Y - point1.Y))));
            }
            Rectangle rectangle1 = view1.DisplayRectangle;
            float     single1    = ((float)rectangle1.Width) / ((float)rectangle1.Height);

            if (System.Math.Abs((float)(((float)num1) / ((float)num2))) < single1)
            {
                num3 = point1.X + num1;
                num4 = point1.Y + (((int)System.Math.Ceiling((double)(((float)System.Math.Abs(num1)) / single1))) * ((num2 < 0) ? -1 : 1));
            }
            else
            {
                num3 = point1.X + (((int)System.Math.Ceiling((double)(System.Math.Abs(num2) * single1))) * ((num1 < 0) ? -1 : 1));
                num4 = point1.Y + num2;
            }
            return(new Rectangle(System.Math.Min(num3, point1.X), System.Math.Min(num4, point1.Y), System.Math.Abs((int)(num3 - point1.X)), System.Math.Abs((int)(num4 - point1.Y))));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Set this mouse action as the active action on the
        /// diagram of the given shape, and activate its drag line
        /// centered on the shape.
        /// </summary>
        /// <param name="chainFromPoint">The point to begin the mouse action</param>
        /// <param name="clientView">The active DiagramClientView</param>
        /// <param name="emulateDrag">true if this should emulate a drag, meaning
        /// that the mouse up acts like a click.</param>
        public void ChainMouseAction(PointD chainFromPoint, DiagramClientView clientView, bool emulateDrag)
        {
            DiagramView activeView = Diagram.ActiveDiagramView;

            if (activeView != null)
            {
                // Move on to the selection action
                clientView.ActiveMouseAction = this;

                // Now emulate a mouse click in the middle of the added constraint. The click
                // actions provide a starting point for the connect action, so a mouse move
                // provides a drag line.
                Point emulateClickPoint = clientView.WorldToDevice(chainFromPoint);
                DiagramMouseEventArgs mouseEventArgs = new DiagramMouseEventArgs(new MouseEventArgs(MouseButtons.Left, 1, emulateClickPoint.X, emulateClickPoint.Y, 0), clientView);
                MouseDown(mouseEventArgs);
                Click(new DiagramPointEventArgs(emulateClickPoint.X, emulateClickPoint.Y, PointRelativeTo.Client, clientView));
                MouseUp(mouseEventArgs);

                // An extra move lets us chain when the mouse is not on the design surface,
                // such as when we are being activated via the task list.
                MouseMove(mouseEventArgs);

                myEmulateDrag = emulateDrag;
                ORMDiagram.SelectToolboxItem(activeView, ResourceStrings.ToolboxRoleConnectorItemId);
            }
        }
Ejemplo n.º 10
0
 public static void DrawBezier(Graphics g, DiagramView view, System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 {
     if (pen != null)
     {
         g.DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
     }
 }
Ejemplo n.º 11
0
 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     INodeIconConstraint constraint1 = this.Constraint;
     SizeF ef1 = constraint1.MinimumIconSize;
     SizeF ef2 = constraint1.MaximumIconSize;
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, ef1, ef2);
 }
Ejemplo n.º 12
0
 protected override void OnLayerChanged(DiagramLayer oldLayer, DiagramLayer newLayer, DiagramShape mainObj)
 {
     base.OnLayerChanged(oldLayer, newLayer, mainObj);
     if (((oldLayer != null) && (newLayer == null)) && oldLayer.IsInDocument)
     {
         DiagramDocument       document1   = oldLayer.Document;
         IDictionaryEnumerator enumerator1 = this.Map.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             DictionaryEntry entry1   = enumerator1.Entry;
             DiagramView     view1    = (DiagramView)entry1.Key;
             Control         control1 = (Control)entry1.Value;
             if ((view1 != null) && (control1 != null))
             {
                 this.DisposeControl(control1, view1);
             }
         }
         this.Map.Clear();
     }
     else if (((oldLayer != null) && (newLayer == null)) && oldLayer.IsInView)
     {
         DiagramView view2    = oldLayer.View;
         Control     control2 = this.FindControl(view2);
         if (control2 != null)
         {
             this.Map.Remove(view2);
             if (control2 != null)
             {
                 this.DisposeControl(control2, view2);
             }
         }
     }
 }
Ejemplo n.º 13
0
        public override void Paint(Graphics g, DiagramView view)
        {
            SizeF ef1 = this.GetShadowOffset(view);

            if (this.Shadowed)
            {
                int num1 = this.myPoints.Length;
                for (int num2 = 0; num2 < num1; num2++)
                {
                    this.myPoints[num2].X += ef1.Width;
                    this.myPoints[num2].Y += ef1.Height;
                }
                if (this.Brush != null)
                {
                    Brush brush1 = this.GetShadowBrush(view);
                    DiagramGraph.DrawPolygon(g, view, null, brush1, this.myPoints);
                }
                else if (this.Pen != null)
                {
                    Pen pen1 = this.GetShadowPen(view, base.InternalPenWidth);
                    DiagramGraph.DrawPolygon(g, view, pen1, null, this.myPoints);
                }
                for (int num3 = 0; num3 < num1; num3++)
                {
                    this.myPoints[num3].X -= ef1.Width;
                    this.myPoints[num3].Y -= ef1.Height;
                }
            }
            DiagramGraph.DrawPolygon(g, view, this.Pen, this.Brush, this.myPoints);
        }
Ejemplo n.º 14
0
 public override void DoBeginEdit(DiagramView view)
 {
     if (this.Label != null)
     {
         this.Label.DoBeginEdit(view);
     }
 }
Ejemplo n.º 15
0
 public static void DrawLines(Graphics g, DiagramView view, System.Drawing.Pen pen, PointF[] points)
 {
     if (pen != null)
     {
         g.DrawLines(pen, points);
     }
 }
Ejemplo n.º 16
0
        public override bool OnSingleClick(InputEventArgs evt, DiagramView view)
        {
            SubGraphNode graph1 = base.Parent as SubGraphNode;

            if ((graph1 == null) || !graph1.Collapsible)
            {
                return(false);
            }
            if (view != null)
            {
                view.StartTransaction();
            }
            string text1 = null;

            if (graph1.IsExpanded)
            {
                graph1.Collapse();
                text1 = "Collapsed SubGraph";
            }
            else if (evt.Control)
            {
                graph1.ExpandAll();
                text1 = "Expanded All SubGraphs";
            }
            else
            {
                graph1.Expand();
                text1 = "Expanded SubGraph";
            }
            if (view != null)
            {
                view.FinishTransaction(text1);
            }
            return(true);
        }
Ejemplo n.º 17
0
 public override RectangleF ExpandPaintBounds(RectangleF rect, DiagramView view)
 {
     if (this.Pen != null)
     {
         float single1 = System.Math.Max(System.Math.Max(this.InternalPenWidth, (float)1f), (float)(this.PenInfo.MiterLimit + 1f));
         DiagramShape.InflateRect(ref rect, single1, single1);
     }
     if (this.Shadowed)
     {
         SizeF ef1 = this.GetShadowOffset(view);
         if (ef1.Width < 0f)
         {
             rect.X     += ef1.Width;
             rect.Width -= ef1.Width;
         }
         else
         {
             rect.Width += ef1.Width;
         }
         if (ef1.Height < 0f)
         {
             rect.Y      += ef1.Height;
             rect.Height -= ef1.Height;
             return(rect);
         }
         rect.Height += ef1.Height;
     }
     return(rect);
 }
Ejemplo n.º 18
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);
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public ShapesController(DiagramView view)
 {
     View   = view;
     Shapes = CreateModel();
     UpdateView();
     BindEvents();
 }
Ejemplo n.º 20
0
        public SearchPanel(DiagramView diagramView)
        {
            this.diagramView = diagramView;

            InitializeComponent();
            InitializeSearchPanelComponent();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Adds the <see cref="DiagramView"/> specified by <paramref name="designer"/> to this <see cref="MultiDiagramDocView"/>.
        /// </summary>
        /// <param name="designer">The <see cref="DiagramView"/> to be added to this <see cref="MultiDiagramDocView"/>.</param>
        /// <param name="selectAsCurrent">Indicates whether focus should be given to the new <see cref="DiagramView"/>.</param>
        public void AddDesigner(DiagramView designer, bool selectAsCurrent)
        {
            if (designer == null)
            {
                throw new ArgumentNullException("designer");
            }
            myVerifyPageOrder = true;
            MultiDiagramDocViewControl docViewControl  = DocViewControl;
            int                       tabCount         = docViewControl.TabCount;
            DiagramTabPage            tabPage          = new DiagramTabPage(docViewControl, designer);
            Diagram                   diagram          = designer.Diagram;
            Dictionary <Diagram, int> diagramRefCounts = myDiagramRefCounts;
            int                       refCount;

            if (!diagramRefCounts.TryGetValue(diagram, out refCount) || refCount <= 0)
            {
                diagram.DiagramRemoved += DiagramRemoved;
            }
            diagramRefCounts[diagram] = refCount + 1;
            if (selectAsCurrent)
            {
                // If this is not here then the tab is not correctly activated.
                docViewControl.SelectedIndex = -1;
                docViewControl.SelectTab(tabPage);
            }
        }
Ejemplo n.º 22
0
 public override bool OnSingleClick(InputEventArgs evt, DiagramView view)
 {
     SubGraphNode graph1 = base.Parent as SubGraphNode;
     if ((graph1 == null) || !graph1.Collapsible)
     {
         return false;
     }
     if (view != null)
     {
         view.StartTransaction();
     }
     string text1 = null;
     if (graph1.IsExpanded)
     {
         graph1.Collapse();
         text1 = "Collapsed SubGraph";
     }
     else if (evt.Control)
     {
         graph1.ExpandAll();
         text1 = "Expanded All SubGraphs";
     }
     else
     {
         graph1.Expand();
         text1 = "Expanded SubGraph";
     }
     if (view != null)
     {
         view.FinishTransaction(text1);
     }
     return true;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// run event for all registred plugins in NodeOpenPlugins </summary>
        public bool ClickOnNodeAction(Diagram diagram, DiagramView diagramView, Node node)
        {
            if (!diagram.isSigned())
            {
                return(false);
            }

            bool stopNextAction = false;

            if (nodeOpenPlugins.Count > 0)
            {
                foreach (INodeOpenPlugin plugin in nodeOpenPlugins)
                {
                    try
                    {
                        stopNextAction = plugin.ClickOnNodeAction(diagram, diagramView, node); //UID6935831875
                        if (stopNextAction)
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Program.log.Write("Exception in plugin: " + plugin.Name + " : " + e.Message);
                    }
                }
            }

            return(stopNextAction);
        }
Ejemplo n.º 24
0
 public override void Paint(Graphics g, DiagramView view)
 {
     if (this.Shadowed)
     {
         PointF[] tfArray1 = this.getPoints();
         int      num1     = tfArray1.Length;
         SizeF    ef1      = this.GetShadowOffset(view);
         for (int num2 = 0; num2 < num1; num2++)
         {
             tfArray1[num2].X += ef1.Width;
             tfArray1[num2].Y += ef1.Height;
         }
         if (this.Brush != null)
         {
             Brush brush1 = this.GetShadowBrush(view);
             DiagramGraph.DrawPolygon(g, view, null, brush1, tfArray1);
         }
         else if (this.Pen != null)
         {
             Pen pen1 = this.GetShadowPen(view, base.InternalPenWidth);
             DiagramGraph.DrawPolygon(g, view, pen1, null, tfArray1);
         }
     }
     DiagramGraph.DrawPolygon(g, view, this.Pen, this.Brush, this.getPoints());
 }
Ejemplo n.º 25
0
        /// <summary>
        /// run event for all registred plugins in KeyPressPlugins </summary>
        public bool KeyPressAction(Diagram diagram, DiagramView diagramView, Keys keyData)
        {
            if (!diagram.isSigned())
            {
                return(false);
            }

            bool stopNextAction = false;

            if (keyPressPlugins.Count > 0)
            {
                foreach (IKeyPressPlugin plugin in keyPressPlugins)
                {
                    try
                    {
                        stopNextAction = plugin.KeyPressAction(diagram, diagramView, keyData);
                        if (stopNextAction)
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Program.log.Write("Exception in plugin: " + plugin.Name + " : " + e.Message);
                    }
                }
            }

            return(stopNextAction);
        }
Ejemplo n.º 26
0
 public virtual void OnAction(DiagramView view, InputEventArgs e)
 {
     if (this.ActionEvent != null)
     {
         this.ActionEvent(this, e);
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// </summary>
        public bool DropAction(DiagramView diagramView, DragEventArgs ev)
        {
            if (!diagramView.diagram.isSigned())
            {
                return(false);
            }

            if (dropPlugins.Count > 0)
            {
                bool acceptAction = false;

                foreach (IDropPlugin plugin in dropPlugins)
                {
                    try
                    {
                        acceptAction = plugin.DropAction(diagramView, ev);

                        if (acceptAction)
                        {
                            return(true);
                        }
                    }
                    catch (Exception e)
                    {
                        Program.log.Write("Exception in plugin: " + plugin.Name + " : " + e.Message);
                    }
                }

                return(acceptAction);
            }

            return(false);
        }
Ejemplo n.º 28
0
        private void AdjustVisibility(bool diagramVisible, bool deferRebuildWatermark)
        {
            DiagramView diagramView = myDiagramView;

            if (!diagramVisible)
            {
                Diagram diagram = diagramView.Diagram;
                if (diagram != null)
                {
                    myDisassociating = true;
                    try
                    {
                        MultiDiagramDocView.DeactivateMouseActions(diagramView);
                        diagram.Disassociate(diagramView);
                    }
                    finally
                    {
                        myDisassociating = false;
                    }
                    SetSelectedComponents(null);
                }

                if (!deferRebuildWatermark)
                {
                    RebuildWatermark();
                }
            }
            diagramView.Visible      = diagramVisible;
            myWatermarkLabel.Visible = !diagramVisible;
        }
Ejemplo n.º 29
0
 public override RectangleF ExpandPaintBounds(RectangleF rect, DiagramView view)
 {
     rect = base.ExpandPaintBounds(rect, view);
     if (((this.Style != DiagramPortStyle.None) && (base.Parent != null)) && base.Parent.Shadowed)
     {
         SizeF ef1 = this.GetShadowOffset(view);
         if (ef1.Width < 0f)
         {
             rect.X += ef1.Width;
             rect.Width -= ef1.Width;
         }
         else
         {
             rect.Width += ef1.Width;
         }
         if (ef1.Height < 0f)
         {
             rect.Y += ef1.Height;
             rect.Height -= ef1.Height;
             return rect;
         }
         rect.Height += ef1.Height;
     }
     return rect;
 }
Ejemplo n.º 30
0
        public bool ClickOnNodeAction(Diagram.Diagram diagram, DiagramView diagramView, Node node)
        {
            if (node.link.Trim() == "#csharp")  // OPEN SCRIPT node with link "script" is executed as script
            {
                String clipboard = Os.GetTextFormClipboard();

                try
                {
                    this.EvaluateAsync(diagram, diagramView, node, clipboard).Wait();
                }
                catch (System.AggregateException ae)
                {
                    ae.Handle(ex =>
                    {
                        Program.log.Write("Exception in embed csharp script: " + ex.Message);
                        return(true);
                    });
                }


                return(true);
            }

            return(false);
        }
Ejemplo n.º 31
0
        public static void Select(IEnumerable <NodeShape> items)
        {
            try
            {
                var     first   = items.First();
                Diagram diagram = first.Diagram;

                if (diagram != null)
                {
                    DiagramView diagramView = diagram.ActiveDiagramView;
                    if ((diagramView != null))
                    {
                        foreach (var item in items)
                        {
                            if (item.CanFocus)
                            {
                                diagramView.Selection.Add(new DiagramItem(item));
                            }
                        }

                        diagramView.DiagramClientView.EnsureVisible(first.AbsoluteBoundingBox, first.EnsureVisiblePreference);
                        diagramView.Selection.Add(diagramView.Selection.FocusedItem);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        public override void Execute(object parameter = null)
        {
            IList <DiagramView> topDiagramViews = Current.MainWindow.DiagramTabManager.GetTopDiagramViews();

            /* there must be two diagrams, each with one selected component, both components must be of the
             * same type and they must not be linked already */
            DiagramView diagramView1 = topDiagramViews[0];
            DiagramView diagramView2 = topDiagramViews[1];

            cmdRemoveVersionLink cmdCreateVersionLinkS = new cmdRemoveVersionLink(Current.Controller);

            cmdCreateVersionLinkS.Set(diagramView1.Diagram.Schema, diagramView2.Diagram.Schema);
            cmdRemoveVersionLink cmdCreateVersionLinkD = new cmdRemoveVersionLink(Current.Controller);

            cmdCreateVersionLinkD.Set(diagramView1.Diagram, diagramView2.Diagram);
            MacroCommand m = new MacroCommand(Current.Controller);

            m.Commands.Add(cmdCreateVersionLinkS);
            m.Commands.Add(cmdCreateVersionLinkD);
            m.CheckFirstOnlyInCanExecute = true;
            m.Execute();


            Current.InvokeSelectionChanged();
        }
Ejemplo n.º 33
0
 public override void Changed(int subhint, int oldI, object oldVal, RectangleF oldRect, int newI, object newVal, RectangleF newRect)
 {
     if (!base.SuspendsUpdates)
     {
         base.Changed(subhint, oldI, oldVal, oldRect, newI, newVal, newRect);
         if (subhint == 0x3eb)
         {
             IDictionaryEnumerator enumerator1 = this.Map.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 DictionaryEntry entry1   = enumerator1.Entry;
                 DiagramView     view1    = (DiagramView)entry1.Key;
                 Control         control1 = (Control)entry1.Value;
                 if (view1 != null)
                 {
                     bool flag1 = this.CanView();
                     if (!flag1 && (control1 != null))
                     {
                         control1.Visible = false;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 34
0
 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     if ((whichHandle == 0x40e) && ((this.ResizesRealtime || (evttype == InputState.Finish)) || (evttype == InputState.Cancel)))
     {
         RectangleF ef1 = this.Bounds;
         float single1 = ef1.Height / ef1.Width;
         float single2 = ef1.Left;
         float single3 = ef1.Top;
         SizeF ef2 = this.Skew;
         if (this.Direction)
         {
             if (newPoint.X < ef1.X)
             {
                 ef2.Width = 0f;
             }
             else if (newPoint.X >= (ef1.X + ef1.Width))
             {
                 ef2.Width = ef1.Width;
             }
             else
             {
                 ef2.Width = newPoint.X - ef1.X;
             }
         }
         else if (newPoint.X >= (ef1.X + ef1.Width))
         {
             ef2.Width = 0f;
         }
         else if (newPoint.X < ef1.X)
         {
             ef2.Width = ef1.Width;
         }
         else
         {
             ef2.Width = (ef1.X + ef1.Width) - newPoint.X;
         }
         if (newPoint.Y < ef1.Y)
         {
             ef2.Height = 0f;
         }
         else if (newPoint.Y >= (ef1.Y + ef1.Height))
         {
             ef2.Height = ef1.Height;
         }
         else
         {
             ef2.Height = newPoint.Y - ef1.Y;
         }
         this.Skew = ef2;
         base.ResetPath();
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
         base.ResetPath();
     }
 }
        /// <summary>
        /// Constuctor.
        /// </summary>
        /// <param name="viewModelStore">The store this view model belongs to.</param>
        /// <param name="modelTreeView">Diagram tree view.</param>
        public DiagramViewModel(ViewModelStore viewModelStore, ModelContextViewModel modelContextVM, DiagramView diagramView)
            : base(viewModelStore)
        {
            this.diagramView = diagramView;
            this.modelContextVM = modelContextVM;
            this.contextMenuOperations = new Collection<MenuItemViewModel>();
            this.selectedVMS = new Collection<object>();

            this.rootNodeVMs = new ObservableCollection<DiagramClassViewModel>();
            this.rootNodeVMsRO = new ReadOnlyObservableCollection<DiagramClassViewModel>(this.rootNodeVMs);

            if (diagramView != null)
            {
                foreach (DiagramClassView view in diagramView.DiagramClassViews)
                    AddDiagramClassView(view);

                // subscribe
                this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DiagramViewHasDiagramClassViews.DomainClassId),
                    true, this.diagramView.Id, new Action<ElementAddedEventArgs>(OnDiagramClassViewAdded));

                this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DiagramViewHasDiagramClassViews.DomainClassId),
                    true, this.diagramView.Id, new Action<ElementDeletedEventArgs>(OnDiagramClassViewRemoved));
            }

            addNewDiagramClassCommand = new DelegateCommand(AddNewDiagramClassCommand_Executed);
            addNewDiagramClassFromTemplateCommand = new DelegateCommand(AddNewDiagramClassFromTemplateCommand_Executed);
            addNewShapeClassCommand = new DelegateCommand(AddNewShapeClassCommand_Executed);
            addNewMappingRelationshipShapeClassCommand = new DelegateCommand(AddNewMappingRelationshipShapeClassCommand_Executed);
            addNewRelationshipShapeClassCommand = new DelegateCommand(AddNewRelationshipShapeClassCommand_Executed);
            addNewDomainPropertyCommand = new DelegateCommand(AddNewDomainPropertyCommand_Executed);

            unparentCommand = new DelegateCommand(UnparentCommand_Executed);
            reparentCommand = new DelegateCommand(ReparentCommand_Executed);

            moveUpCommand = new DelegateCommand(MoveUpCommand_Executed);
            moveDownCommand = new DelegateCommand(MoveDownCommand_Executed);

            deleteCommand = new DelegateCommand(DeleteCommand_Executed, DeleteCommand_CanExecute);

            viewPropertiesCommand = new DelegateCommand(ViewPropertiesCommand_Executed);

            addIncludedDDCCommand = new DelegateCommand(AddIncludedDDCCommand_Executed);
            addImportedDCCommand = new DelegateCommand(AddImportedDCCommand_Executed);

            showTemplateHelperCommand = new DelegateCommand(ShowTemplateHelperCommand_Executed);

            addNewDomainClassSEDCommand = new DelegateCommand(AddNewDomainClassSEDCommand_Executed);
            addNewDomainRLForRLShape = new DelegateCommand(AddNewDomainRLForRLShape_Executed);

            UpdateOperations();

            this.EventManager.GetEvent<SelectionChangedEvent>().Subscribe(new Action<SelectionChangedEventArgs>(OnSelectionChanged));
        }
Ejemplo n.º 36
0
 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     if ((whichHandle < 1030) || ((!this.ResizesRealtime && (evttype != InputState.Finish)) && (evttype != InputState.Cancel)))
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     }
     else
     {
         RectangleF ef1 = this.Bounds;
         SizeF ef2 = this.Corner;
         switch (whichHandle)
         {
             case 1030:
                 {
                     if (newPoint.X >= ef1.X)
                     {
                         if (newPoint.X >= (ef1.X + (ef1.Width / 2f)))
                         {
                             ef2.Width = ef1.Width / 2f;
                             break;
                         }
                         ef2.Width = newPoint.X - ef1.X;
                         break;
                     }
                     ef2.Width = 0f;
                     break;
                 }
             case 0x407:
                 {
                     if (newPoint.Y >= ef1.Y)
                     {
                         if (newPoint.Y >= (ef1.Y + (ef1.Height / 2f)))
                         {
                             ef2.Height = ef1.Height / 2f;
                         }
                         else
                         {
                             ef2.Height = newPoint.Y - ef1.Y;
                         }
                         break;
                     }
                     ef2.Height = 0f;
                     break;
                 }
         }
         this.Corner = ef2;
         base.ResetPath();
     }
 }
Ejemplo n.º 37
0
 public override void Paint(Graphics g, DiagramView view)
 {
     RectangleF ef1 = this.Bounds;
     if (this.Shadowed)
     {
         SizeF ef2 = this.GetShadowOffset(view);
         if (this.Brush != null)
         {
             Brush brush1 = this.GetShadowBrush(view);
             DiagramGraph.DrawRectangle(g, view, null, brush1, ef1.X + ef2.Width, ef1.Y + ef2.Height, ef1.Width, ef1.Height);
         }
         else if (this.Pen != null)
         {
             Pen pen1 = this.GetShadowPen(view, base.InternalPenWidth);
             DiagramGraph.DrawRectangle(g, view, pen1, null, ef1.X + ef2.Width, ef1.Y + ef2.Height, ef1.Width, ef1.Height);
         }
     }
     DiagramGraph.DrawRectangle(g, view, this.Pen, this.Brush, ef1.X, ef1.Y, ef1.Width, ef1.Height);
 }
Ejemplo n.º 38
0
 public virtual Control CreateControl(DiagramView view)
 {
     Type type1 = this.ControlType;
     if (type1 == null)
     {
         return null;
     }
     Control control1 = (Control)Activator.CreateInstance(type1);
     RectangleF ef1 = this.Bounds;
     Rectangle rectangle1 = view.ConvertDocToView(ef1);
     control1.Bounds = rectangle1;
     IDiagramControl obj1 = control1 as IDiagramControl;
     if (obj1 != null)
     {
         obj1.DiagramView = view;
         obj1.DiagramControl = this;
     }
     return control1;
 }
Ejemplo n.º 39
0
 public virtual Pen GetShadowPen(DiagramView view, float width)
 {
     if (view != null)
     {
         return view.GetShadowPen(width);
     }
     return null;
 }
Ejemplo n.º 40
0
 public virtual SizeF GetShadowOffset(DiagramView view)
 {
     if (view != null)
     {
         return view.ShadowOffset;
     }
     return new SizeF();
 }
Ejemplo n.º 41
0
 public virtual Control GetControl(DiagramView view)
 {
     Control control1 = this.FindControl(view);
     if (control1 == null)
     {
         control1 = this.CreateControl(view);
         if (control1 != null)
         {
             this.Map[view] = control1;
             view.AddGoControl(this, control1);
         }
     }
     return control1;
 }
Ejemplo n.º 42
0
 public virtual bool OnMouseOver(InputEventArgs evt, DiagramView view)
 {
     return false;
 }
Ejemplo n.º 43
0
 public virtual void DoBeginEdit(DiagramView view)
 {
 }
Ejemplo n.º 44
0
 public virtual DiagramControl CreateEditor(DiagramView view)
 {
     return null;
 }
Ejemplo n.º 45
0
 public virtual void Paint(Graphics g, DiagramView view)
 {
 }
Ejemplo n.º 46
0
 public override void DoEndEdit(DiagramView view)
 {
     DiagramShape obj1 = this.EditedObject;
     if (obj1 != null)
     {
         obj1.DoEndEdit(view);
     }
 }
Ejemplo n.º 47
0
 public virtual void DisposeControl(Control comp, DiagramView view)
 {
     if ((comp != null) && (view != null))
     {
         if (view.EditControl != this)
         {
             view.RemoveDiagramControl(this, comp);
             comp.Dispose();
         }
         else
         {
             comp.Visible = false;
         }
     }
 }
Ejemplo n.º 48
0
 public override void Paint(Graphics g, DiagramView view)
 {
     Control control1 = this.GetControl(view);
     if (control1 != null)
     {
         RectangleF ef1 = this.Bounds;
         Rectangle rectangle1 = view.ConvertDocToView(ef1);
         control1.Bounds = rectangle1;
         control1.Visible = true;
     }
 }
Ejemplo n.º 49
0
 public virtual string GetToolTip(DiagramView view)
 {
     return null;
 }
Ejemplo n.º 50
0
 public virtual void DoEndEdit(DiagramView view)
 {
 }
Ejemplo n.º 51
0
 public virtual bool OnDoubleClick(InputEventArgs evt, DiagramView view)
 {
     return false;
 }
Ejemplo n.º 52
0
 public virtual void DoMove(DiagramView view, PointF origLoc, PointF newLoc)
 {
     PointF tf1 = this.ComputeMove(origLoc, newLoc);
     this.Location = tf1;
 }
Ejemplo n.º 53
0
 public override RectangleF ExpandPaintBounds(RectangleF rect, DiagramView view)
 {
     DiagramShape obj1 = base.Background;
     if (obj1 != null)
     {
         rect = DiagramShape.UnionRect(rect, obj1.Bounds);
         rect = obj1.ExpandPaintBounds(rect, view);
     }
     return rect;
 }
Ejemplo n.º 54
0
 public virtual void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     if (evttype == InputState.Cancel)
     {
         this.Bounds = origRect;
     }
     else
     {
         RectangleF ef1 = this.ComputeResize(origRect, newPoint, whichHandle, min, max, this.CanReshape() && !view.LastInput.Shift);
         if (this.ResizesRealtime)
         {
             this.Bounds = ef1;
         }
         else
         {
             Rectangle rectangle1 = view.ConvertDocToView(ef1);
             view.DrawXorBox(rectangle1, evttype != InputState.Finish);
             if (evttype == InputState.Finish)
             {
                 this.Bounds = ef1;
             }
         }
     }
 }
Ejemplo n.º 55
0
 public override void Paint(Graphics g, DiagramView view)
 {
     if (this.Shadowed)
     {
         SizeF ef1 = this.GetShadowOffset(view);
         GraphicsPath path1 = this.GetPath(ef1.Width, ef1.Height);
         if (this.Brush != null)
         {
             Brush brush1 = this.GetShadowBrush(view);
             DiagramGraph.DrawPath(g, view, null, brush1, path1);
         }
         else if (this.Pen != null)
         {
             Pen pen1 = this.GetShadowPen(view, base.InternalPenWidth);
             DiagramGraph.DrawPath(g, view, pen1, null, path1);
         }
         base.DisposePath(path1);
     }
     GraphicsPath path2 = this.GetPath(0f, 0f);
     DiagramGraph.DrawPath(g, view, this.Pen, this.Brush, path2);
     base.DisposePath(path2);
 }
Ejemplo n.º 56
0
 public virtual RectangleF ExpandPaintBounds(RectangleF rect, DiagramView view)
 {
     return rect;
 }
Ejemplo n.º 57
0
 public override void DoBeginEdit(DiagramView view)
 {
     if (this.Label != null)
     {
         this.Label.DoBeginEdit(view);
     }
 }
Ejemplo n.º 58
0
 public virtual Brush GetShadowBrush(DiagramView view)
 {
     if (view != null)
     {
         return view.GetShadowBrush();
     }
     return null;
 }
Ejemplo n.º 59
0
 public override string GetToolTip(DiagramView view)
 {
     return this.ToolTipText;
 }
Ejemplo n.º 60
0
 public virtual Control FindControl(DiagramView view)
 {
     return (Control)this.Map[view];
 }