Beispiel #1
0
        private void TaskControlActionDelete()
        {
            TaskDialogResult result;
            ScanTask         selectedTask = typedTaskList.SelectedObject;

            logger.Trace("Displaying task deletion confirmation dialog");
            using (var dialog = new TaskDialog())
            {
                TaskDialogStandardButtons button = TaskDialogStandardButtons.None;
                button |= TaskDialogStandardButtons.Yes;
                button |= TaskDialogStandardButtons.No;
                dialog.StandardButtons   = button;
                dialog.StartupLocation   = TaskDialogStartupLocation.CenterOwner;
                dialog.OwnerWindowHandle = this.Handle;

                dialog.Icon = TaskDialogStandardIcon.Information;

                const string Title       = "Delete Task";
                string       instruction = "The scan task '" + listViewTasks.SelectedItems[0].Text + "' is about to be deleted";
                const string Content     = "Do you want to continue?";

                dialog.InstructionText = instruction;
                dialog.Caption         = Title;
                dialog.Text            = Content;

                result = dialog.Show();
            }

            if (result == TaskDialogResult.Yes)
            {
                try
                {
                    logger.Debug("Removing task {0}", selectedTask.Name);
                    ScanTaskManager.RemoveTask(selectedTask);
                    LoadTaskList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        string.Format(
                            "'{0}' could not be deleted.{1}Detail:{2}",
                            selectedTask.Name,
                            Environment.NewLine,
                            ex.Message),
                        "Task Manager",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                logger.Trace("Removal of task '{0}' cancelled by user", selectedTask.Name);
            }
        }
Beispiel #2
0
        private void LoadTaskList()
        {
            tasks = ScanTaskManager.GetTaskList();

            listViewTasks.Freeze();
            listViewTasks.SetObjects(tasks);
            listViewTasks.Unfreeze();

            SetTaskControlStates();

            logger.Debug("Loaded task list");
        }
Beispiel #3
0
        private void TaskControlActionClone()
        {
            ScanTask selectedTask = typedTaskList.SelectedObject;

            try
            {
                logger.Debug("Cloning task {0}", selectedTask.Name);
                ScanTaskManager.CloneTask(selectedTask, AppFolders.TaskFolder);
                LoadTaskList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    string.Format(
                        "'{0}' could not be cloned.{1}Detail:{2}",
                        selectedTask.Name,
                        Environment.NewLine,
                        ex.Message),
                    "Task Manager",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1);
            }
        }