mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
Fix FancyZones tools build (#24901)
* Fix FancyZones Hit test build * Fix DrawLayoutTest * Fix Zonable tester * Adress PR comments
This commit is contained in:
parent
08fe13a8f6
commit
7d6a7744a8
@ -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.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
@ -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;
|
using System.Windows;
|
||||||
|
|
||||||
[assembly: ThemeInfo(
|
[assembly: ThemeInfo(
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
ResourceDictionaryLocation.None,
|
||||||
//(used if a resource is not found in the page,
|
ResourceDictionaryLocation.SourceAssembly)]
|
||||||
// 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)
|
|
||||||
)]
|
|
||||||
|
@ -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.Collections;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -18,8 +22,8 @@ namespace FancyZone_HitTest
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList _hitResultsList = new ArrayList();
|
private static ArrayList _hitResultsList = new ArrayList();
|
||||||
static ArrayList _visualCalculationList = new ArrayList();
|
private static ArrayList _visualCalculationList = new ArrayList();
|
||||||
|
|
||||||
private void Grid_MouseMove(object sender, MouseEventArgs e)
|
private void Grid_MouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
@ -31,9 +35,7 @@ namespace FancyZone_HitTest
|
|||||||
_visualCalculationList.Clear();
|
_visualCalculationList.Clear();
|
||||||
|
|
||||||
// Set up a callback to receive the hit test result enumeration.
|
// Set up a callback to receive the hit test result enumeration.
|
||||||
VisualTreeHelper.HitTest(hitTestGrid, null,
|
VisualTreeHelper.HitTest(hitTestGrid, null, new HitTestResultCallback(MyHitTestResult), new PointHitTestParameters(gridMouseLocation));
|
||||||
new HitTestResultCallback(MyHitTestResult),
|
|
||||||
new PointHitTestParameters(gridMouseLocation));
|
|
||||||
|
|
||||||
// Perform actions on the hit test results list.
|
// Perform actions on the hit test results list.
|
||||||
if (_hitResultsList.Count > 0)
|
if (_hitResultsList.Count > 0)
|
||||||
@ -73,18 +75,16 @@ namespace FancyZone_HitTest
|
|||||||
item.RelativeMouseLocation, // 3
|
item.RelativeMouseLocation, // 3
|
||||||
item.MouseDistanceFromCenter, // 4
|
item.MouseDistanceFromCenter, // 4
|
||||||
item.Area, // 5
|
item.Area, // 5
|
||||||
item.Area / item.MouseDistanceFromCenter, //6
|
item.Area / item.MouseDistanceFromCenter, // 6
|
||||||
item.Name, // 7
|
item.Name, // 7
|
||||||
item.DistanceFromEdge, //8
|
item.DistanceFromEdge, // 8
|
||||||
item.DistanceFromEdgePercentage // 9
|
item.DistanceFromEdgePercentage); // 9
|
||||||
);
|
|
||||||
itemsHit.Text += Environment.NewLine;
|
itemsHit.Text += Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (reorderedVisualData.Count() > 0)
|
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.Opacity = .75;
|
||||||
rect.Stroke = Brushes.Black;
|
rect.Stroke = Brushes.Black;
|
||||||
rect.StrokeThickness = 5;
|
rect.StrokeThickness = 5;
|
||||||
@ -92,7 +92,7 @@ namespace FancyZone_HitTest
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itemsHit.Text = "";
|
itemsHit.Text = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
// Copyright (c) Microsoft Corporation
|
||||||
using System.Collections.Generic;
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
using System.Text;
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@ -8,14 +12,21 @@ namespace FancyZone_HitTest
|
|||||||
{
|
{
|
||||||
public class VisualData
|
public class VisualData
|
||||||
{
|
{
|
||||||
public Point RelativeMouseLocation;
|
public Point RelativeMouseLocation { get; set; }
|
||||||
public Point CenterMass;
|
|
||||||
public Point TopLeft;
|
public Point CenterMass { get; set; }
|
||||||
public double MouseDistanceFromCenter;
|
|
||||||
public int Area;
|
public Point TopLeft { get; set; }
|
||||||
public string Name;
|
|
||||||
public double DistanceFromEdge;
|
public double MouseDistanceFromCenter { get; set; }
|
||||||
public double DistanceFromEdgePercentage;
|
|
||||||
|
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)
|
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 horDist = (RelativeMouseLocation.X < CenterMass.X) ? RelativeMouseLocation.X : width - mouseX;
|
||||||
var vertDist = (RelativeMouseLocation.Y < CenterMass.Y) ? RelativeMouseLocation.Y : height - mouseY;
|
var vertDist = (RelativeMouseLocation.Y < CenterMass.Y) ? RelativeMouseLocation.Y : height - mouseY;
|
||||||
|
|
||||||
var isHorCalc = (horDist < vertDist);
|
var isHorCalc = horDist < vertDist;
|
||||||
DistanceFromEdge = Math.Floor(isHorCalc ? horDist : vertDist);
|
DistanceFromEdge = Math.Floor(isHorCalc ? horDist : vertDist);
|
||||||
|
|
||||||
if (isHorCalc)
|
if (isHorCalc)
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace FancyZone_HitTest
|
|
||||||
{
|
|
||||||
public class VisualDataComparer<T> : IComparer<VisualData>
|
|
||||||
{
|
|
||||||
int IComparer<VisualData>.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);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<T> : IComparer<VisualData>
|
||||||
|
{
|
||||||
|
int IComparer<VisualData>.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);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -68,7 +68,7 @@ int GetHighlightedZoneIdx(const std::vector<RECT>& zones, const POINT& cursorPos
|
|||||||
{
|
{
|
||||||
if (cursorPosition.x >= zones[i].left && cursorPosition.x < zones[i].right)
|
if (cursorPosition.x >= zones[i].left && cursorPosition.x < zones[i].right)
|
||||||
{
|
{
|
||||||
return i;
|
return static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -361,7 +361,7 @@ void DrawZone(HDC hdc, const ColorSetting& colorSetting, const RECT& rect, size_
|
|||||||
DrawIndex(hdc, rect, index);
|
DrawIndex(hdc, rect, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BYTE OpacitySettingToAlpha(int opacity)
|
constexpr inline BYTE OpacitySettingToAlpha(int opacity)
|
||||||
{
|
{
|
||||||
return static_cast<BYTE>(opacity * 2.55);
|
return static_cast<BYTE>(opacity * 2.55);
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -121,6 +122,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -110,6 +111,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -11,7 +11,7 @@ std::wstring get_process_path(DWORD pid) noexcept
|
|||||||
{
|
{
|
||||||
name.resize(MAX_PATH);
|
name.resize(MAX_PATH);
|
||||||
DWORD name_length = static_cast<DWORD>(name.length());
|
DWORD name_length = static_cast<DWORD>(name.length());
|
||||||
if (QueryFullProcessImageNameW(process, 0, (LPWSTR)name.data(), &name_length) == 0)
|
if (QueryFullProcessImageNameW(process, 0, static_cast<LPWSTR>(name.data()), &name_length) == 0)
|
||||||
{
|
{
|
||||||
name_length = 0;
|
name_length = 0;
|
||||||
}
|
}
|
||||||
@ -185,8 +185,8 @@ bool test_window(HWND window)
|
|||||||
|
|
||||||
auto style = GetWindowLongPtr(window, GWL_STYLE);
|
auto style = GetWindowLongPtr(window, GWL_STYLE);
|
||||||
auto exStyle = GetWindowLongPtr(window, GWL_EXSTYLE);
|
auto exStyle = GetWindowLongPtr(window, GWL_EXSTYLE);
|
||||||
std::cout << "style: 0x" << std::hex << style << ": " << window_styles(style) << "\n";
|
std::cout << "style: 0x" << std::hex << style << ": " << window_styles(static_cast<LONG>(style)) << "\n";
|
||||||
std::cout << "exStyle: 0x" << std::hex << exStyle << ": " << window_exstyles(exStyle) << " \n";
|
std::cout << "exStyle: 0x" << std::hex << exStyle << ": " << window_exstyles(static_cast<LONG>(exStyle)) << " \n";
|
||||||
std::array<char, 256> class_name;
|
std::array<char, 256> class_name;
|
||||||
GetClassNameA(window, class_name.data(), static_cast<int>(class_name.size()));
|
GetClassNameA(window, class_name.data(), static_cast<int>(class_name.size()));
|
||||||
std::cout << "Window class: '" << class_name.data() << "' equals:\n";
|
std::cout << "Window class: '" << class_name.data() << "' equals:\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user