mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Add separator and fix loading profiles
This commit is contained in:
@@ -65,6 +65,8 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Left side -->
|
||||
<ColumnDefinition />
|
||||
<!-- Separator -->
|
||||
<ColumnDefinition Width="10" />
|
||||
<!-- Applied values -->
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
@@ -116,7 +118,8 @@
|
||||
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Grid Grid.Column="1">
|
||||
<AppBarSeparator Grid.Column="1" />
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@@ -322,7 +325,7 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{x:Bind ViewModel.DefaultVariables.Variables, Mode=OneWay}"
|
||||
SelectionMode="Multiple">
|
||||
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid Height="48" ColumnSpacing="8">
|
||||
|
||||
@@ -188,9 +188,6 @@
|
||||
<data name="DefaultVariables" xml:space="preserve">
|
||||
<value>DefaultVariables</value>
|
||||
</data>
|
||||
<data name="ExistingVariablesListViewHeader.Text" xml:space="preserve">
|
||||
<value>Variables</value>
|
||||
</data>
|
||||
<data name="CancelAddVariableBtn.Content" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
|
||||
@@ -42,8 +42,6 @@ namespace EnvironmentVariables.ViewModels
|
||||
[RelayCommand]
|
||||
public void LoadEnvironmentVariables()
|
||||
{
|
||||
ReadAsync();
|
||||
|
||||
EnvironmentVariablesHelper.GetVariables(EnvironmentVariableTarget.Machine, SystemDefaultSet);
|
||||
EnvironmentVariablesHelper.GetVariables(EnvironmentVariableTarget.User, UserDefaultSet);
|
||||
|
||||
@@ -57,7 +55,7 @@ namespace EnvironmentVariables.ViewModels
|
||||
DefaultVariables.Variables.Add(variable);
|
||||
}
|
||||
|
||||
PopulateAppliedVariables();
|
||||
ReadAsync();
|
||||
}
|
||||
|
||||
private async void ReadAsync()
|
||||
@@ -65,7 +63,17 @@ namespace EnvironmentVariables.ViewModels
|
||||
try
|
||||
{
|
||||
var profiles = await _environmentVariablesService.ReadAsync();
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
profile.PropertyChanged += Profile_PropertyChanged;
|
||||
}
|
||||
|
||||
var applied = profiles.Where(x => x.IsEnabled).ToList();
|
||||
AppliedProfile = applied.Count > 0 ? applied.First() : null;
|
||||
|
||||
Profiles = new ObservableCollection<ProfileVariablesSet>(profiles);
|
||||
|
||||
PopulateAppliedVariables();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -84,10 +92,7 @@ namespace EnvironmentVariables.ViewModels
|
||||
|
||||
variables = variables.Concat(UserDefaultSet.Variables).Concat(SystemDefaultSet.Variables).ToList();
|
||||
variables = variables.GroupBy(x => x.Name).Select(y => y.First()).ToList();
|
||||
foreach (var variable in variables)
|
||||
{
|
||||
AppliedVariables.Add(variable);
|
||||
}
|
||||
AppliedVariables = new ObservableCollection<Variable>(variables);
|
||||
}
|
||||
|
||||
internal void EditVariable(Variable original, Variable edited)
|
||||
@@ -141,12 +146,15 @@ namespace EnvironmentVariables.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ = Task.Run(SaveAsync);
|
||||
}
|
||||
|
||||
private void SetAppliedProfile(ProfileVariablesSet profile)
|
||||
{
|
||||
profile.Apply();
|
||||
AppliedProfile = profile;
|
||||
PopulateAppliedVariables();
|
||||
}
|
||||
|
||||
private void UnsetAppliedProfile()
|
||||
@@ -159,6 +167,7 @@ namespace EnvironmentVariables.ViewModels
|
||||
AppliedProfile.IsEnabled = false;
|
||||
AppliedProfile = null;
|
||||
appliedProfile.PropertyChanged += Profile_PropertyChanged;
|
||||
PopulateAppliedVariables();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user