public MainWindow() { InitializeComponent(); Ginfo = new GenericInfo(); Pinfo = new ProductInfo(); _UISettings = new TemplateUISettings() { Color = Properties.Settings.Default.Color, IsDarkMode = Properties.Settings.Default.IsDarkMode, FontFamily = Properties.Settings.Default.FontFamily, FontSize = Properties.Settings.Default.FontSize }; LogWriter.CreateTodaysLog(); KeyBinding OpenCmdKeyBinding = new KeyBinding( ApplicationCommands.New, Key.R, ModifierKeys.Control); this.InputBindings.Add(OpenCmdKeyBinding); //Initial setup process. FillComboBoxes(); SetTheme(new TemplateUISettings() { Color = Properties.Settings.Default.Color, IsDarkMode = Properties.Settings.Default.IsDarkMode, FontFamily = Properties.Settings.Default.FontFamily, FontSize = Properties.Settings.Default.FontSize }); DataContext = UISettings; ContactNameBox.Focus(); }
private async void ClearDataButton_Click(object sender, RoutedEventArgs e) { ContactNameBox.Focus(); var settings = new MetroDialogSettings() { AffirmativeButtonText = "No", NegativeButtonText = "Yes", }; var result = await this.ShowMessageAsync("Are you sure?", "You will be clearing everything", MessageDialogStyle.AffirmativeAndNegative, settings); if (result == MessageDialogResult.Negative) { foreach (UIElement el in GenericInfoGrid.Children) { if (el.GetType() == typeof(TextBox)) { ((TextBox)(el)).Clear(); } } foreach (UIElement el in DeviceInfoGrid.Children) { if (el.GetType() == typeof(TextBox)) { ((TextBox)(el)).Clear(); } if (el.GetType() == typeof(ComboBox)) { ((ComboBox)(el)).SelectedIndex = -1; } } foreach (UIElement el in SoftwareInfoGrid.Children) { if (el.GetType() == typeof(TextBox)) { ((TextBox)(el)).Clear(); } if (el.GetType() == typeof(ComboBox)) { ((ComboBox)(el)).SelectedIndex = -1; } } Ginfo.Clear(); Pinfo.Clear(); ClearRemoteSessionScreen(); RemoteSessionListBox.Items.Clear(); TemplatePreviewBox.Clear(); BlankField.Clear(); } }