public void ExecuteCommand(DynamoModel.RecordableCommand command, string uniqueId, string extensionName)
        {
            // log that the command is being executed
            if (dynamoModel.DebugSettings.VerboseLogging)
            {
                dynamoModel.Logger.Log("Command: " + command);
            }

            var extnDetails = string.Format(
                "ExtensionCommandExecutive ( UniqueId: {0}, Name: {1}, commandTypeName: {2} )",
                uniqueId, extensionName, command.GetType().Name);

            Log(LogMessage.Info(extnDetails));

            try
            {
                // run the command
                dynamoModel.ExecuteCommand(command);
            }
            catch (Exception e)
            {
                // clean up or show failure messages
                Log(LogMessage.Error(string.Format("{0}, from {1}", e.Message, extnDetails)));
            }
        }
Esempio n. 2
0
 internal void RecordCommand(DynamoModel.RecordableCommand command)
 {
     // In the playback mode 'this.recordedCommands' will be
     // 'null' so that the incoming command will not be recorded.
     if (null != recordedCommands)
     {
         if (command.Redundant && (recordedCommands.Count > 0))
         {
             // If a command is being marked "Redundant", then we will
             // only be interested in the most recent one. If we already
             // have another instance recorded immediately prior to this,
             // then replace the old instance with the new (for details,
             // see "RecordableCommand.Redundant" property).
             //
             var previousCommand = recordedCommands.Last();
             if (previousCommand.GetType() != command.GetType())
             {
                 recordedCommands.Add(command);
             }
             else
             {
                 // Replace the existing command instead of adding.
                 recordedCommands[recordedCommands.Count - 1] = command;
             }
         }
         else
         {
             recordedCommands.Add(command);
         }
     }
 }
Esempio n. 3
0
        public void ExecuteCommand(DynamoModel.RecordableCommand command)
        {
            if (null != this.automationSettings)
            {
                this.automationSettings.RecordCommand(command);
            }

            if (Model.DebugSettings.VerboseLogging)
            {
                model.Logger.Log("Command: " + command);
            }

            this.model.ExecuteCommand(command);
        }
Esempio n. 4
0
        void OnModelCommandStarting(DynamoModel.RecordableCommand command)
        {
            var name = command.GetType().Name;

            switch (name)
            {
            case "MakeConnectionCommand":
                MakeConnectionImpl(command as DynamoModel.MakeConnectionCommand);
                break;

            case "UndoRedoCommand":
                UndoRedoImpl(command as DynamoModel.UndoRedoCommand);
                break;

            case "OpenFileCommand":
            case "RunCancelCommand":
            case "ForceRunCancelCommand":
            case "CreateNodeCommand":
            case "CreateProxyNodeCommand":
            case "CreateNoteCommand":
            case "CreateAnnotationCommand":
            case "SelectModelCommand":
            case "SelectInRegionCommand":
            case "DragSelectionCommand":
            case "DeleteModelCommand":
            case "ModelEventCommand":
            case "UpdateModelValueCommand":
            case "ConvertNodesToCodeCommand":
            case "CreateCustomNodeCommand":
            case "SwitchTabCommand":
            case "MutateTestCommand":
            case "UngroupModelCommand":
            case "AddModelToGroupCommand":
            case "AddPresetCommand":
            case "ApplyPresetCommand":
            case "CreateAndConnectNodeCommand":
            case "AddGroupToGroupCommand":
                // for this commands there is no need
                // to do anything before execution
                break;

            default:
                throw new InvalidOperationException("Unhandled command name");
            }
        }
        public void ExecuteCommand(DynamoModel.RecordableCommand command, string uniqueId, string extensionName)
        {
            var extnDetails = string.Format(
                "ViewExtensionCommandExecutive ( UniqueId: {0}, Name: {1}, commandTypeName: {2} )",
                uniqueId, extensionName, command.GetType().Name);

            Log(LogMessage.Info(extnDetails));
            try
            {
                // run the command
                dynamoViewModel.ExecuteCommand(command);
            }
            catch (Exception e)
            {
                // clean up or show failure messages
                Log(LogMessage.Error(string.Format("{0}, from {1}", e.Message, extnDetails)));
            }
        }
Esempio n. 6
0
 void OnCommandStarting(DynamoModel.RecordableCommand command)
 {
     cmdExecutionState = 1;
 }
Esempio n. 7
0
 void OnCommandCompleted(DynamoModel.RecordableCommand command)
 {
     cmdExecutionState--;
 }
Esempio n. 8
0
        private void OnPlaybackTimerTick(object sender, EventArgs e)
        {
            var timer = (DispatcherTimer)sender;

            timer.Stop();                  // Stop the timer before command completes.

            if (loadedCommands.Count <= 0) // There's nothing else for playback.
            {
                if (ExitAfterPlayback == false)
                {
                    // The playback is done, but the command file indicates that
                    // Dynamo should not be shutdown after the playback, so here
                    // we simply invalidate the timer.
                    //
                    playbackTimer = null;
                    ChangeStateInternal(State.Stopped);
                }
                else
                {
                    // The command file requires Dynamo be shutdown after all
                    // commands has been played back. If that's the case, we'll
                    // reconfigure the callback to a shutdown timer, and then
                    // change its interval to the duration specified earlier.
                    //
                    playbackTimer.Tick -= OnPlaybackTimerTick;
                    playbackTimer.Tick += OnShutdownTimerTick;

                    var interval = TimeSpan.FromMilliseconds(PauseAfterPlayback);
                    playbackTimer.Interval = interval;
                    playbackTimer.Start(); // Start shutdown timer.
                    ChangeStateInternal(State.ShuttingDown);
                }

                return;
            }

            // Remove the first command from the loaded commands.
            DynamoModel.RecordableCommand nextCommand = loadedCommands[0];
            loadedCommands.RemoveAt(0);

            // Update the cached command references.
            PreviousCommand = CurrentCommand;
            CurrentCommand  = nextCommand;

            if (nextCommand is DynamoModel.PausePlaybackCommand)
            {
                var command = nextCommand as DynamoModel.PausePlaybackCommand;
                PauseCommandPlayback(command.PauseDurationInMs);
                return;
            }

            try
            {
                // Execute the command, this may take a while longer than the timer
                // inverval (usually very short), that's why the timer was stopped
                // before the command execution starts. After the command is done,
                // the timer is then resumed for the next command in queue.
                //
                owningDynamoModel.ExecuteCommand(nextCommand);
            }
            catch (Exception exception)
            {
                // An exception is thrown while playing back a command. Remove any
                // pending commands and allow the "playbackTimer" to continue with
                // its next tick. Proper shutdown sequence will be initialized
                // when the "playbackTimer" tries to pick up the next command and
                // realized that there is no more commands waiting.
                //
                loadedCommands.Clear();
                PlaybackException = exception;
            }

            timer.Start();
        }
Esempio n. 9
0
        void OnModelCommandCompleted(DynamoModel.RecordableCommand command)
        {
            var name = command.GetType().Name;

            switch (name)
            {
            case "OpenFileCommand":
                this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).XmlFilePath);
                this.VisualizationManager.UnPause();
                break;

            case "MutateTestCommand":
                var mutatorDriver = new Dynamo.TestInfrastructure.MutatorDriver(this);
                mutatorDriver.RunMutationTests();
                break;

            case "SelectInRegionCommand":
                var selectC = command as DynamoModel.SelectInRegionCommand;
                CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection);
                break;

            case "DragSelectionCommand":
                var dragC = command as DynamoModel.DragSelectionCommand;

                if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation)
                {
                    CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor);
                }
                else
                {
                    CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor);
                }
                break;

            case "DeleteModelCommand":
            case "CreateNodeCommand":
            case "CreateNoteCommand":
            case "UndoRedoCommand":
            case "ModelEventCommand":
            case "UpdateModelValueCommand":
            case "ConvertNodesToCodeCommand":
                UndoCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
                break;

            case "SwitchTabCommand":
                if (command.IsInPlaybackMode)
                {
                    RaisePropertyChanged("CurrentWorkspaceIndex");
                }
                break;

            case "RunCancelCommand":
            case "ForceRunCancelCommand":
            case "SelectModelCommand":
            case "MakeConnectionCommand":
            case "CreateCustomNodeCommand":
                // for this commands there is no need
                // to do anything after execution
                break;

            default:
                throw new InvalidOperationException("Unhandled command name");
            }
        }
Esempio n. 10
0
        void OnModelCommandCompleted(DynamoModel.RecordableCommand command)
        {
            var name = command.GetType().Name;

            switch (name)
            {
            case "OpenFileCommand":
                this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).FilePath);
                break;

            case "SelectInRegionCommand":
                var selectC = command as DynamoModel.SelectInRegionCommand;
                CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection);
                break;

            case "DragSelectionCommand":
                var dragC = command as DynamoModel.DragSelectionCommand;

                if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation)
                {
                    CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor);
                }
                else
                {
                    CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor);
                }
                break;

            case "DeleteModelCommand":
                CurrentSpaceViewModel.CancelActiveState();
                RaiseCanExecuteUndoRedo();
                break;

            case "CreateNodeCommand":
            case "CreateProxyNodeCommand":
            case "CreateNoteCommand":
            case "CreateAnnotationCommand":
            case "UndoRedoCommand":
            case "ModelEventCommand":
            case "UpdateModelValueCommand":
            case "ConvertNodesToCodeCommand":
            case "UngroupModelCommand":
            case "AddModelToGroupCommand":
            case "CreateAndConnectNodeCommand":
                RaiseCanExecuteUndoRedo();
                break;

            case "SwitchTabCommand":
                if (command.IsInPlaybackMode)
                {
                    RaisePropertyChanged("CurrentWorkspaceIndex");
                }
                break;

            case "RunCancelCommand":
            case "ForceRunCancelCommand":
            case "SelectModelCommand":
            case "MakeConnectionCommand":
            case "CreateCustomNodeCommand":
            case "AddPresetCommand":
            case "ApplyPresetCommand":
                // for this commands there is no need
                // to do anything after execution
                break;

            default:
                throw new InvalidOperationException("Unhandled command name");
            }
        }