added Fancy Zones Settings (#2161)

This commit is contained in:
Lavius Motileng
2020-04-16 11:45:27 -07:00
committed by GitHub
parent c37884bdb7
commit 10c0325f18
20 changed files with 897 additions and 120 deletions

View File

@@ -5,10 +5,16 @@
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:CustomControls="using:Microsoft.PowerToys.Settings.UI.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<viewModel:FancyZonesViewModel x:Key="eventViewModel"/>
</Page.Resources>
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
@@ -41,69 +47,96 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock Text="Create window layouts to help make multi-tasking easy."
<StackPanel Orientation="Vertical" x:Name="FZSettingsView">
<TextBlock x:Uid="FancyZones_Description"
TextWrapping="Wrap"/>
<ToggleSwitch Header="Enable FancyZones"
IsOn="True"
<ToggleSwitch x:Uid="FancyZones_EnableToggleControl_HeaderText"
IsOn="{ Binding Mode=TwoWay, Path=IsEnabled}"
Margin="{StaticResource SmallTopMargin}" />
<TextBlock Text="Zone behaviour"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<TextBlock x:Uid="FancyZones_ZonBehaivior_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
/>
<CheckBox Content="Hold Shift key or any non-primary mouse button to enable zones while dragging"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<Button x:Uid="FancyZones_LaunchEditorButtonControl_Header"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command = "{Binding LaunchEditorEventHandler, Source={StaticResource eventViewModel}}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
/>
<CheckBox Content="Override Windows Snap hotkeys (Win + arrow) to move windows between zones"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CustomControls:HotkeySettingsControl
x:Uid="FancyZones_HokeyEditorControl_Header"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.EditorHotkey, Mode=TwoWay}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
/>
<CheckBox Content="Flash zones when the active FancyZones layout changes"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_ShiftDragCheckBoxControl_Header"
IsChecked="{ Binding Mode=TwoWay, Path=ShiftDrag}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
/>
<CheckBox Content="Keep windows in their zones when the screen resolution changes"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_OverrideSnapHotkeysCheckBoxControl"
IsChecked="{ Binding Mode=TwoWay, Path=OverrideSnapHotkeys}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<CheckBox Content="During zone layout changes, windows assigned to a zone will match new size/positions"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_ZoneSetChangeFlashZonesCheckBoxControl"
IsChecked="{ Binding Mode=TwoWay, Path=ZoneSetChangeFlashZones}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<CheckBox Content="Keep windows pinned to multiple desktops in the same zone when the active desktop changes"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_DisplayChangeMoveWindowsCheckBoxControl"
IsChecked="{ Binding Mode=TwoWay, Path=DisplayChangeMoveWindows}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
/>
<CheckBox Content="Move newly created windows to their last known zone"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_ZoneSetChangeMoveWindows"
IsChecked="{ Binding Mode=TwoWay, Path=ZoneSetChangeMoveWindows}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<CheckBox Content="Follow mouse cursor instead of focus when launching editor in a multi screen environment"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="FancyZones_KeepWindowsPinned"
IsChecked="{ Binding Mode=TwoWay, Path=VirtualDesktopChangeMoveWindows}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<CheckBox x:Uid="FancyZones_VirtualDesktopChangeMoveWindows"
IsChecked="{ Binding Mode=TwoWay, Path=AppLastZoneMoveWindows}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<CheckBox x:Uid="FancyZones_UseCursorPosEditorStartupScreen"
IsChecked="{ Binding Mode=TwoWay, Path=UseCursorPosEditorStartupScreen}"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<TextBlock Text="Appearance"
<TextBlock x:Uid="Appearancce_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<!-- TO DO: Do we still need this numberbox? The colorpicker has an Alpha/Opacity option as well so we could use that -->
<muxc:NumberBox Header="Zone highlight opacity (%)"
Value="90"
<muxc:NumberBox x:Uid="FancyZones_HighlightOpacity"
Value="{ Binding Mode=TwoWay, Path=HighlightOpacity}"
Minimum="0"
Maximum="100"
SpinButtonPlacementMode="Inline"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}" />
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<TextBlock Text="Zone highlight color (default: #0078D7)"
<TextBlock x:Uid="FancyZones_ZoneHighlightColor"
Style="{StaticResource BodyTextBlockStyle}"
Margin="{StaticResource SmallTopMargin}" />
<muxc:ColorPicker Margin="0,6,0,0"
<muxc:ColorPicker x:Name="ColorChoice"
Margin="0,6,0,0"
HorizontalAlignment="Left"
IsMoreButtonVisible="True"
IsColorSliderVisible="True"
@@ -111,32 +144,52 @@
IsHexInputVisible="True"
IsAlphaEnabled="True"
IsAlphaSliderVisible="True"
IsAlphaTextInputVisible="True" />
IsAlphaTextInputVisible="True"
Color="{Binding Path=ZoneHighlightColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<TextBlock Text="Excluded apps"
<Button x:Uid="FancyZones_SaveColorChoice"
Margin="{StaticResource SmallTopMargin}"
Style="{StaticResource AccentButtonStyle}"
Command = "{Binding SaveColorChoiceEventHandler, Source={StaticResource eventViewModel}}"
CommandParameter="{Binding Color, ElementName=ColorChoice}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<TextBlock x:Uid="FancyZones_ExcludeApps"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<TextBox Header="To exclude an application from snapping to zones add its name here (one per line). Excluded apps will react to the Windows Snap regardless of all other settings."
Margin="{StaticResource SmallTopMargin}"/>
</StackPanel>
<StackPanel
x:Name="SidePanel"
Orientation="Vertical"
HorizontalAlignment="Left"
Width="{StaticResource SidePanelWidth}"
Grid.Column="1">
<TextBox x:Uid="FancyZones_ExcludeApps_TextBoxControl"
Margin="{StaticResource SmallTopMargin}"
Text="{ Binding Mode=TwoWay, Path=ExcludedApps}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
<TextBlock
Text="About this feature"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"/>
<Image
Source="https://user-images.githubusercontent.com/9866362/77859136-f04ae880-7207-11ea-8a7f-4295342fe319.gif" />
<HyperlinkButton
Content="Module overview"
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/src/modules/fancyzones/README.md"/>
</StackPanel>
<StackPanel x:Name="SidePanel"
Orientation="Vertical"
HorizontalAlignment="Left"
Width="{StaticResource SidePanelWidth}"
Grid.Column="1">
<TextBlock x:Uid="About_This_Feature"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"/>
<Image Source="https://user-images.githubusercontent.com/9866362/77859136-f04ae880-7207-11ea-8a7f-4295342fe319.gif" />
<HyperlinkButton x:Uid="Module_overview"
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/src/modules/fancyzones/README.md"/>
<HyperlinkButton x:Uid="Give_Feedback" NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
<!--
<TextBlock Text="Contributors"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
-->
</StackPanel>
</Grid>
</Page>

View File

@@ -2,18 +2,33 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class FancyZonesPage : Page
{
public FancyZonesViewModel ViewModel { get; } = new FancyZonesViewModel();
public FancyZonesViewModel ViewModel { get; set; }
public FancyZonesPage()
{
InitializeComponent();
this.InitializeComponent();
ViewModel = new FancyZonesViewModel();
this.FZSettingsView.DataContext = ViewModel;
}
}
}

View File

@@ -42,10 +42,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
// load and apply theme settings
ReLoadTheme(settings.theme);
ReLoadTheme(settings.Theme);
// load run on start-up settings value and update the ui state.
ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
}
catch
{
@@ -54,10 +54,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
// load and apply theme settings
ReLoadTheme(settings.theme);
ReLoadTheme(settings.Theme);
// load run on start up ui settings value and update the ui state.
ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
}
}
@@ -96,10 +96,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
switch (startup)
{
case "true":
settings.startup = true;
settings.Startup = true;
break;
case "false":
settings.startup = false;
settings.Startup = false;
break;
}
@@ -116,7 +116,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
private void Restart_Elevated(object sender, RoutedEventArgs e)
{
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
settings.run_elevated = true;
settings.RunElevated = true;
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
if (ShellPage.DefaultSndMSGCallback != null)
@@ -136,7 +136,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
// update and save settings to file.
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
settings.theme = themeName;
settings.Theme = themeName;
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
}
}

View File

@@ -29,15 +29,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
base.OnNavigatedTo(e);
settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
}
catch
{
settings = new PowerPreviewSettings(PreviewPaneKey);
SettingsUtils.SaveSettings(settings.ToJsonString(), PreviewPaneKey);
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
}
}
@@ -48,7 +48,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value = swt.IsOn;
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@@ -66,7 +66,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value = swt.IsOn;
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{

View File

@@ -43,11 +43,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
private void UpdateView(PowerRenameSettings settings)
{
Toggle_PowerRename_Enable.IsOn = settings.properties.MruEnabled.value;
Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.ShowExtendedMenu.value;
Toggle_PowerRename_MaxDispListNum.Value = settings.properties.MaxMruSize.value;
Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.ShowIconInMenu.value;
Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.PersistInput.value;
Toggle_PowerRename_Enable.IsOn = settings.properties.MruEnabled.Value;
Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.ShowExtendedMenu.Value;
Toggle_PowerRename_MaxDispListNum.Value = settings.properties.MaxMruSize.Value;
Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.ShowIconInMenu.Value;
Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.PersistInput.Value;
}
private void Toggle_PowerRename_Enable_Toggled(object sender, RoutedEventArgs e)
@@ -57,7 +57,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.MruEnabled.value = swt.IsOn;
settings.properties.MruEnabled.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@@ -75,7 +75,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.ShowIconInMenu.value = swt.IsOn;
settings.properties.ShowIconInMenu.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@@ -93,7 +93,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.ShowExtendedMenu.value = swt.IsOn;
settings.properties.ShowExtendedMenu.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@@ -111,7 +111,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.PersistInput.value = swt.IsOn;
settings.properties.PersistInput.Value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@@ -127,7 +127,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (sender != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.MaxMruSize.value = Convert.ToInt32(sender.Value);
settings.properties.MaxMruSize.Value = Convert.ToInt32(sender.Value);
if (ShellPage.DefaultSndMSGCallback != null)
{