コード例 #1
0
 private void Diagram_ObjectDrawn(object sender, ObjectDrawnEventArgs args)
 {
     if (args.State == DragState.Completed)
     {
         Part_SelectTool.IsSelected = true;
         this.diagramControl.Tool   = Tool.MultipleSelect;
     }
 }
コード例 #2
0
 /// <summary>
 /// Raises when a connection is drawn
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void MainWindow_ObjectDrawn(object sender, ObjectDrawnEventArgs args)
 {
     if (args.State == DragState.Completed)
     {
         // Removing connector when either of its end remains disconnected
         if (args.Item is WireViewModel connector && (connector.SourceNode == null || connector.TargetNode == null))
         {
             (this.diagram.Connectors as ObservableCollection <WireViewModel>).Remove(args.Item as WireViewModel);
         }
     }
 }
コード例 #3
0
        private void CustomDiagram_ObjectDrawn(object sender, ObjectDrawnEventArgs args)
        {
            //SourcePort should be set on Started state
            if (args.State == DragState.Started)
            {
                if (args.Item is IConnector)
                {
                    IConnector connector = args.Item as IConnector;
                    if (connector.SourceNode != null)
                    {
                        if ((connector.SourceNode as NodeViewModel).Ports == null)
                        {
                            //Initialize the Port collection
                            (connector.SourceNode as NodeViewModel).Ports = new ObservableCollection <IPort>();
                        }

                        //Set the TargetPort as NodePort to the Node
                        args.SourcePort = new NodePortViewModel();
                    }
                    if (connector.SourceConnector != null)
                    {
                        if ((connector.SourceConnector as ConnectorViewModel).Ports == null)
                        {
                            //Initialize the Port collection
                            (connector.SourceConnector as ConnectorViewModel).Ports = new ObservableCollection <IPort>();
                        }
                        //Set the TargetPort as ConnectorPort to the Connector
                        args.SourcePort = new ConnectorPortViewModel();
                    }
                }
            }

            //TargetPort should be set on Started state
            if (args.State == DragState.Completed)
            {
                if (args.Item is IConnector)
                {
                    IConnector connector = args.Item as IConnector;
                    if (connector.TargetNode != null)
                    {
                        if ((connector.TargetNode as NodeViewModel).Ports == null)
                        {
                            //Initialize the Port collection
                            (connector.TargetNode as NodeViewModel).Ports = new ObservableCollection <IPort>();
                        }
                        //Set the TargetPort as NodePort to the Node
                        args.TargetPort = new NodePortViewModel();
                    }
                    if (connector.TargetConnector != null)
                    {
                        if ((connector.TargetConnector as ConnectorViewModel).Ports == null)
                        {
                            //Initialize the Port collection
                            (connector.TargetConnector as ConnectorViewModel).Ports = new ObservableCollection <IPort>();
                        }
                        //Set the TargetPort as ConnectorPort to the Connector
                        args.TargetPort = new ConnectorPortViewModel();
                    }
                }
            }
        }