Ejemplo n.º 1
0
        void ITaskManifest.RemoveTask(string identifier)
        {
            if (string.IsNullOrEmpty(identifier))
            {
                throw new ArgumentNullException("identifier");
            }

            _TaskCollection.Remove(identifier);
        }
Ejemplo n.º 2
0
        public override void RunCommand(TaskCommand command)
        {
            switch (command)
            {
            case TaskCommand.OpenLocation:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    string path = (task.Tool as IParametrizedTool).GetOutputLocation();
                    if (string.IsNullOrWhiteSpace(path))
                    {
                        MessageService.Current.Info("Output path isn't defined.");
                    }
                    else
                    {
                        PathHelper.OpenFolderWithExplorer(path);
                    }
                }
            }
            break;

            case TaskCommand.RemoveOutput:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    if (!MessageService.Current.Ask("Remove the selected task and its output?"))
                    {
                        return;
                    }

                    var tool = task.Tool as IParametrizedTool;
                    if (tool != null)
                    {
                        if (tool.RemoveOutputs(_context, _layerService))
                        {
                            _tasks.Remove(task);
                            ActivateToolbox();
                        }
                    }
                }
            }
            break;

            case TaskCommand.RunAnother:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    _context.Toolbox.OpenToolDialog(task.Tool, false);
                }
            }
            break;

            case TaskCommand.Rerun:
                RerunTask();
                break;

            case TaskCommand.Clear:
                if (MessageService.Current.Ask("Remove all the finished tasks from the list?"))
                {
                    _tasks.Clear(true);
                    ActivateToolbox();
                }
                break;

            case TaskCommand.OpenLog:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    _context.Container.Run <TaskLogPresenter, IGisTask>(task);
                }
            }
            break;

            case TaskCommand.CancelTask:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    task.Cancel();
                }
                break;
            }

            case TaskCommand.PauseTask:
            {
                var task = View.SelectedTask;
                if (task != null)
                {
                    task.TogglePause();
                }
            }
            break;

            case TaskCommand.RemoveTask:
            {
                if (MessageService.Current.Ask("Remove the selected task?"))
                {
                    var task = View.SelectedTask;
                    if (task != null)
                    {
                        _tasks.Remove(task);
                        ActivateToolbox();
                    }
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException("command");
            }
        }