public void UpdateTask(Task task, Task oldTask) { int index = TaskList.IndexOf(oldTask); TaskList[index].UpdateTo(task); }
public static void UpdateTo(this Task task, Task newTask) { task.Body = newTask.Body; task.Completed = newTask.Completed; task.Priority = newTask.Priority; }
public void SetState(TombstoneState state) { if (LoadingState != TaskLoadingState.Ready) { // If we're not in a state where we can safely load the state, // wait until we are and then run this method again. _loadingStateObserver .Where(e => e.EventArgs.LoadingState == TaskLoadingState.Ready) .Take(1) .Subscribe(e => SetState(state)); return; } if (!string.IsNullOrEmpty(state.SelectedTaskDraft)) { SelectedTaskDraft = new Task(state.SelectedTaskDraft); } if (!string.IsNullOrEmpty(state.SelectedTask)) { var selectedTask = TaskList.FirstOrDefault(t => t.ToString() == state.SelectedTask); if (selectedTask != null) { SelectedTask = selectedTask; } } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(PrimaryTaskFileService taskFileService, ArchiveTaskFileService archiveFileService, ApplicationSettings applicationSettings) { _applicationSettings = applicationSettings; if (IsInDesignMode) { // Code runs in Blend --> create design time data. TaskList = new TaskList { new Task("A", null, null, "This is a designer task that might be really long the quick brown fox jumped over the lazy dogs"), new Task("", null, null, "This is a designer task2"), new Task("", null, null, "This is a designer task3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") }; var b = new Task("B", null, null, "This is a designer task4", DateTime.Now.AddDays(-1), null, false, null); b.ToggleCompleted(); TaskList.Add(b); TaskList.Add(new Task("C", null, null, "This is a designer task5")); TaskList.Add(new Task("This task has two contexts @home @work")); TaskList.Add(new Task("This task has two projects +planvacation +fixstove")); TaskList.Add(new Task("This task has one of each @home +fixstove")); TaskList.Add(new Task("")); // Blank task line SelectedTask = TaskList[3]; ViewTask(); } else { // Code runs "for real" WireupTaskFileServices(taskFileService, archiveFileService); Messenger.Default.Register<DrillDownMessage>(this, Filter); Messenger.Default.Register<ApplicationStartedMessage>(this, message => { LocalHasChanges = _taskFileService.LocalHasChanges; if(StartupSyncCommand.CanExecute(null)) { StartupSyncCommand.Execute(null); } }); WireUpCommands(); } }
private void AddTask() { SelectedTask = null; SelectedTaskDraft = new Task(string.Empty, null, null, Filters.CreateDefaultBodyText()); SelectedTaskDraftIsNew = true; Messenger.Default.Send(new ViewTaskMessage()); }
public void UpdateTask(TTask task, TTask oldTask) { int index = TaskList.IndexOf(oldTask); TaskList[index].UpdateTo(task); }