Esempio n. 1
0
        //--------------------------------------------------------------------------
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (Graph.MouseOverItem is Connection)
            {
                return;
            }

            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                //IsSelected = !IsSelected;
            }
            else
            {
                IsSelected = true;
            }

            Keyboard.Focus(Graph);

            m_inDrag        = true;
            m_mouseDragLast = MouseUtilities.CorrectGetPosition(Graph);
            foreach (var node in Graph.Selected)
            {
                node.m_startX = node.X;
                node.m_startY = node.Y;
            }

            this.CaptureMouse();

            Graph.UpdateSnapLines();

            e.Handled = true;

            base.OnMouseLeftButtonDown(e);
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                //IsSelected = !IsSelected;
            }
            else
            {
                IsSelected = true;
            }

            m_inDrag        = true;
            m_mouseDragLast = MouseUtilities.CorrectGetPosition(LinkParent.Graph);

            foreach (var node in LinkParent.Graph.Selected)
            {
                node.StoreStartPos();
            }

            this.CaptureMouse();

            e.Handled = true;

            base.OnMouseLeftButtonDown(e);
        }
        //--------------------------------------------------------------------------
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            m_inDrag        = true;
            m_mouseDragLast = MouseUtilities.CorrectGetPosition(LinkParent.Graph);
            m_startX        = Position.X;
            m_startY        = Position.Y;

            this.CaptureMouse();

            e.Handled = true;

            base.OnMouseLeftButtonDown(e);
        }
Esempio n. 4
0
        //--------------------------------------------------------------------------
        protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            var current = MouseUtilities.CorrectGetPosition(Graph);
            var diff    = current - m_mouseDragLast;

            if (Math.Abs(diff.X) < 10 && Math.Abs(diff.Y) < 10)
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    IsSelected = !IsSelected;
                }
            }

            base.OnPreviewMouseLeftButtonUp(e);
        }
Esempio n. 5
0
        //--------------------------------------------------------------------------
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (Graph.CreatingLink != null)
            {
                if (Graph.CreatingLink.AllowedTypes.Contains(GraphNodeItem.Definition.Name) && Graph.CanHaveCircularReferences || Graph.CreatingLink.Link == this || !Graph.CreatingLink.Node.IsCircular(this))
                {
                    Graph.ConnectedLinkTo = this;
                    if (!(Graph.MouseOverItem is Connection))
                    {
                        Graph.MouseOverItem = this;
                    }

                    Graph.m_inProgressLink.Dest = Position;

                    e.Handled = true;
                }
            }

            if (e.LeftButton != MouseButtonState.Pressed)
            {
                m_inDrag = false;
            }

            if (m_inDrag)
            {
                var current = MouseUtilities.CorrectGetPosition(Graph);
                var diff    = current - m_mouseDragLast;

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    var x = m_startX + diff.X / Graph.Scale;
                    var y = m_startY + diff.Y / Graph.Scale;

                    double?chosenSnapX = null;
                    foreach (var snapline in Graph.SnapLinesX)
                    {
                        if (Math.Abs(x - snapline) < 10)
                        {
                            chosenSnapX = snapline;
                            break;
                        }
                        else if (Math.Abs((x + ActualWidth) - snapline) < 10)
                        {
                            chosenSnapX = snapline - ActualWidth;
                            break;
                        }
                    }

                    double?chosenSnapY = null;
                    foreach (var snapline in Graph.SnapLinesY)
                    {
                        if (Math.Abs(y - snapline) < 10)
                        {
                            chosenSnapY = snapline;
                            break;
                        }
                        else if (Math.Abs((y + ActualHeight) - snapline) < 10)
                        {
                            chosenSnapY = snapline - ActualHeight;
                            break;
                        }
                    }

                    if (chosenSnapX.HasValue)
                    {
                        x = chosenSnapX.Value;
                    }
                    if (chosenSnapY.HasValue)
                    {
                        y = chosenSnapY.Value;
                    }

                    diff.X = (x - m_startX) * Graph.Scale;
                    diff.Y = (y - m_startY) * Graph.Scale;
                }

                foreach (var node in Graph.Selected)
                {
                    node.X = node.m_startX + diff.X / Graph.Scale;
                    node.Y = node.m_startY + diff.Y / Graph.Scale;
                }
            }

            base.OnMouseMove(e);
        }
        //--------------------------------------------------------------------------
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                m_inDrag = false;
            }

            if (m_inDrag)
            {
                var current = MouseUtilities.CorrectGetPosition(Graph);
                var diff    = current - m_mouseDragLast;

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    var x = diff.X / Graph.Scale;
                    var y = diff.Y / Graph.Scale;

                    double?chosenSnapX = null;
                    foreach (var snapline in Graph.SnapLinesX)
                    {
                        if (Math.Abs(x - snapline) < 10)
                        {
                            chosenSnapX = snapline;
                            break;
                        }
                        else if (Math.Abs((x + ActualWidth) - snapline) < 10)
                        {
                            chosenSnapX = snapline - ActualWidth;
                            break;
                        }
                    }

                    double?chosenSnapY = null;
                    foreach (var snapline in Graph.SnapLinesY)
                    {
                        if (Math.Abs(y - snapline) < 10)
                        {
                            chosenSnapY = snapline;
                            break;
                        }
                        else if (Math.Abs((y + ActualHeight) - snapline) < 10)
                        {
                            chosenSnapY = snapline - ActualHeight;
                            break;
                        }
                    }

                    if (chosenSnapX.HasValue)
                    {
                        x = chosenSnapX.Value;
                    }
                    if (chosenSnapY.HasValue)
                    {
                        y = chosenSnapY.Value;
                    }

                    diff.X = x * Graph.Scale;
                    diff.Y = y * Graph.Scale;
                }

                m_disableUpdate = true;
                foreach (var node in Nodes)
                {
                    node.X = node.m_startX + diff.X / Graph.Scale;
                    node.Y = node.m_startY + diff.Y / Graph.Scale;
                }
                m_disableUpdate = false;

                UpdateCommentSize();
            }

            base.OnMouseMove(e);
        }
Esempio n. 7
0
        //--------------------------------------------------------------------------
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                m_inDrag = false;
            }

            if (m_inDrag)
            {
                var current = MouseUtilities.CorrectGetPosition(LinkParent.Graph);
                var diff    = current - m_mouseDragLast;

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    var x = m_startX + diff.X / LinkParent.Graph.Scale;
                    var y = m_startY + diff.Y / LinkParent.Graph.Scale;

                    double?chosenSnapX = null;
                    foreach (var snapline in LinkParent.Graph.SnapLinesX)
                    {
                        if (Math.Abs(x - snapline) < 10)
                        {
                            chosenSnapX = snapline;
                            break;
                        }
                        else if (Math.Abs((x + ActualWidth) - snapline) < 10)
                        {
                            chosenSnapX = snapline - ActualWidth;
                            break;
                        }
                    }

                    double?chosenSnapY = null;
                    foreach (var snapline in LinkParent.Graph.SnapLinesY)
                    {
                        if (Math.Abs(y - snapline) < 10)
                        {
                            chosenSnapY = snapline;
                            break;
                        }
                        else if (Math.Abs((y + ActualHeight) - snapline) < 10)
                        {
                            chosenSnapY = snapline - ActualHeight;
                            break;
                        }
                    }

                    if (chosenSnapX.HasValue)
                    {
                        x = chosenSnapX.Value;
                    }
                    if (chosenSnapY.HasValue)
                    {
                        y = chosenSnapY.Value;
                    }

                    diff.X = (x - m_startX) * LinkParent.Graph.Scale;
                    diff.Y = (y - m_startY) * LinkParent.Graph.Scale;
                }

                foreach (var node in LinkParent.Graph.Selected)
                {
                    node.Translate(new Point(diff.X / LinkParent.Graph.Scale, diff.Y / LinkParent.Graph.Scale));
                }
            }

            base.OnMouseMove(e);
        }