diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/App.xaml.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/App.xaml.cs index 7074a87893..72ca27d12d 100644 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/App.xaml.cs +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/App.xaml.cs @@ -1,4 +1,8 @@ -using System; +// 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 System; using System.Collections.Generic; using System.Configuration; using System.Data; diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/AssemblyInfo.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/AssemblyInfo.cs index 8b5504ecfb..f0c9de69e8 100644 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/AssemblyInfo.cs +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/AssemblyInfo.cs @@ -1,10 +1,9 @@ +// 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 System.Windows; [assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] + ResourceDictionaryLocation.None, + ResourceDictionaryLocation.SourceAssembly)] diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/MainWindow.xaml.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/MainWindow.xaml.cs index 14b3d98042..65ed5140ad 100644 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/MainWindow.xaml.cs +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/MainWindow.xaml.cs @@ -1,4 +1,8 @@ -using System; +// 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 System; using System.Collections; using System.Linq; using System.Windows; @@ -18,8 +22,8 @@ namespace FancyZone_HitTest InitializeComponent(); } - static ArrayList _hitResultsList = new ArrayList(); - static ArrayList _visualCalculationList = new ArrayList(); + private static ArrayList _hitResultsList = new ArrayList(); + private static ArrayList _visualCalculationList = new ArrayList(); private void Grid_MouseMove(object sender, MouseEventArgs e) { @@ -31,9 +35,7 @@ namespace FancyZone_HitTest _visualCalculationList.Clear(); // Set up a callback to receive the hit test result enumeration. - VisualTreeHelper.HitTest(hitTestGrid, null, - new HitTestResultCallback(MyHitTestResult), - new PointHitTestParameters(gridMouseLocation)); + VisualTreeHelper.HitTest(hitTestGrid, null, new HitTestResultCallback(MyHitTestResult), new PointHitTestParameters(gridMouseLocation)); // Perform actions on the hit test results list. if (_hitResultsList.Count > 0) @@ -73,18 +75,16 @@ namespace FancyZone_HitTest item.RelativeMouseLocation, // 3 item.MouseDistanceFromCenter, // 4 item.Area, // 5 - item.Area / item.MouseDistanceFromCenter, //6 + item.Area / item.MouseDistanceFromCenter, // 6 item.Name, // 7 - item.DistanceFromEdge, //8 - item.DistanceFromEdgePercentage // 9 - ); + item.DistanceFromEdge, // 8 + item.DistanceFromEdgePercentage); // 9 itemsHit.Text += Environment.NewLine; } - if (reorderedVisualData.Count() > 0) { - var rect = (hitTestGrid.FindName(reorderedVisualData.First().Name) as Rectangle); + var rect = hitTestGrid.FindName(reorderedVisualData.First().Name) as Rectangle; rect.Opacity = .75; rect.Stroke = Brushes.Black; rect.StrokeThickness = 5; @@ -92,7 +92,7 @@ namespace FancyZone_HitTest } else { - itemsHit.Text = ""; + itemsHit.Text = string.Empty; } } diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/Utilities.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/Utilities.cs index 0e3435842c..5c12984b2b 100644 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/Utilities.cs +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/Utilities.cs @@ -1,6 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; +// 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 System.Windows; using System.Windows.Media; diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/VisualData.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/VisualData.cs index 516d7ce9e9..da05363085 100644 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/VisualData.cs +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/VisualData.cs @@ -1,4 +1,8 @@ -using System; +// 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 System; using System.Windows; using System.Windows.Input; using System.Windows.Media; @@ -8,14 +12,21 @@ namespace FancyZone_HitTest { public class VisualData { - public Point RelativeMouseLocation; - public Point CenterMass; - public Point TopLeft; - public double MouseDistanceFromCenter; - public int Area; - public string Name; - public double DistanceFromEdge; - public double DistanceFromEdgePercentage; + public Point RelativeMouseLocation { get; set; } + + public Point CenterMass { get; set; } + + public Point TopLeft { get; set; } + + public double MouseDistanceFromCenter { get; set; } + + public int Area { get; set; } + + public string Name { get; set; } + + public double DistanceFromEdge { get; set; } + + public double DistanceFromEdgePercentage { get; set; } public VisualData(Shape item, MouseEventArgs e, Visual root) { @@ -36,7 +47,7 @@ namespace FancyZone_HitTest var horDist = (RelativeMouseLocation.X < CenterMass.X) ? RelativeMouseLocation.X : width - mouseX; var vertDist = (RelativeMouseLocation.Y < CenterMass.Y) ? RelativeMouseLocation.Y : height - mouseY; - var isHorCalc = (horDist < vertDist); + var isHorCalc = horDist < vertDist; DistanceFromEdge = Math.Floor(isHorCalc ? horDist : vertDist); if (isHorCalc) diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer.cs deleted file mode 100644 index f028d4b603..0000000000 --- a/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; - -namespace FancyZone_HitTest -{ - public class VisualDataComparer : IComparer - { - int IComparer.Compare(VisualData x, VisualData y) - { - // has quirks but workable - if (x.DistanceFromEdge == y.DistanceFromEdge) - { - return y.Area.CompareTo(x.Area); - } - else - { - return x.DistanceFromEdge.CompareTo(y.DistanceFromEdge); - } - - // entire screen won't work - //if (x.MouseDistanceFromCenter == y.MouseDistanceFromCenter) - //{ - // return y.Area.CompareTo(x.Area); - //} - //else - //{ - // return x.MouseDistanceFromCenter.CompareTo(y.MouseDistanceFromCenter); - //} - - //if (x.DistanceFromEdgePercentage == y.DistanceFromEdgePercentage) - //{ - // return y.Area.CompareTo(x.Area); - //} - //else - //{ - // return x.DistanceFromEdgePercentage.CompareTo(y.DistanceFromEdgePercentage); - //} - } - } -} diff --git a/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer`1.cs b/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer`1.cs new file mode 100644 index 0000000000..9a331baa62 --- /dev/null +++ b/tools/FancyZone_HitTest/FancyZone_HitTest/VisualDataComparer`1.cs @@ -0,0 +1,44 @@ +// 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 System.Collections.Generic; + +namespace FancyZone_HitTest +{ + public class VisualDataComparer : IComparer + { + int IComparer.Compare(VisualData x, VisualData y) + { + // has quirks but workable + if (x.DistanceFromEdge == y.DistanceFromEdge) + { + return y.Area.CompareTo(x.Area); + } + else + { + return x.DistanceFromEdge.CompareTo(y.DistanceFromEdge); + } + + // entire screen won't work + /* + if (x.MouseDistanceFromCenter == y.MouseDistanceFromCenter) + { + return y.Area.CompareTo(x.Area); + } + else + { + return x.MouseDistanceFromCenter.CompareTo(y.MouseDistanceFromCenter); + } + + if (x.DistanceFromEdgePercentage == y.DistanceFromEdgePercentage) + { + return y.Area.CompareTo(x.Area); + } + else + { + return x.DistanceFromEdgePercentage.CompareTo(y.DistanceFromEdgePercentage); + }*/ + } + } +} diff --git a/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.cpp b/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.cpp index dec87a7907..0f65e17c22 100644 --- a/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.cpp +++ b/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.cpp @@ -68,7 +68,7 @@ int GetHighlightedZoneIdx(const std::vector& zones, const POINT& cursorPos { if (cursorPosition.x >= zones[i].left && cursorPosition.x < zones[i].right) { - return i; + return static_cast(i); } } return -1; @@ -361,7 +361,7 @@ void DrawZone(HDC hdc, const ColorSetting& colorSetting, const RECT& rect, size_ DrawIndex(hdc, rect, index); } -inline BYTE OpacitySettingToAlpha(int opacity) +constexpr inline BYTE OpacitySettingToAlpha(int opacity) { return static_cast(opacity * 2.55); } diff --git a/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.vcxproj b/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.vcxproj index 5fd9dd3166..51ae22a786 100644 --- a/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.vcxproj +++ b/tools/FancyZones_DrawLayoutTest/FancyZones_DrawLayoutTest.vcxproj @@ -107,6 +107,7 @@ true _DEBUG;_WINDOWS;%(PreprocessorDefinitions) true + NotUsing Windows @@ -121,6 +122,7 @@ true NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true + NotUsing Windows diff --git a/tools/FancyZones_zonable_tester/FancyZones_zonable_tester.vcxproj b/tools/FancyZones_zonable_tester/FancyZones_zonable_tester.vcxproj index 737c70d64f..06cc9201af 100644 --- a/tools/FancyZones_zonable_tester/FancyZones_zonable_tester.vcxproj +++ b/tools/FancyZones_zonable_tester/FancyZones_zonable_tester.vcxproj @@ -80,6 +80,7 @@ true true stdcpplatest + NotUsing Console @@ -110,6 +111,7 @@ true true stdcpplatest + NotUsing Console diff --git a/tools/FancyZones_zonable_tester/main.cpp b/tools/FancyZones_zonable_tester/main.cpp index f39eb214c7..534b84efee 100644 --- a/tools/FancyZones_zonable_tester/main.cpp +++ b/tools/FancyZones_zonable_tester/main.cpp @@ -11,7 +11,7 @@ std::wstring get_process_path(DWORD pid) noexcept { name.resize(MAX_PATH); DWORD name_length = static_cast(name.length()); - if (QueryFullProcessImageNameW(process, 0, (LPWSTR)name.data(), &name_length) == 0) + if (QueryFullProcessImageNameW(process, 0, static_cast(name.data()), &name_length) == 0) { name_length = 0; } @@ -185,8 +185,8 @@ bool test_window(HWND window) auto style = GetWindowLongPtr(window, GWL_STYLE); auto exStyle = GetWindowLongPtr(window, GWL_EXSTYLE); - std::cout << "style: 0x" << std::hex << style << ": " << window_styles(style) << "\n"; - std::cout << "exStyle: 0x" << std::hex << exStyle << ": " << window_exstyles(exStyle) << " \n"; + std::cout << "style: 0x" << std::hex << style << ": " << window_styles(static_cast(style)) << "\n"; + std::cout << "exStyle: 0x" << std::hex << exStyle << ": " << window_exstyles(static_cast(exStyle)) << " \n"; std::array class_name; GetClassNameA(window, class_name.data(), static_cast(class_name.size())); std::cout << "Window class: '" << class_name.data() << "' equals:\n";