Added extension assemblies for WinForms and WinUI/UWP

pull/279/head
dahall 2022-01-16 17:58:29 -07:00
parent a4c638cf36
commit b29be14b93
4 changed files with 72 additions and 2 deletions

View File

@ -346,7 +346,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VssApi", "UnitTests\PInvoke
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.Windows.Shell.Common", "Windows.Shell.Common\Vanara.Windows.Shell.Common.csproj", "{B83E33E5-2C2E-4D14-8638-729FCA4E447D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.Windows.Extensions", "Windows.Extensions\Vanara.Windows.Extensions.csproj", "{AE4636A6-A15A-4A73-8F7D-D5F878276992}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.Windows.Extensions", "Windows.Extensions\Vanara.Windows.Extensions.csproj", "{AE4636A6-A15A-4A73-8F7D-D5F878276992}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.WinUI.Extensions", "WinUI.Extensions\Vanara.WinUI.Extensions.csproj", "{52F98DFA-8430-4BA7-9937-D0087D17B56E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -2135,6 +2137,24 @@ Global
{AE4636A6-A15A-4A73-8F7D-D5F878276992}.Release|x64.Build.0 = Release|Any CPU
{AE4636A6-A15A-4A73-8F7D-D5F878276992}.Release|x86.ActiveCfg = Release|Any CPU
{AE4636A6-A15A-4A73-8F7D-D5F878276992}.Release|x86.Build.0 = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|x64.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|x64.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|x86.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Debug|x86.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|x64.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|x64.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|x86.ActiveCfg = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.DebugNoTests|x86.Build.0 = Debug|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|Any CPU.Build.0 = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|x64.ActiveCfg = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|x64.Build.0 = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|x86.ActiveCfg = Release|Any CPU
{52F98DFA-8430-4BA7-9937-D0087D17B56E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,29 @@
using Windows.Foundation;
using Windows.UI;
namespace Vanara.PInvoke
{
/// <summary>Conversion extension methods for WinUI/UWP and Vanara types.</summary>
public static class SystemFoundationExtensions
{
/// <summary>Converts <see cref="POINT"/> to <see cref="Point"/>.</summary>
/// <param name="pt">The point to convert.</param>
/// <returns>The converted value.</returns>
public static Point ToPoint(this in POINT pt) => new(pt.X, pt.Y);
/// <summary>Converts <see cref="SIZE"/> to <see cref="Size"/>.</summary>
/// <param name="sz">The size to convert.</param>
/// <returns>The converted value.</returns>
public static Size ToSize(this in SIZE sz) => new(sz.cx, sz.cy);
/// <summary>Converts <see cref="COLORREF"/> to <see cref="Color"/>.</summary>
/// <param name="c">The color to convert.</param>
/// <returns>The converted value.</returns>
public static Color ToColor(this in COLORREF c) => new() { A = c.A, R = c.R, G = c.G, B = c.B };
/// <summary>Converts <see cref="Color"/> to <see cref="COLORREF"/>.</summary>
/// <param name="c">The color to convert.</param>
/// <returns>The converted value.</returns>
public static COLORREF ToCOLORREF(this in Color c) => new(c.R, c.G, c.B) { A = c.A };
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Extension methods and conversions from Vanara P/Invoke types and methods to UWP and WinUI types and methods.</Description>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<TargetFrameworks>net45;net5.0-windows;net6.0-windows;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<UseWPF>true</UseWPF>
<AssemblyName>Vanara.WinUI.Extensions</AssemblyName>
<PackageId>$(AssemblyName)</PackageId>
<PackageTags>pinvoke;vanara;net-extensions;interop;winui;uwp;windows platform</PackageTags>
<PackageReleaseNotes />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\PInvoke\Gdi32\Vanara.PInvoke.Gdi32.csproj" />
<ProjectReference Include="..\PInvoke\User32\Vanara.PInvoke.User32.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.WindowsRuntime" Version ="4.7.0" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Extension methods and conversions from Vanara P/Invoke types and methods to Windows Forms types and methods.</Description>
<AssemblyTitle>$(AssemblyName)</AssemblyTitle>
<TargetFrameworks>net20;net35;net40;net45;net5.0-windows;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net45;net5.0-windows;net6.0-windows;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyName>Vanara.Windows.Extensions</AssemblyName>