Files
PowerToys/src/modules/Projects/ProjectsEditor/ProjectEditorPage.xaml
2024-06-27 20:10:44 +02:00

270 lines
13 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>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<DataTemplate x:Key="headerTemplate">
<Border
HorizontalAlignment="Stretch">
<DockPanel
HorizontalAlignment="Stretch"
>
<TextBlock
DockPanel.Dock="Left"
Text="{Binding MonitorName}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
Margin="0,0,20,0"
VerticalAlignment="Center"/>
<CheckBox
DockPanel.Dock="Right"
HorizontalAlignment="Right"
x:Name="SelectAllOnMonitorCheckBox"
Tag="{Binding MonitorName}"
Margin="10,0,0,0"
FontSize="14"
Content="{Binding SelectString}"
Checked="SelectAllOnMonitorCheckBox_Modified"
Unchecked="SelectAllOnMonitorCheckBox_Modified"/>
</DockPanel>
</Border>
</DataTemplate>
<DataTemplate x:Key="appTemplate">
<Border
Background="{DynamicResource SecondaryBackgroundBrush}"
MouseEnter="AppBorder_MouseEnter"
MouseLeave="AppBorder_MouseLeave">
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock
Text="&#xE7BA;"
Foreground="#EED202"
FontSize="14"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
FontWeight="Normal"
Margin="5 0 0 0"
ToolTip="{x:Static props:Resources.NotFoundTooltip}"
Visibility="{Binding IsNotFound, Converter={StaticResource BoolToVis}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Center"/>
<Image
Grid.Column="1"
Width="20"
Height="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="10"
Source="{Binding IconBitmapImage}"/>
<TextBlock
Grid.Column="2"
Text="{Binding RepeatIndexString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
Width="20"
VerticalAlignment="Center"/>
<TextBlock
Grid.Column="3"
Text="{Binding AppName}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="14"
FontWeight="Normal"
VerticalAlignment="Center"/>
<TextBox
x:Name="CommandLineTextBox"
Grid.Column="4"
Text="{Binding CommandLineArguments, Mode=TwoWay}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Background="{DynamicResource TertiaryBackgroundBrush}"
BorderThickness="0"
FontSize="14"
FontWeight="Normal"
VerticalContentAlignment="Center" />
<TextBlock
Grid.Column="4"
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="5"
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
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">
<Button
Margin="0,20,0,20"
Click="CancelButtonClicked"
Background="Transparent"
VerticalAlignment="Center">
<TextBlock
Text="{x:Static props:Resources.Projects}"
FontSize="24"
FontWeight="Normal"
Foreground="{DynamicResource PrimaryForegroundBrush}"
VerticalAlignment="Center"/>
</Button>
<TextBlock
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
FontSize="16"
Margin="10,0,0,0"
Text="&#xE76C;"
VerticalAlignment="Center"/>
<TextBlock
Text="{Binding EditorWindowTitle}"
FontSize="24"
FontWeight="SemiBold"
Margin="10,0,0,0"
Foreground="{DynamicResource PrimaryForegroundBrush}"
VerticalAlignment="Center"/>
</StackPanel>
<DockPanel Grid.Row="1">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" >
<Button x:Name="DeleteButton"
Margin="10,0,0,0"
Height="36"
Padding="24,0,24,0"
Content="{x:Static props:Resources.DeleteSelected}"
Background="{DynamicResource SecondaryBackgroundBrush}"
AutomationProperties.Name="{x:Static props:Resources.Cancel}"
IsEnabled="{Binding IsAnySelected, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Click="RemoveSelectedButtonClicked"/>
<CheckBox
x:Name="SelectAllCheckBox"
Margin="10,0,0,0"
FontSize="14"
Content="{x:Static props:Resources.SelectedAllInProject}"
Checked="SelectAllCheckBox_Modified"
Unchecked="SelectAllCheckBox_Modified"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" 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"
TextChanged="EditNameTextBox_TextChanged"
KeyDown="EditNameTextBoxKeyDown" />
</StackPanel>
</DockPanel>
<Border
Grid.Row="2"
HorizontalAlignment="Stretch"
Background="{DynamicResource MonitorViewBackgroundBrush}"
CornerRadius="5">
<Image
Width="{Binding PreviewImageWidth, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Height="200"
Source="{Binding PreviewImage, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Stretch="Fill"
Margin="2"/>
</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, UpdateSourceTrigger=PropertyChanged}"
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"
IsEnabled="{Binding CanBeSaved, UpdateSourceTrigger=PropertyChanged}"
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>