public MainWindow() { InitializeComponent(); Recycled.FillRecycledDataTable(); NewRowCommand.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(NewRowCommand, NewRowOnClicked)); FindReplaceCommand.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control | ModifierKeys.Shift)); CommandBindings.Add(new CommandBinding(FindReplaceCommand, FindReplace)); FindCommand.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(FindCommand, Find)); FullScreenCommand.InputGestures.Add(new KeyGesture(Key.F11)); CommandBindings.Add(new CommandBinding(FullScreenCommand, Fullscreen)); NextTabCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(NextTabCommand, NextTab)); PreviousTabCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Control | ModifierKeys.Shift)); CommandBindings.Add(new CommandBinding(PreviousTabCommand, PreviousTab)); CreateBarcodeCommand.InputGestures.Add(new KeyGesture(Key.B, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(CreateBarcodeCommand, CreateBarcode)); SaveCurrentSheetCommand.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(SaveCurrentSheetCommand, ExportCurrentSheetToExcel)); RefreshCommand.InputGestures.Add(new KeyGesture(Key.R, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(RefreshCommand, RefreshAll_OnClick)); InitializeOrRefreshEverything(0); var backupTimer = new Timer(240000) { Enabled = true }; backupTimer.Elapsed += Backup; }
public void InitializeOrRefreshEverything(int tabIndex) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; CurrentVisualStyle = Settings.Default.Theme; App.ThisIsNowConcurrent = false; App.ThisMadeLastChange = false; ResetGroupsBox.IsChecked = false; DeleteModeCheckBox.IsChecked = false; SearchField.Clear(); SearchField.AutoCompleteSource = SearchBoxAutoCompleteItems; MasterTabControl.Items.Clear(); var dataSets = App.MainSet(this); MasterDataSet = dataSets; MasterDataGrids.Clear(); EditedCells.Clear(); ProgressGrid.Visibility = Visibility.Hidden; using (var conn = new SqlConnection(App.ConnectionString)) { conn.Open(); foreach (string s in App.GetTableNames(conn)) { var tab = new TabItemExt { Header = s }; MasterTabControl.Items.Add(tab); } int i = 0; foreach (DataTable dt in MasterDataSet.Tables) { WriteToDataGrid(dt, App.GetPrefabOfDataTable(conn, dt), (TabItem)MasterTabControl.Items[i]); i++; } conn.Close(); } if (MasterTabControl.Items.Count > 0 && tabIndex < MasterTabControl.Items.Count) { MasterTabControl.SelectedIndex = tabIndex; } else if (tabIndex >= MasterTabControl.Items.Count) { MasterTabControl.SelectedIndex = MasterTabControl.Items.Count - 1; } else { MasterTabControl.SelectedIndex = 0; } RefreshRevertTables(); if (MasterTabControl.Items.Count < 1) { SearchField.IsEnabled = false; ResetSorts.IsEnabled = false; ResetGroupsBox.IsEnabled = false; DeleteModeCheckBox.IsEnabled = false; //RevertChanges.IsEnabled = false; NewRowButton.IsEnabled = false; RefreshAll.IsEnabled = false; BarcodeTextBox.IsEnabled = false; BarcodeInventoryCommit.IsEnabled = false; } else { SearchField.IsEnabled = true; ResetSorts.IsEnabled = true; ResetSorts.IsChecked = true; ResetGroupsBox.IsEnabled = true; DeleteModeCheckBox.IsEnabled = true; RefreshAll.IsEnabled = true; BarcodeTextBox.IsEnabled = true; BarcodeInventoryCommit.IsEnabled = true; NewRowButton.IsEnabled = true; } Recycled.FillRecycledDataTable(); System.Windows.Forms.Cursor.Current = Cursors.Default; }