Exemple #1
0
        public Connection(WorkflowCanvas canvas, RenderNode startPoint, RenderNode endPoint, ConnectingLine line)
        {
            this.Canvas = canvas;
            Line        = line;
            if (startPoint.Node.GetConnectionType() == INodeConnectionType.OUTPUT &&
                endPoint.Node.GetConnectionType() == INodeConnectionType.INPUT)
            {
                Input  = (BaseInputNode)endPoint.Node;
                Output = (BaseOutputNode)startPoint.Node;

                Start = startPoint;
                End   = endPoint;
            }
            else if (startPoint.Node.GetConnectionType() == INodeConnectionType.INPUT &&
                     endPoint.Node.GetConnectionType() == INodeConnectionType.OUTPUT)
            {
                Input  = (BaseInputNode)startPoint.Node;
                Output = (BaseOutputNode)endPoint.Node;
                Start  = endPoint;
                End    = startPoint;
            }

            contextMenu = new ContextMenu();
            MenuItem item = new MenuItem();

            item.Header = "Disconnect";
            contextMenu.Items.Add(item);

            item.Click += delegate
            {
                Disconnect();
            };
        }
Exemple #2
0
        public WorkflowScrollViewer()
        {
            PanningMode = PanningMode.Both;
            HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;

            DockPanel panel = new DockPanel();

            WorkflowCanvas canvas = new WorkflowCanvas();

            canvas.Scroller = this;
            panel.Children.Add(canvas);

            ChildCanvas = canvas;
            Content     = panel;
        }
Exemple #3
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            logger.Trace("Entered");
            base.OnMouseDown(e);

            if (Parent != WfCanvas)
            {
                return;
            }

            // Keyboard.ClearFocus();
            //e.Handled = true;

            if (e.OriginalSource == PageImage)
            {
                if (!this.IsFocused)
                {
                    if (this.Focus())
                    {
                        IsActive = true;
                    }
                }
            }
            else if (e.OriginalSource.GetType() == typeof(Ellipse))
            {
                IsActive = true;
            }



            if (e.ClickCount > 1)
            {
                logger.Trace("doubleclick_1");
                OnDoubleClick(this, e);
                return;
            }

            /*
             * if (MouseButtonState.Pressed == e.RightButton)
             * {
             *  logger.Info("this.PageImage.ContextMenu.IsOpen = true");
             *  if (!this.PageImage.ContextMenu.IsOpen)
             *      this.PageImage.ContextMenu.IsOpen = true;
             * }
             */

            if (!IsDragged && MouseButtonState.Pressed == e.LeftButton)
            {
                RelMousePos = e.MouseDevice.GetPosition(this);
                // Use a hit test to determine if node
                HitTestResult result = VisualTreeHelper.HitTest(
                    this, e.MouseDevice.GetPosition(this));

                if (result.VisualHit.GetType().IsAssignableFrom(typeof(Ellipse)))
                {
                    Ellipse    shape = (Ellipse)result.VisualHit;
                    RenderNode node  = null;
                    foreach (var inputNode in InputNodes)
                    {
                        if (inputNode.Visual == shape)
                        {
                            node = inputNode;
                        }
                    }
                    foreach (var outputNode in OutputNodes)
                    {
                        if (outputNode.Visual == shape)
                        {
                            node = outputNode;
                        }
                    }
                    logger.Info("Calling delete OnNodeDragStart to start drawing connection line ");
                    OnNodeStartConnectionLine(node ?? throw new Exception("Hit ellipse shape is not in a node map"));
                    return;
                }
                // If not, just drag the module
                IsDragged = true;
                logger.Info("IsDragged ={0}", IsDragged);

                WorkflowCanvas.SetZIndex(this, 2);
                var window = Window.GetWindow(this);

                if (window != null)
                {
                    window.MouseUp += OnCanvasDragDrop;
                }
            }
        }