Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IconExtension for WinUI #493

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions WinUI.Extensions/IconExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
*
* Reference GitHub URL "tajbender.Vanara\Windows.Forms\Extensions\IconExtension.cs"
*
*
*/

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vanara.PInvoke;

namespace Vanara.WinUI.Extensions;

/// <summary>Used to determine the size of the icon returned by various shell methods.</summary>
public enum IconSize
{
/// <summary>
/// The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in
/// Display Properties, the image is 48x48 pixels.
/// </summary>
Large = Shell32.SHIL.SHIL_LARGE,
/// <summary>The image is the Shell standard small icon size of 16x16, but the size can be customized by the user.</summary>
Small = Shell32.SHIL.SHIL_SMALL,
/// <summary>The image is the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user.</summary>
ExtraLarge = Shell32.SHIL.SHIL_EXTRALARGE,
/// <summary>Windows Vista and later. The image is normally 256x256 pixels.</summary>
Jumbo = Shell32.SHIL.SHIL_JUMBO
}

/// <summary>Extension methods for <see cref="Icon"/>.
/// This class replaces "Vanara.Windows.Forms.Extensions.IconExtension" for WinUI.
/// </summary>
public static class IconExtension
{
//public static async Task<SoftwareBitmapSource> GetWinUi3BitmapSourceFromIcon(Icon bitmapIcon)
//{
// ArgumentNullException.ThrowIfNull(bitmapIcon);

// return await GetWinUi3BitmapSourceFromGdiBitmap(bitmapIcon.ToBitmap());
//}
}
4 changes: 3 additions & 1 deletion WinUI.Extensions/Vanara.WinUI.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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;net48;net6.0;net7.0;net8.0-windows;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0-windows;netcoreapp3.1</TargetFrameworks>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<UseWPF>true</UseWPF>
<AssemblyName>Vanara.WinUI.Extensions</AssemblyName>
Expand All @@ -16,6 +16,7 @@ SystemFoundationExtensions

</PackageReleaseNotes>
<PackageReadmeFile>pkgreadme.md</PackageReadmeFile>
<RootNamespace>Vanara.WinUI.Extensions</RootNamespace>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="netstandard" />
Expand All @@ -26,6 +27,7 @@ SystemFoundationExtensions
<ProjectReference Include="..\Windows.Shell.Common\Vanara.Windows.Shell.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
</ItemGroup>
</Project>