private void btnEditTask_Click(object sender, RoutedEventArgs e) { if (dgTasks.SelectedItem != null) { int selectedIndex = -2; try { int tmpSelectedIndexFromDG = dgTasks.SelectedIndex; selectedIndex = SearchIDFormDG(dgTasks.Columns[0].GetCellContent(dgTasks.Items[dgTasks.SelectedIndex]) as TextBlock); NewTaskForm newTaskFormWindow = new NewTaskForm(tasks[selectedIndex]); newTaskFormWindow.ShowDialog(); if (newTaskFormWindow.ApplyChanges) { tasks[selectedIndex] = newTaskFormWindow.simpleTask; } IOScripts.SerializeTaskTemplate(tasks, tasksDataFile); RefreshDataGrid(); dgTasks.SelectedIndex = tmpSelectedIndexFromDG; //dgTasks_MouseDown(null, null); tbxComment.Text = tasks[selectedIndex].comment; tbxLinkToJira.Text = tasks[selectedIndex].linkToJira; tbxcatalogPath.Text = tasks[selectedIndex].catalogPath; RefreshWorkTime(); } catch (Exception exc) { CustomMessageBox.Show(CustomMesageBoxTypes.Error, $"{exc.Message}\n\n{selectedIndex.ToString()}"); } } }
private void btnWorkTimeRemove_Click(object sender, RoutedEventArgs e) { if (dataGridSelectedItemIndex != -1 && lbxWorkingTime.SelectedItem != null) { tasks[dataGridSelectedItemIndex].workTime.RemoveAt(lbxWorkingTime.SelectedIndex); IOScripts.SerializeTaskTemplate(tasks, tasksDataFile); RefreshWorkTime(); } }
public MainWindow() { InitializeComponent(); mainWindow.Title = WindowName; tasks = IOScripts.DeserializeTaskTemplate(tasksDataFile); RefreshDataGrid(); btnClearFiltr_Click(null, null); IOScripts.CheckExistsConfigFile(configFileName); }
private void btnWorkTimeAdd_Click(object sender, RoutedEventArgs e) { if (dataGridSelectedItemIndex != -1) { WorkTimeWindow workTimeWindow = new WorkTimeWindow(); workTimeWindow.ShowDialog(); if (workTimeWindow.ApplyChanges) { tasks[dataGridSelectedItemIndex].workTime.Add(workTimeWindow.prerioid); } IOScripts.SerializeTaskTemplate(tasks, tasksDataFile); RefreshWorkTime(); } }
private void btnWorkTimeEdit_Click(object sender, RoutedEventArgs e) { if (dataGridSelectedItemIndex != -1 && lbxWorkingTime.SelectedItem != null) { int lbxWorkingTimeIndex = lbxWorkingTime.SelectedIndex; WorkTimeWindow workTimeWindow = new WorkTimeWindow(tasks[dataGridSelectedItemIndex].workTime[lbxWorkingTimeIndex]); workTimeWindow.ShowDialog(); if (workTimeWindow.ApplyChanges) { tasks[dataGridSelectedItemIndex].workTime[lbxWorkingTimeIndex] = workTimeWindow.prerioid; } IOScripts.SerializeTaskTemplate(tasks, tasksDataFile); RefreshWorkTime(); } }
private void btnOpenCatalogPath_Click(object sender, RoutedEventArgs e) { if (Directory.Exists(tbxcatalogPath.Text)) { ProcessStartInfo startInfo = new ProcessStartInfo { Arguments = $"\"{tbxcatalogPath.Text}\"", FileName = IOScripts.SearchInFile("Default explorer", configFileName) }; Process.Start(startInfo); } else { CustomMessageBox.Show(CustomMesageBoxTypes.Error, string.Format("{0} Directory does not exist!", tbxcatalogPath.Text)); } }
public static List <TaskTemplate> DeserializeTaskTemplate(string fileName = defaultTaskTemplateFileName) { List <TaskTemplate> tasks = new List <TaskTemplate>(); try { var mySerializer = new XmlSerializer(typeof(List <TaskTemplate>)); var myFileStream = new FileStream("TempName.xml", FileMode.Open); tasks = (List <TaskTemplate>)mySerializer.Deserialize(myFileStream); myFileStream.Close(); return(tasks); } catch { MessageBox.Show($"Created xaml file: {fileName}"); IOScripts.SerializeTaskTemplate(new List <TaskTemplate>(), fileName); } return(new List <TaskTemplate>()); }
private void btnAddNewTask_Click(object sender, RoutedEventArgs e) { NewTaskForm newTaskFormWindow = null; if (tasks.Count.Equals(0)) { newTaskFormWindow = new NewTaskForm(0); } else { newTaskFormWindow = new NewTaskForm(dgTasks.Items.Count); } newTaskFormWindow.ShowDialog(); if (newTaskFormWindow.ApplyChanges) { tasks.Add(newTaskFormWindow.simpleTask); } IOScripts.SerializeTaskTemplate(tasks, tasksDataFile); RefreshDataGrid(); }