Files
PowerToys/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml
Seraphima Zykova b8e5ccfb7b [FancyZones] Editor multi monitor support (#6562)
Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
2020-11-17 11:38:19 +03:00

465 lines
27 KiB
XML

<Controls:MetroWindow x:Class="FancyZonesEditor.MainWindow"
x:Name="MainWindow1"
AutomationProperties.Name="{x:Static props:Resources.Fancy_Zones_Main_Editor}"
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:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:local="clr-namespace:FancyZonesEditor"
xmlns:Converters="clr-namespace:FancyZonesEditor.Converters"
xmlns:props="clr-namespace:FancyZonesEditor.Properties" xmlns:local1="clr-namespace:FancyZonesEditor.ViewModels"
mc:Ignorable="d"
Title=""
Width="810"
SizeToContent="Height"
Background="White"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Initialized="OnInitialized"
Closing="OnClosing">
<Window.Resources>
<Converters:BooleanToBrushConverter x:Key="BooleanToBrushConverter" />
<Converters:ModelToVisibilityConverter x:Key="ModelToVisibilityConverter" />
<Converters:BooleanToIntConverter x:Key="BooleanToIntConverter" />
<Style x:Key="titleText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="LineHeight" Value="24" />
<Setter Property="FontSize" Value="18"/>
<Setter Property="Margin" Value="16,20,0,0" />
</Style>
<Style x:Key="zoneCount" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="Regular" />
<Setter Property="FontSize" Value="24"/>
<Setter Property="LineHeight" Value="24" />
<Setter Property="Margin" Value="20,0,20,0" />
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="tabText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="#767676"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="LineHeight" Value="20" />
<Setter Property="Margin" Value="24,20,0,0" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="settingText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="LineHeight" Value="20" />
<Setter Property="Margin" Value="7,10,0,0" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
<Style x:Key="settingCheckBoxText" TargetType="CheckBox">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Margin" Value="5,10,0,0" />
</Style>
<Style x:Key="templateTitleText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="customButtonFocusVisualStyle">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="1" Stroke="White" StrokeDashArray="1 2" StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="secondaryButton" TargetType="Button">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="0,5,0,5"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#767676"/>
<Setter Property="Margin" Value="16,0,0,0" />
<Setter Property="Width" Value="245"/>
<Setter Property="Height" Value="32"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource customButtonFocusVisualStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#5D5D5D"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="primaryButton" TargetType="Button">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="0,5,0,5"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#0078D7"/>
<Setter Property="Margin" Value="16,0,0,0" />
<Setter Property="Width" Value="245"/>
<Setter Property="Height" Value="32"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource customButtonFocusVisualStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#024D89"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="spinnerButton" TargetType="Button">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontSize" Value="24"/>
<Setter Property="Padding" Value="0,0,0,5"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="#F2F2F2"/>
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
<Style x:Key="newLayoutButton" TargetType="Button">
<Setter Property="Background" Value="#f2f2f2"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontFamily" Value="SegoeUI"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="FontSize" Value="148"/>
</Style>
<Style x:Key="textBox" TargetType="TextBox">
<Setter Property="BorderBrush" Value="#cccccc"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FontFamily" Value="SegoeUI"/>
<Setter Property="FontWeight" Value="Regular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="16,6,0,0"/>
<Setter Property="Padding" Value="5,5,5,5"/>
</Style>
<Style x:Key="desktopIdText" TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="42" />
<Setter Property="Foreground" Value="#303030" />
</Style>
<Style x:Key="desktopDimensionsText" TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Foreground" Value="#303030" />
</Style>
<Style x:Key="desktopButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#DADADA" />
<Setter Property="Width" Value="{Binding DisplayWidth}" />
<Setter Property="Height" Value="{Binding DisplayHeight}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="0"
BorderBrush="#303030"
BorderThickness="2" >
<ContentPresenter x:Name="contentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#C2C2C2" />
</Trigger>
<DataTrigger Binding="{Binding Selected}" Value="true">
<Setter Property="Background" Value="#0078D7" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="templateBackground" TargetType="Border">
<Setter Property="Background" Value="#F2F2F2"/>
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="BorderThickness" Value="2"/>
</Style>
<ControlTemplate x:Key="myTabs">
<Grid Width="404">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="2"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Name="myTabText" Text="{TemplateBinding TabItem.Header}" Style="{StaticResource tabText}" />
<Rectangle Grid.Row="1" x:Name="myTabLine" Fill="#F2F2F2" Height="1"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabItem.IsSelected" Value="True">
<Setter TargetName="myTabText" Property="Foreground" Value="#2A79D7"/>
<Setter TargetName="myTabLine" Property="Fill" Value="#2A79D7" />
<Setter TargetName="myTabLine" Property="Height" Value="2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="desktopButton">
<Button Style="{StaticResource desktopButtonStyle}"
Command="{Binding DataContext.SelectCommand, ElementName= MainWindowItemControl}"
CommandParameter="{Binding}"
Margin="1,6,1,6">
<Button.Content>
<Grid Name="MonitorsGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="0.40*"/>
</Grid.RowDefinitions>
<TextBlock Name="desktopId" Text="{Binding Index}" Style="{StaticResource desktopIdText}" Grid.Row="0"/>
<TextBlock Name="desktopDimensions" Text="{Binding Dimensions}" Style="{StaticResource desktopDimensionsText}" Grid.Row="1" />
</Grid>
</Button.Content>
</Button>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Selected}" Value="true">
<Setter TargetName="desktopId" Property="Foreground" Value="#F2F2F2" />
<Setter TargetName="desktopDimensions" Property="Foreground" Value="#F2F2F2" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<StackPanel FocusManager.FocusedElement="{Binding ElementName=decrementZones}">
<TextBlock Name="DialogTitle" Text="{x:Static props:Resources.Choose_Layout}" Style="{StaticResource titleText}" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True"
ScrollViewer.PanningMode="HorizontalOnly"
Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UIElement}}"
PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<ScrollViewer.DataContext>
<local1:MonitorViewModel></local1:MonitorViewModel>
</ScrollViewer.DataContext>
<ItemsControl x:Name="MainWindowItemControl"
ItemsSource="{Binding MonitorInfoForViewModel}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="Transparent"
Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="8, 16, 8, 8"
Visibility="{Binding DesktopsPanelVisibility}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Template="{StaticResource desktopButton}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
<TabControl BorderThickness="0" x:Name="TemplateTab" AutomationProperties.LabeledBy="{Binding ElementName=DialogTitle}" SelectedIndex="{Binding IsCustomLayoutActive, Mode=OneWay, Converter={StaticResource BooleanToIntConverter}}">
<TabItem Header="{x:Static props:Resources.Templates}" Template="{StaticResource myTabs}" AutomationProperties.Name="{x:Static props:Resources.Tab_Item_Templates}">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="0,15,0,8" Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="decrementZones" Width="40" Height="40" AutomationProperties.Name="{x:Static props:Resources.Zone_Count_Decrement}" Content="-" Style="{StaticResource spinnerButton}" Click="DecrementZones_Click"/>
<TextBlock x:Name="zoneCount" Text="{Binding ZoneCount}" Style="{StaticResource zoneCount}"/>
<Button x:Name="incrementZones" Width="40" Height="40" AutomationProperties.Name="{x:Static props:Resources.Zone_Count_Increment}" Content="+" Style="{StaticResource spinnerButton}" Click="IncrementZones_Click"/>
</StackPanel>
</Grid>
<ItemsControl ItemsSource="{Binding DefaultModels}" Margin="8,0,0,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"
Margin="2"
ItemWidth="{Binding ElementName=MainWindow1, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Path=WrapPanelItemSize}"
ItemHeight="{Binding ElementName=WrapPanel1, Path=ItemWidth}"
x:Name="WrapPanel1" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="8"
BorderBrush="{Binding Path=IsSelected, Converter={StaticResource BooleanToBrushConverter}}"
Background="{Binding Path=IsApplied, Converter={StaticResource BooleanToBrushConverter}}"
Style="{StaticResource templateBackground}"
MouseDown="LayoutItem_Click"
Focusable="True"
FocusManager.GotFocus="LayoutItem_Focused"
KeyDown="LayoutItem_Apply">
<DockPanel Margin="0,20,0,0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
LastChildFill="True">
<TextBlock Name="layoutName"
Padding="8,0,8,0"
TextTrimming="CharacterEllipsis"
DockPanel.Dock="Top"
Text="{Binding Name}"
Style="{StaticResource templateTitleText}" />
<local:LayoutPreview Margin="16" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</DockPanel>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsApplied}" Value="true">
<Setter TargetName="layoutName" Property="Foreground" Value="#F2F2F2" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</TabItem>
<TabItem Header="{x:Static props:Resources.Custom}" Template="{StaticResource myTabs}" AutomationProperties.Name="{x:Static props:Resources.Tab_Item_Custom}">
<StackPanel>
<ItemsControl ItemsSource="{Binding CustomModels}" Margin="8,8,0,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" ItemWidth="{Binding ElementName=MainWindow1, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Path=WrapPanelItemSize}" ItemHeight="{Binding ElementName=WrapPanel2, Path=ItemWidth}" x:Name="WrapPanel2" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="8"
BorderBrush="{Binding Path=IsSelected, Converter={StaticResource BooleanToBrushConverter}}"
Background="{Binding Path=IsApplied, Converter={StaticResource BooleanToBrushConverter}}"
Style="{StaticResource templateBackground}"
MouseDown="LayoutItem_Click"
Focusable="True"
FocusManager.GotFocus="LayoutItem_Focused"
KeyDown="LayoutItem_Apply">
<DockPanel Margin="0,20,0,0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
LastChildFill="True">
<DockPanel DockPanel.Dock="Top" LastChildFill="True" >
<Button x:Name="DeleteButton" AutomationProperties.Name="{x:Static props:Resources.Custom_Layout_Delete_Button}"
Visibility="{Binding Converter={StaticResource ModelToVisibilityConverter}}"
DockPanel.Dock="Right"
MaxHeight="10"
Click="OnDelete"
Padding="8,4,8,4"
Margin="0,0,8,0"
BorderThickness="0"
Background="#f2f2f2">
<Image Source="images/Delete.png" />
</Button>
<TextBlock Name="layoutName"
DockPanel.Dock="Top"
TextTrimming="CharacterEllipsis" Padding="8,0,8,0"
Text="{Binding Name}"
Style="{StaticResource templateTitleText}" />
</DockPanel>
<local:LayoutPreview Margin="16" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</DockPanel>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsApplied}" Value="true">
<Setter TargetName="layoutName" Property="Foreground" Value="#F2F2F2" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</TabItem>
</TabControl>
<Grid Margin="10,4,10,8" >
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<CheckBox x:Name="spaceAroundSetting" Content="{x:Static props:Resources.Show_Space_Zones}" Style="{StaticResource settingCheckBoxText}" IsChecked="{Binding ShowSpacing}" Grid.Row="0" Grid.Column="0"/>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
<TextBlock x:Name="paddingValue"
Text="{x:Static props:Resources.Space_Around_Zones}"
Style="{StaticResource settingText}"
IsEnabled="{Binding ShowSpacing}"
MaxWidth="{Binding Path=SettingsTextMaxWidth, ElementName=MainWindow1}"
TextWrapping="Wrap"/>
<TextBox AutomationProperties.LabeledBy="{Binding ElementName=paddingValue}" Text="{Binding Path=Spacing,Mode=TwoWay}" Style="{StaticResource textBox}" MinWidth="32" IsEnabled="{Binding ShowSpacing}" />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
<TextBlock x:Name="sensitivityRadiusValue"
Text="{x:Static props:Resources.Distance_adjacent_zones}"
Style="{StaticResource settingText}"
MaxWidth="{Binding Path=SettingsTextMaxWidth, ElementName=MainWindow1}"
TextWrapping="Wrap"/>
<TextBox AutomationProperties.LabeledBy="{Binding ElementName=sensitivityRadiusValue}" Text="{Binding Path=SensitivityRadius,Mode=TwoWay}" Style="{StaticResource textBox}" MinWidth="40"/>
</StackPanel>
</Grid>
<StackPanel Orientation="Horizontal" Margin="0,10,0,16">
<Button x:Name="EditCustomButton" Content="{x:Static props:Resources.Edit_Selected_Layout}" Padding="8" Style="{StaticResource secondaryButton}" Click="EditLayout_Click"/>
<Button x:Name="ApplyCustomButton" Content="{x:Static props:Resources.Apply}" Padding="8" Style="{StaticResource primaryButton}" Click="Apply_Click"/>
<Button x:Name="CloseButton"
Content="{x:Static props:Resources.Close}"
Visibility="{Binding DesktopsPanelVisibility}"
Padding="8"
Style="{StaticResource secondaryButton}"
Click="CloseButton_Click" >
<Button.DataContext>
<local1:MonitorViewModel></local1:MonitorViewModel>
</Button.DataContext>
</Button>
</StackPanel>
</StackPanel>
</Controls:MetroWindow>