Ejemplo n.º 1
0
        private void EditTaskOptions()
        {
            if(activeTask != null) {
                ScheduledTask task = (ScheduledTask)activeTask.Tag;
                ScheduleOptions options = new ScheduleOptions();
                options.Options = _options;
                options.EditMode = true;
                options.Task = task;

                if(options.ShowDialog() == DialogResult.OK) {
                    ListViewItem taskItem = null;
                    ScheduledTask newTask = options.Task;

                    for(int i = 0; i < TaskList.Items.Count; i++) {
                        if((ScheduledTask)TaskList.Items[i].Tag == (ScheduledTask)activeTask.Tag) {
                            taskItem = TaskList.Items[i];
                            break;
                        }
                    }

                    TaskManager.SaveTask(SecureDeleteLocations.GetTaskFile(task.TaskId), newTask);

                    // update the <guid,taskName> mapping
                    if(_options.SessionNames.ContainsKey(newTask.TaskId)) {
                        _options.SessionNames[task.TaskId] = newTask.Name;
                    }
                    else {
                        _options.SessionNames.Add(task.TaskId, newTask.Name);
                    }

                    // save options
                    SDOptionsFile.TrySaveOptions(_options);
                    manager.LoadOptions();

                    // reschedule
                    disableRescheduling = true;

                    if(manager.LoadAndHandleTask(newTask.TaskId) == false) {
                        Debug.ReportWarning("Failed to handle edited task");
                    }
                    else {
                        // update interface
                        if(taskItem != null) {
                            taskItem.Tag = manager.GetTaskById(task.TaskId);
                            activeTask = taskItem;
                        }

                        UpdateTaskItem(activeTask);
                    }
                    disableRescheduling = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void AddTask()
        {
            WipeSession session = new WipeSession();
            session.GenerateGuid();
            ScheduledTask task = new ScheduledTask();
            task.TaskId = session.SessionId;
            task.Schedule = new OneTimeSchedule();
            task.Name = "Untitled task";
            task.Enabled = true;

            // show the dialog
            ScheduleOptions options = new ScheduleOptions();
            options.Options = _options;
            options.EditMode = false;
            options.Task = task;

            if(options.ShowDialog() == DialogResult.OK) {
                task = options.Task;
                manager.LoadOptions();
                manager.AddTask(task, true);

                SessionSaver.SaveSession(session, SecureDeleteLocations.GetSessionFile(task.TaskId));
                ListViewItem item = CreateTaskItem(task);
                UpdateTaskItem(item);

                // add to the <guid,taskName> mapping
                _options.SessionNames.Add(task.TaskId, task.Name);
                SDOptionsFile.TrySaveOptions(_options);
                TaskList.Items[TaskList.Items.Count - 1].Selected = true;
            }

            _actionManager.StateChanged();
        }