Ejemplo n.º 1
0
                internal static bool CheckIsDoubleClick(
                    MouseClickHistory prevClick, MouseClickHistory curClick)
                {
                    if (prevClick == null || (curClick.Source != prevClick.Source))
                    {
                        return(false); // Click events did not come from same source
                    }
                    int clickInterval = curClick.Timestamp - prevClick.Timestamp;

                    if (clickInterval > System.Windows.Forms.SystemInformation.DoubleClickTime)
                    {
                        return(false); // Time difference is more than system DoubleClickTime
                    }
                    double diff = Math.Abs(prevClick.Position.X - curClick.Position.X);

                    if (diff > Configurations.DoubleClickAcceptableDistance)
                    {
                        return(false); // Click is beyond acceptable threshold.
                    }
                    diff = Math.Abs(prevClick.Position.Y - curClick.Position.Y);
                    if (diff > Configurations.DoubleClickAcceptableDistance)
                    {
                        return(false); // Click is beyond acceptable threshold.
                    }
                    return(true);
                }
Ejemplo n.º 2
0
            internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (false != ignoreMouseClick)
                {
                    ignoreMouseClick = false;
                    return(false);
                }

                MouseClickHistory curClick = new MouseClickHistory(sender, e);

                bool eventHandled        = false;
                bool returnFocusToSearch = true;

                if (this.currentState == State.Connection)
                {
                    // Clicking on the canvas while connecting simply cancels
                    // the operation and drop the temporary connector.
                    SetCurrentState(State.None);

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.None)
                {
                    // Record the mouse down position.
                    IInputElement element = sender as IInputElement;
                    mouseDownPos = e.GetPosition(element);

                    // We'll see if there is any node being clicked on. If so,
                    // then the state machine should initiate a drag operation.
                    if (null != GetSelectableFromPoint(mouseDownPos))
                    {
                        InitiateDragSequence();
                    }
                    else if (e.Source is Dynamo.Controls.EndlessGrid && MouseClickHistory.CheckIsDoubleClick(prevClick, curClick))
                    {
                        CreateCodeBlockNode(mouseDownPos); // Double clicking on background (EndlessGrid)
                        returnFocusToSearch = false;       // Keep the focus on newly created code block node.
                        prevClick           = null;
                    }
                    else
                    {
                        InitiateWindowSelectionSequence();
                    }

                    prevClick = curClick;

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.PanMode)
                {
                    owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                }

                if (returnFocusToSearch != false)
                {
                    dynSettings.ReturnFocusToSearch();
                }

                return(eventHandled);
            }
Ejemplo n.º 3
0
                public static bool CheckIsDoubleClick(MouseClickHistory prevClick, MouseClickHistory curClick)
                {
                    if (prevClick == null || (curClick.Source != prevClick.Source))
                        return false; // Click events did not come from same source

                    int clickInterval = curClick.Timestamp - prevClick.Timestamp;
                    if (clickInterval > System.Windows.Forms.SystemInformation.DoubleClickTime)
                        return false; // Time difference is more than system DoubleClickTime

                    double diff = Math.Abs(prevClick.Position.X - curClick.Position.X);
                    if (diff > Configurations.DoubleClickAcceptableDistance)
                        return false; // Click is beyond acceptable threshold.

                    diff = Math.Abs(prevClick.Position.Y - curClick.Position.Y);
                    if (diff > Configurations.DoubleClickAcceptableDistance)
                        return false; // Click is beyond acceptable threshold.

                    return true;
                }
Ejemplo n.º 4
0
            internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (false != ignoreMouseClick)
                {
                    ignoreMouseClick = false;
                    return false;
                }

                MouseClickHistory curClick = new MouseClickHistory(sender, e);

                bool eventHandled = false;
                if (this.currentState == State.Connection)
                {
                    // Clicking on the canvas while connecting simply cancels 
                    // the operation and drop the temporary connector.
                    SetCurrentState(State.None);

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.None)
                {
                    // Record the mouse down position.
                    IInputElement element = sender as IInputElement;
                    mouseDownPos = e.GetPosition(element);

                    // We'll see if there is any node being clicked on. If so, 
                    // then the state machine should initiate a drag operation.
                    if (null != GetSelectableFromPoint(mouseDownPos))
                        InitiateDragSequence();
                    else if (e.Source is Dynamo.Controls.EndlessGrid && MouseClickHistory.CheckIsDoubleClick(prevClick, curClick))
                    {
                        CreateCodeBlockNode(mouseDownPos); // Double clicking on background (EndlessGrid)
                        prevClick = null;
                    }
                    else
                        InitiateWindowSelectionSequence();

                    prevClick = curClick;

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.PanMode)
                {
                    owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                }

                dynSettings.ReturnFocusToSearch();

                return eventHandled;
            }
Ejemplo n.º 5
0
            internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (false != ignoreMouseClick)
                {
                    ignoreMouseClick = false;
                    return false;
                }

                MouseClickHistory curClick = new MouseClickHistory(sender, e);

                bool eventHandled = false;
                bool returnFocusToSearch = true;
                if (this.currentState == State.Connection)
                {
                    // Clicking on the canvas while connecting simply cancels 
                    // the operation and drop the temporary connector.
                    SetCurrentState(State.None);

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.None)
                {
                    // Record the mouse down position.
                    IInputElement element = sender as IInputElement;
                    mouseDownPos = e.GetPosition(element);

                    // We'll see if there is any node being clicked on. If so, 
                    // then the state machine should initiate a drag operation.
                    if (null != GetSelectableFromPoint(mouseDownPos))
                        InitiateDragSequence();
                    else
                    {
                        if ((e.Source is Dynamo.Controls.EndlessGrid) == false)
                            InitiateWindowSelectionSequence();
                        else if (!MouseClickHistory.CheckIsDoubleClick(prevClick, curClick))
                            InitiateWindowSelectionSequence();
                        else
                        {
                            // Double-clicking on the background grid results in 
                            // a code block node being created, in which case we
                            // should keep the input focus on the code block to 
                            // avoid it being dismissed (with empty content).
                            // 
                            CreateCodeBlockNode(mouseDownPos);
                            returnFocusToSearch = false;
                            curClick = null;
                        }
                    }

                    prevClick = curClick;

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.PanMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }
                else if (this.currentState == State.OrbitMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }

                if (returnFocusToSearch != false)
                    dynSettings.ReturnFocusToSearch();

                return eventHandled;
            }
Ejemplo n.º 6
0
            internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (false != ignoreMouseClick)
                {
                    ignoreMouseClick = false;
                    return(false);
                }

                MouseClickHistory curClick = new MouseClickHistory(sender, e);

                bool eventHandled        = false;
                bool returnFocusToSearch = true;

                if (this.currentState == State.Connection)
                {
                    // Clicking on the canvas while connecting simply cancels
                    // the operation and drop the temporary connector.
                    SetCurrentState(State.None);

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.None)
                {
                    // Record the mouse down position.
                    IInputElement element = sender as IInputElement;
                    mouseDownPos = e.GetPosition(element);

                    // We'll see if there is any node being clicked on. If so,
                    // then the state machine should initiate a drag operation.
                    if (null != GetSelectableFromPoint(mouseDownPos))
                    {
                        InitiateDragSequence();
                        returnFocusToSearch = ShouldDraggingReturnFocusToSearch();
                    }
                    else
                    {
                        if ((e.Source is Dynamo.Controls.EndlessGrid) == false)
                        {
                            InitiateWindowSelectionSequence();
                        }
                        else if (!MouseClickHistory.CheckIsDoubleClick(prevClick, curClick))
                        {
                            InitiateWindowSelectionSequence();
                        }
                        else
                        {
                            // Double-clicking on the background grid results in
                            // a code block node being created, in which case we
                            // should keep the input focus on the code block to
                            // avoid it being dismissed (with empty content).
                            //
                            CreateCodeBlockNode(mouseDownPos);

                            returnFocusToSearch = false;
                            curClick            = null;
                        }
                    }

                    prevClick = curClick;

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.PanMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }
                else if (this.currentState == State.OrbitMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }

                if (returnFocusToSearch != false)
                {
                    owningWorkspace.DynamoViewModel.ReturnFocusToSearch();
                }

                return(eventHandled);
            }