private void InitCommand() { TaskDone = new RelayCommand(() => { var result = service.MessageBoxShow( $"現在実行中のタスク「{TaskTitle}」を完了しますか?", "タスクを完了しますか?", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { model.Done(); } }); TaskPostpone = new RelayCommand(() => { model.Postpone(); }); TaskAdd = new RelayCommand(() => { var task = new TaskItem(); service.ShowDialog(new TaskAddView(task)); if (task.Title != null) { model.AddTask(task); } }); TaskRemove = new RelayCommand(() => { if (SelectedTask == null) { return; } var result = service.MessageBoxShow( $"選択中のタスク「{SelectedTask.Title}」を削除しますか?", "確認", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { model.Remove(SelectedTask); } }); TaskUpdate = new RelayCommand(() => { var task = SelectedTask.Clone(); service.ShowDialog(new TaskAddView(task)); if (task.Title != null) { model.Update(SelectedTask, task); } }); TaskCopy = new RelayCommand(() => { service.ClipboardSet(SelectedTask.ToString()); }); TaskPaste = new RelayCommand(() => { // クリップボードの中身を取得して整える var array = service.ClipboardGet() .Replace("\r", "") .Replace("\n", Environment.NewLine) .Split(new string[] { Environment.NewLine }, 2, StringSplitOptions.None); var task = new TaskItem(array[0]); if (array.Length > 1) { task.Description = array[1]; } service.ShowDialog(new TaskAddView(task)); if (task.Title != null) { model.AddTask(task); } }); TaskDoubleClick = new RelayCommand <TaskItem>(item => { model.Work(item); }); TaskUp = new RelayCommand(() => { if (SelectedTask != null) { model.Move(SelectedTask, -1); } }); TaskDown = new RelayCommand(() => { if (SelectedTask != null) { model.Move(SelectedTask, +1); } }); TaskWork = new RelayCommand(() => { if (SelectedTask != null) { model.Work(SelectedTask); } }); TaskSave = new RelayCommand(() => { model.Save(); }); service.AddClosing((sender, e) => { model.Save(); }); }