* Fix FancyZones Hit test build

* Fix DrawLayoutTest

* Fix Zonable tester

* Adress PR comments
This commit is contained in:
Aaron Junker 2023-03-20 19:18:20 +01:00 коммит произвёл GitHub
Родитель 08fe13a8f6
Коммит 7d6a7744a8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 102 добавлений и 78 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)]

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)

Просмотреть файл

@ -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)
{
return i;
return static_cast<int>(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<BYTE>(opacity * 2.55);
}

Просмотреть файл

@ -107,6 +107,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -121,6 +122,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

Просмотреть файл

@ -80,6 +80,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -110,6 +111,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

Просмотреть файл

@ -11,7 +11,7 @@ std::wstring get_process_path(DWORD pid) noexcept
{
name.resize(MAX_PATH);
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;
}
@ -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<LONG>(style)) << "\n";
std::cout << "exStyle: 0x" << std::hex << exStyle << ": " << window_exstyles(static_cast<LONG>(exStyle)) << " \n";
std::array<char, 256> class_name;
GetClassNameA(window, class_name.data(), static_cast<int>(class_name.size()));
std::cout << "Window class: '" << class_name.data() << "' equals:\n";