Force some tabs to not be accessible while Profile Editor is open

Related to issue #992
This commit is contained in:
Travis Nickles 2020-01-04 13:53:44 -06:00
parent 7a79dc569a
commit 478150a825
5 changed files with 53 additions and 3 deletions

View File

@ -37,7 +37,7 @@
</DockPanel> </DockPanel>
</StackPanel> </StackPanel>
<TabControl x:Name="mainTabCon" DockPanel.Dock="Top" SelectionChanged="MainTabCon_SelectionChanged"> <TabControl x:Name="mainTabCon" DockPanel.Dock="Top" SelectionChanged="MainTabCon_SelectionChanged">
<TabItem Header="{lex:Loc Controllers}"> <TabItem Header="{lex:Loc Controllers}" IsEnabled="{Binding FullTabsEnabled,Mode=OneWay}">
<Grid> <Grid>
<Label x:Name="noContLb" Visibility="Hidden" Content="No Controllers Connected (Max 4)" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" /> <Label x:Name="noContLb" Visibility="Hidden" Content="No Controllers Connected (Max 4)" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
<ListView x:Name="controllerLV" ItemsSource="{Binding ControllerCol}" SelectionMode="Single" SelectedIndex="{Binding CurrentIndex, Mode=OneWayToSource}" Margin="0"> <ListView x:Name="controllerLV" ItemsSource="{Binding ControllerCol}" SelectionMode="Single" SelectedIndex="{Binding CurrentIndex, Mode=OneWayToSource}" Margin="0">
@ -201,12 +201,12 @@
</ListBox> </ListBox>
</DockPanel> </DockPanel>
</TabItem> </TabItem>
<TabItem Header="{lex:Loc AutoProfiles}"> <TabItem Header="{lex:Loc AutoProfiles}" IsEnabled="{Binding FullTabsEnabled,Mode=OneWay}">
<local:AutoProfiles x:Name="autoProfControl"> <local:AutoProfiles x:Name="autoProfControl">
</local:AutoProfiles> </local:AutoProfiles>
</TabItem> </TabItem>
<TabItem x:Name="settingsTab" Header="{lex:Loc Settings}"> <TabItem x:Name="settingsTab" Header="{lex:Loc Settings}" IsEnabled="{Binding ViewEnabled,Mode=OneWay}">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<WrapPanel Orientation="Vertical" Margin="8,16,8,8"> <WrapPanel Orientation="Vertical" Margin="8,16,8,8">
<WrapPanel.Resources> <WrapPanel.Resources>

View File

@ -32,6 +32,7 @@ namespace DS4WinWPF.DS4Forms
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private MainWindowsViewModel mainWinVM;
private StatusLogMsg lastLogMsg = new StatusLogMsg(); private StatusLogMsg lastLogMsg = new StatusLogMsg();
private ProfileList profileListHolder = new ProfileList(); private ProfileList profileListHolder = new ProfileList();
private LogViewModel logvm; private LogViewModel logvm;
@ -58,6 +59,9 @@ namespace DS4WinWPF.DS4Forms
{ {
InitializeComponent(); InitializeComponent();
mainWinVM = new MainWindowsViewModel();
DataContext = mainWinVM;
App root = Application.Current as App; App root = Application.Current as App;
settingsWrapVM = new SettingsViewModel(); settingsWrapVM = new SettingsViewModel();
settingsTab.DataContext = settingsWrapVM; settingsTab.DataContext = settingsWrapVM;
@ -257,6 +261,7 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
autoprofileChecker.RequestServiceChange += AutoprofileChecker_RequestServiceChange; autoprofileChecker.RequestServiceChange += AutoprofileChecker_RequestServiceChange;
autoProfileHolder.AutoProfileColl.CollectionChanged += AutoProfileColl_CollectionChanged; autoProfileHolder.AutoProfileColl.CollectionChanged += AutoProfileColl_CollectionChanged;
//autoProfControl.AutoProfVM.AutoProfileSystemChange += AutoProfVM_AutoProfileSystemChange; //autoProfControl.AutoProfVM.AutoProfileSystemChange += AutoProfVM_AutoProfileSystemChange;
mainWinVM.FullTabsEnabledChanged += MainWinVM_FullTabsEnabledChanged;
bool wmiConnected = false; bool wmiConnected = false;
WqlEventQuery q = new WqlEventQuery(); WqlEventQuery q = new WqlEventQuery();
@ -288,6 +293,11 @@ Suspend support not enabled.", true);
} }
} }
private void MainWinVM_FullTabsEnabledChanged(object sender, EventArgs e)
{
settingsWrapVM.ViewEnabled = mainWinVM.FullTabsEnabled;
}
private void TrayIconVM_RequestServiceChange(object sender, EventArgs e) private void TrayIconVM_RequestServiceChange(object sender, EventArgs e)
{ {
ChangeService(); ChangeService();
@ -1274,6 +1284,7 @@ Suspend support not enabled.", true);
editor = null; editor = null;
mainTabCon.SelectedIndex = 0; mainTabCon.SelectedIndex = 0;
mainWinVM.FullTabsEnabled = true;
//Task.Run(() => GC.Collect(0, GCCollectionMode.Forced, false)); //Task.Run(() => GC.Collect(0, GCCollectionMode.Forced, false));
} }
@ -1288,6 +1299,7 @@ Suspend support not enabled.", true);
{ {
profOptsToolbar.Visibility = Visibility.Collapsed; profOptsToolbar.Visibility = Visibility.Collapsed;
profilesListBox.Visibility = Visibility.Collapsed; profilesListBox.Visibility = Visibility.Collapsed;
mainWinVM.FullTabsEnabled = false;
preserveSize = false; preserveSize = false;
oldSize.Width = Width; oldSize.Width = Width;

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS4WinWPF.DS4Forms.ViewModels
{
public class MainWindowsViewModel
{
private bool fullTabsEnabled = true;
public bool FullTabsEnabled
{
get => fullTabsEnabled;
set
{
fullTabsEnabled = value;
FullTabsEnabledChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler FullTabsEnabledChanged;
}
}

View File

@ -173,6 +173,19 @@ namespace DS4WinWPF.DS4Forms.ViewModels
} }
} }
private bool viewEnabled = true;
public bool ViewEnabled
{
get => viewEnabled;
set
{
viewEnabled = value;
ViewEnabledChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler ViewEnabledChanged;
public SettingsViewModel() public SettingsViewModel()
{ {
checkEveryUnitIdx = 1; checkEveryUnitIdx = 1;

View File

@ -225,6 +225,7 @@
<Compile Include="DS4Forms\ViewModels\BindingWindowViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\BindingWindowViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\ControllerListViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\ControllerListViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\LanguagePackViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\LanguagePackViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\MainWindowsViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\MappingListViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\MappingListViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\ProfileSettingsViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\ProfileSettingsViewModel.cs" />
<Compile Include="DS4Forms\ViewModels\RecordBoxViewModel.cs" /> <Compile Include="DS4Forms\ViewModels\RecordBoxViewModel.cs" />