private void TaskListBox_Text_FilePath_OnClick(object sender, MouseButtonEventArgs args) { try { Task task = ((sender as FrameworkElement).DataContext as Task.TaskListItem).Task; if (task == null) { return; } if (DialogWindow != null && DialogWindow.IsVisible) { DialogWindow.Close(); DialogWindow = null; } InputDialogWindow dialogWindow = new InputDialogWindow("Enter file path", task.FilePath); this.DialogWindow = dialogWindow; dialogWindow.Owner = this; dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialogWindow.OnMessageEvent += (string message) => { if (message == null) { return; } if (TaskStorage == null) { return; } lock (TaskStorage) { TaskStorage.RemoveValue(task); task.FilePath = message; TaskStorage.Put(task.Id, task); UpdateList(); } }; dialogWindow.ShowDialog(); } catch (Exception e) { } }
private void TaskListBox_ImportTaskButton_OnClick(object sender, RoutedEventArgs args) { try { Task task = ((sender as FrameworkElement).DataContext as Task.TaskListItem).Task; if (task == null) { return; } if (DialogWindow != null && DialogWindow.IsVisible) { DialogWindow.Close(); DialogWindow = null; } ImportTaskWindow dialogWindow = new ImportTaskWindow(task); this.DialogWindow = dialogWindow; dialogWindow.Owner = this; dialogWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialogWindow.OnSelectEvent += (Task newTask) => { if (newTask == null || newTask.Id == null || newTask.Id.Length <= 0) { return; } if (TaskStorage == null) { return; } lock (TaskStorage) { TaskStorage.RemoveValue(task); TaskStorage.Put(newTask.Id, newTask); UpdateList(); } }; dialogWindow.ShowDialog(); } catch (Exception e) { Console.WriteLine(e); } }
private void TaskListBox_RemoveTaskButton_OnClick(object sender, RoutedEventArgs args) { try { Task task = ((sender as FrameworkElement).DataContext as Task.TaskListItem).Task; if (task == null) { return; } if (TaskStorage != null) { TaskStorage.RemoveValue(task); } UpdateList(); } catch (Exception e) { Console.WriteLine(e); } }