mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Applied variables
This commit is contained in:
@@ -68,20 +68,18 @@
|
||||
<!-- Applied values -->
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0">
|
||||
<ScrollViewer
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
x:Uid="ProfilesLbl"
|
||||
Margin="0,32,0,0"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}" />
|
||||
<TextBlock x:Uid="ProfilesDescriptionLbl" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
<ItemsControl
|
||||
Grid.Row="1"
|
||||
Margin="0,16,0,4"
|
||||
ItemsSource="{x:Bind ViewModel.Profiles}">
|
||||
<ItemsControl Margin="0,16,0,4" ItemsSource="{x:Bind ViewModel.Profiles}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:ProfileVariablesSet">
|
||||
<labs:SettingsExpander
|
||||
@@ -118,6 +116,53 @@
|
||||
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</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>
|
||||
|
||||
<ContentDialog
|
||||
|
||||
@@ -197,6 +197,12 @@
|
||||
<data name="ConfirmAddVariableBtn.Content" xml:space="preserve">
|
||||
<value>Add</value>
|
||||
</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">
|
||||
<value>Variables</value>
|
||||
</data>
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using EnvironmentVariables.Helpers;
|
||||
@@ -24,6 +26,9 @@ namespace EnvironmentVariables.ViewModels
|
||||
|
||||
public ProfileVariablesSet AppliedProfile { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Variable> _appliedVariables = new ObservableCollection<Variable>();
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
}
|
||||
@@ -56,6 +61,24 @@ namespace EnvironmentVariables.ViewModels
|
||||
{
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user