private void UpdateConfigGrid() { ConfigurationManager.CurrentPreset = (string)PresetConfigListBox.SelectedItem; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && ConfigurationManager.CurrentPreset != null && selectedProcess.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset)) { //Switch to the process grid for custom program screen if (selectedProcess.Name == "CUSTOM") { ProcessDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = true; ProcessDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; ConfigDataGrid.IsEnabled = false; ConfigDataGrid.Visibility = Visibility.Hidden; ParametersTextBox.Visibility = Visibility.Hidden; ProcessDataGrid.IsEnabled = true; ProcessDataGrid.Visibility = Visibility.Visible; ProcessTab.IsEnabled = true; ProcessTab.Visibility = Visibility.Visible; //Hide parameter buttons if ORDER is the current tab if ((string)(ProcessTab.SelectedItem as TabItem)?.Header == "ORDER") { AddParameterButton.Visibility = Visibility.Hidden; AddParameterButton.IsEnabled = false; RemoveParameterButton.Visibility = Visibility.Hidden; RemoveParameterButton.IsEnabled = false; } } else { ConfigDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = false; ConfigDataGrid.IsEnabled = true; ConfigDataGrid.Visibility = Visibility.Visible; ParametersTextBox.Visibility = Visibility.Visible; ProcessDataGrid.IsEnabled = false; ProcessDataGrid.Visibility = Visibility.Hidden; ProcessTab.IsEnabled = false; ProcessTab.Visibility = Visibility.Hidden; ConfigDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; //Make buttons visible if they were disabled if (!AddParameterButton.IsEnabled) { AddParameterButton.Visibility = Visibility.Visible; AddParameterButton.IsEnabled = true; RemoveParameterButton.Visibility = Visibility.Visible; RemoveParameterButton.IsEnabled = true; } UpdateParameterTextBox(); } } }
private void UpdateConfigGrid() { ConfigurationManager.CurrentPresetMap = PresetMapConfigListBox.SelectedItem == null ? ConfigurationManager.CurrentPresetMap : (string)((PresetMapCheckbox)PresetMapConfigListBox.SelectedItem).PresetMap; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && !string.IsNullOrWhiteSpace(ConfigurationManager.CurrentPresetMap) && ConfigurationManager.PresetMapDictionary.Keys.Any(x => x == ConfigurationManager.CurrentPresetMap) && ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].Keys.Any(x => x == selectedProcess.Name)) { //Switch to the process grid for custom program screen if (selectedProcess.Name == "CUSTOM") { ProcessDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = true; ProcessDataGrid.ItemsSource = ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap][selectedProcess.Name]; ConfigDataGrid.IsEnabled = false; ConfigDataGrid.Visibility = Visibility.Hidden; ParametersTextBox.Visibility = Visibility.Hidden; ProcessDataGrid.IsEnabled = true; ProcessDataGrid.Visibility = Visibility.Visible; ProcessTab.IsEnabled = true; ProcessTab.Visibility = Visibility.Visible; //Hide parameter buttons if ORDER is the current tab if ((string)(ProcessTab.SelectedItem as TabItem)?.Header == "ORDER") { AddParameterButton.Visibility = Visibility.Hidden; AddParameterButton.IsEnabled = false; RemoveParameterButton.Visibility = Visibility.Hidden; RemoveParameterButton.IsEnabled = false; } } else { ConfigDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = false; ConfigDataGrid.IsEnabled = true; ConfigDataGrid.Visibility = Visibility.Visible; ParametersTextBox.Visibility = Visibility.Visible; ProcessDataGrid.IsEnabled = false; ProcessDataGrid.Visibility = Visibility.Hidden; ProcessTab.IsEnabled = false; ProcessTab.Visibility = Visibility.Hidden; ConfigDataGrid.ItemsSource = ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap][selectedProcess.Name]; //Make buttons visible if they were disabled if (!AddParameterButton.IsEnabled) { AddParameterButton.Visibility = Visibility.Visible; AddParameterButton.IsEnabled = true; RemoveParameterButton.Visibility = Visibility.Visible; RemoveParameterButton.IsEnabled = true; } UpdateParameterTextBox(false); } } CompileProcessesListBox.SelectedIndex = CompileProcessesListBox.SelectedIndex > 0 && CompileProcessesListBox.SelectedIndex <= CompileProcessesListBox.Items.Count ? CompileProcessesListBox.SelectedIndex : 0; }