From 778a6054425c384f0593dfb3852f53f36075a8cf Mon Sep 17 00:00:00 2001 From: Lisa Glover Date: Mon, 10 Jun 2024 20:25:13 -0700 Subject: [PATCH 1/2] Fixed the Spectral panel so the plot view is selected when switching between panels --- Vts.Gui.Wpf/MainWindow.xaml.cs | 55 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/Vts.Gui.Wpf/MainWindow.xaml.cs b/Vts.Gui.Wpf/MainWindow.xaml.cs index f8adebf..5bdf476 100644 --- a/Vts.Gui.Wpf/MainWindow.xaml.cs +++ b/Vts.Gui.Wpf/MainWindow.xaml.cs @@ -35,35 +35,34 @@ public MainWindow() public static MainWindow Current { get; set; } private void InputTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (sender is TabControl inputTab && - OutputTabControl != null && OutputTabControl.Items.Count > 1) + if (sender is not TabControl inputTab || + OutputTabControl == null || OutputTabControl.Items.Count <= 1) return; + if (inputTab.SelectedItem is not TabItem tabItem) return; + WindowViewModel.Current.PlotVM?.SetCustomPlotLabel.Execute(""); + switch (tabItem.Name) { - if (!(inputTab.SelectedItem is TabItem tabItem)) return; - WindowViewModel.Current.PlotVM?.SetCustomPlotLabel.Execute(""); - switch (tabItem.Name) - { - // default handles: "TabForward": - // "TabInverse": - // "TabSpectral": - default: - _logger.Debug($"Current Tab: {tabItem.Header}\n"); - OutputTabControl.SelectedItem = OutputTabControl.Items[0]; - ((TabItem)OutputTabControl.Items[0]).Visibility = Visibility.Visible; - ((TabItem)OutputTabControl.Items[1]).Visibility = Visibility.Collapsed; - break; - case "TabFluence": - OutputTabControl.SelectedItem = OutputTabControl.Items[1]; - ((TabItem)OutputTabControl.Items[1]).Visibility = Visibility.Visible; - ((TabItem)OutputTabControl.Items[0]).Visibility = Visibility.Collapsed; - break; - case "TabMonteCarlo": - ((TabItem)OutputTabControl.Items[1]).Visibility = Visibility.Visible; - ((TabItem)OutputTabControl.Items[0]).Visibility = Visibility.Visible; - break; - case "TabSpectral": - WindowViewModel.Current.PlotVM?.SetCustomPlotLabel.Execute(WindowViewModel.Current.SpectralMappingVM.SelectedTissue.Name); - break; - } + // default handles: "TabForward": + // "TabInverse": + default: + OutputTabControl.SelectedItem = OutputTabControl.Items[0]; + (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; + (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Collapsed; + break; + case "TabFluence": + OutputTabControl.SelectedItem = OutputTabControl.Items[1]; + (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Visible; + (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Collapsed; + break; + case "TabMonteCarlo": + (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Visible; + (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; + break; + case "TabSpectral": + OutputTabControl.SelectedItem = OutputTabControl.Items[0]; + (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; + (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Collapsed; + WindowViewModel.Current.PlotVM?.SetCustomPlotLabel.Execute(WindowViewModel.Current.SpectralMappingVM.SelectedTissue.Name); + break; } } From 287594e455c818792322d4a8a8f17b5179927dc3 Mon Sep 17 00:00:00 2001 From: Lisa Glover Date: Wed, 12 Jun 2024 16:25:41 -0700 Subject: [PATCH 2/2] Moved the logger declaration and removed redundant parentheses --- Vts.Gui.Wpf/MainWindow.xaml.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Vts.Gui.Wpf/MainWindow.xaml.cs b/Vts.Gui.Wpf/MainWindow.xaml.cs index 5bdf476..b9fd6e1 100644 --- a/Vts.Gui.Wpf/MainWindow.xaml.cs +++ b/Vts.Gui.Wpf/MainWindow.xaml.cs @@ -17,12 +17,11 @@ namespace Vts.Gui.Wpf public partial class MainWindow { private int _numViews; - private readonly ILogger _logger; public MainWindow() { - _logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(MainWindow)); - _logger.Info("Starting application"); + var logger = LoggerFactoryLocator.GetDefaultNLogFactory().Create(typeof(MainWindow)); + logger.Info("Starting application"); var observableTarget = NLog.LogManager.Configuration.AllTargets.FirstOrDefault(target => target is ObservableTarget); ((IObservable)observableTarget)?.Subscribe( @@ -45,22 +44,22 @@ private void InputTabControl_SelectionChanged(object sender, SelectionChangedEve // "TabInverse": default: OutputTabControl.SelectedItem = OutputTabControl.Items[0]; - (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; - (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Collapsed; + ((TabItem)OutputTabControl.Items[0])!.Visibility = Visibility.Visible; + ((TabItem)OutputTabControl.Items[1])!.Visibility = Visibility.Collapsed; break; case "TabFluence": OutputTabControl.SelectedItem = OutputTabControl.Items[1]; - (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Visible; - (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Collapsed; + ((TabItem)OutputTabControl.Items[1])!.Visibility = Visibility.Visible; + ((TabItem)OutputTabControl.Items[0])!.Visibility = Visibility.Collapsed; break; case "TabMonteCarlo": - (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Visible; - (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; + ((TabItem)OutputTabControl.Items[1])!.Visibility = Visibility.Visible; + ((TabItem)OutputTabControl.Items[0])!.Visibility = Visibility.Visible; break; case "TabSpectral": OutputTabControl.SelectedItem = OutputTabControl.Items[0]; - (((TabItem)OutputTabControl.Items[0])!).Visibility = Visibility.Visible; - (((TabItem)OutputTabControl.Items[1])!).Visibility = Visibility.Collapsed; + ((TabItem)OutputTabControl.Items[0])!.Visibility = Visibility.Visible; + ((TabItem)OutputTabControl.Items[1])!.Visibility = Visibility.Collapsed; WindowViewModel.Current.PlotVM?.SetCustomPlotLabel.Execute(WindowViewModel.Current.SpectralMappingVM.SelectedTissue.Name); break; }