private void Button_delete_selected_Click(object sender, RoutedEventArgs e) { int counter = 0; foreach (CheckBox cb in listBox_Tasks.Items) { if (cb.IsChecked == true) { TodoList selectedTodoList = (TodoList)cb.Tag; List <TodoList> listTemp = TodoListManager.GetListFromJson(); TaskSched_Communicator.DeleteTask(selectedTodoList.TaskName); if (FileSystem.DeleteTodoListFile(selectedTodoList.XamlFilePath)) { counter++; } //update the json file (with the deleted todolists) listTemp.RemoveAll((x) => x.TaskName.Equals(selectedTodoList.TaskName)); TodoListManager.UpdateJsonFile(listTemp); } } MessageBox.Show($"Deleted {counter} Todo-Lists"); UpdateList(); }
private void Button_showTodoList_Click(object sender, RoutedEventArgs e) { foreach (var item in listBox_Tasks.Items) { CheckBox tmp = (CheckBox)item; if (tmp.IsChecked == true) { if (!TaskSched_Communicator.RunTask(((TodoList)tmp.Tag).TaskName)) { MessageBox.Show("Task could not be executed"); } } } }
private void Button_reg_new_process_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".exe"; dlg.Filter = "Executables (*.exe)|*.exe|All Files (*.*)|*.*"; bool?result = dlg.ShowDialog(); if (result == true) { string processToRegister = dlg.FileName; string taskName = "[PTD]__" + processToRegister.Replace("\\", "_").Replace(":", "_").Replace(" ", "_"); string xamlPath = Constants.todoListDataFolder + taskName + ".xaml"; string processId = taskName + new Random().Next(); TodoList todoList = new TodoList() { DisplayName = dlg.FileName, TaskName = taskName, XamlFilePath = xamlPath, Id = processId }; bool exec = TaskSched_Communicator.CreateTask(processToRegister, taskName, processId); if (exec) { TodoListManager.AddTodoList(todoList); //Adds the new TodoList to the json file } else { MessageBox.Show("Failed to register task"); } } UpdateList(); }