private void EditWindow_Closing(object sender, DataGrid originalTable, int selectedIndex, int originalType) { DocumentEditWindow editWindow = (DocumentEditWindow)sender; DocTable item = sources[originalTable][selectedIndex]; int newType = (int)editWindow.DocTypeCombo.SelectedValue; if (newType != originalType) { sources[originalTable].RemoveAt(selectedIndex); sources[originalTable].AddIndexes(); originalTable.Items.Refresh(); if (typeToTable.ContainsKey(newType)) { sources[typeToTable[newType]].Add(item); sources[typeToTable[newType]].AddIndexes(); typeToTable[newType].Items.Refresh(); } else { //if there's no table generated then there is no need to add somewhere return; } } item.name = editWindow.DocumentName.Text; item.date = DatabaseHandler.GetDocumentDate(item.id); //TODO UPDATE POINTS }
private void Table_MouseDoubleClick(int docType, DocTable item) { if (item == null) { return; } DocumentEditWindow editWindow = new DocumentEditWindow(item.id); editWindow.Owner = Window.GetWindow(this); editWindow.ShowInTaskbar = false; editWindow.Closing += (sender, e) => { if (!e.Cancel) { UpdateCategories(); } }; editWindow.ShowDialog(); }
/// <summary> /// Editing table row /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Table_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGrid table = (DataGrid)sender; if (table.SelectedIndex != -1 && table.CurrentCell.Column != null && table.CurrentCell.Column.DisplayIndex != 3) { DocumentEditWindow editWindow = new DocumentEditWindow(sources[table][table.SelectedIndex].id); int originalType = tableToType[table]; editWindow.Owner = Window.GetWindow(this); editWindow.Closing += (object ss, CancelEventArgs ex) => { if (!ex.Cancel) { EditWindow_Closing(ss, table, table.SelectedIndex, originalType); updaterOfPoints?.Invoke(); } }; editWindow.ShowInTaskbar = false; editWindow.ShowDialog(); } }