mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-29 00:24:42 +01:00
Profiles init
This commit is contained in:
@@ -24,6 +24,13 @@
|
||||
<ProjectPriFileName>PowerToys.EnvironmentVariables.pri</ProjectPriFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Styles\**" />
|
||||
<EmbeddedResource Remove="Styles\**" />
|
||||
<None Remove="Styles\**" />
|
||||
<Page Remove="Styles\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="EnvironmentVariablesXAML\Views\MainPage.xaml" />
|
||||
</ItemGroup>
|
||||
@@ -69,4 +76,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PRIResource Remove="Styles\**" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Application
|
||||
x:Class="EnvironmentVariables.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
@@ -7,10 +7,11 @@
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/EnvironmentVariablesXAML/Styles/TextBlock.xaml" />
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
<!-- Other merged dictionaries here -->
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- Other app resources here -->
|
||||
<!-- Other app resources here -->
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<x:Double x:Key="SecondaryTextFontSize">12</x:Double>
|
||||
<Style x:Key="SecondaryTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="{StaticResource SecondaryTextFontSize}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource TextFillColorSecondaryBrush}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -20,99 +20,140 @@
|
||||
</ic:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Button -->
|
||||
<RowDefinition />
|
||||
<!-- Profiles -->
|
||||
<RowDefinition />
|
||||
<!-- Default sets -->
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Left side -->
|
||||
<ColumnDefinition />
|
||||
<!-- Applied values -->
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Uid="NewProfileBtn"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0">Placeholder for profiles</TextBlock>
|
||||
<Grid Grid.Row="2" Grid.Column="0">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Button -->
|
||||
<RowDefinition Height="32" />
|
||||
<!-- Profile sets -->
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Uid="DefaultVariablesLbl" />
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||
<labs:SettingsExpander>
|
||||
<labs:SettingsExpander.Header>
|
||||
<!-- TODO(stefan): How to use HeaderIcon here instead of this stack panel???? -->
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<Image
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="{x:Bind ViewModel.UserDefaultSet.IconPath}" />
|
||||
<TextBlock Text="{x:Bind ViewModel.UserDefaultSet.Name}" />
|
||||
</StackPanel>
|
||||
</labs:SettingsExpander.Header>
|
||||
<labs:SettingsExpander.Items>
|
||||
<ListView
|
||||
x:Name="UserDefaultSetVariablesList"
|
||||
x:Uid="UserDefaultSetVariablesList"
|
||||
ItemsSource="{x:Bind ViewModel.UserDefaultSet.Variables, Mode=OneWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1"><Run Text="{x:Bind Name}" /></TextBlock>
|
||||
<TextBlock Grid.Column="2"><Run Text="{x:Bind Values}" /></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</labs:SettingsExpander.Items>
|
||||
</labs:SettingsExpander>
|
||||
<labs:SettingsExpander>
|
||||
<labs:SettingsExpander.Header>
|
||||
<!-- TODO(stefan): How to use HeaderIcon here instead of this stack panel???? -->
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<Image
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="{x:Bind ViewModel.SystemDefaultSet.IconPath}" />
|
||||
<TextBlock Text="{x:Bind ViewModel.SystemDefaultSet.Name}" />
|
||||
</StackPanel>
|
||||
</labs:SettingsExpander.Header>
|
||||
<labs:SettingsExpander.Items>
|
||||
<ListView
|
||||
x:Name="SystemDefaultSetVariablesList"
|
||||
x:Uid="SystemDefaultSetVariablesList"
|
||||
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1"><Run Text="{x:Bind Name}" /></TextBlock>
|
||||
<TextBlock Grid.Column="2"><Run Text="{x:Bind Values}" /></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</labs:SettingsExpander.Items>
|
||||
</labs:SettingsExpander>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Left side -->
|
||||
<ColumnDefinition />
|
||||
<!-- Applied values -->
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Uid="NewProfileBtn"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0" />
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Vertical">
|
||||
<TextBlock x:Uid="ProfilesLbl" />
|
||||
<TextBlock x:Uid="ProfilesDescriptionLbl" Style="{StaticResource SecondaryTextStyle}" />
|
||||
</StackPanel>
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{x:Bind ViewModel.Profiles}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:ProfileVariablesSet">
|
||||
<labs:SettingsExpander Header="{x:Bind Name}">
|
||||
<labs:SettingsExpander.HeaderIcon>
|
||||
<ImageIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="{x:Bind IconPath}" />
|
||||
</labs:SettingsExpander.HeaderIcon>
|
||||
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind Mode=TwoWay, Path=IsEnabled}" />
|
||||
<labs:SettingsExpander.Items>
|
||||
<ListView
|
||||
x:Name="ProfileVariablesList"
|
||||
x:Uid="ProfileVariablesList"
|
||||
ItemsSource="{x:Bind Variables, Mode=OneWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1"><Run Text="{x:Bind Name}" /></TextBlock>
|
||||
<TextBlock Grid.Column="2"><Run Text="{x:Bind Values}" /></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</labs:SettingsExpander.Items>
|
||||
|
||||
</labs:SettingsExpander>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Uid="DefaultVariablesLbl" Grid.Row="0" />
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||
<labs:SettingsExpander Header="{x:Bind ViewModel.UserDefaultSet.Name}">
|
||||
<labs:SettingsExpander.HeaderIcon>
|
||||
<ImageIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="{x:Bind ViewModel.UserDefaultSet.IconPath}" />
|
||||
</labs:SettingsExpander.HeaderIcon>
|
||||
<labs:SettingsExpander.Items>
|
||||
<ListView
|
||||
x:Name="UserDefaultSetVariablesList"
|
||||
x:Uid="UserDefaultSetVariablesList"
|
||||
ItemsSource="{x:Bind ViewModel.UserDefaultSet.Variables, Mode=OneWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1"><Run Text="{x:Bind Name}" /></TextBlock>
|
||||
<TextBlock Grid.Column="2"><Run Text="{x:Bind Values}" /></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</labs:SettingsExpander.Items>
|
||||
</labs:SettingsExpander>
|
||||
<labs:SettingsExpander Header="{x:Bind ViewModel.SystemDefaultSet.Name}">
|
||||
<labs:SettingsExpander.HeaderIcon>
|
||||
<ImageIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="{x:Bind ViewModel.SystemDefaultSet.IconPath}" />
|
||||
</labs:SettingsExpander.HeaderIcon>
|
||||
<labs:SettingsExpander.Items>
|
||||
<ListView
|
||||
x:Name="SystemDefaultSetVariablesList"
|
||||
x:Uid="SystemDefaultSetVariablesList"
|
||||
ItemsSource="{x:Bind ViewModel.SystemDefaultSet.Variables, Mode=OneWay}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:Variable">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1"><Run Text="{x:Bind Name}" /></TextBlock>
|
||||
<TextBlock Grid.Column="2"><Run Text="{x:Bind Values}" /></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</labs:SettingsExpander.Items>
|
||||
</labs:SettingsExpander>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace EnvironmentVariables.Models
|
||||
{
|
||||
public class ProfileVariablesSet : VariablesSet
|
||||
{
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public ProfileVariablesSet(Guid id, string name)
|
||||
: base(id, name, VariablesSetType.Profile)
|
||||
{
|
||||
|
||||
@@ -126,6 +126,12 @@
|
||||
<data name="NewProfileBtn.Content" xml:space="preserve">
|
||||
<value>New</value>
|
||||
</data>
|
||||
<data name="ProfilesDescriptionLbl.Text" xml:space="preserve">
|
||||
<value>You can create profiles to quickly apply a set of preconfigured variables</value>
|
||||
</data>
|
||||
<data name="ProfilesLbl.Text" xml:space="preserve">
|
||||
<value>Profiles</value>
|
||||
</data>
|
||||
<data name="System" xml:space="preserve">
|
||||
<value>System</value>
|
||||
</data>
|
||||
|
||||
@@ -13,9 +13,11 @@ namespace EnvironmentVariables.ViewModels
|
||||
{
|
||||
public partial class MainViewModel
|
||||
{
|
||||
public VariablesSet UserDefaultSet { get; private set; } = new DefaultVariablesSet(VariablesSet.UserGuid, ResourceLoaderInstance.ResourceLoader.GetString("User"), VariablesSetType.User);
|
||||
public DefaultVariablesSet UserDefaultSet { get; private set; } = new DefaultVariablesSet(VariablesSet.UserGuid, ResourceLoaderInstance.ResourceLoader.GetString("User"), VariablesSetType.User);
|
||||
|
||||
public VariablesSet SystemDefaultSet { get; private set; } = new DefaultVariablesSet(VariablesSet.SystemGuid, ResourceLoaderInstance.ResourceLoader.GetString("System"), VariablesSetType.System);
|
||||
public DefaultVariablesSet SystemDefaultSet { get; private set; } = new DefaultVariablesSet(VariablesSet.SystemGuid, ResourceLoaderInstance.ResourceLoader.GetString("System"), VariablesSetType.System);
|
||||
|
||||
public ObservableCollection<ProfileVariablesSet> Profiles { get; private set; } = new ObservableCollection<ProfileVariablesSet>();
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
@@ -29,6 +31,16 @@ namespace EnvironmentVariables.ViewModels
|
||||
|
||||
SystemDefaultSet.Variables.Add(new Variable("system1", "svalue1"));
|
||||
SystemDefaultSet.Variables.Add(new Variable("system2", "svalue2"));
|
||||
|
||||
var profile1 = new ProfileVariablesSet(Guid.NewGuid(), "profile1");
|
||||
profile1.Variables.Add(new Variable("profile11", "pvalue1"));
|
||||
profile1.Variables.Add(new Variable("profile12", "pvalue2"));
|
||||
var profile2 = new ProfileVariablesSet(Guid.NewGuid(), "profile2");
|
||||
profile2.Variables.Add(new Variable("profile21", "pvalue11"));
|
||||
profile2.Variables.Add(new Variable("profile22", "pvalue22"));
|
||||
|
||||
Profiles.Add(profile1);
|
||||
Profiles.Add(profile2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user