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)));
            }
            
        }
        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)));
            }
        }
示例#3
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");
            }
        }
示例#4
0
        void OnModelCommandStarting(DynamoModel.RecordableCommand command)
        {
            var name = command.GetType().Name;
            switch (name)
            {
                case "OpenFileCommand":
                    this.VisualizationManager.Pause();
                    break;

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

                case "RunCancelCommand":
                case "ForceRunCancelCommand":
                case "CreateNodeCommand":
                case "CreateNoteCommand":
                case "SelectModelCommand":
                case "SelectInRegionCommand":
                case "DragSelectionCommand":
                case "DeleteModelCommand":
                case "UndoRedoCommand":
                case "ModelEventCommand":
                case "UpdateModelValueCommand":
                case "ConvertNodesToCodeCommand":
                case "CreateCustomNodeCommand":
                case "SwitchTabCommand":
                case "MutateTestCommand":
                    // for this commands there is no need
                    // to do anything before execution
                    break;

                default:
                    throw new InvalidOperationException("Unhandled command name");
            }
        }
 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);
     }
 }