Files
PowerToys/src/modules/Projects/ProjectsEditor/ProjectEditorPage.xaml
2024-06-05 19:10:50 +02:00

233 lines
11 KiB
XML

<Page x:Class="ProjectsEditor.ProjectEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:props="clr-namespace:ProjectsEditor.Properties"
xmlns:local="clr-namespace:ProjectsEditor"
xmlns:models="clr-namespace:ProjectsEditor.Models"
mc:Ignorable="d"
Title="Project Editor"
Background="{DynamicResource PrimaryBackgroundBrush}">
<Page.Resources>
<DataTemplate x:Key="headerTemplate">
<Border>
<TextBlock
Text="{Binding .}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
Margin="0,20,20,5"
VerticalAlignment="Center"/>
</Border>
</DataTemplate>
<DataTemplate x:Key="appTemplate">
<Border
Background="{DynamicResource SecondaryBackgroundBrush}"
MouseEnter="AppBorder_MouseEnter"
MouseLeave="AppBorder_MouseLeave">
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image
Width="20"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="10"
Source="{Binding IconBitmapImage}"/>
<TextBlock
Grid.Column="1"
Text="{Binding RepeatIndexString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
Width="20"
VerticalAlignment="Center"/>
<TextBlock
Grid.Column="2"
Text="{Binding AppName}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
VerticalAlignment="Center"/>
<TextBox
x:Name="CommandLineTextBox"
Grid.Column="3"
Text="{Binding CommandLineArguments, Mode=TwoWay}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Background="{DynamicResource TertiaryBackgroundBrush}"
BorderThickness="0"
FontSize="14"
FontWeight="Normal"
VerticalContentAlignment="Center" />
<TextBlock
Grid.Column="3"
IsHitTestVisible="False"
Text="{x:Static props:Resources.WriteArgs}"
Foreground="{DynamicResource SecondaryForegroundBrush}"
Background="{DynamicResource TertiaryBackgroundBrush}"
FontSize="14"
FontWeight="Normal"
VerticalAlignment="Center"
Margin="12,0,12,0">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Text, ElementName=CommandLineTextBox}" Value="">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<CheckBox
Grid.Column="4"
IsChecked="{Binding IsSelected, Mode=TwoWay}"
Checked="CheckBox_Checked"
Unchecked="CheckBox_Checked"
Margin="10"/>
</Grid>
</Border>
</DataTemplate>
<models:AppListDataTemplateSelector
HeaderTemplate="{StaticResource headerTemplate}"
AppTemplate="{StaticResource appTemplate}"
x:Key="AppListDataTemplateSelector"/>
</Page.Resources>
<Grid Margin="40,0,40,40">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock Text="{x:Static props:Resources.Projects}" FontSize="24" FontWeight="Normal" Margin="0,20,0,20" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
<TextBlock
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="16"
Margin="10,30,0,20"
Text="&#xE76C;" />
<TextBlock Text="{Binding EditorWindowTitle}" FontSize="24" FontWeight="SemiBold" Margin="10,20,0,20" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Vertical">
<TextBlock Text="{x:Static props:Resources.ProjectName}" FontSize="14" FontWeight="Normal" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
<TextBox
x:Name="EditNameTextBox"
Width="320"
Text="{Binding Name, Mode=TwoWay}"
Background="{DynamicResource SecondaryBackgroundBrush}"
BorderBrush="{DynamicResource PrimaryBorderBrush}"
BorderThickness="2"
Margin="0,6,0,6"
HorizontalAlignment="Left"
GotFocus="EditNameTextBox_GotFocus"
KeyDown="EditNameTextBoxKeyDown" />
</StackPanel>
<Border
Grid.Row="2"
HorizontalAlignment="Stretch"
Background="{DynamicResource MonitorViewBackgroundBrush}"
CornerRadius="5">
<ScrollViewer
HorizontalAlignment="Center"
HorizontalScrollBarVisibility="Auto">
<ItemsControl
ItemsSource="{Binding Monitors, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel
IsItemsHost="True"
Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="models:MonitorSetup">
<Grid
Margin="20,20,20,20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding MonitorInfoWithResolution}" Foreground="{DynamicResource PrimaryForegroundBrush}" FontSize="16" FontWeight="Normal" Margin="0,5,0,5"/>
<Border
Grid.Row="1"
CornerRadius="5"
BorderBrush="{DynamicResource TertiaryBackgroundBrush}"
BorderThickness="2"
Margin="0,0,0,10">
<Image
Width="200"
Height="140"
Source="{Binding PreviewImage, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Stretch="Fill"
Margin="2"/>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
<ScrollViewer
Margin="0,10,0,0"
VerticalScrollBarVisibility="Auto"
Grid.Row="3">
<StackPanel Orientation="Vertical">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ItemsControl
ItemsSource="{Binding ApplicationsListed, Mode=OneWay}"
ItemTemplateSelector="{StaticResource AppListDataTemplateSelector}">
</ItemsControl>
</Grid>
</StackPanel>
</ScrollViewer>
<DockPanel Grid.Row="4" Margin="0,20,0,20">
<CheckBox
DockPanel.Dock="Left"
Content="{x:Static props:Resources.CreateShortcut}"
IsChecked="{Binding IsShortcutNeeded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontSize="14"/>
<StackPanel
DockPanel.Dock="Right"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="40,0,0,0">
<Button
x:Name="CancelButton"
Margin="20,0,0,0"
Height="36"
Padding="24,0,24,0"
Content="{x:Static props:Resources.Cancel}"
Background="{DynamicResource SecondaryBackgroundBrush}"
AutomationProperties.Name="{x:Static props:Resources.Cancel}"
Click="CancelButtonClicked">
</Button>
<Button
x:Name="SaveButton"
Margin="20,0,0,0"
Padding="24,0,24,0"
Height="36"
Content="{x:Static props:Resources.Save_project}"
AutomationProperties.Name="{x:Static props:Resources.Save_project}"
Click="SaveButtonClicked"
Style="{StaticResource AccentButtonStyle}">
</Button>
</StackPanel>
</DockPanel>
</Grid>
</Page>