public static void PreviewKeyDown(DBTableControl.DBEditorTableControl mainTable, KeyEventArgs e) { #if DEBUG // Set Ctrl-B as testing key; if (e.Key == Key.B && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { string rowswitherrors = "Rows that have logged errors: \n\n"; for (int i = 0; i < mainTable.CurrentTable.Rows.Count; i++) { if (mainTable.CurrentTable.Rows[i].HasErrors) { rowswitherrors = rowswitherrors + i + "\n"; } } MessageBox.Show(rowswitherrors); } else if (e.Key == Key.D && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { var test = mainTable.EditedFile.Entries[0]; var type = mainTable.EditedFile.CurrentType; } else if (e.Key == Key.Z && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { string clipboardtext = ClipboardHelper.GetClipboardText(); clipboardtext = clipboardtext.Replace("\t", "\\t"); clipboardtext = clipboardtext.Replace("\r", "\\r"); clipboardtext = clipboardtext.Replace("\n", "\\n"); MessageBox.Show(clipboardtext); } else if (e.Key == Key.X && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { var cell = mainTable.GetCell(0, 0); string outputstring = ""; for (int i = 0; i < mainTable.dbDataGrid.Items.Count; i++) { if (!(mainTable.dbDataGrid.Items[i] is DataRowView)) { continue; } int datarow = mainTable.CurrentTable.Rows.IndexOf((mainTable.dbDataGrid.Items[i] as DataRowView).Row); outputstring = outputstring + String.Format("Visual row {0}, stored at CurrentTable[{1}].\n\r", i, datarow); } MessageBox.Show(outputstring); } #endif }
public static ListEditor Show(DBTableControl.DBEditorTableControl mainTable) { ListEditor hiddencolumnslisteditor = new ListEditor { LeftLabel = "Visible Columns:", RightLabel = "Hidden Columns:", OriginalOrder = mainTable.dbDataGrid.Columns.Select(n => (string)n.Header).ToList <string>(), LeftList = mainTable.CurrentTable.Columns.OfType <DataColumn>() .Where(n => !(bool)n.ExtendedProperties["Hidden"]) .Select(n => n.ColumnName).ToList(), RightList = mainTable.CurrentTable.Columns.OfType <DataColumn>() .Where(n => (bool)n.ExtendedProperties["Hidden"]) .Select(n => n.ColumnName).ToList() }; return(hiddencolumnslisteditor); }
static void Import(DBTableControl.DBEditorTableControl _parentDbEdtiorTable, string filename, ICodec <DBFile> codec) { System.Windows.Forms.OpenFileDialog openDBFileDialog = new System.Windows.Forms.OpenFileDialog { InitialDirectory = _parentDbEdtiorTable._exportDirectory, FileName = filename }; bool tryAgain = false; if (openDBFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _parentDbEdtiorTable._importDirectory = System.IO.Path.GetDirectoryName(openDBFileDialog.FileName); do { try { try { using (var stream = new MemoryStream(File.ReadAllBytes(openDBFileDialog.FileName))) { var loadedfile = codec.Decode(stream); // No need to import to editedFile directly, since it will be handled in the _parentDbEdtiorTable.Import(loadedfile); } } catch (DBFileNotSupportedException exception) { _parentDbEdtiorTable.showDBFileNotSupportedMessage(exception.Message); } _parentDbEdtiorTable.CurrentPackedFile.Data = (_parentDbEdtiorTable._codec.Encode(_parentDbEdtiorTable.EditedFile)); } catch (Exception ex) { tryAgain = (System.Windows.Forms.MessageBox.Show(string.Format("Import failed: {0}", ex.Message), "Import failed", System.Windows.Forms.MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Retry); } } while (tryAgain); } }
static public void ImportCAXml(DBTableControl.DBEditorTableControl _parentDbEdtiorTable) { // TODO: Implement }
static public void ImportBinary(DBTableControl.DBEditorTableControl _parentDbEdtiorTable) { Import(_parentDbEdtiorTable, _parentDbEdtiorTable.EditedFile.CurrentType.Name, _parentDbEdtiorTable._codec); }
static public void ImportCSV(DBTableControl.DBEditorTableControl _parentDbEdtiorTable) { Import(_parentDbEdtiorTable, String.Format("{0}.tsv", _parentDbEdtiorTable.EditedFile.CurrentType.Name), new TextDbCodec()); }