Beispiel #1
0
 public Command GetCommand(CommandDefinition commandDefinition)
 {
     Command command;
     if (!_commands.TryGetValue(commandDefinition, out command))
         command = _commands[commandDefinition] = new Command(commandDefinition);
     return command;
 }
Beispiel #2
0
 public TargetableCommand GetTargetableCommand(Command command)
 {
     TargetableCommand targetableCommand;
     if (!_targetableCommands.TryGetValue(command, out targetableCommand))
         targetableCommand = _targetableCommands[command] = new TargetableCommand(command);
     return targetableCommand;
 }
Beispiel #3
0
        public CommandMenuItem(Command command, StandardMenuItem parent)
        {
            _command = command;
            _parent = parent;

            _listItems = new List<StandardMenuItem>();
        }
        public CommandToolBarItem(ToolBarItemDefinition toolBarItem, Command command, IToolBar parent)
        {
            _toolBarItem = toolBarItem;
            _command = command;
            _parent = parent;

            command.PropertyChanged += OnCommandPropertyChanged;
        }
Beispiel #5
0
        public CommandMenuItem(Command command, StandardMenuItem parent)
        {
            _command = command;
            _keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
            _parent = parent;

            _listItems = new List<StandardMenuItem>();
        }
        public override Task Run(Command command)
        {
            var tag = (NewFileTag) command.Tag;
            var newDocument = tag.EditorProvider.CreateNew("Untitled " + (_newFileCounter++) + tag.FileType.FileExtension);
            _shell.OpenDocument(newDocument);

            return TaskUtility.Completed;
        }
        public override Task Run(Command command)
        {
            var dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == true)
                _shell.OpenDocument(GetEditor(dialog.FileName));

            return TaskUtility.Completed;
        }
Beispiel #8
0
        public CommandToolBarItem(ToolBarItemDefinition toolBarItem, Command command, IToolBar parent)
        {
            _toolBarItem = toolBarItem;
            _command = command;
            _keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
            _parent = parent;

            command.PropertyChanged += OnCommandPropertyChanged;
        }
 public override void Update(Command command, List<Command> commands)
 {
     for (var i = 0; i < _shell.Documents.Count; i++)
     {
         var document = _shell.Documents[i];
         commands.Add(new Command(command.CommandDefinition)
         {
             Checked = _shell.ActiveItem == document,
             Text = string.Format("_{0} {1}", i + 1, document.DisplayName),
             Tag = document
         });
     }
 }
 public override void Update(Command command, List<Command> commands)
 {
     foreach (var editorProvider in _editorProviders)
         foreach (var editorFileType in editorProvider.FileTypes)
             commands.Add(new Command(command.CommandDefinition)
             {
                 Text = editorFileType.Name,
                 Tag = new NewFileTag
                 {
                     EditorProvider = editorProvider,
                     FileType = editorFileType
                 }
             });
 }
 public void Populate(Command command, List<Command> commands)
 {
     if (_populateMethod == null)
         throw new InvalidOperationException("Populate can only be called for list-type commands.");
     _populateMethod.Invoke(_commandHandler, new object[] { command, commands });
 }
 public void Update(Command command)
 {
     if (_updateMethod != null)
         _updateMethod.Invoke(_commandHandler, new object[] { command });
 }
Beispiel #13
0
 public CommandToolBarItem(Command command, IToolBar parent)
 {
     _command = command;
     _parent = parent;
 }
 public override Task Run(Command command)
 {
     _shell.OpenDocument(new SceneViewModel());
     return TaskUtility.Completed;
 }
 public override Task Run(Command command)
 {
     _windowManager.ShowDialog(IoC.Get<SettingsViewModel>());
     return TaskUtility.Completed;
 }
Beispiel #16
0
 public override void Update(Command command)
 {
     command.Enabled = (_shell.ActiveItem != null && _shell.ActiveItem.UndoRedoManager.UndoStack.Any());
 }
Beispiel #17
0
 public TargetableCommand(Command command)
 {
     _command = command;
     _commandRouter = IoC.Get<ICommandRouter>();
 }
Beispiel #18
0
 public abstract Task Run(Command command);
 public override Task Run(Command command)
 {
     _shell.OpenDocument(new GraphViewModel(IoC.Get<IInspectorTool>()));
     return TaskUtility.Completed;
 }
 public override Task Run(Command command)
 {
     _shell.ShowTool<IPropertyGrid>();
     return TaskUtility.Completed;
 }
 public override Task Run(Command command)
 {
     _shell.ShowTool<PrimitiveListViewModel>();
     return TaskUtility.Completed;
 }
 public Task Run(Command command)
 {
     return (Task) _runMethod.Invoke(_commandHandler, new object[] { command });
 }
Beispiel #23
0
        /// <summary>
        /// Save changes to a runbook, credential, schedule or variable.
        /// </summary>
        /// <param name="instance"></param>
        public async Task<OperationResult> Save(IViewModel instance, Command command)
        {
            Logger.DebugFormat("Save({0})", instance);
            var context = GetConnection();

            try {
                if (instance.Model is RunbookModelProxy)
                {
                    //SaveSmaRunbook(context, instance);
                    await SaveRunbookAsync(instance.Model as RunbookModelProxy, instance.Content);
                }
                else if (instance.Model is VariableModelProxy)
                {
                    var proxy = (VariableModelProxy)instance.Model;
                    await SaveVariableAsync(proxy);
                }
                else if (instance.Model is CredentialModelProxy)
                {
                    var proxy = (CredentialModelProxy)instance.Model;
                    await SaveCredentialAsync(proxy);
                }
                else if (instance.Model is ScheduleModelProxy)
                {
                    var proxy = (ScheduleModelProxy)instance.Model;
                    await SaveScheduleAsync(proxy);
                }
                else if (instance.Model is ConnectionModelProxy)
                {
                    var proxy = (ConnectionModelProxy)instance.Model;
                    await SaveConnectionAsync(proxy);
                }
                else if (instance.Model is ModuleModelProxy)
                {
                    var proxy = (ModuleModelProxy)instance.Model;
                    await SaveModuleAsync(proxy);
                }
                else
                    throw new NotImplementedException();

                // And lastly, open the document (or put focus on it if its open)
                var shell = IoC.Get<IShell>();
                shell.OpenDocument((IDocument)instance);
            }
            catch (DataServiceQueryException ex)
            {
                throw new ApplicationException("Error when saving the object. Please refer to the output for more information", ex);
            }

            if (command != null)
                Execute.OnUIThread(() => { command.Enabled = true; });

            LongRunningOperation.Stop();

            return new OperationResult
            {
                Status = OperationStatus.Succeeded,
                HttpStatusCode = HttpStatusCode.OK
            };
        }
 public override Task Run(Command command)
 {
     _shell.ShowTool<IToolbox>();
     return TaskUtility.Completed;
 }
Beispiel #25
0
 public virtual void Update(Command command)
 {
 }
 public override Task Run(Command command)
 {
     _shell.ShowTool<IInspectorTool>();
     return TaskUtility.Completed;
 }
Beispiel #27
0
 public override Task Run(Command command)
 {
     _shell.ActiveItem.UndoRedoManager.Undo(1);
     return TaskUtility.Completed;
 }
Beispiel #28
0
 /// <summary>
 /// Only override for "list"-type commands
 /// (commands that expand into a list of commands)
 /// </summary>
 public virtual void Update(Command command, List<Command> commands)
 {
     throw new NotSupportedException();
 }
 public override Task Run(Command command)
 {
     _shell.OpenDocument((IDocument) IoC.GetInstance(typeof(HelixViewModel), null));
     return TaskUtility.Completed;
 }
Beispiel #30
0
        public async Task<OperationResult> Save(IViewModel instance, Command command)
        {
            var operationResult = default(OperationResult);

            if (instance.Model is RunbookModelProxy)
            {
                operationResult = await SaveRunbookAsync(instance.Model as RunbookModelProxy, instance.Content);
            }
            else if (instance.Model is VariableModelProxy)
            {
                if (await SaveVariableAsync(instance.Model as VariableModelProxy))
                {
                    operationResult = new OperationResult
                    {
                        Status = OperationStatus.Succeeded,
                        HttpStatusCode = System.Net.HttpStatusCode.OK
                    };
                }
            }
            else if (instance.Model is CredentialModelProxy)
            {
                if (await SaveCredentialAsync(instance.Model as CredentialModelProxy))
                {
                    operationResult = new OperationResult
                    {
                        Status = OperationStatus.Succeeded,
                        HttpStatusCode = System.Net.HttpStatusCode.OK
                    };
                }
            }
            else if (instance.Model is ScheduleModelProxy)
            {
                if (await SaveScheduleAsync(instance.Model as ScheduleModelProxy))
                {
                    operationResult = new OperationResult
                    {
                        Status = OperationStatus.Succeeded,
                        HttpStatusCode = System.Net.HttpStatusCode.OK
                    };
                }
            }
            else if (instance.Model is ModuleModelProxy)
            {
                if (await SaveModuleAsync(instance.Model as ModuleModelProxy))
                {
                    operationResult = new OperationResult
                    {
                        Status = OperationStatus.Succeeded,
                        HttpStatusCode = System.Net.HttpStatusCode.OK
                    };
                }
            }
            else if (instance.Model is ConnectionModelProxy)
            {
                if (await SaveConnectionAsync(instance.Model as ConnectionModelProxy))
                {
                    operationResult = new OperationResult
                    {
                        Status = OperationStatus.Succeeded,
                        HttpStatusCode = System.Net.HttpStatusCode.OK
                    };
                }
            }
            else
                throw new NotImplementedException();

            if (operationResult == null)
            {
                operationResult = new OperationResult
                {
                    Status = OperationStatus.Failed,
                    HttpStatusCode = System.Net.HttpStatusCode.InternalServerError
                };
            }

            // And lastly, open the document (or put focus on it if its open)
            var shell = IoC.Get<IShell>();
            shell.OpenDocument((IDocument)instance);

            if (command != null)
                Execute.OnUIThread(() => { command.Enabled = true; });

            return operationResult;
        }