Move *everything* from setting flyout content and the flyout icons to a UWP control and simplified creation of the wpf host via a NotificationFlyoutApplication where you only need to set the UWP flyout

This commit is contained in:
Daniel Clark
2021-02-10 11:49:16 +00:00
parent 083c7b9365
commit b5b8641527
27 changed files with 315 additions and 166 deletions
@@ -0,0 +1,29 @@
using System;
using System.Drawing;
namespace NotificationFlyout.Shared.UI
{
public static class ImageSourceExtensions
{
public static Icon ConvertToIcon(this ImageSource imageSource, uint dpi)
{
if (imageSource == null) return null;
var uri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute);
var streamResource = Application.GetResourceStream(uri);
if (streamResource == null) throw new ArgumentException(nameof(streamResource));
return new Icon(streamResource.Stream, new System.Drawing.Size(PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CXICON, dpi), PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CYICON, dpi)));
}
private enum SystemMetricFlag : int
{
SM_CXICON = 11,
SM_CYICON = 12,
SM_CXSMICON = 49,
SM_CYSMICON = 50
}
}
}