diff --git a/samples/NotificationFlyoutSample.Host/NotificationFlyoutSample.Host.csproj b/samples/NotificationFlyoutSample.Host/NotificationFlyoutSample.Host.csproj
index c280b18..27e9885 100644
--- a/samples/NotificationFlyoutSample.Host/NotificationFlyoutSample.Host.csproj
+++ b/samples/NotificationFlyoutSample.Host/NotificationFlyoutSample.Host.csproj
@@ -11,11 +11,6 @@
false
-
-
-
-
-
@@ -26,10 +21,5 @@
-
-
-
-
-
diff --git a/samples/NotificationFlyoutSample.Host/Program.cs b/samples/NotificationFlyoutSample.Host/Program.cs
index 2e523ad..9195f20 100644
--- a/samples/NotificationFlyoutSample.Host/Program.cs
+++ b/samples/NotificationFlyoutSample.Host/Program.cs
@@ -1,4 +1,5 @@
-using System;
+using NotificationFlyout.Wpf.UI.Controls;
+using System;
namespace NotificationFlyoutSample.Host
{
@@ -10,7 +11,10 @@ namespace NotificationFlyoutSample.Host
using (new NotificationFlyoutSample.App())
{
var app = new App();
- new SampleNotificationFlyout();
+ new NotificationFlyoutApplication
+ {
+ Flyout = new Shell()
+ };
app.Run();
}
}
diff --git a/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml b/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml
deleted file mode 100644
index 6d456f7..0000000
--- a/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml.cs b/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml.cs
deleted file mode 100644
index d2795ec..0000000
--- a/samples/NotificationFlyoutSample.Host/SampleNotificationFlyout.xaml.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace NotificationFlyoutSample.Host
-{
- public partial class SampleNotificationFlyout
- {
- public SampleNotificationFlyout()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/samples/NotificationFlyoutSample.Host/Assets/Icon-Light.ico b/samples/NotificationFlyoutSample/Assets/Icon-Light.ico
similarity index 100%
rename from samples/NotificationFlyoutSample.Host/Assets/Icon-Light.ico
rename to samples/NotificationFlyoutSample/Assets/Icon-Light.ico
diff --git a/samples/NotificationFlyoutSample.Host/Assets/Icon.ico b/samples/NotificationFlyoutSample/Assets/Icon.ico
similarity index 100%
rename from samples/NotificationFlyoutSample.Host/Assets/Icon.ico
rename to samples/NotificationFlyoutSample/Assets/Icon.ico
diff --git a/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj b/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
index 3b706aa..43b98c3 100644
--- a/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
+++ b/samples/NotificationFlyoutSample/NotificationFlyoutSample.csproj
@@ -130,6 +130,8 @@
+
+
diff --git a/samples/NotificationFlyoutSample/Shell.xaml b/samples/NotificationFlyoutSample/Shell.xaml
index 4b00e6c..789a697 100644
--- a/samples/NotificationFlyoutSample/Shell.xaml
+++ b/samples/NotificationFlyoutSample/Shell.xaml
@@ -1,21 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls"
+ xmlns:winui="using:Microsoft.UI.Xaml.Controls"
+ LightIconSource="/Assets/Icon.ico">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/NotificationFlyoutSample/Shell.xaml.cs b/samples/NotificationFlyoutSample/Shell.xaml.cs
index 127099a..1a1fbfd 100644
--- a/samples/NotificationFlyoutSample/Shell.xaml.cs
+++ b/samples/NotificationFlyoutSample/Shell.xaml.cs
@@ -9,18 +9,18 @@
private void Theme_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
{
- switch (Theme.SelectedIndex)
- {
- case 0:
- RequestedTheme = Windows.UI.Xaml.ElementTheme.Default;
- break;
- case 1:
- RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
- break;
- case 2:
- RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
- break;
- }
+ //switch (Theme.SelectedIndex)
+ //{
+ // case 0:
+ // RequestedTheme = Windows.UI.Xaml.ElementTheme.Default;
+ // break;
+ // case 1:
+ // RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
+ // break;
+ // case 2:
+ // RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
+ // break;
+ //}
}
}
}
diff --git a/src/NotificationFlyout.Shared.UI/Class1.cs b/src/NotificationFlyout.Shared.UI/Class1.cs
new file mode 100644
index 0000000..5f7c39c
--- /dev/null
+++ b/src/NotificationFlyout.Shared.UI/Class1.cs
@@ -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
+ }
+ }
+
+}
diff --git a/src/NotificationFlyout.Shared.UI/NotificationFlyout.Shared.UI.csproj b/src/NotificationFlyout.Shared.UI/NotificationFlyout.Shared.UI.csproj
new file mode 100644
index 0000000..cb63190
--- /dev/null
+++ b/src/NotificationFlyout.Shared.UI/NotificationFlyout.Shared.UI.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netcoreapp3.1
+
+
+
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout.Uwp.UI.Controls.csproj b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout.Uwp.UI.Controls.csproj
index 312e3d1..0d59f50 100644
--- a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout.Uwp.UI.Controls.csproj
+++ b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout.Uwp.UI.Controls.csproj
@@ -8,11 +8,11 @@
false
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyout.cs b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyout.cs
new file mode 100644
index 0000000..faa4a62
--- /dev/null
+++ b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyout.cs
@@ -0,0 +1,56 @@
+using System;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Media;
+
+namespace NotificationFlyout.Uwp.UI.Controls
+{
+ public class NotificationFlyout : DependencyObject
+ {
+ public static readonly DependencyProperty IconSourceProperty =
+ DependencyProperty.Register(nameof(IconSource),
+ typeof(ImageSource), typeof(NotificationFlyout),
+ new PropertyMetadata(null, OnIconPropertyChanged));
+
+ public static readonly DependencyProperty LightIconSourceProperty =
+ DependencyProperty.Register(nameof(LightIconSource),
+ typeof(ImageSource), typeof(NotificationFlyout),
+ new PropertyMetadata(null, OnIconPropertyChanged));
+
+ public static DependencyProperty ContentProperty =
+ DependencyProperty.Register(nameof(Content),
+ typeof(UIElement), typeof(NotificationFlyout),
+ new PropertyMetadata(null));
+
+ internal event EventHandler ContentChanged;
+ internal event EventHandler IconSourceChanged;
+
+ public UIElement Content
+ {
+ get => (UIElement)GetValue(ContentProperty);
+ set => SetValue(ContentProperty, value);
+ }
+
+ public ImageSource IconSource
+ {
+ get => (ImageSource)GetValue(IconSourceProperty);
+ set => SetValue(IconSourceProperty, value);
+ }
+
+ public ImageSource LightIconSource
+ {
+ get => (ImageSource)GetValue(LightIconSourceProperty);
+ set => SetValue(LightIconSourceProperty, value);
+ }
+
+ private static void OnIconPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
+ {
+ var sender = dependencyObject as NotificationFlyout;
+ sender?.OnIconPropertyChanged();
+ }
+
+ private void OnIconPropertyChanged()
+ {
+ IconSourceChanged?.Invoke(this, EventArgs.Empty);
+ }
+ }
+}
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.cs
similarity index 100%
rename from src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs
rename to src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.cs
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml
similarity index 100%
rename from src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml
rename to src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.cs
similarity index 100%
rename from src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs
rename to src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.cs
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.xaml
similarity index 100%
rename from src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml
rename to src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.xaml
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/Properties/AssemblyInfo.cs b/src/NotificationFlyout.Uwp.UI.Controls/Properties/AssemblyInfo.cs
index 2bb7383..e89e66b 100644
--- a/src/NotificationFlyout.Uwp.UI.Controls/Properties/AssemblyInfo.cs
+++ b/src/NotificationFlyout.Uwp.UI.Controls/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("NotificationFlyout.Uwp.UI.Controls")]
@@ -11,4 +12,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: ComVisible(false)]
\ No newline at end of file
+[assembly: ComVisible(false)]
+[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI.Controls")]
diff --git a/src/NotificationFlyout.Uwp.UI.Controls/Themes/Generic.xaml b/src/NotificationFlyout.Uwp.UI.Controls/Themes/Generic.xaml
index ccdd7da..3c597f0 100644
--- a/src/NotificationFlyout.Uwp.UI.Controls/Themes/Generic.xaml
+++ b/src/NotificationFlyout.Uwp.UI.Controls/Themes/Generic.xaml
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/NotificationFlyout.Uwp.UI/Extensions/ImageSourceExtensions.cs b/src/NotificationFlyout.Uwp.UI/Extensions/ImageSourceExtensions.cs
new file mode 100644
index 0000000..acfba4e
--- /dev/null
+++ b/src/NotificationFlyout.Uwp.UI/Extensions/ImageSourceExtensions.cs
@@ -0,0 +1,29 @@
+using Microsoft.Windows.Sdk;
+using System;
+using System.Drawing;
+using System.IO;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Media.Imaging;
+
+namespace NotificationFlyout.Uwp.UI.Extensions
+{
+ public static class ImageSourceExtensions
+ {
+ public static Icon ConvertToIcon(this ImageSource imageSource, uint dpi)
+ {
+ var bitmapImage = (BitmapImage)imageSource;
+ var uri = $"{AppDomain.CurrentDomain.BaseDirectory}{bitmapImage.UriSource}".Replace("ms-appx:///", "").Replace("/", "\\");
+
+ using var stream = File.OpenRead(uri);
+ return new Icon(stream, new 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
+ }
+ }
+}
diff --git a/src/NotificationFlyout.Uwp.UI/NativeMethods.txt b/src/NotificationFlyout.Uwp.UI/NativeMethods.txt
new file mode 100644
index 0000000..2d0c9bc
--- /dev/null
+++ b/src/NotificationFlyout.Uwp.UI/NativeMethods.txt
@@ -0,0 +1 @@
+GetSystemMetricsForDpi
\ No newline at end of file
diff --git a/src/NotificationFlyout.Uwp.UI/NotificationFlyout.Uwp.UI.csproj b/src/NotificationFlyout.Uwp.UI/NotificationFlyout.Uwp.UI.csproj
new file mode 100644
index 0000000..691244d
--- /dev/null
+++ b/src/NotificationFlyout.Uwp.UI/NotificationFlyout.Uwp.UI.csproj
@@ -0,0 +1,28 @@
+
+
+ uap10.0.19041
+ AnyCPU;x64
+ false
+ false
+ 9.0
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
\ No newline at end of file
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout.Wpf.UI.Controls.csproj b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout.Wpf.UI.Controls.csproj
index ba4fb18..5968141 100644
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout.Wpf.UI.Controls.csproj
+++ b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout.Wpf.UI.Controls.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs
deleted file mode 100644
index 4b653b1..0000000
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System.Windows;
-using System.Windows.Markup;
-using System.Windows.Media;
-
-namespace NotificationFlyout.Wpf.UI.Controls
-{
- [ContentProperty(nameof(Content))]
- public class NotificationFlyout : DependencyObject
- {
- public static readonly DependencyProperty IconSourceProperty =
- DependencyProperty.Register(nameof(IconSource),
- typeof(ImageSource), typeof(NotificationFlyout),
- new PropertyMetadata(null, OnIconPropertyChanged));
-
- public static readonly DependencyProperty LightIconSourceProperty =
- DependencyProperty.Register(nameof(LightIconSource),
- typeof(ImageSource), typeof(NotificationFlyout),
- new PropertyMetadata(null, OnIconPropertyChanged));
-
- public static DependencyProperty ContentProperty =
- DependencyProperty.Register(nameof(Content),
- typeof(Windows.UI.Xaml.UIElement), typeof(NotificationFlyout),
- new PropertyMetadata(null, OnFlyoutPresenterPropertyChanged));
-
- private readonly NotificationFlyoutXamlHost _xamlHost;
-
- public NotificationFlyout()
- {
- _xamlHost = new NotificationFlyoutXamlHost();
- _xamlHost.Show();
- }
-
- public Windows.UI.Xaml.UIElement Content
- {
- get => (Windows.UI.Xaml.UIElement)GetValue(ContentProperty);
- set => SetValue(ContentProperty, value);
- }
-
- public ImageSource IconSource
- {
- get => (ImageSource)GetValue(IconSourceProperty);
- set => SetValue(IconSourceProperty, value);
- }
-
- public ImageSource LightIconSource
- {
- get => (ImageSource)GetValue(LightIconSourceProperty);
- set => SetValue(LightIconSourceProperty, value);
- }
-
- public void HideFlyout()
- {
- _xamlHost.HideFlyout();
- }
-
- public void ShowFlyout()
- {
- _xamlHost.ShowFlyout();
- }
-
- private static void OnFlyoutPresenterPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
- {
- var sender = dependencyObject as NotificationFlyout;
- sender?.OnFlyoutPresenterPropertyChanged();
- }
-
- private static void OnIconPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
- {
- var sender = dependencyObject as NotificationFlyout;
- sender?.OnIconPropertyChanged();
- }
-
- private void OnFlyoutPresenterPropertyChanged()
- {
- _xamlHost.SetFlyoutContent(Content);
- }
-
- private void OnIconPropertyChanged()
- {
- _xamlHost.SetIcons(IconSource, LightIconSource);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs
new file mode 100644
index 0000000..337fe2b
--- /dev/null
+++ b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutApplication.cs
@@ -0,0 +1,49 @@
+using System.Windows;
+using System.Windows.Markup;
+
+namespace NotificationFlyout.Wpf.UI.Controls
+{
+ [ContentProperty(nameof(Flyout))]
+ public class NotificationFlyoutApplication : DependencyObject
+ {
+ public static DependencyProperty FlyoutProperty =
+ DependencyProperty.Register(nameof(Flyout),
+ typeof(Uwp.UI.Controls.NotificationFlyout), typeof(NotificationFlyoutApplication),
+ new PropertyMetadata(null, OnFlyoutPropertyChanged));
+
+ private readonly NotificationFlyoutXamlHost _xamlHost;
+
+ public NotificationFlyoutApplication()
+ {
+ _xamlHost = new NotificationFlyoutXamlHost();
+ _xamlHost.Show();
+ }
+
+ public Uwp.UI.Controls.NotificationFlyout Flyout
+ {
+ get => (Uwp.UI.Controls.NotificationFlyout)GetValue(FlyoutProperty);
+ set => SetValue(FlyoutProperty, value);
+ }
+
+ public void HideFlyout()
+ {
+ _xamlHost.HideFlyout();
+ }
+
+ public void ShowFlyout()
+ {
+ _xamlHost.ShowFlyout();
+ }
+
+ private static void OnFlyoutPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
+ {
+ var sender = dependencyObject as NotificationFlyoutApplication;
+ sender?.OnFlyoutPropertyChanged();
+ }
+
+ private void OnFlyoutPropertyChanged()
+ {
+ _xamlHost.SetFlyout(Flyout);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
index 88f75ac..093779d 100644
--- a/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
+++ b/src/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
@@ -1,6 +1,7 @@
using Microsoft.Toolkit.Wpf.UI.XamlHost;
using NotificationFlyout.Uwp.UI.Controls;
using NotificationFlyout.Wpf.UI.Extensions;
+using NotificationFlyout.Uwp.UI.Extensions;
using NotificationFlyout.Wpf.UI.Helpers;
using System;
using System.Windows;
@@ -14,9 +15,8 @@ namespace NotificationFlyout.Wpf.UI.Controls
private const string ShellTrayHandleName = "Shell_TrayWnd";
private const double WindowSize = 5;
- private ImageSource _defaultIconSource;
+ private Uwp.UI.Controls.NotificationFlyout _flyout;
private bool _isLoaded;
- private ImageSource _lightIconSource;
private NotificationIconHelper _notificationIconHelper;
private SystemPersonalisationHelper _systemPersonalisationHelper;
private TaskbarHelper _taskbarHelper;
@@ -30,13 +30,25 @@ namespace NotificationFlyout.Wpf.UI.Controls
Loaded += OnLoaded;
}
- public void SetFlyoutContent(Windows.UI.Xaml.UIElement content)
+ public void SetFlyout(Uwp.UI.Controls.NotificationFlyout flyout)
{
- var flyoutHost = GetFlyoutHost();
- if (flyoutHost != null)
+ if (_flyout != null)
{
- flyoutHost.Content = content;
+ _flyout.ContentChanged -= OnFlyoutContentChanged;
+ _flyout.IconSourceChanged -= OnFlyoutIconSourceChanged;
}
+
+ _flyout = flyout;
+ _flyout.ContentChanged += OnFlyoutContentChanged;
+ _flyout.IconSourceChanged += OnFlyoutIconSourceChanged;
+
+ UpdateFlyoutContent();
+ UpdateIcons();
+ }
+
+ private void OnFlyoutIconSourceChanged(object sender, EventArgs args)
+ {
+ UpdateIcons();
}
internal void HideFlyout()
@@ -48,14 +60,6 @@ namespace NotificationFlyout.Wpf.UI.Controls
}
}
- internal void SetIcons(ImageSource defaultIconSource, ImageSource lightIconSource)
- {
- _defaultIconSource = defaultIconSource;
- _lightIconSource = lightIconSource;
-
- UpdateIcon();
- }
-
internal void ShowFlyout()
{
var flyoutHost = GetFlyoutHost();
@@ -82,6 +86,11 @@ namespace NotificationFlyout.Wpf.UI.Controls
return _xamlHost.GetUwpInternalObject() as NotificationFlyoutHost;
}
+ private void OnFlyoutContentChanged(object sender, EventArgs args)
+ {
+ UpdateFlyoutContent();
+ }
+
private void OnIconInvoked(object sender, NotificationIconInvokedEventArgs args)
{
ShowFlyout();
@@ -95,7 +104,6 @@ namespace NotificationFlyout.Wpf.UI.Controls
_isLoaded = true;
UpdateWindow();
- UpdateIcon();
this.Hidden();
}
@@ -106,7 +114,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args)
{
- UpdateIcon();
+ UpdateIcons();
}
private void PrepareDefaultWindow()
@@ -149,10 +157,29 @@ namespace NotificationFlyout.Wpf.UI.Controls
Content = _xamlHost;
}
- private void UpdateIcon()
+ private void UpdateFlyoutContent()
+ {
+ if (_flyout == null) return;
+
+ var content = _flyout.Content;
+ if (content == null) return;
+
+ var flyoutHost = GetFlyoutHost();
+ if (flyoutHost != null)
+ {
+ flyoutHost.Content = content;
+ }
+ }
+
+ private void UpdateIcons()
{
if (!_isLoaded) return;
+ if (_flyout == null) return;
+
+ var _defaultIconSource = _flyout.IconSource;
+ var _lightIconSource = _flyout.LightIconSource;
+
var shellTrayHandle = WindowHelper.GetHandle(ShellTrayHandleName);
if (shellTrayHandle == null) return;
diff --git a/src/NotificationFlyout.sln b/src/NotificationFlyout.sln
index e3cdc08..624c71f 100644
--- a/src/NotificationFlyout.sln
+++ b/src/NotificationFlyout.sln
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotificationFlyout.Uwp.UI", "NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj", "{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -88,6 +90,26 @@ Global
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|x64
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.ActiveCfg = Release|Any CPU
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM.Build.0 = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x64.Build.0 = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x86.Build.0 = Debug|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM.ActiveCfg = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM.Build.0 = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM64.Build.0 = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x64.ActiveCfg = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x64.Build.0 = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x86.ActiveCfg = Release|Any CPU
+ {3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE