[New PowerToy] Add Screen Ruler module for measuring screen contents (#19701)

* [MeasureTool] initial commit

* [chore] clean up needless WindowsTargetPlatformVersion overrides from projects

* [MeasureTool] initial implementation

* Fix build errors

* Update vsconfig for needed Windows 10 SDK versions

* fix spellchecker

* another spellcheck fix

* more spellcheck errors

* Fix measurement being off by 1 on both ends

* UI fixes

* Add feet to crosses

* Remove anti-aliasing, as it's creating artifacts

* Use pixel tolerance from settings

* Tooltip updates

* Restore antialiasing to draw the tooltip

* remove comment for spell check

* Updated icons

* Icon updates

* Improve measurement accuracy and display

* Fix spellchecker

* Add less precise drawing on continuous warning

* Add setting for turning cross feet on

* Swap LMB/RMB for interaction

* Uncheck active tool's RadioButton when it exits

* activation hotkey toggles UI instead of just launching it

* track runner process and exit when it exits

* add proj ref

* toolbar is interactive during measurements

* always open toolbar on the main display

* refactor colors

* refactor edge detection & overlay ui

* refactor overlay ui even more

* simplify state structs

* multimonitor preparation: eliminate global state

* prepare for merge

* spelling

* proper thread termination + minor fixes

* multimonitor: launch tools on all monitors

* multimonitor support: track cursor position

* spell

* fix powertoys!

* ScreenSize -> Box

* add shadow effect for textbox

* spell

* fix debug mode

* dynamic text box size based on text layout metrics

* add mouse wheel to adjust pixel tolerance + per channel detection algorithm setting

* spelling

* fix per channel distance calculations

* update installer deps + spelling

* tool activation telemetry

* update assets and try to fix build

* use × instead of x

* allow multiple measurements with bounds tool with shift-click

* move #define DEBUG_OVERLAY in an appropriate space

* spell-checked

* update issue template + refactor text box drawing

* implement custom renderer and make × semiopaque

* spelling

* pass dpiScale to x renderer

* add sse2neon license

* update OOBE

* move license to NOTICE

* appropriate module preview image

* localization for AutomationPeer

* increase default pixel tolerance from 5 to 30

* add PowerToys.MeasureToolUI.exe to bugreport

* explicitly set texture dims

* clarify continuous capture description

* fix a real spelling error!

* cleanup

* clean up x2

* debug texture

* fix texture access

* fix saveasbitmap

* improve sum of all channel diffs method score calc

* optimize

* ContinuousCapture is enabled by default to avoid confusion

* build fix

* draw captured screen in a non continuous mode

* cast a spell...

* merge fix

* disable stroboscopic effect

* split global/perScreen measure state and minor improvements

* spelling

* fix comment

* primary monitor debug also active for the bounds tool

* dpi from rt for custom renderer

* add comment

* fix off by 1

* make backround convertion success for non continuous mode non-essential

* fix spelling

* overlay window covers taskbar

* fix CI

* revert taskbar covering

* fix CI

* fix ci again

* fix 2

* fix ci

* CI fix

* fix arm ci

* cleanup cursor convertion between coordinate spaces

* fix spelling

* Fix signing

* Fix MeasureToolUI version

* Fix core version

* fix race condition in system internals which happens during concurrent d3d/d2d resource creation

Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
Andrey Nekrasov
2022-08-27 02:17:20 +03:00
committed by GitHub
parent 2274e0c67d
commit 78d65a87cd
114 changed files with 5319 additions and 337 deletions

View File

@@ -128,6 +128,7 @@ namespace Microsoft.PowerToys.Settings.UI
case "FileExplorer": StartupPage = typeof(Views.PowerPreviewPage); break;
case "ShortcutGuide": StartupPage = typeof(Views.ShortcutGuidePage); break;
case "VideoConference": StartupPage = typeof(Views.VideoConferencePage); break;
case "MeasureTool": StartupPage = typeof(Views.MeasureToolPage); break;
default: Debug.Assert(false, "Unexpected SettingsWindow argument value"); break;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -21,6 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Enums
Run,
ShortcutGuide,
VideoConference,
MeasureTool,
WhatsNew,
}
}

View File

@@ -0,0 +1,34 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.OOBE.Views.OobeMeasureTool"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkitcontrols="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d">
<controls:OOBEPageControl x:Uid="Oobe_MeasureTool" HeroImage="ms-appx:///Assets/Modules/OOBE/ScreenRuler.gif">
<controls:OOBEPageControl.PageContent>
<StackPanel Orientation="Vertical">
<TextBlock x:Uid="Oobe_HowToLaunch" Style="{ThemeResource OobeSubtitleStyle}" />
<controls:ShortcutWithTextLabelControl x:Name="HotkeyActivation" x:Uid="Oobe_MeasureTool_Activation" />
<toolkitcontrols:MarkdownTextBlock x:Uid="Oobe_MeasureTool_HowToLaunch" Background="Transparent" />
<StackPanel
Margin="0,24,0,0"
Orientation="Horizontal"
Spacing="12">
<Button x:Uid="OOBE_Settings" Click="SettingsLaunchButton_Click" />
<HyperlinkButton NavigateUri="https://aka.ms/PowerToysOverview_MeasureTool" Style="{StaticResource TextButtonStyle}">
<TextBlock x:Uid="LearnMore_MeasureTool" TextWrapping="Wrap" />
</HyperlinkButton>
</StackPanel>
</StackPanel>
</controls:OOBEPageControl.PageContent>
</controls:OOBEPageControl>
</Page>

View File

@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class OobeMeasureTool : Page
{
public OobePowerToysModule ViewModel { get; set; }
public OobeMeasureTool()
{
this.InitializeComponent();
ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.MeasureTool]);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (OobeShellPage.OpenMainWindowCallback != null)
{
OobeShellPage.OpenMainWindowCallback(typeof(MeasureToolPage));
}
ViewModel.LogOpeningSettingsEvent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyActivation.Keys = SettingsRepository<MeasureToolSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
ViewModel.LogClosingModuleEvent();
}
}
}

View File

@@ -1,15 +1,12 @@
<UserControl
x:Class="Microsoft.PowerToys.Settings.UI.OOBE.Views.OobeShellPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:localModels="using:Microsoft.PowerToys.Settings.UI.OOBE.ViewModel"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HighContrastAdjustment="None">
<UserControl x:Class="Microsoft.PowerToys.Settings.UI.OOBE.Views.OobeShellPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:localModels="using:Microsoft.PowerToys.Settings.UI.OOBE.ViewModel"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
HighContrastAdjustment="None">
<!-- todo(Stefan):
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True"
-->
@@ -27,149 +24,132 @@
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="NavigationView.PaneDisplayMode"
Value="LeftMinimal" />
<Setter Target="NavigationView.IsPaneToggleButtonVisible"
Value="True" />
<Setter Target="NavigationView.PaneDisplayMode" Value="LeftMinimal" />
<Setter Target="NavigationView.IsPaneToggleButtonVisible" Value="True" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<muxc:NavigationView IsSettingsVisible="False"
IsPaneToggleButtonVisible="False"
IsPaneOpen="True"
x:Name="NavigationView"
OpenPaneLength="296"
PaneDisplayMode="Left"
SelectionChanged="NavigationView_SelectionChanged"
IsBackButtonVisible="Collapsed">
<muxc:NavigationView IsSettingsVisible="False" IsPaneToggleButtonVisible="False"
IsPaneOpen="True" x:Name="NavigationView" OpenPaneLength="296"
PaneDisplayMode="Left" SelectionChanged="NavigationView_SelectionChanged"
IsBackButtonVisible="Collapsed">
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem x:Uid="Shell_General"
Tag="Overview">
<muxc:NavigationViewItem x:Uid="Shell_General" Tag="Overview">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToys.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToys.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_AlwaysOnTop"
Tag="AlwaysOnTop">
<muxc:NavigationViewItem x:Uid="Shell_AlwaysOnTop" Tag="AlwaysOnTop">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAlwaysOnTop.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAlwaysOnTop.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_Awake"
Tag="Awake">
<muxc:NavigationViewItem x:Uid="Shell_Awake" Tag="Awake">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAwake.png"
ShowAsMonochrome="False" />
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ColorPicker"
Tag="ColorPicker">
<muxc:NavigationViewItem x:Uid="Shell_ColorPicker" Tag="ColorPicker">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsColorPicker.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsColorPicker.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_FancyZones"
Tag="FancyZones">
<muxc:NavigationViewItem x:Uid="Shell_FancyZones" Tag="FancyZones">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFancyZones.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFancyZones.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerPreview"
Tag="FileExplorer">
<muxc:NavigationViewItem x:Uid="Shell_PowerPreview" Tag="FileExplorer">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFileExplorerPreview.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFileExplorerPreview.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ImageResizer"
Tag="ImageResizer">
<muxc:NavigationViewItem x:Uid="Shell_ImageResizer" Tag="ImageResizer">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsImageResizer.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsImageResizer.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_KeyboardManager"
Tag="KBM">
<muxc:NavigationViewItem x:Uid="Shell_KeyboardManager" Tag="KBM">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsKeyboardManager.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsKeyboardManager.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_MouseUtilities"
Tag="MouseUtils">
<muxc:NavigationViewItem x:Uid="Shell_MouseUtilities" Tag="MouseUtils">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsMouseUtils.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsMouseUtils.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerAccent"
Tag="PowerAccent">
<muxc:NavigationViewItem x:Uid="Shell_PowerAccent" Tag="PowerAccent">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerAccent.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerAccent.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerOCR"
Tag="PowerOCR">
<muxc:NavigationViewItem x:Uid="Shell_PowerOCR" Tag="PowerOCR">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerOCR.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerOCR.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerRename"
Tag="PowerRename">
<muxc:NavigationViewItem x:Uid="Shell_PowerRename" Tag="PowerRename">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerRename.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerRename.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerLauncher"
Tag="Run">
<muxc:NavigationViewItem x:Uid="Shell_PowerLauncher" Tag="Run">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToysRun.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToysRun.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ShortcutGuide"
Tag="ShortcutGuide">
<muxc:NavigationViewItem x:Uid="Shell_MeasureTool" Tag="MeasureTool">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsShortcutGuide.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False"
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsScreenRuler.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_VideoConference"
Tag="VideoConference">
<muxc:NavigationViewItem x:Uid="Shell_ShortcutGuide" Tag="ShortcutGuide">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png"
ShowAsMonochrome="False" />
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsShortcutGuide.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_VideoConference" Tag="VideoConference">
<muxc:NavigationViewItem.Icon>
<BitmapIcon
UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<muxc:NavigationView.FooterMenuItems>
<muxc:NavigationViewItem x:Uid="Shell_WhatsNew"
Tag="WhatsNew">
<muxc:NavigationViewItem x:Uid="Shell_WhatsNew" Tag="WhatsNew">
<muxc:NavigationViewItem.Icon>
<FontIcon Glyph="&#xF133;"/>
<FontIcon Glyph="&#xF133;" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.FooterMenuItems>
@@ -178,4 +158,4 @@
</muxc:NavigationView.Content>
</muxc:NavigationView>
</Grid>
</UserControl>
</UserControl>

View File

@@ -136,6 +136,13 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
ModuleName = "VideoConference",
IsNew = true,
});
Modules.Insert((int)PowerToysModules.MeasureTool, new OobePowerToysModule()
{
ModuleName = "MeasureTool",
IsNew = true,
});
Modules.Insert((int)PowerToysModules.WhatsNew, new OobePowerToysModule()
{
ModuleName = "WhatsNew",
@@ -189,6 +196,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
case "ShortcutGuide": NavigationFrame.Navigate(typeof(OobeShortcutGuide)); break;
case "VideoConference": NavigationFrame.Navigate(typeof(OobeVideoConference)); break;
case "MouseUtils": NavigationFrame.Navigate(typeof(OobeMouseUtils)); break;
case "MeasureTool": NavigationFrame.Navigate(typeof(OobeMeasureTool)); break;
}
}
}

View File

@@ -121,6 +121,61 @@
<value>Video Conference Mute</value>
<comment>Navigation view item name for Video Conference</comment>
</data>
<data name="Shell_MeasureTool.Content" xml:space="preserve">
<value>Screen Ruler</value>
<comment>Product name: Navigation view item name for Screen Ruler</comment>
</data>
<data name="MeasureTool.ModuleDescription" xml:space="preserve">
<value>Screen Ruler is a quick and easy way to measure pixels on your screen.
Inspired by Roolr.</value>
<comment>"Screen Ruler" is the name of the utility</comment>
</data>
<data name="MeasureTool.ModuleTitle" xml:space="preserve">
<value>Screen Ruler</value>
<comment>"Screen Ruler" is the name of the utility</comment>
</data>
<data name="MeasureTool_ActivationSettings.Header" xml:space="preserve">
<value>Activation</value>
</data>
<data name="MeasureTool_Settings.Header" xml:space="preserve">
<value>Behavior</value>
<comment>"Screen Ruler" is the name of the utility</comment>
</data>
<data name="MeasureTool_ActivationShortcut.Header" xml:space="preserve">
<value>Activation shortcut</value>
</data>
<data name="MeasureTool_ActivationShortcut.Description" xml:space="preserve">
<value>Customize the shortcut to bring up the command bar</value>
<comment>"Screen Ruler" is the name of the utility</comment>
</data>
<data name="MeasureTool_PixelTolerance.Header" xml:space="preserve">
<value>Pixel tolerance for edge detection</value>
</data>
<data name="MeasureTool_MeasureCrossColor.Header" xml:space="preserve">
<value>Line color</value>
</data>
<data name="MeasureTool_ContinuousCapture.Header" xml:space="preserve">
<value>Capture screen continuously during measuring</value>
</data>
<data name="MeasureTool_ContinuousCapture.Description" xml:space="preserve">
<value>Refresh screen contexts in real-time instead of making a screenshot once. If enabled, tracing is slightly offset from the cursor position to not intersect with previously rendered cross lines.</value>
</data>
<data name="MeasureTool_PerColorChannelEdgeDetection.Header" xml:space="preserve">
<value>Per color channel edge detection</value>
</data>
<data name="MeasureTool_PerColorChannelEdgeDetection.Description" xml:space="preserve">
<value>If enabled, test that all color channels are within a tolerance distance from each other. Otherwise, check that the sum of all color channels differences is smaller than the tolerance.</value>
</data>
<data name="MeasureTool_DrawFeetOnCross.Header" xml:space="preserve">
<value>Draw feet on cross</value>
</data>
<data name="MeasureTool_DrawFeetOnCross.Description" xml:space="preserve">
<value>Adds feet to the end of cross lines. Always off for continuous capture.</value>
</data>
<data name="MeasureTool_EnableMeasureTool.Header" xml:space="preserve">
<value>Enable Screen Ruler</value>
<comment>"Screen Ruler" is the name of the utility</comment>
</data>
<data name="VideoConference_Enable.Header" xml:space="preserve">
<value>Enable Video Conference Mute</value>
</data>
@@ -1364,6 +1419,9 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
</data>
<data name="Oobe_Run.Description" xml:space="preserve">
<value>PowerToys Run is a quick launcher for power users that contains some additional features without sacrificing performance.</value>
</data>
<data name="Oobe_MeasureTool.Description" xml:space="preserve">
<value>Screen Ruler is a quick and easy way to measure pixels on your screen.</value>
</data>
<data name="Oobe_ShortcutGuide.Description" xml:space="preserve">
<value>Shortcut Guide presents the user with a listing of available shortcuts for the current state of the desktop.</value>
@@ -1456,6 +1514,16 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="Oobe_VideoConference_ToggleVid.Text" xml:space="preserve">
<value>to toggle your video</value>
</data>
<data name="Oobe_MeasureTool_Activation.Text" xml:space="preserve">
<value>to bring up the Screen Ruler command bar.</value>
</data>
<data name="Oobe_MeasureTool_HowToLaunch.Text" xml:space="preserve">
<value>The Bounds mode lets you select a specific area to measure. You can also shift-drag an area to persist in on screen. The various Spacing modes allows tracing similar pixels along horizontal and vertical axes with a customizable pixel tolerance threshold (use settings or mouse wheel to adjust it).</value>
</data>
<data name="Oobe_MeasureTool.Title" xml:space="preserve">
<value>Screen Ruler</value>
<comment>Do not localize this string</comment>
</data>
<data name="Oobe_ColorPicker.Title" xml:space="preserve">
<value>Color Picker</value>
<comment>Do not localize this string</comment>
@@ -1698,6 +1766,10 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="LearnMore_Run.Text" xml:space="preserve">
<value>Learn more about PowerToys Run</value>
<comment>PowerToys Run is a product name, do not loc</comment>
</data>
<data name="LearnMore_MeasureTool.Text" xml:space="preserve">
<value>Learn more about Screen Ruler</value>
<comment>Screen Ruler is a product name, do not loc</comment>
</data>
<data name="LearnMore_ShortcutGuide.Text" xml:space="preserve">
<value>Learn more about Shortcut Guide</value>
@@ -2292,4 +2364,4 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="Run_ConflictingKeywordInfo_Link.Content" xml:space="preserve">
<value>Learn more about conflicting activation commands</value>
</data>
</root>
</root>

View File

@@ -0,0 +1,77 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.MeasureToolPage"
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"
mc:Ignorable="d"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
AutomationProperties.LandmarkType="Main">
<controls:SettingsPageControl x:Uid="MeasureTool"
ModuleImageSource="ms-appx:///Assets/Modules/ScreenRuler.png">
<controls:SettingsPageControl.ModuleContent>
<StackPanel Orientation="Vertical">
<controls:Setting x:Uid="MeasureTool_EnableMeasureTool">
<controls:Setting.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsScreenRuler.png" ShowAsMonochrome="False" />
</controls:Setting.Icon>
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" x:Uid="ToggleSwitch" HorizontalAlignment="Right"/>
</controls:Setting.ActionContent>
</controls:Setting>
<controls:SettingsGroup x:Uid="MeasureTool_ActivationSettings" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">
<controls:Setting x:Uid="MeasureTool_ActivationShortcut" Icon="&#xEDA7;">
<controls:Setting.ActionContent>
<controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.ActivationShortcut, Mode=TwoWay}"
MinWidth="{StaticResource SettingActionControlMinWidth}"/>
</controls:Setting.ActionContent>
</controls:Setting>
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="MeasureTool_Settings" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}">
<controls:Setting x:Uid="MeasureTool_ContinuousCapture" Icon="&#xE7FB;">
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind ViewModel.ContinuousCapture, Mode=TwoWay}" x:Uid="MeasureTool_ContinuousCapture_ToggleSwitch" />
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="MeasureTool_PerColorChannelEdgeDetection" Icon="&#xE7FB;">
<controls:Setting.ActionContent>
<ToggleSwitch
IsOn="{x:Bind ViewModel.PerColorChannelEdgeDetection, Mode=TwoWay}"
x:Uid="MeasureTool_PerColorChannelEdgeDetection_ToggleSwitch" />
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="MeasureTool_PixelTolerance">
<controls:Setting.ActionContent>
<Slider Minimum="0"
Maximum="255"
MinWidth="{StaticResource SettingActionControlMinWidth}"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.PixelTolerance}"/>
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="MeasureTool_DrawFeetOnCross">
<controls:Setting.ActionContent>
<ToggleSwitch IsOn="{x:Bind ViewModel.DrawFeetOnCross, Mode=TwoWay}" x:Uid="MeasureTool_DrawFeetOnCross_ToggleSwitch" />
</controls:Setting.ActionContent>
</controls:Setting>
<controls:Setting x:Uid="MeasureTool_MeasureCrossColor">
<controls:Setting.ActionContent>
<controls:ColorPickerButton SelectedColor="{x:Bind Path=ViewModel.CrossColor, Mode=TwoWay}" />
</controls:Setting.ActionContent>
</controls:Setting>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>
<controls:SettingsPageControl.PrimaryLinks>
<controls:PageLink x:Uid="LearnMore_MeasureTool" Link="https://aka.ms/PowerToysOverview_MeasureTool"/>
</controls:SettingsPageControl.PrimaryLinks>
</controls:SettingsPageControl>
</Page>

View File

@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
using Microsoft.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class MeasureToolPage : Page
{
private MeasureToolViewModel ViewModel { get; set; }
private const string ModuleName = "Measure Tool";
public MeasureToolPage()
{
var settingsUtils = new SettingsUtils();
ViewModel = new MeasureToolViewModel(
settingsUtils,
SettingsRepository<GeneralSettings>.GetInstance(settingsUtils),
SettingsRepository<MeasureToolSettings>.GetInstance(settingsUtils),
ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel;
InitializeComponent();
}
}
}

View File

@@ -3,16 +3,18 @@
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:helpers="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:helpers="using:Microsoft.PowerToys.Settings.UI.Helpers"
xmlns:views="using:Microsoft.PowerToys.Settings.UI.Views"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:i="using:Microsoft.Xaml.Interactivity"
HighContrastAdjustment="None"
mc:Ignorable="d">
<!--TODO(stefan): Bring back Should be available in v1.1
BackdropMaterial.ApplyToRootOrPageBackground="True"-->
<!--
TODO(stefan): Bring back Should be available in v1.1
BackdropMaterial.ApplyToRootOrPageBackground="True"
-->
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="Loaded">
@@ -20,96 +22,76 @@
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Grid x:Name="RootGrid"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<muxc:NavigationView x:Name="navigationView"
IsBackButtonVisible="Collapsed"
IsTitleBarAutoPaddingEnabled="False"
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"
IsSettingsVisible="False"
CompactModeThresholdWidth="1007"
ExpandedModeThresholdWidth="1007"
PaneOpened="NavigationView_PaneOpened"
PaneClosed="NavigationView_PaneClosed">
<muxc:NavigationView
x:Name="navigationView"
CompactModeThresholdWidth="1007"
ExpandedModeThresholdWidth="1007"
IsBackButtonVisible="Collapsed"
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
IsSettingsVisible="False"
IsTitleBarAutoPaddingEnabled="False"
PaneClosed="NavigationView_PaneClosed"
PaneOpened="NavigationView_PaneOpened"
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}">
<muxc:NavigationView.Resources>
<SolidColorBrush x:Key="NavigationViewContentBackground"
Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentGridBorderBrush"
Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentGridBorderBrush" Color="Transparent" />
</muxc:NavigationView.Resources>
<muxc:NavigationView.MenuItems>
<muxc:NavigationViewItem x:Uid="Shell_General"
helpers:NavHelper.NavigateTo="views:GeneralPage">
<muxc:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsSettings.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsSettings.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_AlwaysOnTop"
helpers:NavHelper.NavigateTo="views:AlwaysOnTopPage">
<muxc:NavigationViewItem x:Uid="Shell_AlwaysOnTop" helpers:NavHelper.NavigateTo="views:AlwaysOnTopPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAlwaysOnTop.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAlwaysOnTop.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_Awake"
helpers:NavHelper.NavigateTo="views:AwakePage">
<muxc:NavigationViewItem x:Uid="Shell_Awake" helpers:NavHelper.NavigateTo="views:AwakePage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAwake.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsAwake.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ColorPicker"
helpers:NavHelper.NavigateTo="views:ColorPickerPage">
<muxc:NavigationViewItem x:Uid="Shell_ColorPicker" helpers:NavHelper.NavigateTo="views:ColorPickerPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsColorPicker.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsColorPicker.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_FancyZones"
helpers:NavHelper.NavigateTo="views:FancyZonesPage">
<muxc:NavigationViewItem x:Uid="Shell_FancyZones" helpers:NavHelper.NavigateTo="views:FancyZonesPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFancyZones.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFancyZones.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerPreview"
helpers:NavHelper.NavigateTo="views:PowerPreviewPage">
<muxc:NavigationViewItem x:Uid="Shell_PowerPreview" helpers:NavHelper.NavigateTo="views:PowerPreviewPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFileExplorerPreview.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsFileExplorerPreview.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ImageResizer"
helpers:NavHelper.NavigateTo="views:ImageResizerPage">
<muxc:NavigationViewItem x:Uid="Shell_ImageResizer" helpers:NavHelper.NavigateTo="views:ImageResizerPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsImageResizer.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsImageResizer.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_KeyboardManager"
helpers:NavHelper.NavigateTo="views:KeyboardManagerPage">
<muxc:NavigationViewItem x:Uid="Shell_KeyboardManager" helpers:NavHelper.NavigateTo="views:KeyboardManagerPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsKeyboardManager.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsKeyboardManager.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_MouseUtilities"
helpers:NavHelper.NavigateTo="views:MouseUtilsPage">
<muxc:NavigationViewItem x:Uid="Shell_MouseUtilities" helpers:NavHelper.NavigateTo="views:MouseUtilsPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsMouseUtils.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsMouseUtils.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
@@ -121,11 +103,9 @@
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerRename"
helpers:NavHelper.NavigateTo="views:PowerRenamePage">
<muxc:NavigationViewItem x:Uid="Shell_PowerRename" helpers:NavHelper.NavigateTo="views:PowerRenamePage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerRename.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerRename.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
@@ -137,44 +117,44 @@
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_PowerLauncher"
helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
<muxc:NavigationViewItem x:Uid="Shell_PowerLauncher" helpers:NavHelper.NavigateTo="views:PowerLauncherPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToysRun.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsPowerToysRun.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_MeasureTool" helpers:NavHelper.NavigateTo="views:MeasureToolPage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsScreenRuler.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ShortcutGuide" helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
<muxc:NavigationViewItem.Icon>
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsShortcutGuide.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_ShortcutGuide"
helpers:NavHelper.NavigateTo="views:ShortcutGuidePage">
<muxc:NavigationViewItem
x:Uid="Shell_VideoConference"
helpers:NavHelper.NavigateTo="views:VideoConferencePage"
IsEnabled="{x:Bind ViewModel.IsVideoConferenceBuild, Mode=OneWay}">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsShortcutGuide.png"
ShowAsMonochrome="False" />
<BitmapIcon ShowAsMonochrome="False" UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Shell_VideoConference"
helpers:NavHelper.NavigateTo="views:VideoConferencePage"
IsEnabled="{x:Bind ViewModel.IsVideoConferenceBuild, Mode=OneWay}">
<muxc:NavigationViewItem.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png"
ShowAsMonochrome="False" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</muxc:NavigationView.MenuItems>
<muxc:NavigationView.PaneFooter>
<StackPanel Orientation="Vertical">
<muxc:NavigationViewItem x:Uid="OOBE_NavViewItem"
Tapped="OOBEItem_Tapped">
<muxc:NavigationViewItem x:Uid="OOBE_NavViewItem" Tapped="OOBEItem_Tapped">
<muxc:NavigationViewItem.Icon>
<FontIcon Glyph="&#xF133;"/>
<FontIcon Glyph="&#xF133;" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
<muxc:NavigationViewItem x:Uid="Feedback_NavViewItem"
Tapped="FeedbackItem_Tapped">
<muxc:NavigationViewItem x:Uid="Feedback_NavViewItem" Tapped="FeedbackItem_Tapped">
<muxc:NavigationViewItem.Icon>
<FontIcon Glyph="&#xED15;"/>
<FontIcon Glyph="&#xED15;" />
</muxc:NavigationViewItem.Icon>
</muxc:NavigationViewItem>
</StackPanel>