Esempio n. 1
0
 public void NewFile()
 {
     NodeCollection.Clear();
     ConnectorCollection.Clear();
     Children.Clear();
     if (radialMenu != null)
     {
         radialMenu.Dispose();
     }
     radialMenu    = null;
     selectionNode = null;
 }
Esempio n. 2
0
        private void ShowSelectionNode()
        {
            if (selectionNode == null)
            {
                selectionNode = new SelectionNode(this);
            }

            selectionNode.Left = Mouse.GetPosition(this).X - 45;
            selectionNode.Top  = Mouse.GetPosition(this).Y - 20;

            selectionNode.Show();
        }
Esempio n. 3
0
 public void NewFile()
 {
     NodeCollection.Clear();
     ConnectorCollection.Clear();
     Children.Clear();
     if (radialMenu != null) radialMenu.Dispose();
     radialMenu = null;
     selectionNode = null;
 }
Esempio n. 4
0
        private void ShowSelectionNode()
        {
            if (selectionNode == null)
            {
                selectionNode = new SelectionNode(this);
            }

            selectionNode.Left = Mouse.GetPosition(this).X - 45;
            selectionNode.Top = Mouse.GetPosition(this).Y - 20;

            selectionNode.Show();
        }
Esempio n. 5
0
        private async void HandleMouseDown(object sender, MouseButtonEventArgs e)
        {
            switch (MouseMode)
            {
            case MouseModes.Nothing:

                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    if (e.ClickCount == 2)
                    {
                        // double click in empty space of canvas
                        var node = new SelectionNode(this)
                        {
                            Left = Mouse.GetPosition(this).X - 15,
                            Top  = Mouse.GetPosition(this).Y - 20
                        };
                    }
                    else
                    {
                        var mouseUpOnNode = false;

                        foreach (var node in NodeCollection)
                        {
                            if (VisualTreeHelper.HitTest(node.Border, e.GetPosition(node)) != null)
                            {
                                mouseUpOnNode = true;
                            }
                        }

                        // if mouse up in empty space
                        if (!mouseUpOnNode)
                        {
                            startSelectionPoint = Mouse.GetPosition(this);
                            MouseMode           = MouseModes.Selection;
                            SplineMode          = SplineModes.Nothing;

                            if (radialMenu != null)
                            {
                                radialMenu.IsOpen = false;
                                radialMenu.Dispose();
                                radialMenu = null;
                            }
                        }
                    }
                }
                else if (e.MiddleButton == MouseButtonState.Pressed)
                {
                    // panning
                    foreach (var node in NodeCollection)
                    {
                        node.OldMousePosition = e.GetPosition(this);

                        if (MouseMode != MouseModes.Panning)
                        {
                            MouseMove += node.HostCanvas_MouseMove;
                        }
                    }

                    MouseMode = MouseModes.Panning;
                }
                else if (e.RightButton == MouseButtonState.Pressed)
                {
                    if (radialMenu == null)
                    {
                        radialMenu = new RadialContentMenu(this);
                        Children.Add(radialMenu);
                    }

                    if (radialMenu.IsOpen)
                    {
                        radialMenu.IsOpen = false;
                        await Task.Delay(400);
                    }
                    radialMenu.SetValue(LeftProperty, Mouse.GetPosition(this).X - 150);
                    radialMenu.SetValue(TopProperty, Mouse.GetPosition(this).Y - 150);

                    radialMenu.IsOpen = true;
                }

                break;
            }
        }
        private async void HandleMouseDown(object sender, MouseButtonEventArgs e)
        {
            switch (MouseMode)
            {
                case MouseModes.Nothing:

                    if (e.LeftButton == MouseButtonState.Pressed)
                    {
                        if (e.ClickCount == 2)
                        {
                            // double click in empty space of canvas
                            var node = new SelectionNode(this)
                            {
                                Left = Mouse.GetPosition(this).X - 15,
                                Top = Mouse.GetPosition(this).Y - 20
                            };
                        }
                        else
                        {
                            var mouseUpOnNode = false;

                            foreach (var node in NodeCollection)
                            {
                                if (VisualTreeHelper.HitTest(node.Border, e.GetPosition(node)) != null)
                                    mouseUpOnNode = true;
                            }

                            // if mouse up in empty space
                            if (!mouseUpOnNode)
                            {
                                startSelectionPoint = Mouse.GetPosition(this);
                                MouseMode = MouseModes.Selection;
                                SplineMode = SplineModes.Nothing;

                                if (radialMenu != null)
                                {
                                    radialMenu.IsOpen = false;
                                    radialMenu.Dispose();
                                    radialMenu = null;
                                }
                            }
                        }
                    }
                    else if (e.MiddleButton == MouseButtonState.Pressed)
                    {
                        // panning
                        foreach (var node in NodeCollection)
                        {
                            node.OldMousePosition = e.GetPosition(this);

                            if (MouseMode != MouseModes.Panning)
                                MouseMove += node.HostCanvas_MouseMove;
                        }

                        MouseMode = MouseModes.Panning;
                    }
                    else if (e.RightButton == MouseButtonState.Pressed)
                    {
                        if (radialMenu == null)
                        {
                            radialMenu = new RadialContentMenu(this);
                            Children.Add(radialMenu);
                        }

                        if (radialMenu.IsOpen)
                        {
                            radialMenu.IsOpen = false;
                            await Task.Delay(400);
                        }
                        radialMenu.SetValue(LeftProperty, Mouse.GetPosition(this).X - 150);
                        radialMenu.SetValue(TopProperty, Mouse.GetPosition(this).Y - 150);

                        radialMenu.IsOpen = true;
                    }

                    break;
            }
        }