示例#1
0
        /// <summary>
        /// Create the lists of actions that can be performed on a mouse click or with a keystroke
        /// </summary>
        private void CreateDirectActions()
        {
            // the order in which the actions are defined determines the order in which they are tried
            editorDragActionsMouseClicked = new List <EditorActionMouseDrag>
            {
                //new EditorActionMouseDragVectorNode(), // No longer needed since the DragAutoConnect handles this directly
                new EditorActionMouseDragAutoConnect()
            };

            // the order in which the actions are defined determines the order in which they are tried
            editorActionsMouseClicked = new List <EditorAction>
            {
                new EditorActionAddStart(),
                new EditorActionOtherStartDirection(),
                new EditorActionTakeOtherExit(),
                new EditorActionTakeOtherExitPassingPath(),
                new EditorActionAutoFixBrokenNodes(),
                new EditorActionRemovePassingPath(),
                new EditorActionEditWait(),
                new EditorActionRemoveReverse(),
                new EditorActionRemoveEnd(),
            };

            possibleAddEndAction  = new EditorActionAddEnd();
            possibleAddWaitAction = new EditorActionAddWait();
        }
示例#2
0
        /// <summary>
        /// Determine which action would be taken if, subsequently, the left-mouse button will be clicked
        /// </summary>
        /// <param name="wantDragAction">Do we want a drag-action?</param>
        /// <param name="wantClickAction">Do we want a click-action?</param>
        /// <param name="mouseX">The current location of the mouse in x-direction</param>
        /// <param name="mouseY">The current location of the mouse in y-direction</param>
        public void DeterminePossibleActions(bool wantDragAction, bool wantClickAction, int mouseX, int mouseY)
        {
            CurrentActionDescription = "";
            activeMouseDragAction    = null;
            activeMouseClickAction   = null;
            if (wantDragAction)
            {
                foreach (EditorActionMouseDrag mouseDragAction in editorDragActionsMouseClicked)
                {
                    if (mouseDragAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits,
                                                  mouseX, mouseY))
                    {
                        CurrentActionDescription = mouseDragAction.ToString();
                        activeMouseDragAction    = mouseDragAction;
                        return;
                    }
                }
            }
            else if (wantClickAction)
            {
                foreach (EditorAction action in editorActionsMouseClicked)
                {
                    bool actionCanBeExecuted = action.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits,
                                                                mouseX, mouseY);
                    if (actionCanBeExecuted)
                    {
                        CurrentActionDescription = action.ToString();
                        activeMouseClickAction   = action;
                        return;
                    }
                }
            }

            //direct key actions
            activeAddEndAction = possibleAddEndAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits, mouseX, mouseY) ?
                                 possibleAddEndAction : null;
            activeAddWaitAction = possibleAddWaitAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits, mouseX, mouseY) ?
                                  possibleAddWaitAction : null;
        }