refactoring for the next stage
This commit is contained in:
@@ -3,4 +3,4 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<Application.Resources />
|
<Application.Resources />
|
||||||
</Application>
|
</Application>
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace NotificationFlyoutSample.Host
|
namespace NotificationFlyoutSample.Host
|
||||||
{
|
{
|
||||||
@@ -14,4 +8,4 @@ namespace NotificationFlyoutSample.Host
|
|||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,4 @@ using System.Windows;
|
|||||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
//(used if a resource is not found in the page,
|
//(used if a resource is not found in the page,
|
||||||
// app, or any theme specific resource dictionaries)
|
// app, or any theme specific resource dictionaries)
|
||||||
)]
|
)]
|
||||||
@@ -12,11 +12,11 @@ namespace NotificationFlyoutSample.Host
|
|||||||
{
|
{
|
||||||
var app = new App();
|
var app = new App();
|
||||||
new NotificationFlyoutApplication
|
new NotificationFlyoutApplication
|
||||||
{
|
{
|
||||||
Flyout = new Shell()
|
Flyout = new Shell()
|
||||||
};
|
};
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI.Controls", "..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj", "{094A2030-C430-490B-AB26-205385A0D4BF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI.Controls", "..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj", "{094A2030-C430-490B-AB26-205385A0D4BF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "NotificationFlyoutSample.Package", "NotificationFlyoutSample.Package\NotificationFlyoutSample.Package.wapproj", "{E2F52D15-A3BB-41CE-901C-AB491C50327A}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI", "..\src\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj", "{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI", "..\src\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj", "{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
@@ -143,36 +141,6 @@ Global
|
|||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x64.Build.0 = Release|x64
|
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x64.Build.0 = Release|x64
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.ActiveCfg = Release|Any CPU
|
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.Build.0 = Release|Any CPU
|
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|Any CPU.ActiveCfg = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|Any CPU.Build.0 = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|Any CPU.Deploy.0 = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM.ActiveCfg = Debug|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM.Build.0 = Debug|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM.Deploy.0 = Debug|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM64.Build.0 = Debug|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x64.Deploy.0 = Debug|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x86.ActiveCfg = Debug|x86
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x86.Build.0 = Debug|x86
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Debug|x86.Deploy.0 = Debug|x86
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM.ActiveCfg = Release|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM.Build.0 = Release|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM.Deploy.0 = Release|ARM
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM64.ActiveCfg = Release|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM64.Build.0 = Release|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|ARM64.Deploy.0 = Release|ARM64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x64.Build.0 = Release|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x64.Deploy.0 = Release|x64
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x86.ActiveCfg = Release|x86
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x86.Build.0 = Release|x86
|
|
||||||
{E2F52D15-A3BB-41CE-901C-AB491C50327A}.Release|x86.Deploy.0 = Release|x86
|
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
<xamlhost:XamlApplication.Resources>
|
<xamlhost:XamlApplication.Resources>
|
||||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" Version="Latest" />
|
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" Version="Latest" />
|
||||||
</xamlhost:XamlApplication.Resources>
|
</xamlhost:XamlApplication.Resources>
|
||||||
</xamlhost:XamlApplication>
|
</xamlhost:XamlApplication>
|
||||||
@@ -9,4 +9,4 @@ namespace NotificationFlyoutSample
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("NotificationFlyoutSample")]
|
[assembly: AssemblyTitle("NotificationFlyoutSample")]
|
||||||
@@ -17,11 +16,11 @@ using System.Runtime.InteropServices;
|
|||||||
// Version information for an assembly consists of the following four values:
|
// Version information for an assembly consists of the following four values:
|
||||||
//
|
//
|
||||||
// Major Version
|
// Major Version
|
||||||
// Minor Version
|
// Minor Version
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||||
|
|
||||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
<Type Name="App1.MyClass" Dynamic="Required All" />
|
||||||
|
|
||||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||||
@@ -22,10 +22,7 @@
|
|||||||
the application package. The asterisks are not wildcards.
|
the application package. The asterisks are not wildcards.
|
||||||
-->
|
-->
|
||||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Add your application specific runtime directives here. -->
|
<!-- Add your application specific runtime directives here. -->
|
||||||
|
|
||||||
|
|
||||||
</Application>
|
</Application>
|
||||||
</Directives>
|
</Directives>
|
||||||
@@ -6,9 +6,11 @@
|
|||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
IconSource="/Assets/Icon.ico"
|
IconSource="/Assets/Icon.ico"
|
||||||
LightIconSource="/Assets/Icon-Light.ico">
|
LightIconSource="/Assets/Icon-Light.ico">
|
||||||
<controls:NotificationFlyout.ContextMenuItems>
|
<controls:NotificationFlyout.ContextMenu>
|
||||||
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
<controls:NotificationFlyoutContextMenu>
|
||||||
</controls:NotificationFlyout.ContextMenuItems>
|
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
||||||
|
</controls:NotificationFlyoutContextMenu>
|
||||||
|
</controls:NotificationFlyout.ContextMenu>
|
||||||
<StackPanel Margin="24">
|
<StackPanel Margin="24">
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="Theme"
|
x:Name="Theme"
|
||||||
@@ -44,7 +46,10 @@
|
|||||||
IsIndeterminate="True"
|
IsIndeterminate="True"
|
||||||
ShowError="False"
|
ShowError="False"
|
||||||
ShowPaused="False" />
|
ShowPaused="False" />
|
||||||
<Button Margin="0,0,0,8" Content="Open window" Click="Button_Click" />
|
<Button
|
||||||
|
Margin="0,0,0,8"
|
||||||
|
Click="Button_Click"
|
||||||
|
Content="Open window" />
|
||||||
<Slider Margin="0,0,0,8" />
|
<Slider Margin="0,0,0,8" />
|
||||||
<TextBox Margin="0,0,0,8" />
|
<TextBox Margin="0,0,0,8" />
|
||||||
<CalendarView Margin="0,0,0,8" />
|
<CalendarView Margin="0,0,0,8" />
|
||||||
@@ -83,4 +88,4 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<muxc:RatingControl AutomationProperties.Name="RatingControl with placeholder" PlaceholderValue="0" />
|
<muxc:RatingControl AutomationProperties.Name="RatingControl with placeholder" PlaceholderValue="0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</controls:NotificationFlyout>
|
</controls:NotificationFlyout>
|
||||||
@@ -14,9 +14,11 @@
|
|||||||
case 0:
|
case 0:
|
||||||
RequestedTheme = Windows.UI.Xaml.ElementTheme.Default;
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Default;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
|
RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
|
||||||
break;
|
break;
|
||||||
@@ -35,4 +37,4 @@
|
|||||||
app.OpenAsWindow<WindowContent>();
|
app.OpenAsWindow<WindowContent>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,4 +24,4 @@
|
|||||||
</muxc:NavigationView.MenuItems>
|
</muxc:NavigationView.MenuItems>
|
||||||
<Frame x:Name="contentFrame" />
|
<Frame x:Name="contentFrame" />
|
||||||
</muxc:NavigationView>
|
</muxc:NavigationView>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,17 +1,4 @@
|
|||||||
using System;
|
using Windows.UI.Xaml.Controls;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
|
||||||
using Windows.Foundation;
|
|
||||||
using Windows.Foundation.Collections;
|
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
using Windows.UI.Xaml.Data;
|
|
||||||
using Windows.UI.Xaml.Input;
|
|
||||||
using Windows.UI.Xaml.Media;
|
|
||||||
using Windows.UI.Xaml.Navigation;
|
|
||||||
|
|
||||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||||
|
|
||||||
@@ -24,4 +11,4 @@ namespace NotificationFlyoutSample
|
|||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<Version>1.0.0</Version> </PropertyGroup>
|
<Version>1.0.0</Version> </PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="NotificationFlyout\ContextMenuFlyoutHost.xaml">
|
<Page Include="NotificationFlyout\NotificationFlyoutContextMenuFlyoutHost.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Controls
|
|
||||||
{
|
|
||||||
internal class ContextMenuFlyoutHost : Control
|
|
||||||
{
|
|
||||||
private MenuFlyout _flyout;
|
|
||||||
private Grid _root;
|
|
||||||
|
|
||||||
public ContextMenuFlyoutHost()
|
|
||||||
{
|
|
||||||
DefaultStyleKey = typeof(ContextMenuFlyoutHost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HideFlyout()
|
|
||||||
{
|
|
||||||
if (_flyout == null) return;
|
|
||||||
_flyout.Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowFlyout()
|
|
||||||
{
|
|
||||||
if (_root == null) return;
|
|
||||||
if (_flyout == null) return;
|
|
||||||
|
|
||||||
_flyout.ShowAt(_root, new FlyoutShowOptions { Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft, ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnApplyTemplate()
|
|
||||||
{
|
|
||||||
_root = GetTemplateChild("Root") as Grid;
|
|
||||||
_flyout = GetTemplateChild("Flyout") as MenuFlyout;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void SetMenuItems(IList<MenuFlyoutItemBase> addedItems, IList<MenuFlyoutItemBase> removedItems = null)
|
|
||||||
{
|
|
||||||
if (_flyout == null) return;
|
|
||||||
|
|
||||||
if (removedItems != null)
|
|
||||||
{
|
|
||||||
foreach (var item in removedItems)
|
|
||||||
{
|
|
||||||
_flyout.Items.Remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in addedItems)
|
|
||||||
{
|
|
||||||
_flyout.Items.Add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Linq;
|
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Markup;
|
using Windows.UI.Xaml.Markup;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
|
|
||||||
@@ -13,6 +8,11 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
[ContentProperty(Name = "Content")]
|
[ContentProperty(Name = "Content")]
|
||||||
public class NotificationFlyout : DependencyObject
|
public class NotificationFlyout : DependencyObject
|
||||||
{
|
{
|
||||||
|
public static readonly DependencyProperty FlyoutPresenterStyleProperty =
|
||||||
|
DependencyProperty.Register(nameof(FlyoutPresenterStyle),
|
||||||
|
typeof(Style), typeof(NotificationFlyout),
|
||||||
|
new PropertyMetadata(null));
|
||||||
|
|
||||||
public static readonly DependencyProperty IconSourceProperty =
|
public static readonly DependencyProperty IconSourceProperty =
|
||||||
DependencyProperty.Register(nameof(IconSource),
|
DependencyProperty.Register(nameof(IconSource),
|
||||||
typeof(ImageSource), typeof(NotificationFlyout),
|
typeof(ImageSource), typeof(NotificationFlyout),
|
||||||
@@ -21,48 +21,45 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
public static readonly DependencyProperty LightIconSourceProperty =
|
public static readonly DependencyProperty LightIconSourceProperty =
|
||||||
DependencyProperty.Register(nameof(LightIconSource),
|
DependencyProperty.Register(nameof(LightIconSource),
|
||||||
typeof(ImageSource), typeof(NotificationFlyout),
|
typeof(ImageSource), typeof(NotificationFlyout),
|
||||||
new PropertyMetadata(null, OnIconPropertyChanged));
|
new PropertyMetadata(null));
|
||||||
|
|
||||||
public static readonly DependencyProperty RequestedThemeProperty =
|
public static readonly DependencyProperty RequestedThemeProperty =
|
||||||
DependencyProperty.Register(nameof(RequestedTheme),
|
DependencyProperty.Register(nameof(RequestedTheme),
|
||||||
typeof(ElementTheme), typeof(NotificationFlyout),
|
typeof(ElementTheme), typeof(NotificationFlyout),
|
||||||
new PropertyMetadata(ElementTheme.Default, OnRequestedThemePropertyChanged));
|
new PropertyMetadata(ElementTheme.Default));
|
||||||
|
|
||||||
public static INotificationFlyoutApplication _applicationInstance;
|
|
||||||
|
|
||||||
public static DependencyProperty ContentProperty =
|
public static DependencyProperty ContentProperty =
|
||||||
DependencyProperty.Register(nameof(Content),
|
DependencyProperty.Register(nameof(Content),
|
||||||
typeof(UIElement), typeof(NotificationFlyout),
|
typeof(UIElement), typeof(NotificationFlyout),
|
||||||
new PropertyMetadata(null, OnContentPropertyChanged));
|
|
||||||
|
|
||||||
public static DependencyProperty ContextMenuItemsProperty =
|
|
||||||
DependencyProperty.Register(nameof(ContextMenuItems),
|
|
||||||
typeof(IList<MenuFlyoutItemBase>), typeof(NotificationFlyout),
|
|
||||||
new PropertyMetadata(null));
|
new PropertyMetadata(null));
|
||||||
public NotificationFlyout()
|
|
||||||
{
|
|
||||||
ContextMenuItems = new ObservableCollection<MenuFlyoutItemBase>();
|
|
||||||
(ContextMenuItems as INotifyCollectionChanged).CollectionChanged += OnContextMenuItemsChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal event EventHandler ContentChanged;
|
public static DependencyProperty ContextMenuProperty =
|
||||||
|
DependencyProperty.Register(nameof(ContextMenu),
|
||||||
|
typeof(NotificationFlyoutContextMenu), typeof(NotificationFlyout),
|
||||||
|
new PropertyMetadata(null, OnContextMenuPropertyChanged));
|
||||||
|
|
||||||
|
private static INotificationFlyoutApplication _applicationInstance;
|
||||||
|
|
||||||
|
internal event EventHandler ContextMenuChanged;
|
||||||
|
|
||||||
internal event EventHandler IconSourceChanged;
|
internal event EventHandler IconSourceChanged;
|
||||||
|
|
||||||
internal event EventHandler<NotificationFlyoutMenuItemsChangedEventArgs> MenuItemsChanged;
|
|
||||||
|
|
||||||
internal event EventHandler RequestedThemeChanged;
|
|
||||||
|
|
||||||
public UIElement Content
|
public UIElement Content
|
||||||
{
|
{
|
||||||
get => (UIElement)GetValue(ContentProperty);
|
get => (UIElement)GetValue(ContentProperty);
|
||||||
set => SetValue(ContentProperty, value);
|
set => SetValue(ContentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<MenuFlyoutItemBase> ContextMenuItems
|
public NotificationFlyoutContextMenu ContextMenu
|
||||||
{
|
{
|
||||||
get => (IList<MenuFlyoutItemBase>)GetValue(ContextMenuItemsProperty);
|
get => (NotificationFlyoutContextMenu)GetValue(ContextMenuProperty);
|
||||||
set => SetValue(ContextMenuItemsProperty, value);
|
set => SetValue(ContextMenuProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Style FlyoutPresenterStyle
|
||||||
|
{
|
||||||
|
get => (Style)GetValue(FlyoutPresenterStyleProperty);
|
||||||
|
set => SetValue(FlyoutPresenterStyleProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSource IconSource
|
public ImageSource IconSource
|
||||||
@@ -83,20 +80,14 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
set => SetValue(RequestedThemeProperty, value);
|
set => SetValue(RequestedThemeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static INotificationFlyoutApplication GetApplication()
|
public static INotificationFlyoutApplication GetApplication() => _applicationInstance;
|
||||||
{
|
|
||||||
return _applicationInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void SetApplication(INotificationFlyoutApplication application)
|
internal static void SetApplication(INotificationFlyoutApplication application) => _applicationInstance = application;
|
||||||
{
|
|
||||||
_applicationInstance = application;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnContentPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
private static void OnContextMenuPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
var sender = dependencyObject as NotificationFlyout;
|
var sender = dependencyObject as NotificationFlyout;
|
||||||
sender?.OnContentPropertyChanged();
|
sender?.OnContextMenuPropertyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnIconPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
private static void OnIconPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
||||||
@@ -105,46 +96,14 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
sender?.OnIconPropertyChanged();
|
sender?.OnIconPropertyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnRequestedThemePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
private void OnContextMenuPropertyChanged()
|
||||||
{
|
{
|
||||||
var sender = dependencyObject as NotificationFlyout;
|
ContextMenuChanged?.Invoke(this, EventArgs.Empty);
|
||||||
sender?.OnRequestedThemePropertyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnContentPropertyChanged()
|
|
||||||
{
|
|
||||||
ContentChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnContextMenuItemsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
|
||||||
{
|
|
||||||
var addedItems = args.NewItems.Cast<MenuFlyoutItemBase>().ToList();
|
|
||||||
var removedItems = args.NewItems.Cast<MenuFlyoutItemBase>().ToList();
|
|
||||||
|
|
||||||
MenuItemsChanged?.Invoke(this, new NotificationFlyoutMenuItemsChangedEventArgs(addedItems, removedItems));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnIconPropertyChanged()
|
private void OnIconPropertyChanged()
|
||||||
{
|
{
|
||||||
IconSourceChanged?.Invoke(this, EventArgs.Empty);
|
IconSourceChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRequestedThemePropertyChanged()
|
|
||||||
{
|
|
||||||
RequestedThemeChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
internal class NotificationFlyoutMenuItemsChangedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public NotificationFlyoutMenuItemsChangedEventArgs(IList<MenuFlyoutItemBase> addedItems, IList<MenuFlyoutItemBase> removedItems)
|
|
||||||
{
|
|
||||||
AddedItems = addedItems;
|
|
||||||
RemovedItems = removedItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IList<MenuFlyoutItemBase> AddedItems { get; private set; }
|
|
||||||
|
|
||||||
public IList<MenuFlyoutItemBase> RemovedItems { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Markup;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Uwp.UI.Controls
|
||||||
|
{
|
||||||
|
[ContentProperty(Name = "MenuItems")]
|
||||||
|
public class NotificationFlyoutContextMenu : DependencyObject
|
||||||
|
{
|
||||||
|
public static DependencyProperty MenuItemsProperty =
|
||||||
|
DependencyProperty.Register(nameof(MenuItems),
|
||||||
|
typeof(IList<MenuFlyoutItemBase>), typeof(NotificationFlyout),
|
||||||
|
new PropertyMetadata(null));
|
||||||
|
|
||||||
|
public NotificationFlyoutContextMenu() => MenuItems = new ObservableCollection<MenuFlyoutItemBase>();
|
||||||
|
|
||||||
|
public IList<MenuFlyoutItemBase> MenuItems
|
||||||
|
{
|
||||||
|
get => (IList<MenuFlyoutItemBase>)GetValue(MenuItemsProperty);
|
||||||
|
set => SetValue(MenuItemsProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Uwp.UI.Controls
|
||||||
|
{
|
||||||
|
internal class NotificationFlyoutContextMenuFlyoutHost : Control
|
||||||
|
{
|
||||||
|
private NotificationFlyout _flyout;
|
||||||
|
private MenuFlyout _menuFlyout;
|
||||||
|
private Grid _root;
|
||||||
|
|
||||||
|
public NotificationFlyoutContextMenuFlyoutHost() => DefaultStyleKey = typeof(NotificationFlyoutContextMenuFlyoutHost);
|
||||||
|
|
||||||
|
public void HideFlyout()
|
||||||
|
{
|
||||||
|
if (_menuFlyout == null) return;
|
||||||
|
_menuFlyout.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowFlyout()
|
||||||
|
{
|
||||||
|
if (_root == null) return;
|
||||||
|
if (_menuFlyout == null) return;
|
||||||
|
|
||||||
|
_menuFlyout.ShowAt(_root, new FlyoutShowOptions
|
||||||
|
{
|
||||||
|
Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft,
|
||||||
|
ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetOwningFlyout(NotificationFlyout flyout)
|
||||||
|
{
|
||||||
|
if (_flyout != null)
|
||||||
|
{
|
||||||
|
(_flyout.ContextMenu.MenuItems as INotifyCollectionChanged).CollectionChanged -= OnContextMenuItemsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
_flyout = flyout;
|
||||||
|
|
||||||
|
var contextMenu = _flyout.ContextMenu;
|
||||||
|
if (contextMenu == null) return;
|
||||||
|
|
||||||
|
(contextMenu.MenuItems as INotifyCollectionChanged).CollectionChanged += OnContextMenuItemsChanged;
|
||||||
|
|
||||||
|
PrepareMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnApplyTemplate()
|
||||||
|
{
|
||||||
|
_root = GetTemplateChild("Root") as Grid;
|
||||||
|
_menuFlyout = GetTemplateChild("Flyout") as MenuFlyout;
|
||||||
|
|
||||||
|
PrepareMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnContextMenuItemsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (_flyout == null) return;
|
||||||
|
|
||||||
|
var contextMenu = _flyout.ContextMenu;
|
||||||
|
if (contextMenu == null) return;
|
||||||
|
|
||||||
|
var addedItems = args.NewItems.Cast<MenuFlyoutItemBase>().ToList();
|
||||||
|
var removedItems = args.NewItems.Cast<MenuFlyoutItemBase>().ToList();
|
||||||
|
|
||||||
|
if (removedItems != null)
|
||||||
|
{
|
||||||
|
foreach (var item in removedItems)
|
||||||
|
{
|
||||||
|
_menuFlyout.Items.Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in addedItems)
|
||||||
|
{
|
||||||
|
_menuFlyout.Items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrepareMenuItems()
|
||||||
|
{
|
||||||
|
if (_menuFlyout == null) return;
|
||||||
|
if (_flyout == null) return;
|
||||||
|
|
||||||
|
var contextMenu = _flyout.ContextMenu;
|
||||||
|
if (contextMenu == null) return;
|
||||||
|
|
||||||
|
_menuFlyout.Items.Clear();
|
||||||
|
|
||||||
|
var items = contextMenu.MenuItems;
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
_menuFlyout.Items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -2,10 +2,10 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls">
|
xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls">
|
||||||
<Style TargetType="controls:ContextMenuFlyoutHost">
|
<Style TargetType="controls:NotificationFlyoutContextMenuFlyoutHost">
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="controls:ContextMenuFlyoutHost">
|
<ControlTemplate TargetType="controls:NotificationFlyoutContextMenuFlyoutHost">
|
||||||
<Grid x:Name="Root">
|
<Grid x:Name="Root">
|
||||||
<FlyoutBase.AttachedFlyout>
|
<FlyoutBase.AttachedFlyout>
|
||||||
<MenuFlyout x:Name="Flyout" />
|
<MenuFlyout x:Name="Flyout" />
|
||||||
+21
-3
@@ -2,6 +2,7 @@
|
|||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Controls
|
namespace NotificationFlyout.Uwp.UI.Controls
|
||||||
@@ -17,9 +18,26 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
private string _placement;
|
private string _placement;
|
||||||
private Grid _root;
|
private Grid _root;
|
||||||
|
|
||||||
public NotificationFlyoutHost()
|
public NotificationFlyoutHost() => DefaultStyleKey = typeof(NotificationFlyoutHost);
|
||||||
|
|
||||||
|
internal void SetOwningFlyout(NotificationFlyout flyout)
|
||||||
{
|
{
|
||||||
DefaultStyleKey = typeof(NotificationFlyoutHost);
|
BindingOperations.SetBinding(this, ContentProperty,
|
||||||
|
new Binding
|
||||||
|
{
|
||||||
|
Source = flyout,
|
||||||
|
Path =
|
||||||
|
new PropertyPath(nameof(Content)),
|
||||||
|
Mode = BindingMode.TwoWay
|
||||||
|
});
|
||||||
|
|
||||||
|
BindingOperations.SetBinding(this, RequestedThemeProperty,
|
||||||
|
new Binding
|
||||||
|
{
|
||||||
|
Source = flyout,
|
||||||
|
Path = new PropertyPath(nameof(RequestedTheme)),
|
||||||
|
Mode = BindingMode.TwoWay
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public UIElement Content
|
public UIElement Content
|
||||||
@@ -54,7 +72,7 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
{
|
{
|
||||||
Placement = placementMode,
|
Placement = placementMode,
|
||||||
ShowMode = FlyoutShowMode.Standard,
|
ShowMode = FlyoutShowMode.Standard,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnApplyTemplate()
|
protected override void OnApplyTemplate()
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Uwp.UI.Controls
|
||||||
|
{
|
||||||
|
internal class NotificationFlyoutMenuItemsChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public NotificationFlyoutMenuItemsChangedEventArgs(IList<MenuFlyoutItemBase> addedItems, IList<MenuFlyoutItemBase> removedItems)
|
||||||
|
{
|
||||||
|
AddedItems = addedItems;
|
||||||
|
RemovedItems = removedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<MenuFlyoutItemBase> AddedItems { get; private set; }
|
||||||
|
|
||||||
|
public IList<MenuFlyoutItemBase> RemovedItems { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-4
@@ -4,9 +4,6 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
{
|
{
|
||||||
public class NotificationFlyoutPresenter : ContentControl
|
public class NotificationFlyoutPresenter : ContentControl
|
||||||
{
|
{
|
||||||
public NotificationFlyoutPresenter()
|
public NotificationFlyoutPresenter() => DefaultStyleKey = typeof(NotificationFlyoutPresenter);
|
||||||
{
|
|
||||||
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -76,4 +76,4 @@
|
|||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -13,4 +13,4 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI.Controls")]
|
[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI.Controls")]
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml" />
|
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml" />
|
||||||
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.xaml" />
|
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutPresenter.xaml" />
|
||||||
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/ContextMenuFlyoutHost.xaml" />
|
<ResourceDictionary Source="ms-appx:///NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutContextMenuFlyoutHost.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -12,4 +12,4 @@ namespace NotificationFlyout.Uwp.UI.Extensions
|
|||||||
return result != 15700;
|
return result != 15700;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Extensions
|
namespace NotificationFlyout.Uwp.UI.Extensions
|
||||||
{
|
{
|
||||||
@@ -27,8 +25,7 @@ namespace NotificationFlyout.Uwp.UI.Extensions
|
|||||||
var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(bitmapImage.UriSource);
|
var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(bitmapImage.UriSource);
|
||||||
using var stream = await storageFile.OpenStreamForReadAsync();
|
using var stream = await storageFile.OpenStreamForReadAsync();
|
||||||
return new Icon(stream, new Size(PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CXICON, dpi), PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CYICON, dpi)));
|
return new Icon(stream, new Size(PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CXICON, dpi), PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CYICON, dpi)));
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum SystemMetricFlag : int
|
private enum SystemMetricFlag : int
|
||||||
@@ -39,4 +36,4 @@ namespace NotificationFlyout.Uwp.UI.Extensions
|
|||||||
SM_CYSMICON = 50
|
SM_CYSMICON = 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,4 +8,4 @@ namespace NotificationFlyout.Uwp.UI
|
|||||||
|
|
||||||
void OpenAsWindow<TUIElement>() where TUIElement : UIElement;
|
void OpenAsWindow<TUIElement>() where TUIElement : UIElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+13
-34
@@ -1,5 +1,4 @@
|
|||||||
using NotificationFlyout.Uwp.UI;
|
using NotificationFlyout.Uwp.UI;
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
|
||||||
@@ -13,23 +12,18 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
typeof(Uwp.UI.Controls.NotificationFlyout), typeof(NotificationFlyoutApplication),
|
typeof(Uwp.UI.Controls.NotificationFlyout), typeof(NotificationFlyoutApplication),
|
||||||
new PropertyMetadata(null, OnFlyoutPropertyChanged));
|
new PropertyMetadata(null, OnFlyoutPropertyChanged));
|
||||||
|
|
||||||
private static NotificationFlyoutApplication _instance;
|
private static NotificationFlyoutApplication _application;
|
||||||
private readonly ContextMenuXamlHost _contextMenuXamlHost;
|
private NotificationFlyoutXamlHost _notificationFlyoutXamlHost;
|
||||||
private readonly NotificationFlyoutXamlHost _notificationFlyoutXamlHost;
|
|
||||||
|
|
||||||
public NotificationFlyoutApplication()
|
public NotificationFlyoutApplication()
|
||||||
{
|
{
|
||||||
_instance = this;
|
_application = this;
|
||||||
|
Uwp.UI.Controls.NotificationFlyout.SetApplication(this);
|
||||||
|
|
||||||
_notificationFlyoutXamlHost = new NotificationFlyoutXamlHost();
|
PrepareFlyoutHost();
|
||||||
_notificationFlyoutXamlHost.ContextMenuRequested += OnContextMenuRequested;
|
|
||||||
_notificationFlyoutXamlHost.Show();
|
|
||||||
|
|
||||||
_contextMenuXamlHost = new ContextMenuXamlHost();
|
|
||||||
_contextMenuXamlHost.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static INotificationFlyoutApplication Current => _instance;
|
public static INotificationFlyoutApplication Current => _application;
|
||||||
|
|
||||||
public Uwp.UI.Controls.NotificationFlyout Flyout
|
public Uwp.UI.Controls.NotificationFlyout Flyout
|
||||||
{
|
{
|
||||||
@@ -37,16 +31,9 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
set => SetValue(FlyoutProperty, value);
|
set => SetValue(FlyoutProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Exit()
|
public void Exit() => _notificationFlyoutXamlHost.Close();
|
||||||
{
|
|
||||||
_contextMenuXamlHost.Close();
|
|
||||||
_notificationFlyoutXamlHost.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HideFlyout()
|
public void HideFlyout() => _notificationFlyoutXamlHost.HideFlyout();
|
||||||
{
|
|
||||||
_notificationFlyoutXamlHost.HideFlyout();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenAsWindow<TUIElement>() where TUIElement : Windows.UI.Xaml.UIElement
|
public void OpenAsWindow<TUIElement>() where TUIElement : Windows.UI.Xaml.UIElement
|
||||||
{
|
{
|
||||||
@@ -54,10 +41,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowFlyout()
|
public void ShowFlyout() => _notificationFlyoutXamlHost.ShowFlyout();
|
||||||
{
|
|
||||||
_notificationFlyoutXamlHost.ShowFlyout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnFlyoutPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
private static void OnFlyoutPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||||
{
|
{
|
||||||
@@ -65,17 +49,12 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
sender?.OnFlyoutPropertyChanged();
|
sender?.OnFlyoutPropertyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnContextMenuRequested(object sender, EventArgs args)
|
private void OnFlyoutPropertyChanged() => _notificationFlyoutXamlHost.SetOwningFlyout(Flyout);
|
||||||
{
|
|
||||||
_contextMenuXamlHost?.ShowContextMenuFlyout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnFlyoutPropertyChanged()
|
private void PrepareFlyoutHost()
|
||||||
{
|
{
|
||||||
_notificationFlyoutXamlHost?.SetFlyout(Flyout);
|
_notificationFlyoutXamlHost = new NotificationFlyoutXamlHost();
|
||||||
_contextMenuXamlHost?.SetFlyout(Flyout);
|
_notificationFlyoutXamlHost.Show();
|
||||||
|
|
||||||
Uwp.UI.Controls.NotificationFlyout.SetApplication(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
using NotificationFlyout.Uwp.UI.Controls;
|
||||||
|
using NotificationFlyout.Wpf.UI.Extensions;
|
||||||
|
using NotificationFlyout.Wpf.UI.Helpers;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Wpf.UI.Controls
|
||||||
|
{
|
||||||
|
internal class NotificationFlyoutContextMenuXamlHost : TransparentXamlHost<NotificationFlyoutContextMenuFlyoutHost>
|
||||||
|
{
|
||||||
|
public NotificationFlyoutContextMenuXamlHost() => Topmost = true;
|
||||||
|
|
||||||
|
internal void SetOwningFlyout(Uwp.UI.Controls.NotificationFlyout flyout)
|
||||||
|
{
|
||||||
|
var content = GetHostContent();
|
||||||
|
if (content != null)
|
||||||
|
{
|
||||||
|
content.SetOwningFlyout(flyout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ShowContextMenuFlyout()
|
||||||
|
{
|
||||||
|
var position = CursorHelper.GetPhysicalCursorPos();
|
||||||
|
this.SetWindowPosition(position.y, position.x, WindowSize, WindowSize);
|
||||||
|
|
||||||
|
var flyoutHost = GetHostContent();
|
||||||
|
if (flyoutHost != null)
|
||||||
|
{
|
||||||
|
flyoutHost.ShowFlyout();
|
||||||
|
}
|
||||||
|
|
||||||
|
Activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivated(EventArgs args)
|
||||||
|
{
|
||||||
|
var flyoutHost = GetHostContent();
|
||||||
|
if (flyoutHost != null)
|
||||||
|
{
|
||||||
|
flyoutHost.HideFlyout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
-90
@@ -3,6 +3,7 @@ using NotificationFlyout.Uwp.UI.Extensions;
|
|||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
using NotificationFlyout.Wpf.UI.Extensions;
|
||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
using NotificationFlyout.Wpf.UI.Helpers;
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
@@ -13,33 +14,12 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
{
|
{
|
||||||
private const string ShellTrayHandleName = "Shell_TrayWnd";
|
private const string ShellTrayHandleName = "Shell_TrayWnd";
|
||||||
|
|
||||||
|
private NotificationFlyoutContextMenuXamlHost _contextMenuXamlHost;
|
||||||
private Uwp.UI.Controls.NotificationFlyout _flyout;
|
private Uwp.UI.Controls.NotificationFlyout _flyout;
|
||||||
|
|
||||||
private NotificationIconHelper _notificationIconHelper;
|
private NotificationIconHelper _notificationIconHelper;
|
||||||
private SystemPersonalisationHelper _systemPersonalisationHelper;
|
private SystemPersonalisationHelper _systemPersonalisationHelper;
|
||||||
private TaskbarHelper _taskbarHelper;
|
private TaskbarHelper _taskbarHelper;
|
||||||
|
|
||||||
internal event EventHandler ContextMenuRequested;
|
|
||||||
|
|
||||||
public void SetFlyout(Uwp.UI.Controls.NotificationFlyout flyout)
|
|
||||||
{
|
|
||||||
if (_flyout != null)
|
|
||||||
{
|
|
||||||
_flyout.ContentChanged -= OnFlyoutContentChanged;
|
|
||||||
_flyout.IconSourceChanged -= OnFlyoutIconSourceChanged;
|
|
||||||
_flyout.RequestedThemeChanged -= OnFlyoutIconSourceChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
_flyout = flyout;
|
|
||||||
_flyout.ContentChanged += OnFlyoutContentChanged;
|
|
||||||
_flyout.IconSourceChanged += OnFlyoutIconSourceChanged;
|
|
||||||
_flyout.RequestedThemeChanged += OnFlyoutRequestedThemeChanged;
|
|
||||||
|
|
||||||
UpdateIcons();
|
|
||||||
UpdateFlyoutContent();
|
|
||||||
UpdateRequestedTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void HideFlyout()
|
internal void HideFlyout()
|
||||||
{
|
{
|
||||||
var flyoutHost = GetHostContent();
|
var flyoutHost = GetHostContent();
|
||||||
@@ -49,10 +29,32 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SetOwningFlyout(Uwp.UI.Controls.NotificationFlyout flyout)
|
||||||
|
{
|
||||||
|
if (_flyout != null)
|
||||||
|
{
|
||||||
|
_flyout.IconSourceChanged -= OnIconSourceChanged;
|
||||||
|
_flyout.ContextMenuChanged -= OnContextMenuChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
_flyout = flyout;
|
||||||
|
_flyout.IconSourceChanged += OnIconSourceChanged;
|
||||||
|
_flyout.ContextMenuChanged += OnContextMenuChanged;
|
||||||
|
|
||||||
|
var content = GetHostContent();
|
||||||
|
if (content != null)
|
||||||
|
{
|
||||||
|
content.SetOwningFlyout(_flyout);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateIcons();
|
||||||
|
PrepareContextMenu();
|
||||||
|
}
|
||||||
|
|
||||||
internal void ShowFlyout()
|
internal void ShowFlyout()
|
||||||
{
|
{
|
||||||
var flyoutHost = GetHostContent();
|
var content = GetHostContent();
|
||||||
if (flyoutHost != null)
|
if (content != null)
|
||||||
{
|
{
|
||||||
var taskbarState = _taskbarHelper.GetCurrentState();
|
var taskbarState = _taskbarHelper.GetCurrentState();
|
||||||
var flyoutPlacement = taskbarState.Position switch
|
var flyoutPlacement = taskbarState.Position switch
|
||||||
@@ -65,10 +67,18 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
};
|
};
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
flyoutHost.ShowFlyout(flyoutPlacement);
|
content.ShowFlyout(flyoutPlacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnClosed(EventArgs args)
|
||||||
|
{
|
||||||
|
_notificationIconHelper.Dispose();
|
||||||
|
|
||||||
|
if (_contextMenuXamlHost == null) return;
|
||||||
|
_contextMenuXamlHost.Close();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnContentLoaded()
|
protected override void OnContentLoaded()
|
||||||
{
|
{
|
||||||
PrepareNotificationIcon();
|
PrepareNotificationIcon();
|
||||||
@@ -76,25 +86,9 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
UpdateWindow();
|
UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDeactivated(EventArgs args)
|
protected override void OnDeactivated(EventArgs args) => HideFlyout();
|
||||||
{
|
|
||||||
HideFlyout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnFlyoutContentChanged(object sender, EventArgs args)
|
private void OnContextMenuChanged(object sender, EventArgs args) => PrepareContextMenu();
|
||||||
{
|
|
||||||
UpdateFlyoutContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnFlyoutIconSourceChanged(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
UpdateIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnFlyoutRequestedThemeChanged(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
UpdateRequestedTheme();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnIconInvoked(object sender, NotificationIconInvokedEventArgs args)
|
private void OnIconInvoked(object sender, NotificationIconInvokedEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -105,20 +99,35 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
if (args.MouseButton == MouseButton.Right)
|
if (args.MouseButton == MouseButton.Right)
|
||||||
{
|
{
|
||||||
ContextMenuRequested?.Invoke(this, EventArgs.Empty);
|
ShowContextMenuFlyout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTaskbarChanged(object sender, EventArgs args)
|
private void OnIconSourceChanged(object sender, EventArgs args) => UpdateIcons();
|
||||||
{
|
|
||||||
UpdateWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args)
|
private void OnTaskbarChanged(object sender, EventArgs args) => UpdateWindow();
|
||||||
{
|
|
||||||
UpdateIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args) => UpdateIcons();
|
||||||
|
|
||||||
|
private void PrepareContextMenu()
|
||||||
|
{
|
||||||
|
if (_contextMenuXamlHost != null)
|
||||||
|
{
|
||||||
|
_contextMenuXamlHost.Close();
|
||||||
|
_contextMenuXamlHost = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var contextMenu = _flyout.ContextMenu;
|
||||||
|
if (contextMenu == null) return;
|
||||||
|
|
||||||
|
if (_contextMenuXamlHost == null)
|
||||||
|
{
|
||||||
|
_contextMenuXamlHost = new NotificationFlyoutContextMenuXamlHost();
|
||||||
|
_contextMenuXamlHost.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
_contextMenuXamlHost.SetOwningFlyout(_flyout);
|
||||||
|
}
|
||||||
private void PrepareNotificationIcon()
|
private void PrepareNotificationIcon()
|
||||||
{
|
{
|
||||||
_notificationIconHelper = NotificationIconHelper.Create(this);
|
_notificationIconHelper = NotificationIconHelper.Create(this);
|
||||||
@@ -136,59 +145,30 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
_taskbarHelper.TaskbarChanged += OnTaskbarChanged;
|
_taskbarHelper.TaskbarChanged += OnTaskbarChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClosed(EventArgs args)
|
private void ShowContextMenuFlyout()
|
||||||
{
|
{
|
||||||
_notificationIconHelper.Dispose();
|
if (_contextMenuXamlHost == null) return;
|
||||||
|
_contextMenuXamlHost.ShowContextMenuFlyout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateFlyoutContent()
|
|
||||||
{
|
|
||||||
if (_flyout == null) return;
|
|
||||||
|
|
||||||
var content = _flyout.Content;
|
|
||||||
if (content == null) return;
|
|
||||||
|
|
||||||
var flyoutHost = GetHostContent();
|
|
||||||
if (flyoutHost != null)
|
|
||||||
{
|
|
||||||
flyoutHost.Content = content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void UpdateIcons()
|
private async void UpdateIcons()
|
||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
if (_flyout == null) return;
|
if (_flyout == null) return;
|
||||||
|
|
||||||
var _defaultIconSource = _flyout.IconSource;
|
var iconSource = _flyout.IconSource;
|
||||||
var _lightIconSource = _flyout.LightIconSource;
|
var lightIconSource = _flyout.LightIconSource;
|
||||||
|
|
||||||
var shellTrayHandle = WindowHelper.GetHandle(ShellTrayHandleName);
|
var shellTrayHandle = WindowHelper.GetHandle(ShellTrayHandleName);
|
||||||
if (shellTrayHandle == null) return;
|
if (shellTrayHandle == null) return;
|
||||||
|
|
||||||
|
var desiredIconSource = _systemPersonalisationHelper.Theme == SystemTheme.Dark ? iconSource : lightIconSource;
|
||||||
|
if (desiredIconSource == null) return;
|
||||||
|
|
||||||
var dpi = WindowHelper.GetDpi(shellTrayHandle);
|
var dpi = WindowHelper.GetDpi(shellTrayHandle);
|
||||||
|
using var icon = await desiredIconSource.ConvertToIconAsync(dpi);
|
||||||
var iconSource = _systemPersonalisationHelper.Theme == SystemTheme.Dark ? _defaultIconSource : _lightIconSource;
|
|
||||||
if (iconSource == null) return;
|
|
||||||
|
|
||||||
using var icon = await iconSource.ConvertToIconAsync(dpi);
|
|
||||||
_notificationIconHelper.SetIcon(icon.Handle);
|
_notificationIconHelper.SetIcon(icon.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRequestedTheme()
|
|
||||||
{
|
|
||||||
if (_flyout == null) return;
|
|
||||||
|
|
||||||
var requestedTheme = _flyout.RequestedTheme;
|
|
||||||
|
|
||||||
var flyoutHost = GetHostContent();
|
|
||||||
if (flyoutHost != null)
|
|
||||||
{
|
|
||||||
flyoutHost.RequestedTheme = requestedTheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateWindow()
|
private void UpdateWindow()
|
||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
using NotificationFlyout.Uwp.UI.Controls;
|
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
|
||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Controls
|
|
||||||
{
|
|
||||||
internal class ContextMenuXamlHost : TransparentXamlHost<ContextMenuFlyoutHost>
|
|
||||||
{
|
|
||||||
private Uwp.UI.Controls.NotificationFlyout _flyout;
|
|
||||||
|
|
||||||
public ContextMenuXamlHost()
|
|
||||||
{
|
|
||||||
Topmost = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetFlyout(Uwp.UI.Controls.NotificationFlyout flyout)
|
|
||||||
{
|
|
||||||
if (_flyout != null)
|
|
||||||
{
|
|
||||||
_flyout.MenuItemsChanged -= OnContextMenuItemsChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
_flyout = flyout;
|
|
||||||
UpdateMenuItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowContextMenuFlyout()
|
|
||||||
{
|
|
||||||
var position = CursorHelper.GetPhysicalCursorPos();
|
|
||||||
this.SetWindowPosition(position.y, position.x, WindowSize, WindowSize);
|
|
||||||
|
|
||||||
var flyoutHost = GetHostContent();
|
|
||||||
if (flyoutHost != null)
|
|
||||||
{
|
|
||||||
flyoutHost.ShowFlyout();
|
|
||||||
}
|
|
||||||
|
|
||||||
Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnContentLoaded()
|
|
||||||
{
|
|
||||||
UpdateMenuItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDeactivated(EventArgs args)
|
|
||||||
{
|
|
||||||
var flyoutHost = GetHostContent();
|
|
||||||
if (flyoutHost != null)
|
|
||||||
{
|
|
||||||
flyoutHost.HideFlyout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnContextMenuItemsChanged(object sender, NotificationFlyoutMenuItemsChangedEventArgs args)
|
|
||||||
{
|
|
||||||
UpdateMenuItems(args.AddedItems, args.RemovedItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateMenuItems()
|
|
||||||
{
|
|
||||||
if (_flyout == null) return;
|
|
||||||
UpdateMenuItems(_flyout.ContextMenuItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateMenuItems(IList<MenuFlyoutItemBase> addedItems, IList<MenuFlyoutItemBase> removedItems = default)
|
|
||||||
{
|
|
||||||
var flyoutHost = GetHostContent();
|
|
||||||
if (flyoutHost != null)
|
|
||||||
{
|
|
||||||
flyoutHost.SetMenuItems(addedItems, removedItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
ContentRendered += OnContentRendered;
|
ContentRendered += OnContentRendered;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TXamlContent GetHostContent()
|
internal TXamlContent GetHostContent()
|
||||||
{
|
{
|
||||||
if (_xamlHost == null) return null;
|
if (_xamlHost == null) return null;
|
||||||
return _xamlHost.GetUwpInternalObject() as TXamlContent;
|
return _xamlHost.GetUwpInternalObject() as TXamlContent;
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
SM_CYSMICON = 50
|
SM_CYSMICON = 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
return operatingSystem.Version.Build > (int)version;
|
return operatingSystem.Version.Build > (int)version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,4 +11,4 @@
|
|||||||
Windows10_1809 = 17763,
|
Windows10_1809 = 17763,
|
||||||
Windows10_1903 = 18362
|
Windows10_1903 = 18362
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,4 +12,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
return new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
return new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
return string.IsNullOrWhiteSpace(valueName) ? defaultValue : key.GetValue(valueName, defaultValue) is T value ? value : defaultValue;
|
return string.IsNullOrWhiteSpace(valueName) ? defaultValue : key.GetValue(valueName, defaultValue) is T value ? value : defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,4 +36,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
SWP_NOACTIVATE = 0x0010,
|
SWP_NOACTIVATE = 0x0010,
|
||||||
WS_EX_NOACTIVATE = 0x08000000,
|
WS_EX_NOACTIVATE = 0x08000000,
|
||||||
SWP_SHOWWINDOW = 0x0040,
|
SWP_SHOWWINDOW = 0x0040,
|
||||||
WS_EX_APPWINDOW = 0x00040000,
|
WS_EX_APPWINDOW = 0x00040000,
|
||||||
WS_EX_TOOLWINDOW = 0x00000080
|
WS_EX_TOOLWINDOW = 0x00000080
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,4 +44,4 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)IntPtr.Zero, (int)left, (int)top, (int)width, (int)height, (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.SWP_NOZORDER | (uint)WindowFlag.SWP_NOACTIVATE);
|
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)IntPtr.Zero, (int)left, (int)top, (int)width, (int)height, (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.SWP_NOZORDER | (uint)WindowFlag.SWP_NOACTIVATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
{
|
{
|
||||||
public static POINT GetPhysicalCursorPos()
|
public static POINT GetPhysicalCursorPos()
|
||||||
{
|
{
|
||||||
PInvoke.GetPhysicalCursorPos(out POINT point);
|
PInvoke.GetPhysicalCursorPos(out var point);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,6 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
CreateNotificationIcon();
|
CreateNotificationIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~NotificationIconHelper()
|
~NotificationIconHelper()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
@@ -147,9 +146,11 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
case (uint)WndProcMessages.WM_LBUTTONUP:
|
case (uint)WndProcMessages.WM_LBUTTONUP:
|
||||||
InvokeIconInvoked(MouseButton.Left);
|
InvokeIconInvoked(MouseButton.Left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (uint)WndProcMessages.WM_MBUTTONUP:
|
case (uint)WndProcMessages.WM_MBUTTONUP:
|
||||||
InvokeIconInvoked(MouseButton.Middle);
|
InvokeIconInvoked(MouseButton.Middle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (uint)WndProcMessages.WM_RBUTTONUP:
|
case (uint)WndProcMessages.WM_RBUTTONUP:
|
||||||
InvokeIconInvoked(MouseButton.Right);
|
InvokeIconInvoked(MouseButton.Right);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||||
private static extern bool SystemParametersInfo(int nAction, int nParam, ref RECT rc, int nUpdate);
|
private static extern bool SystemParametersInfo(int nAction, int nParam, ref RECT rc, int nUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,4 +74,4 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
return DefWindowProcW(hwnd, (uint)msg, wParam, (lParam));
|
return DefWindowProcW(hwnd, (uint)msg, wParam, (lParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@
|
|||||||
Dark,
|
Dark,
|
||||||
Light,
|
Light,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,4 +115,4 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
public int lParam;
|
public int lParam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace NotificationFlyout.Wpf.UI
|
namespace NotificationFlyout.Wpf.UI
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum TaskbarPosition
|
public enum TaskbarPosition
|
||||||
{
|
{
|
||||||
Left = 0,
|
Left = 0,
|
||||||
|
|||||||
@@ -13,6 +13,5 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
public SystemTheme Theme { get; private set; }
|
public SystemTheme Theme { get; private set; }
|
||||||
|
|
||||||
public bool IsColorPrevalence { get; private set; }
|
public bool IsColorPrevalence { get; private set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Microsoft.Windows.Sdk;
|
||||||
using Microsoft.Windows.Sdk;
|
using System;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Wpf.UI.Helpers
|
||||||
{
|
{
|
||||||
@@ -15,4 +15,4 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
return PInvoke.GetDpiForWindow((HWND)handle);
|
return PInvoke.GetDpiForWindow((HWND)handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace NotificationFlyout.Wpf.UI
|
|||||||
{
|
{
|
||||||
var monitorData = GetMonitorData(monitorHandle);
|
var monitorData = GetMonitorData(monitorHandle);
|
||||||
|
|
||||||
Bounds = new Rect(monitorData.MonitorRect.left, monitorData.MonitorRect.top, monitorData.MonitorRect.right - monitorData.MonitorRect.left, monitorData.MonitorRect.bottom - monitorData.MonitorRect.top);
|
Bounds = new Rect(monitorData.MonitorRect.left, monitorData.MonitorRect.top, monitorData.MonitorRect.right - monitorData.MonitorRect.left, monitorData.MonitorRect.bottom - monitorData.MonitorRect.top);
|
||||||
Primary = (monitorData.Flags & (int)MonitorFlag.MONITOR_DEFAULTTOPRIMARY) != 0;
|
Primary = (monitorData.Flags & (int)MonitorFlag.MONITOR_DEFAULTTOPRIMARY) != 0;
|
||||||
DeviceName = monitorData.DeviceName;
|
DeviceName = monitorData.DeviceName;
|
||||||
}
|
}
|
||||||
@@ -62,14 +62,8 @@ namespace NotificationFlyout.Wpf.UI
|
|||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is Screen monitor)
|
if (obj is not Screen monitor) return false;
|
||||||
{
|
return _monitorHandle == monitor._monitorHandle;
|
||||||
if (_monitorHandle == monitor._monitorHandle)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
|
|||||||
Reference in New Issue
Block a user