mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Applied variables
This commit is contained in:
@@ -68,20 +68,18 @@
|
|||||||
<!-- Applied values -->
|
<!-- Applied values -->
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
<StackPanel Grid.Row="1" Grid.Column="0">
|
VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Uid="ProfilesLbl"
|
x:Uid="ProfilesLbl"
|
||||||
Margin="0,32,0,0"
|
Margin="0,32,0,0"
|
||||||
Style="{StaticResource BodyStrongTextBlockStyle}" />
|
Style="{StaticResource BodyStrongTextBlockStyle}" />
|
||||||
<TextBlock x:Uid="ProfilesDescriptionLbl" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
<TextBlock x:Uid="ProfilesDescriptionLbl" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||||
|
|
||||||
<ItemsControl
|
<ItemsControl Margin="0,16,0,4" ItemsSource="{x:Bind ViewModel.Profiles}">
|
||||||
Grid.Row="1"
|
|
||||||
Margin="0,16,0,4"
|
|
||||||
ItemsSource="{x:Bind ViewModel.Profiles}">
|
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate x:DataType="models:ProfileVariablesSet">
|
<DataTemplate x:DataType="models:ProfileVariablesSet">
|
||||||
<labs:SettingsExpander
|
<labs:SettingsExpander
|
||||||
@@ -118,6 +116,53 @@
|
|||||||
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}" />
|
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
<StackPanel Grid.Column="1">
|
||||||
|
<TextBlock
|
||||||
|
x:Uid="AppliedVariablesLbl"
|
||||||
|
Margin="0,32,0,0"
|
||||||
|
Style="{StaticResource BodyStrongTextBlockStyle}" />
|
||||||
|
<TextBlock x:Uid="AppliedVariablesDescriptionLbl" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||||
|
<ScrollViewer
|
||||||
|
x:Name="AppliedVariablesScrollViewer"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalScrollBarVisibility="Auto">
|
||||||
|
<ItemsControl Margin="0,16,0,4" ItemsSource="{x:Bind ViewModel.AppliedVariables, Mode=TwoWay}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="models:Variable">
|
||||||
|
<Grid Height="48" ColumnSpacing="8">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="20" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<FontIcon
|
||||||
|
Grid.Column="0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
||||||
|
Glyph="{x:Bind ParentType, Mode=OneWay, Converter={StaticResource VariableTypeToGlyphConverter}}" />
|
||||||
|
<StackPanel
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Vertical">
|
||||||
|
<TextBlock
|
||||||
|
Text="{x:Bind Name}"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="NoWrap" />
|
||||||
|
<TextBlock
|
||||||
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{x:Bind Values}"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="NoWrap" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<ContentDialog
|
<ContentDialog
|
||||||
|
|||||||
@@ -197,6 +197,12 @@
|
|||||||
<data name="ConfirmAddVariableBtn.Content" xml:space="preserve">
|
<data name="ConfirmAddVariableBtn.Content" xml:space="preserve">
|
||||||
<value>Add</value>
|
<value>Add</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="AppliedVariablesDescriptionLbl.Text" xml:space="preserve">
|
||||||
|
<value>List of applied variables</value>
|
||||||
|
</data>
|
||||||
|
<data name="AppliedVariablesLbl.Text" xml:space="preserve">
|
||||||
|
<value>Applied variables</value>
|
||||||
|
</data>
|
||||||
<data name="NewProfileVariablesListViewHeader.Text" xml:space="preserve">
|
<data name="NewProfileVariablesListViewHeader.Text" xml:space="preserve">
|
||||||
<value>Variables</value>
|
<value>Variables</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using EnvironmentVariables.Helpers;
|
using EnvironmentVariables.Helpers;
|
||||||
@@ -24,6 +26,9 @@ namespace EnvironmentVariables.ViewModels
|
|||||||
|
|
||||||
public ProfileVariablesSet AppliedProfile { get; set; }
|
public ProfileVariablesSet AppliedProfile { get; set; }
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private ObservableCollection<Variable> _appliedVariables = new ObservableCollection<Variable>();
|
||||||
|
|
||||||
public MainViewModel()
|
public MainViewModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -56,6 +61,24 @@ namespace EnvironmentVariables.ViewModels
|
|||||||
{
|
{
|
||||||
DefaultVariables.Variables.Add(variable);
|
DefaultVariables.Variables.Add(variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PopulateAppliedVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateAppliedVariables()
|
||||||
|
{
|
||||||
|
var variables = new List<Variable>();
|
||||||
|
if (AppliedProfile != null)
|
||||||
|
{
|
||||||
|
variables = variables.Concat(AppliedProfile.Variables).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void EditVariable(Variable original, Variable edited)
|
internal void EditVariable(Variable original, Variable edited)
|
||||||
|
|||||||
Reference in New Issue
Block a user