Exemplo n.º 1
0
        public override void MouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (e.OriginalSource is FrameworkElement element)
                {
                    if (element.Parent is NodeBubble bubble)
                    {
                        this.ClickCount++;

                        if (this.ClickCount == 1)
                        {
                            this.StartNode = bubble;
                            this.PhantomArrow.StartPoint = bubble.Position;
                            MainWindow.Current.MyCanvas.Children.Add(this.PhantomArrow);
                        }
                        else
                        {
                            if (bubble != this.StartNode)
                            {
                                this.EndNode = bubble;
                            }
                        }
                    }
                }

                // TODO: use status bar to show this info.
            }
        }
Exemplo n.º 2
0
 public override void MouseDownHandler(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         if (e.OriginalSource is FrameworkElement element)
         {
             if (element.Parent is NodeBubble bubble)
             {
                 this.BubbleToMove = bubble;
             }
         }
     }
 }
Exemplo n.º 3
0
        public override void MouseUpHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (this.ClickCount >= 2)
                {
                    if (this.StartNode != null && this.EndNode != null)
                    {
                        if (!MainWindow.Current.Arrows.ContainsKeys(this.StartNode.NodeID, this.EndNode.NodeID))
                        {
                            var link = new FlowLink
                            {
                                From  = this.StartNode.NodeID,
                                To    = this.EndNode.NodeID,
                                Label = string.Empty
                            };

                            var arrow = new BezierLink
                            {
                                StartPoint  = this.StartNode.Position,
                                EndPoint    = this.EndNode.Position,
                                StartOffset = DataManager.NodeSize / 2,
                                EndOffset   = DataManager.NodeSize / 2,
                                Tag         = (link.From, link.To)
                            };

                            Canvas.SetZIndex(arrow, 100);
                            arrow.ReadyControl();

                            MainWindow.Current.MyCanvas.Children.Add(arrow);
                            MainWindow.Current.Arrows.Add(link.From, link.To, arrow);
                            DataManager.CurrentDocument.LinksStore.Add(link.From, link.To, link);
                        }

                        this.ClickCount = 0;
                        this.StartNode  = null;
                        this.EndNode    = null;
                        MainWindow.Current.MyCanvas.Children.Remove(this.PhantomArrow);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public override void MouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                var clickPoint = e.GetPosition(MainWindow.Current.MyCanvas);
                if (MainWindow.Current.GridToggleSwitch.IsChecked == true)
                {
                    clickPoint = MainWindow.Current.GridLines.Snap(clickPoint);
                }

                var node = new FlowNode
                {
                    ID       = Guid.NewGuid(),
                    Name     = "New node",
                    Metadata = new FlowElementMetadata
                    {
                        Left = clickPoint.X,
                        Top  = clickPoint.Y
                    },
                    Properties = new JObject
                    {
                        { "role", string.Empty },
                        { "user", string.Empty }
                    }
                };

                var bubble = new NodeBubble
                {
                    NodeID   = node.ID,
                    Text     = node.Name,
                    Position = clickPoint
                };

                Canvas.SetZIndex(bubble, 100);
                bubble.ReadyControl();

                MainWindow.Current.MyCanvas.Children.Add(bubble);
                MainWindow.Current.Bubbles.Add(node.ID, bubble);
                DataManager.CurrentDocument.NodesStore.Add(node.ID, node);
            }
        }
Exemplo n.º 5
0
        public override void MouseUpHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (this.BubbleToMove != null)
                {
                    if (MainWindow.Current.GridToggleSwitch.IsChecked == true)
                    {
                        this.BubbleToMove.Position = MainWindow.Current.GridLines.Snap(this.BubbleToMove.Position);
                        this.BubbleToMove.ReadyControl();
                        this.UpdateAllLinks(this.BubbleToMove.Position);
                    }

                    var node = DataManager.CurrentDocument.NodesStore[this.BubbleToMove.NodeID];
                    node.Metadata.Left = this.BubbleToMove.Position.X;
                    node.Metadata.Top  = this.BubbleToMove.Position.Y;
                }

                this.BubbleToMove = null;
            }
        }