Пример #1
0
        /// <summary>
        /// Called to query the application for feedback while the user is dragging the connection.
        /// </summary>
        public void QueryConnnectionFeedback(ConnectorViewModel draggedOutConnector, ConnectorViewModel draggedOverConnector, out object feedbackIndicator, out bool connectionOk)
        {
            if (draggedOutConnector == draggedOverConnector)
            {
                //
                // Can't connect to self!
                // Provide feedback to indicate that this connection is not valid!
                //
                feedbackIndicator = new ConnectionBadIndicator();
                connectionOk      = false;
            }
            else
            {
                var sourceConnector = draggedOutConnector;
                var destConnector   = draggedOverConnector;

                //
                // Only allow connections from output connector to input connector (ie each
                // connector must have a different type).
                // Also only allocation from one node to another, never one node back to the same node.
                //
                connectionOk = sourceConnector.ParentNode != destConnector.ParentNode &&
                               sourceConnector.Type != destConnector.Type;

                if (connectionOk)
                {
                    //
                    // Yay, this is a valid connection!
                    // Provide feedback to indicate that this connection is ok!
                    //
                    feedbackIndicator = new ConnectionOkIndicator();
                }
                else
                {
                    //
                    // Connectors with the same connector type (eg input & input, or output & output)
                    // can't be connected.
                    // Only connectors with separate connector type (eg input & output).
                    // Provide feedback to indicate that this connection is not valid!
                    //
                    feedbackIndicator = new ConnectionBadIndicator();
                }
            }
        }
Пример #2
0
        //Add Connections
        private void Connect(NodeVM headnode, NodeVM tailnode, string label)
        {
            ConnectorViewModel conn = new ConnectorViewModel();

            conn.SourceNode = tailnode;
            conn.TargetNode = headnode;
            if (label == "Yes")
            {
                //To Represent Annotation Properties
                conn.Annotations = new ObservableCollection <IAnnotation>()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content             = label,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        WrapText            = TextWrapping.NoWrap,
                        ReadOnly            = true,
                        ViewTemplate        = App.Current.Resources["viewtemplate"] as DataTemplate,
                        EditTemplate        = App.Current.Resources["edittemplate"] as DataTemplate,
                        Margin = new Thickness(0, 0, 0, 10),
                    }
                };
            }
            else if (label == "No")
            {
                //To Represent Annotation Properties
                conn.Annotations = new ObservableCollection <IAnnotation>()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content             = label,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        ReadOnly            = true,
                        WrapText            = TextWrapping.NoWrap,
                        ViewTemplate        = App.Current.Resources["viewtemplate"] as DataTemplate,
                        EditTemplate        = App.Current.Resources["edittemplate"] as DataTemplate,
                        Margin = new Thickness(0, 10, 0, 0),
                    }
                };
            }
            (Connectors as ObservableCollection <ConnectorViewModel>).Add(conn);
        }
Пример #3
0
        //Create and add port for connector
        private ConnectorPort AddPort(ConnectorViewModel connector, double length)
        {
            ConnectorPort port = new ConnectorPort()
            {
                Width     = 10,
                Height    = 10,
                Length    = length,
                Connector = connector,
                Shape     = new EllipseGeometry()
                {
                    RadiusX = 5, RadiusY = 5
                },
                PortVisibility = PortVisibility.Visible,
                Constraints    = PortConstraints.Default & ~PortConstraints.Inherit
            };

            (connector.Ports as ICollection <IConnectorPort>).Add(port);
            return(port);
        }
Пример #4
0
        //Add Connections
        private void Connect(CustomNode headnode, CustomNode tailnode, string label)
        {
            ConnectorViewModel conn = new ConnectorViewModel();

            conn.SourceNode           = tailnode;
            conn.TargetNode           = headnode;
            conn.TargetDecoratorStyle = this.Resources["connectorstyle"] as Style;
            if (label == "Yes")
            {
                //To Represent Annotation Properties
                conn.Annotations = new ObservableCollection <IAnnotation>()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content             = label,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        WrapText            = TextWrapping.NoWrap,
                        ReadOnly            = true,
                        ViewTemplate        = App.Current.Resources["viewtemplate"] as DataTemplate,
                        EditTemplate        = App.Current.Resources["edittemplate"] as DataTemplate
                    }
                };
            }
            else if (label == "No")
            {
                //To Represent Annotation Properties
                conn.Annotations = new ObservableCollection <IAnnotation>()
                {
                    new AnnotationEditorViewModel()
                    {
                        Content             = label,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        ReadOnly            = true,
                        WrapText            = TextWrapping.NoWrap,
                        ViewTemplate        = App.Current.Resources["viewtemplate"] as DataTemplate,
                        EditTemplate        = App.Current.Resources["edittemplate"] as DataTemplate
                    }
                };
            }
            (Diagram.Connectors as ICollection <ConnectorViewModel>).Add(conn);
        }
Пример #5
0
        void thumbDragThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.HitBlock     = null;
            this.HitConnector = null;
            this.pathGeometry = null;
            this.Cursor       = Cursors.Cross;
            this.connection.StrokeDashArray = new DoubleCollection(new double[] { 1, 2 });

            if (sender == sourceDragThumb)
            {
                fixConnector  = connection.Sink;
                dragConnector = connection.Source;
            }
            else if (sender == sinkDragThumb)
            {
                dragConnector = connection.Sink;
                fixConnector  = connection.Source;
            }
        }
Пример #6
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            simpleCollection = new SimpleCollection(objectsPath, linksPath, true);

            int tric = (int)Math.Sqrt(simpleCollection.Objects.Count);
            int x = -1, y = 0;

            foreach (SimpleObject obj in simpleCollection.Objects)
            {
                SettingsDesignerItemViewModel box = new SettingsDesignerItemViewModel();
                box.Parent = window1ViewModel.DiagramViewModel;
                box.Left   = start + step * ++x;
                box.Top    = start + step * y;
                if (x >= tric)
                {
                    x = -1; y++; raws++;
                }
                box.Id = obj.Id;
                window1ViewModel.DiagramViewModel.Items.Add(box);
            }
            foreach (SimpleLink link in simpleCollection.Links)
            {
                SettingsDesignerItemViewModel firstObj  = null;
                SettingsDesignerItemViewModel secondObj = null;
                try
                {
                    firstObj  = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == link.Start);
                    secondObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(s => s.Id == link.End);
                }
                catch (Exception)
                {
                    continue; //:)
                }
                if (null != firstObj && null != secondObj)
                {
                    ConnectorViewModel con1 = new ConnectorViewModel(firstObj.RightConnector, secondObj.TopConnector);
                    con1.Parent = window1ViewModel.DiagramViewModel;
                    con1.Id     = maxId * firstObj.Id + secondObj.Id; //:)
                    window1ViewModel.DiagramViewModel.Items.Add(con1);
                }
            }
        }
Пример #7
0
 //Event to notify the Changes
 void info_ItemAdded(object sender, ItemAddedEventArgs args)
 {
     //Items added due to clipboard operation
     if (args.ItemSource == ItemSource.ClipBoard)
     {
         if (args.Item is INode)
         {
             NodeVm node = args.Item as NodeVm;
             if (!node.IsCustomStyle)
             {
                 node.ShapeStyle = App.Current.Resources["nodeshapestyle"] as Style;
             }
             else
             {
                 node.ShapeStyle = App.Current.Resources["nodeshapestyle1"] as Style;
             }
             AnnotationEditorViewModel vm = (node.Annotations as ICollection <IAnnotation>).ToList()[0] as AnnotationEditorViewModel;
             if (node.IsMultiline)
             {
                 vm.ViewTemplate = App.Current.Resources["viewtemplate"] as DataTemplate;
             }
             else
             {
                 vm.ViewTemplate = App.Current.Resources["viewtemplate1"] as DataTemplate;
             }
         }
     }
     if (args.Item is ConnectorViewModel)
     {
         ConnectorViewModel cvm = args.Item as ConnectorViewModel;
         if (cvm.Annotations == null)
         {
             cvm.Annotations = new ObservableCollection <IAnnotation>()
             {
                 new AnnotationEditorViewModel()
                 {
                     Content = "",
                 }
             };
         }
     }
 }
Пример #8
0
        private void HitTesting(Point hitPoint)
        {
            var hitObject = this._designerCanvas.InputHitTest(hitPoint) as DependencyObject;

            if (hitObject == null || !(hitObject is Border || hitObject is Ellipse))
            {
                this.HitConnector = null;
                return;
            }
            var fe  = (FrameworkElement)hitObject;
            var cvm = fe.DataContext as ConnectorViewModel;

            if (cvm == null || cvm.Orientation == this._connection.SourceConnector.Orientation)
            {
                this.HitConnector = null;
                return;
            }

            this.HitConnector = cvm;
        }
Пример #9
0
        public ValueBufferNode(JObject data, Guid[] executeIn, Guid[] executeOut, Guid[] dataIn, Guid[] dataOut) : base(ValueBufferNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conExecute = new ExecutionConnectorViewModel(executeIn[0]);
            conIn      = new ConnectorViewModel("Set", typeof(INodeData), dataIn[0]);
            conOut     = new ConnectorViewModel("Value", typeof(INodeData), dataOut[0]);

            this.InputExecutionConnectors.Add(conExecute);
            this.InputConnectors.Add(conIn);
            this.OutputConnectors.Add(conOut);

            // Set Name
            Name = (string)data["name"];

            // State Values
            //Value = (Double)data["value"]; // no way to serilize generic values yet

            // Create Dialog
            dlgEdit = new PropertyDialog();
        }
Пример #10
0
        public ValueChangedNode() : base(ValueChangedNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conExecuteIn  = new ExecutionConnectorViewModel();
            conExecuteOut = new ExecutionConnectorViewModel();
            conIn         = new ConnectorViewModel("Set", typeof(INodeData));
            conOut        = new ConnectorViewModel("Value", typeof(INodeData));

            this.InputExecutionConnectors.Add(conExecuteIn);
            this.OutputExecutionConnectors.Add(conExecuteOut);
            this.InputConnectors.Add(conIn);
            this.OutputConnectors.Add(conOut);

            // State Values
            Value    = null;
            OldValue = null;

            // Create Dialog
            dlgEdit = new PropertyDialog();
        }
Пример #11
0
        protected override void OnAttached()
        {
            base.OnAttached();

            if (AssociatedObject.Visibility == Visibility.Collapsed)
            {
                return;
            }

            this._isDrag = false;
            AssociatedObject.MouseLeftButtonDown += this.OnPreviewMouseLeftButtonDown;
            AssociatedObject.MouseMove           += this.OnMouseMove;
            AssociatedObject.MouseLeftButtonUp   += this.OnMouseLeftButtonUp;
            AssociatedObject.Loaded += this.OnBorderLoaded;

            this._designerCanvas = CommonHelper.GetDesignerCanvas(AssociatedObject);
            this._tabViewModel   = this._designerCanvas.DataContext as SchemeTabViewModel;

            this._connectorViewModel = (ConnectorViewModel)AssociatedObject.DataContext;
        }
Пример #12
0
        public MathNumericConstantNode(JObject data, Guid[] executeIn, Guid[] executeOut, Guid[] dataIn, Guid[] dataOut) : base(MathNumericConstantNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conOut = new ConnectorViewModel("Value", typeof(NodeDataNumeric), dataOut[0]);

            this.OutputConnectors.Add(conOut);

            // Set Name
            Name = (string)data["name"];

            // State Values
            if (!Enum.TryParse <CastType>((string)data["CastToType"], out CastToType))
            {
                CastToType = CastType.Double;
            }
            Value = (Double)data["value"];

            // Create Dialog
            dlgEdit = new PropertyDialog();
        }
Пример #13
0
        //Add ConnectorPort
        private ConnectorPort addport(ConnectorViewModel line, double length)
        {
            ConnectorPort port = new ConnectorPort()
            {
                Width     = 10,
                Height    = 10,
                Length    = length,
                Connector = line,
                Shape     = new EllipseGeometry()
                {
                    RadiusX = 5, RadiusY = 5
                },
                PortVisibility = PortVisibility.Visible,
                ShapeStyle     = this.Resources["style"] as Style,
                Constraints    = PortConstraints.Default & ~PortConstraints.Inherit
            };

            (line.Ports as ICollection <IConnectorPort>).Add(port);
            return(port);
        }
Пример #14
0
        /// <summary>
        /// Create and add the connector to the connector collection.
        /// </summary>
        /// <param name="spoint">Sourcepoint of the connector</param>
        /// <param name="tpoint">Targetpoint of the connector</param>
        /// <param name="styleid">ThemestyleId</param>
        /// <returns></returns>
        ConnectorViewModel AddConnector(Point spoint, Point tpoint, StyleId styleid)
        {
            ConnectorViewModel connector = new ConnectorViewModel()
            {
                SourcePoint            = spoint,
                TargetPoint            = tpoint,
                ThemeStyleId           = styleid,
                ConnectorGeometryStyle = View.Resources["geometryStyle"] as Style
            };

            connector.Annotations = new ObservableCollection <IAnnotation>()
            {
                new TextAnnotationViewModel()
                {
                    Text = styleid.ToString()
                }
            };
            (this.Connectors as ObservableCollection <ConnectorViewModel>).Add(connector);
            return(connector);
        }
Пример #15
0
        public SerializationViewModel()
        {
            SnapSettings = new SnapSettings()
            {
                SnapConstraints = SnapConstraints.ShowLines,
            };

            SelectedItems = new SelectorViewModel();

            HorizontalRuler = new Ruler()
            {
                Orientation = Orientation.Horizontal
            };
            VerticalRuler = new Ruler()
            {
                Orientation = Orientation.Vertical
            };

            CustomNode Node1 = CreateNode(450, 60, "Ellipse", "Start", (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0F0F1")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node2 = CreateNode(450, 210, "Rectangle", "Alarm Rings", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node3 = CreateNode(450, 360, "Diamond", "Ready to Get Up?", (SolidColorBrush)(new BrushConverter().ConvertFrom("#C5EFAF")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node4 = CreateNode(700, 360, "Rectangle", "Hit Snooze Button", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node5 = CreateNode(700, 210, "Delay", "Delay", (SolidColorBrush)(new BrushConverter().ConvertFrom("#F8EEE5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node6 = CreateNode(450, 510, "Rectangle", "Climb Out of Bed", (SolidColorBrush)(new BrushConverter().ConvertFrom("#FBFDC5")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));
            CustomNode Node7 = CreateNode(450, 660, "Ellipse", "End", (SolidColorBrush)(new BrushConverter().ConvertFrom("#D0F0F1")), (SolidColorBrush)(new BrushConverter().ConvertFrom("#797979")));

            ConnectorViewModel Con1 = CreateConnector(Node1, Node2, "");
            ConnectorViewModel Con2 = CreateConnector(Node2, Node3, "");
            ConnectorViewModel Con3 = CreateConnector(Node3, Node4, "No");
            ConnectorViewModel Con4 = CreateConnector(Node3, Node6, "Yes");
            ConnectorViewModel Con5 = CreateConnector(Node5, Node2, "After 5 mins");
            ConnectorViewModel Con6 = CreateConnector(Node4, Node5, "");
            ConnectorViewModel Con7 = CreateConnector(Node6, Node7, "");

            NewCommand            = new Command(OnNew);
            LoadCommand           = new Command(OnLoad);
            SaveCommand           = new Command(OnSave);
            ItemAddedCommand      = new Command(ItemAddedExecution);
            ItemSelectedCommand   = new Command(OnItemSelectedCommand);
            ItemUnSelectedCommand = new Command(OnItemUnSelected);
        }
Пример #16
0
        /// <summary>
        /// This shows you how you can create diagram items in code, which means you can
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            SettingsDesignerItemViewModel item1 = new SettingsDesignerItemViewModel();

            item1.Parent = window1ViewModel.DiagramViewModel;
            item1.Left   = 100;
            item1.Top    = 100;
            window1ViewModel.DiagramViewModel.Items.Add(item1);

            PersistDesignerItemViewModel item2 = new PersistDesignerItemViewModel();

            item2.Parent = window1ViewModel.DiagramViewModel;
            item2.Left   = 300;
            item2.Top    = 300;
            window1ViewModel.DiagramViewModel.Items.Add(item2);

            ConnectorViewModel con1 = new ConnectorViewModel(item1.RightConnector, item2.TopConnector);

            con1.Parent = window1ViewModel.DiagramViewModel;
            window1ViewModel.DiagramViewModel.Items.Add(con1);
        }
        /// <summary>
        /// Called to query the application for feedback while the user is dragging the connection.
        /// </summary>
        public void QueryConnnectionFeedback(ConnectorViewModel draggedOutConnector, ConnectorViewModel draggedOverConnector, out object feedbackIndicator, out bool connectionOk)
        {
            if (draggedOutConnector == draggedOverConnector)
            {
                //
                // Can't connect to self!
                // Provide feedback to indicate that this connection is not valid!
                //
                feedbackIndicator = new ConnectionBadIndicator("Can't connect to self");
                connectionOk      = false;
            }
            else
            {
                string message         = string.Empty;
                var    sourceConnector = draggedOutConnector;
                var    destConnector   = draggedOverConnector;

                //
                // Only allow connections from output connector to input connector (ie each
                // connector must have a different type).
                // Also only allocation from one node to another, never one node back to the same node.
                //
                connectionOk = IsValidConnection(sourceConnector, draggedOverConnector, ref message);

                if (connectionOk)
                {
                    feedbackIndicator = new ConnectionOkIndicator();
                }
                else
                {
                    //
                    // Connectors with the same connector type (eg input & input, or output & output)
                    // can't be connected.
                    // Only connectors with separate connector type (eg input & output).
                    // Provide feedback to indicate that this connection is not valid!
                    //
                    feedbackIndicator = new ConnectionBadIndicator(message);
                }
            }
        }
Пример #18
0
        public void Defect_MAGN_491()
        {
            // TODO: Rename this XML to match the test case name.
            RunCommandsFromFile("Defect-MAGN-491.xml");
            var connectors = workspaceViewModel.Connectors;

            Assert.NotNull(connectors);
            Assert.AreEqual(2, connectors.Count);

            // Get to the only two connectors in the session.
            ConnectorViewModel firstConnector  = connectors[0];
            ConnectorViewModel secondConnector = connectors[1];

            // Find out the corresponding ports they connect to.
            Point firstPoint  = firstConnector.ConnectorModel.End.Center;
            Point secondPoint = secondConnector.ConnectorModel.End.Center;

            Assert.AreEqual(firstPoint.X, firstConnector.CurvePoint3.X);
            Assert.AreEqual(firstPoint.Y, firstConnector.CurvePoint3.Y);
            Assert.AreEqual(secondPoint.X, secondConnector.CurvePoint3.X);
            Assert.AreEqual(secondPoint.Y, secondConnector.CurvePoint3.Y);
        }
Пример #19
0
        void AddNewLink(SimpleLink newLink)
        {
            SettingsDesignerItemViewModel firstObj  = null;
            SettingsDesignerItemViewModel secondObj = null;

            try
            {
                firstObj  = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(f => f.Id == newLink.Start);
                secondObj = (SettingsDesignerItemViewModel)window1ViewModel.DiagramViewModel.Items.First(s => s.Id == newLink.End);
            }
            catch (Exception)
            {
                return; //:)
            }
            if (null != firstObj && null != secondObj)
            {
                ConnectorViewModel con1 = new ConnectorViewModel(firstObj.RightConnector, secondObj.TopConnector);
                con1.Parent = window1ViewModel.DiagramViewModel;
                con1.Id     = newLink.Id;
                window1ViewModel.DiagramViewModel.Items.Add(con1);
            }
        }
Пример #20
0
        public DiagramVM()
        {
            //Adding Commands
            ConnectorSourceChangedCommand = new DelegateCommand(OnConnectorSourceChangedCommand);
            ConnectorTargetChangedCommand = new DelegateCommand(OnConnectorTargetChangedCommand);
            //Creating nodes
            NodeViewModel SourceNode = new NodeViewModel()
            {
                UnitHeight = 100,
                UnitWidth  = 100,
                OffsetX    = 200,
                OffsetY    = 200,
                Shape      = App.Current.MainWindow.Resources["Rectangle"],
            };

            NodeViewModel TargetNode = new NodeViewModel()
            {
                UnitHeight = 100,
                UnitWidth  = 100,
                OffsetX    = 400,
                OffsetY    = 400,
                Shape      = App.Current.MainWindow.Resources["Rectangle"],
            };

            //Adding nodes into node's collection
            (this.Nodes as NodeCollection).Add(SourceNode);
            (this.Nodes as NodeCollection).Add(TargetNode);

            //Creating connector.
            ConnectorViewModel connector = new ConnectorViewModel()
            {
                SourceNode = SourceNode,
                TargetNode = TargetNode,
            };

            //Adding connectors into connector's collection
            (this.Connectors as ConnectorCollection).Add(connector);
        }
Пример #21
0
        public ConnectionHandler(DiagramViewModel diagramViewModel, ConnectorViewModel startConnector)
            : base(diagramViewModel)
        {
            StartConnector      = startConnector;
            PossibleConnections = new List <ConnectorViewModel>();
            //InvertApplication.Log("YUP YUP YUP");
            var items = diagramViewModel.GraphItems.OfType <ConnectorViewModel>().ToArray();

            foreach (var connector in items)
            {
                foreach (var strategy in InvertGraphEditor.ConnectionStrategies)
                {
                    if (strategy.Connect(diagramViewModel, StartConnector, connector) != null)
                    {
                        PossibleConnections.Add(connector);
                    }
                }
            }
            foreach (var a in PossibleConnections)
            {
                a.IsMouseOver = true;
            }
        }
Пример #22
0
 public override object GetValue(ConnectorViewModel connector, object context)
 {
     if (conInput.IsConnected)
     {
         return(conInput.AttachedConnections.Select(connection =>
         {
             try
             {
                 object tmp = connection.SourceConnector.ParentNode.GetValue(connection.SourceConnector, context);
                 if (typeof(INodeData).IsAssignableFrom(tmp.GetType()))
                 {
                     return (INodeData)tmp;
                 }
                 return null;
             }
             catch
             {
                 return null;
             }
         }).Where(val => val != null).FirstOrDefault());
     }
     return(null);
 }
Пример #23
0
 public virtual void OnMouseMove(MouseEvent e)
 {
     ConnectorAtMouse = null;
     ViewModelAtMouse = null;
     foreach (var source in DiagramViewModel.GraphItems.Reverse())
     {
         if (source.Bounds.Contains(e.MousePosition))
         {
             if (source is ConnectorViewModel)
             {
                 ConnectorAtMouse = (ConnectorViewModel)source;
             }
             else
             {
                 ViewModelAtMouse = ConnectorAtMouse;
             }
         }
         if (ConnectorAtMouse != null)
         {
             break;
         }
     }
 }
Пример #24
0
        /// <summary>
        /// Create a connection between two nodes.
        /// </summary>
        /// <param name="source">Source node</param>
        /// <param name="destination">Destination node</param>
        public void ConnectNodes(NodeViewModel source, NodeViewModel destination)
        {
            if (Network == null || source == null || destination == null)
            {
                return;
            }

            //
            // Check if the connection already exists.
            //
            if (source.AttachedConnections.Any(c => c.DestConnector.ParentNode == destination))
            {
                return;
            }

            //
            // Create connectors
            //
            ConnectorViewModel sourceConn      = new ConnectorViewModel("Out1");
            ConnectorViewModel destinationConn = new ConnectorViewModel("In1");

            source.OutputConnectors.Add(sourceConn);
            destination.InputConnectors.Add(destinationConn);

            //
            // Create a connection between the nodes.
            //
            ConnectionViewModel connection = new ConnectionViewModel();

            connection.SourceConnector = sourceConn;
            connection.DestConnector   = destinationConn;

            //
            // Add the connection to the view-model.
            //
            this.Network.Connections.Add(connection);
        }
Пример #25
0
        public ScaledRadialNode() : base(ScaledRadialNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conOutX  = new ConnectorViewModel("X", typeof(NodeDataNumeric));
            conOutY  = new ConnectorViewModel("Y", typeof(NodeDataNumeric));
            conInX   = new ConnectorViewModel("X", typeof(NodeDataNumeric));
            conInY   = new ConnectorViewModel("Y", typeof(NodeDataNumeric));
            conInMin = new ConnectorViewModel("Min", typeof(NodeDataNumeric));
            conInMax = new ConnectorViewModel("Max", typeof(NodeDataNumeric));

            this.OutputConnectors.Add(conOutX);
            this.OutputConnectors.Add(conOutY);
            this.InputConnectors.Add(conInX);
            this.InputConnectors.Add(conInY);
            this.InputConnectors.Add(conInMin);
            this.InputConnectors.Add(conInMax);

            // State Values
            Min = 0;
            Max = 1;

            // Create Dialog
            dlgEdit = new PropertyDialog();
        }
Пример #26
0
 private void OnDropCommand(object parameter)
 {
     if ((parameter as ItemDropEventArgs).Source is INode && ((parameter as ItemDropEventArgs).Source as NodeViewModel).Name.ToString() == "Connector")
     {
         src    = ((parameter as ItemDropEventArgs).Source as INode).OffsetX;
         target = ((parameter as ItemDropEventArgs).Source as INode).OffsetY;
         (parameter as ItemDropEventArgs).Cancel = true;
         ConnectorViewModel con = new ConnectorViewModel()
         {
             SourcePoint = new Point(src - 30, target - 30),
             TargetPoint = new Point(src + 30, target + 30),
             Segments    = new ObservableCollection <IConnectorSegment>()
             {
                 //Specify the segment as orthogonal segment
                 new OrthogonalSegment()
                 {
                     Direction = OrthogonalDirection.Bottom,
                     Length    = 60,
                 },
                 new OrthogonalSegment()
                 {
                     Direction = OrthogonalDirection.Right,
                     Length    = 55,
                 },
             },
             Annotations = new ObservableCollection <IAnnotation>()
             {
                 new AnnotationEditorViewModel()
                 {
                     Constraints = AnnotationConstraints.Editable | AnnotationConstraints.Selectable | AnnotationConstraints.Resizable,
                 }
             },
         };
         (this.Connectors as ObservableCollection <ConnectorViewModel>).Add(con);
     }
 }
Пример #27
0
        private ConnectorViewModel GetModelToUpdate(Connector connector)
        {
            lock (this.lockObj)
            {
                var modelToUpdate = this.connectors.FirstOrDefault(sub => sub.Identifier == connector.Configuration.Identifier);
                if (modelToUpdate == null)
                {
                    var presentationPlugIn = PluginManager.Instance.GetPresentationPlugin(connector.Configuration.Type);
                    if (presentationPlugIn != null)
                    {
                        modelToUpdate = presentationPlugIn.CreateViewModel(connector);
                    }
                    else
                    {
                        modelToUpdate = new ConnectorViewModel(connector);
                    }

                    modelToUpdate.PropertyChanged += this.OnPropertyChanged;
                    this.connectors.Add(modelToUpdate);
                }

                return(modelToUpdate);
            }
        }
Пример #28
0
        // Load Data Constructor
        public EmoteSetVariableNode(JObject data, Guid[] executeIn, Guid[] executeOut, Guid[] dataIn, Guid[] dataOut)
        {
            // Prepare Connections
            conExecute = new ExecutionConnectorViewModel(executeIn[0]);
            inputValue = new ConnectorViewModel("Value", typeof(NodeDataNumeric), dataIn[0]);
            if (dataIn.Length > 1) // allow loading older node graph saves
            {
                inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric), dataIn[1]);
                inputEasing     = new ConnectorViewModel("Easing", typeof(NodeDataNumeric), dataIn[2]);
            }
            else
            {
                inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric));
                inputEasing     = new ConnectorViewModel("Easing", typeof(NodeDataNumeric));
            }

            this.InputExecutionConnectors.Add(conExecute);
            this.InputConnectors.Add(inputValue);
            this.InputConnectors.Add(inputFrameCount);
            this.InputConnectors.Add(inputEasing);

            // Set Name
            Name = (string)data["name"];

            // State Values
            value      = (float)data["value"];
            frameCount = (float)data["frameCount"];
            easing     = (float)data["easing"];
            varName    = (string)data["varName"];

            // Create Dialog
            dlgEdit = new PropertyDialog();

            // Get Character Context
            charContext = CharacterContext.GetCharacterContext();
        }
Пример #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="container"></param>
        /// <returns></returns>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is ConnectorViewModel)
            {
                ConnectorViewModel c = item as ConnectorViewModel;

                switch (c.Type)
                {
                case ConnectorType.Input:
                    return(NodeInTemplate);

                case ConnectorType.VariableInput:
                    return(VarInTemplate);

                case ConnectorType.Output:
                    return(NodeOutTemplate);

                case ConnectorType.VariableOutput:
                    return(VarOutTemplate);
                }
            }

            return(base.SelectTemplate(item, container));
        }
 public JenkinsStatusViewModel(ConnectorViewModel model)
     : base(model)
 {
 }
Пример #31
0
        public void DrawConnector(float scale, ConnectorViewModel viewModel)
        {

        }