This commit is contained in:
TheXamlGuy
2024-01-06 14:34:25 +00:00
parent 53537aa4c7
commit e1c7846e45
73 changed files with 251 additions and 198 deletions
@@ -1,11 +1,12 @@
using Hyperbar.Extensions;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Hyperbar.Widget.Contextual; namespace Hyperbar.Widget.Contextual;
public class ContextualWidgetBuilder : public class ContextualWidgetBuilder :
IWidgetBuilder IWidgetBuilder
{ {
public void Create(IServiceCollection services) => services public void Create(IServiceCollection services) => services
.AddConfiguration<ContextualWidgetConfiguration>() .AddConfiguration<ContextualWidgetConfiguration>()
.AddWidgetTemplate<ContextualWidgetViewModel>(); .AddWidgetTemplate<ContextualWidgetViewModel>();
} }
@@ -1,5 +1,5 @@
namespace Hyperbar.Widget.Contextual; namespace Hyperbar.Widget.Contextual;
public class ContextualWidgetConfiguration public class ContextualWidgetConfiguration
{ {
} }
@@ -3,7 +3,7 @@
public class ContextualWidgetViewModel : public class ContextualWidgetViewModel :
WidgetViewModelBase WidgetViewModelBase
{ {
public ContextualWidgetViewModel(ITemplateFactory templateFactory, public ContextualWidgetViewModel(ITemplateFactory templateFactory,
IServiceFactory serviceFactory) : base(templateFactory, serviceFactory) IServiceFactory serviceFactory) : base(templateFactory, serviceFactory)
{ {
Add<WidgetButtonViewModel>(); Add<WidgetButtonViewModel>();
@@ -53,4 +53,4 @@ public class DesktopFlyout :
private void OnPlacementPropertyChanged() => UpdatePlacement(); private void OnPlacementPropertyChanged() => UpdatePlacement();
private void UpdatePlacement() => host.UpdatePlacement(Placement); private void UpdatePlacement() => host.UpdatePlacement(Placement);
} }
@@ -1,7 +1,7 @@
using Microsoft.UI.Xaml; using Hyperbar.Windows.Win32;
using Hyperbar.Windows.Win32; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
namespace Hyperbar.Windows.Controls; namespace Hyperbar.Windows.Controls;
@@ -20,7 +20,7 @@ internal class DesktopFlyoutHost : Window
presenter.SizeChanged += OnChildSizeChanged; presenter.SizeChanged += OnChildSizeChanged;
Content = root; Content = root;
this.SetOpacity(0); this.SetOpacity(0);
this.SetStyle(WindowStyle.SysMenu | WindowStyle.Visible); this.SetStyle(WindowStyle.SysMenu | WindowStyle.Visible);
this.SetTopMost(true); this.SetTopMost(true);
@@ -37,7 +37,7 @@ internal class DesktopFlyoutHost : Window
return; return;
} }
// presenter.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); // presenter.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
double height = presenter.DesiredSize.Height; double height = presenter.DesiredSize.Height;
double width = presenter.DesiredSize.Width; double width = presenter.DesiredSize.Width;
@@ -47,15 +47,19 @@ internal class DesktopFlyoutHost : Window
case DesktopFlyoutPlacement.Left: case DesktopFlyoutPlacement.Left:
this.Snap(WindowPlacement.Left, 0, 0); this.Snap(WindowPlacement.Left, 0, 0);
break; break;
case DesktopFlyoutPlacement.Top: case DesktopFlyoutPlacement.Top:
this.Snap(WindowPlacement.Top, width, height); this.Snap(WindowPlacement.Top, width, height);
break; break;
case DesktopFlyoutPlacement.Right: case DesktopFlyoutPlacement.Right:
this.Snap(WindowPlacement.Right, 0, 0); this.Snap(WindowPlacement.Right, 0, 0);
break; break;
case DesktopFlyoutPlacement.Bottom: case DesktopFlyoutPlacement.Bottom:
this.Snap(WindowPlacement.Bottom, width, height); this.Snap(WindowPlacement.Bottom, width, height);
break; break;
default: default:
break; break;
} }
@@ -85,4 +89,4 @@ internal class DesktopFlyoutHost : Window
UpdatePlacement(placement); UpdatePlacement(placement);
} }
} }
@@ -6,4 +6,4 @@ public enum DesktopFlyoutPlacement
Top, Top,
Right, Right,
Bottom Bottom
} }
@@ -37,4 +37,4 @@ public class DesktopFlyoutPresenter :
} }
internal void UpdatePlacementState(DesktopFlyoutPlacement placement) => VisualStateManager.GoToState(this, $"{placement}Placement", true); internal void UpdatePlacementState(DesktopFlyoutPlacement placement) => VisualStateManager.GoToState(this, $"{placement}Placement", true);
} }
@@ -83,4 +83,4 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>
@@ -29,6 +29,7 @@ public class DesktopFlyoutPresenterTemplateSettings : DependencyObject
get => (double)GetValue(HeightProperty); get => (double)GetValue(HeightProperty);
set => SetValue(HeightProperty, value); set => SetValue(HeightProperty, value);
} }
public double NegativeHeight public double NegativeHeight
{ {
get => (double)GetValue(NegativeHeightProperty); get => (double)GetValue(NegativeHeightProperty);
@@ -46,4 +47,4 @@ public class DesktopFlyoutPresenterTemplateSettings : DependencyObject
get => (double)GetValue(WidthProperty); get => (double)GetValue(WidthProperty);
set => SetValue(WidthProperty, value); set => SetValue(WidthProperty, value);
} }
} }
@@ -3,4 +3,4 @@
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Hyperbar.Windows.Controls/DesktopFlyout/DesktopFlyoutPresenter.xaml" /> <ResourceDictionary Source="ms-appx:///Hyperbar.Windows.Controls/DesktopFlyout/DesktopFlyoutPresenter.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
+1 -3
View File
@@ -2,6 +2,4 @@
public interface IPrimaryCommand public interface IPrimaryCommand
{ {
}
}
@@ -1,6 +1,6 @@
namespace Hyperbar.Windows.Primary; namespace Hyperbar.Windows.Primary;
public class KeyAcceleratorCommand : public class KeyAcceleratorCommand :
IPrimaryCommand IPrimaryCommand
{ {
public string? Icon { get; set; } public string? Icon { get; set; }
@@ -8,5 +8,4 @@ public class KeyAcceleratorCommand :
public string? Key { get; set; } public string? Key { get; set; }
public string[]? Modifiers { get; set; } public string[]? Modifiers { get; set; }
} }
@@ -1,3 +1,4 @@
using Hyperbar.Extensions;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace Hyperbar.Windows.Primary; namespace Hyperbar.Windows.Primary;
@@ -7,5 +8,4 @@ public class PrimaryWidgetBuilder :
{ {
public void Create(IServiceCollection services) => services.AddConfiguration<PrimaryWidgetConfiguration>() public void Create(IServiceCollection services) => services.AddConfiguration<PrimaryWidgetConfiguration>()
.AddWidgetTemplate<PrimaryWidgetViewModel>(); .AddWidgetTemplate<PrimaryWidgetViewModel>();
} }
@@ -1,8 +1,6 @@
namespace Hyperbar.Windows.Primary; namespace Hyperbar.Windows.Primary;
public class PrimaryWidgetConfiguration : public class PrimaryWidgetConfiguration :
List<IPrimaryCommand> List<IPrimaryCommand>
{ {
}
}
@@ -3,17 +3,16 @@
public class PrimaryWidgetViewModel : public class PrimaryWidgetViewModel :
WidgetViewModelBase WidgetViewModelBase
{ {
public PrimaryWidgetViewModel(ITemplateFactory templateFactory, public PrimaryWidgetViewModel(ITemplateFactory templateFactory,
IServiceFactory serviceFactory) : base(templateFactory, serviceFactory) IServiceFactory serviceFactory) : base(templateFactory, serviceFactory)
{ {
; ;
Add<WidgetButtonViewModel>("test 1", new Action(() => { Add<WidgetButtonViewModel>("test 1", new Action(() =>
{
})); }));
Add<WidgetButtonViewModel>("test 2", new Action(() => { })); Add<WidgetButtonViewModel>("test 2", new Action(() => { }));
Add<WidgetButtonViewModel>("test 4", new Action(() => { })); Add<WidgetButtonViewModel>("test 4", new Action(() => { }));
Add<WidgetButtonViewModel>("test 5", new Action(() => { })); Add<WidgetButtonViewModel>("test 5", new Action(() => { }));
} }
} }
@@ -1,8 +1,8 @@
using System; using System;
using System.Runtime.InteropServices;
using Windows.Win32; using Windows.Win32;
using Windows.Win32.Foundation; using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi; using Windows.Win32.Graphics.Gdi;
using System.Runtime.InteropServices;
using Windows.Win32.UI.WindowsAndMessaging; using Windows.Win32.UI.WindowsAndMessaging;
namespace Hyperbar.Windows.Win32; namespace Hyperbar.Windows.Win32;
@@ -15,7 +15,7 @@ public static class HwndExtensions
WS_EX_LAYERED = 0x80000 WS_EX_LAYERED = 0x80000
} }
public static void SetWindowOpacity(this IntPtr hWnd, public static void SetWindowOpacity(this IntPtr hWnd,
byte value) byte value)
{ {
HWND hWND = new(hWnd); HWND hWND = new(hWnd);
@@ -72,14 +72,17 @@ public static class HwndExtensions
left = 0; left = 0;
top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2; top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2;
break; break;
case WindowPlacement.Top: case WindowPlacement.Top:
left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2; left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2;
top = 0; top = 0;
break; break;
case WindowPlacement.Right: case WindowPlacement.Right:
left = info.rcWork.left + info.rcWork.right - actualWidth; left = info.rcWork.left + info.rcWork.right - actualWidth;
top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2; top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2;
break; break;
case WindowPlacement.Bottom: case WindowPlacement.Bottom:
left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2; left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2;
top = info.rcWork.bottom + info.rcWork.top - actualHeight; top = info.rcWork.bottom + info.rcWork.top - actualHeight;
@@ -88,4 +91,4 @@ public static class HwndExtensions
PInvoke.SetWindowPos(new HWND(hwnd), new HWND(), left, top, actualWidth, actualHeight, 0); PInvoke.SetWindowPos(new HWND(hwnd), new HWND(), left, top, actualWidth, actualHeight, 0);
} }
} }
@@ -1,7 +1,6 @@
using Microsoft.UI.Windowing; using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using System; using System;
using Windows.UI.Popups;
using WinRT.Interop; using WinRT.Interop;
namespace Hyperbar.Windows.Win32; namespace Hyperbar.Windows.Win32;
@@ -34,4 +33,4 @@ public static class WindowExtensions
WindowPlacement placement, WindowPlacement placement,
double? width = null, double? width = null,
double? height = null) => window.GetHandle().SnapWindow(placement, width, height); double? height = null) => window.GetHandle().SnapWindow(placement, width, height);
} }
@@ -30,4 +30,4 @@ public enum WindowStyle
TiledWindow = 0xCF0000, TiledWindow = 0xCF0000,
Visible = 0x10000000, Visible = 0x10000000,
VScroll = 0x200000 VScroll = 0x200000
} }
+55 -3
View File
@@ -19,6 +19,7 @@ namespace Windows.Win32
return __result; return __result;
} }
} }
/// <inheritdoc cref = "SHAppBarMessage(uint, APPBARDATA64*)"/> /// <inheritdoc cref = "SHAppBarMessage(uint, APPBARDATA64*)"/>
internal static unsafe nuint SHAppBarMessage(uint dwMessage, ref APPBARDATA64 pData) internal static unsafe nuint SHAppBarMessage(uint dwMessage, ref APPBARDATA64 pData)
{ {
@@ -74,6 +75,7 @@ namespace Windows.Win32
return __result; return __result;
} }
} }
/// <inheritdoc cref = "Shell_NotifyIcon(uint, NOTIFYICONDATAW32*)"/> /// <inheritdoc cref = "Shell_NotifyIcon(uint, NOTIFYICONDATAW32*)"/>
internal static unsafe bool Shell_NotifyIcon(uint dwMessage, in NOTIFYICONDATAW64 lpData) internal static unsafe bool Shell_NotifyIcon(uint dwMessage, in NOTIFYICONDATAW64 lpData)
{ {
@@ -134,24 +136,28 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint cbSize; internal uint cbSize;
/// <summary> /// <summary>
/// <para>Type: <b>HWND</b></para> /// <para>Type: <b>HWND</b></para>
/// <para>The handle to the appbar window. Not all messages use this member. See the individual message page to see if you need to provide an <b>hWind</b> value.</para> /// <para>The handle to the appbar window. Not all messages use this member. See the individual message page to see if you need to provide an <b>hWind</b> value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HWND hWnd; internal HWND hWnd;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>An application-defined message identifier. The application uses the specified identifier for notification messages that it sends to the appbar identified by the <b>hWnd</b> member. This member is used when sending the <a href="https://docs.microsoft.com/windows/desktop/shell/abm-new">ABM_NEW</a> message.</para> /// <para>An application-defined message identifier. The application uses the specified identifier for notification messages that it sends to the appbar identified by the <b>hWnd</b> member. This member is used when sending the <a href="https://docs.microsoft.com/windows/desktop/shell/abm-new">ABM_NEW</a> message.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uCallbackMessage; internal uint uCallbackMessage;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b> A value that specifies an edge of the screen. This member is used when sending one of these messages: </para> /// <para>Type: <b>UINT</b> A value that specifies an edge of the screen. This member is used when sending one of these messages: </para>
/// <para>This doc was truncated.</para> /// <para>This doc was truncated.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uEdge; internal uint uEdge;
/// <summary> /// <summary>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a></b> A <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure whose use varies depending on the message:</para> /// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a></b> A <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure whose use varies depending on the message:</para>
/// <para></para> /// <para></para>
@@ -159,6 +165,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal RECT rc; internal RECT rc;
/// <summary> /// <summary>
/// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </para> /// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </para>
/// <para>This doc was truncated.</para> /// <para>This doc was truncated.</para>
@@ -179,24 +186,28 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint cbSize; internal uint cbSize;
/// <summary> /// <summary>
/// <para>Type: <b>HWND</b></para> /// <para>Type: <b>HWND</b></para>
/// <para>The handle to the appbar window. Not all messages use this member. See the individual message page to see if you need to provide an <b>hWind</b> value.</para> /// <para>The handle to the appbar window. Not all messages use this member. See the individual message page to see if you need to provide an <b>hWind</b> value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HWND hWnd; internal HWND hWnd;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>An application-defined message identifier. The application uses the specified identifier for notification messages that it sends to the appbar identified by the <b>hWnd</b> member. This member is used when sending the <a href="https://docs.microsoft.com/windows/desktop/shell/abm-new">ABM_NEW</a> message.</para> /// <para>An application-defined message identifier. The application uses the specified identifier for notification messages that it sends to the appbar identified by the <b>hWnd</b> member. This member is used when sending the <a href="https://docs.microsoft.com/windows/desktop/shell/abm-new">ABM_NEW</a> message.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uCallbackMessage; internal uint uCallbackMessage;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b> A value that specifies an edge of the screen. This member is used when sending one of these messages: </para> /// <para>Type: <b>UINT</b> A value that specifies an edge of the screen. This member is used when sending one of these messages: </para>
/// <para>This doc was truncated.</para> /// <para>This doc was truncated.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uEdge; internal uint uEdge;
/// <summary> /// <summary>
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a></b> A <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure whose use varies depending on the message:</para> /// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a></b> A <a href="https://docs.microsoft.com/windows/desktop/api/windef/ns-windef-rect">RECT</a> structure whose use varies depending on the message:</para>
/// <para></para> /// <para></para>
@@ -204,6 +215,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal RECT rc; internal RECT rc;
/// <summary> /// <summary>
/// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </para> /// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </para>
/// <para>This doc was truncated.</para> /// <para>This doc was truncated.</para>
@@ -211,16 +223,20 @@ namespace Windows.Win32
/// </summary> /// </summary>
internal LPARAM lParam; internal LPARAM lParam;
} }
internal struct __ushort_128 internal struct __ushort_128
{ {
internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127; internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127;
/// <summary>Always <c>128</c>.</summary> /// <summary>Always <c>128</c>.</summary>
internal int Length => 128; internal int Length => 128;
/// <summary> /// <summary>
/// Gets a ref to an individual element of the inline array. /// Gets a ref to an individual element of the inline array.
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it. /// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
/// </summary> /// </summary>
internal ref ushort this[int index] => ref AsSpan()[index]; internal ref ushort this[int index] => ref AsSpan()[index];
/// <summary> /// <summary>
/// Gets this inline array as a span. /// Gets this inline array as a span.
/// </summary> /// </summary>
@@ -249,20 +265,24 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint cbSize; internal uint cbSize;
/// <summary> /// <summary>
/// <para>Type: <b>HWND</b></para> /// <para>Type: <b>HWND</b></para>
/// <para>A handle to the window that receives notifications associated with an icon in the notification area.</para> /// <para>A handle to the window that receives notifications associated with an icon in the notification area.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HWND hWnd; internal HWND hWnd;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>The application-defined identifier of the taskbar icon. The Shell uses either (<b>hWnd</b> plus <b>uID</b>) or <b>guidItem</b> to identify which icon to operate on when <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">Shell_NotifyIcon</a> is invoked. You can have multiple icons associated with a single <b>hWnd</b> by assigning each a different <b>uID</b>. If <b>guidItem</b> is specified, <b>uID</b> is ignored.</para> /// <para>The application-defined identifier of the taskbar icon. The Shell uses either (<b>hWnd</b> plus <b>uID</b>) or <b>guidItem</b> to identify which icon to operate on when <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">Shell_NotifyIcon</a> is invoked. You can have multiple icons associated with a single <b>hWnd</b> by assigning each a different <b>uID</b>. If <b>guidItem</b> is specified, <b>uID</b> is ignored.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uID; internal uint uID;
/// <summary>Type: <b>UINT</b></summary> /// <summary>Type: <b>UINT</b></summary>
internal uint uFlags; internal uint uFlags;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>An application-defined message identifier. The system uses this identifier to send notification messages to the window identified in <b>hWnd</b>. These notification messages are sent when a mouse event or hover occurs in the bounding rectangle of the icon, when the icon is selected or activated with the keyboard, or when those actions occur in the balloon notification.</para> /// <para>An application-defined message identifier. The system uses this identifier to send notification messages to the window identified in <b>hWnd</b>. These notification messages are sent when a mouse event or hover occurs in the bounding rectangle of the icon, when the icon is selected or activated with the keyboard, or when those actions occur in the balloon notification.</para>
@@ -273,6 +293,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uCallbackMessage; internal uint uCallbackMessage;
/// <summary> /// <summary>
/// <para>Type: <b>HICON</b></para> /// <para>Type: <b>HICON</b></para>
/// <para>A handle to the icon to be added, modified, or deleted. Windows XP and later support icons of up to 32 BPP.</para> /// <para>A handle to the icon to be added, modified, or deleted. Windows XP and later support icons of up to 32 BPP.</para>
@@ -280,6 +301,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HICON hIcon; internal HICON hIcon;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[64]</b></para> /// <para>Type: <b>TCHAR[64]</b></para>
/// <para>A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters, including the terminating null character.</para> /// <para>A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters, including the terminating null character.</para>
@@ -287,33 +309,40 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_128 szTip; internal __ushort_128 szTip;
/// <summary>Type: <b>DWORD</b></summary> /// <summary>Type: <b>DWORD</b></summary>
internal uint dwState; internal uint dwState;
/// <summary> /// <summary>
/// <para>Type: <b>DWORD</b></para> /// <para>Type: <b>DWORD</b></para>
/// <para><b>Windows 2000 and later</b>. A value that specifies which bits of the <b>dwState</b> member are retrieved or modified. The possible values are the same as those for <b>dwState</b>. For example, setting this member to <b>NIS_HIDDEN</b> causes only the item's hidden state to be modified while the icon sharing bit is ignored regardless of its value.</para> /// <para><b>Windows 2000 and later</b>. A value that specifies which bits of the <b>dwState</b> member are retrieved or modified. The possible values are the same as those for <b>dwState</b>. For example, setting this member to <b>NIS_HIDDEN</b> causes only the item's hidden state to be modified while the icon sharing bit is ignored regardless of its value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint dwStateMask; internal uint dwStateMask;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[256]</b></para> /// <para>Type: <b>TCHAR[256]</b></para>
/// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies the text to display in a balloon notification. It can have a maximum of 256 characters, including the terminating null character, but should be restricted to 200 characters in English to accommodate localization. To remove the balloon notification from the UI, either delete the icon (with <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">NIM_DELETE</a>) or set the <b>NIF_INFO</b> flag in <b>uFlags</b> and set <b>szInfo</b> to an empty string.</para> /// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies the text to display in a balloon notification. It can have a maximum of 256 characters, including the terminating null character, but should be restricted to 200 characters in English to accommodate localization. To remove the balloon notification from the UI, either delete the icon (with <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">NIM_DELETE</a>) or set the <b>NIF_INFO</b> flag in <b>uFlags</b> and set <b>szInfo</b> to an empty string.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_256 szInfo; internal __ushort_256 szInfo;
internal _Anonymous_e__Union Anonymous; internal _Anonymous_e__Union Anonymous;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[64]</b></para> /// <para>Type: <b>TCHAR[64]</b></para>
/// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies a title for a balloon notification. This title appears in a larger font immediately above the text. It can have a maximum of 64 characters, including the terminating null character, but should be restricted to 48 characters in English to accommodate localization.</para> /// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies a title for a balloon notification. This title appears in a larger font immediately above the text. It can have a maximum of 64 characters, including the terminating null character, but should be restricted to 48 characters in English to accommodate localization.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_64 szInfoTitle; internal __ushort_64 szInfoTitle;
/// <summary> /// <summary>
/// <para>Type: <b>DWORD</b></para> /// <para>Type: <b>DWORD</b></para>
/// <para><b>Windows 2000 and later</b>. Flags that can be set to modify the behavior and appearance of a balloon notification. The icon is placed to the left of the title. If the <b>szInfoTitle</b> member is zero-length, the icon is not shown.</para> /// <para><b>Windows 2000 and later</b>. Flags that can be set to modify the behavior and appearance of a balloon notification. The icon is placed to the left of the title. If the <b>szInfoTitle</b> member is zero-length, the icon is not shown.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint dwInfoFlags; internal uint dwInfoFlags;
/// <summary> /// <summary>
/// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para> /// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para>
/// <para></para> /// <para></para>
@@ -321,6 +350,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal global::System.Guid guidItem; internal global::System.Guid guidItem;
/// <summary> /// <summary>
/// <para>Type: <b>HICON</b></para> /// <para>Type: <b>HICON</b></para>
/// <para><b>Windows Vista and later</b>. The handle of a customized notification icon provided by the application that should be used independently of the notification area icon. If this member is non-NULL and the NIIF_USER flag is set in the <b>dwInfoFlags</b> member, this icon is used as the notification icon. If this member is <b>NULL</b>, the legacy behavior is carried out.</para> /// <para><b>Windows Vista and later</b>. The handle of a customized notification icon provided by the application that should be used independently of the notification area icon. If this member is non-NULL and the NIIF_USER flag is set in the <b>dwInfoFlags</b> member, this icon is used as the notification icon. If this member is <b>NULL</b>, the legacy behavior is carried out.</para>
@@ -328,17 +358,19 @@ namespace Windows.Win32
/// </summary> /// </summary>
internal HICON hBalloonIcon; internal HICON hBalloonIcon;
internal struct __ushort_256 internal struct __ushort_256
{ {
internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255; internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255;
/// <summary>Always <c>256</c>.</summary> /// <summary>Always <c>256</c>.</summary>
internal int Length => 256; internal int Length => 256;
/// <summary> /// <summary>
/// Gets a ref to an individual element of the inline array. /// Gets a ref to an individual element of the inline array.
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it. /// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
/// </summary> /// </summary>
internal ref ushort this[int index] => ref AsSpan()[index]; internal ref ushort this[int index] => ref AsSpan()[index];
/// <summary> /// <summary>
/// Gets this inline array as a span. /// Gets this inline array as a span.
/// </summary> /// </summary>
@@ -353,22 +385,25 @@ namespace Windows.Win32
{ {
[FieldOffset(0)] [FieldOffset(0)]
internal uint uTimeout; internal uint uTimeout;
[FieldOffset(0)] [FieldOffset(0)]
internal uint uVersion; internal uint uVersion;
} }
} }
internal struct __ushort_64 internal struct __ushort_64
{ {
internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63; internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
/// <summary>Always <c>64</c>.</summary> /// <summary>Always <c>64</c>.</summary>
internal int Length => 64; internal int Length => 64;
/// <summary> /// <summary>
/// Gets a ref to an individual element of the inline array. /// Gets a ref to an individual element of the inline array.
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it. /// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
/// </summary> /// </summary>
internal ref ushort this[int index] => ref AsSpan()[index]; internal ref ushort this[int index] => ref AsSpan()[index];
/// <summary> /// <summary>
/// Gets this inline array as a span. /// Gets this inline array as a span.
/// </summary> /// </summary>
@@ -378,7 +413,6 @@ namespace Windows.Win32
internal Span<ushort> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 64); internal Span<ushort> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 64);
} }
/// <summary>Contains information that the system needs to display notifications in the notification area. Used by Shell_NotifyIcon.</summary> /// <summary>Contains information that the system needs to display notifications in the notification area. Used by Shell_NotifyIcon.</summary>
/// <remarks> /// <remarks>
/// <para>See <a href="https://msdn.microsoft.com/library/aa511497.aspx">Notifications</a> in the Windows User Experience Interaction Guidelines for more information on notification UI and content best practices.</para> /// <para>See <a href="https://msdn.microsoft.com/library/aa511497.aspx">Notifications</a> in the Windows User Experience Interaction Guidelines for more information on notification UI and content best practices.</para>
@@ -397,20 +431,24 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint cbSize; internal uint cbSize;
/// <summary> /// <summary>
/// <para>Type: <b>HWND</b></para> /// <para>Type: <b>HWND</b></para>
/// <para>A handle to the window that receives notifications associated with an icon in the notification area.</para> /// <para>A handle to the window that receives notifications associated with an icon in the notification area.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HWND hWnd; internal HWND hWnd;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>The application-defined identifier of the taskbar icon. The Shell uses either (<b>hWnd</b> plus <b>uID</b>) or <b>guidItem</b> to identify which icon to operate on when <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">Shell_NotifyIcon</a> is invoked. You can have multiple icons associated with a single <b>hWnd</b> by assigning each a different <b>uID</b>. If <b>guidItem</b> is specified, <b>uID</b> is ignored.</para> /// <para>The application-defined identifier of the taskbar icon. The Shell uses either (<b>hWnd</b> plus <b>uID</b>) or <b>guidItem</b> to identify which icon to operate on when <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">Shell_NotifyIcon</a> is invoked. You can have multiple icons associated with a single <b>hWnd</b> by assigning each a different <b>uID</b>. If <b>guidItem</b> is specified, <b>uID</b> is ignored.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uID; internal uint uID;
/// <summary>Type: <b>UINT</b></summary> /// <summary>Type: <b>UINT</b></summary>
internal uint uFlags; internal uint uFlags;
/// <summary> /// <summary>
/// <para>Type: <b>UINT</b></para> /// <para>Type: <b>UINT</b></para>
/// <para>An application-defined message identifier. The system uses this identifier to send notification messages to the window identified in <b>hWnd</b>. These notification messages are sent when a mouse event or hover occurs in the bounding rectangle of the icon, when the icon is selected or activated with the keyboard, or when those actions occur in the balloon notification.</para> /// <para>An application-defined message identifier. The system uses this identifier to send notification messages to the window identified in <b>hWnd</b>. These notification messages are sent when a mouse event or hover occurs in the bounding rectangle of the icon, when the icon is selected or activated with the keyboard, or when those actions occur in the balloon notification.</para>
@@ -421,6 +459,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint uCallbackMessage; internal uint uCallbackMessage;
/// <summary> /// <summary>
/// <para>Type: <b>HICON</b></para> /// <para>Type: <b>HICON</b></para>
/// <para>A handle to the icon to be added, modified, or deleted. Windows XP and later support icons of up to 32 BPP.</para> /// <para>A handle to the icon to be added, modified, or deleted. Windows XP and later support icons of up to 32 BPP.</para>
@@ -428,6 +467,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal HICON hIcon; internal HICON hIcon;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[64]</b></para> /// <para>Type: <b>TCHAR[64]</b></para>
/// <para>A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters, including the terminating null character.</para> /// <para>A null-terminated string that specifies the text for a standard tooltip. It can have a maximum of 64 characters, including the terminating null character.</para>
@@ -435,33 +475,40 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_128 szTip; internal __ushort_128 szTip;
/// <summary>Type: <b>DWORD</b></summary> /// <summary>Type: <b>DWORD</b></summary>
internal uint dwState; internal uint dwState;
/// <summary> /// <summary>
/// <para>Type: <b>DWORD</b></para> /// <para>Type: <b>DWORD</b></para>
/// <para><b>Windows 2000 and later</b>. A value that specifies which bits of the <b>dwState</b> member are retrieved or modified. The possible values are the same as those for <b>dwState</b>. For example, setting this member to <b>NIS_HIDDEN</b> causes only the item's hidden state to be modified while the icon sharing bit is ignored regardless of its value.</para> /// <para><b>Windows 2000 and later</b>. A value that specifies which bits of the <b>dwState</b> member are retrieved or modified. The possible values are the same as those for <b>dwState</b>. For example, setting this member to <b>NIS_HIDDEN</b> causes only the item's hidden state to be modified while the icon sharing bit is ignored regardless of its value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint dwStateMask; internal uint dwStateMask;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[256]</b></para> /// <para>Type: <b>TCHAR[256]</b></para>
/// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies the text to display in a balloon notification. It can have a maximum of 256 characters, including the terminating null character, but should be restricted to 200 characters in English to accommodate localization. To remove the balloon notification from the UI, either delete the icon (with <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">NIM_DELETE</a>) or set the <b>NIF_INFO</b> flag in <b>uFlags</b> and set <b>szInfo</b> to an empty string.</para> /// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies the text to display in a balloon notification. It can have a maximum of 256 characters, including the terminating null character, but should be restricted to 200 characters in English to accommodate localization. To remove the balloon notification from the UI, either delete the icon (with <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona">NIM_DELETE</a>) or set the <b>NIF_INFO</b> flag in <b>uFlags</b> and set <b>szInfo</b> to an empty string.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_256 szInfo; internal __ushort_256 szInfo;
internal _Anonymous_e__Union Anonymous; internal _Anonymous_e__Union Anonymous;
/// <summary> /// <summary>
/// <para>Type: <b>TCHAR[64]</b></para> /// <para>Type: <b>TCHAR[64]</b></para>
/// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies a title for a balloon notification. This title appears in a larger font immediately above the text. It can have a maximum of 64 characters, including the terminating null character, but should be restricted to 48 characters in English to accommodate localization.</para> /// <para><b>Windows 2000 and later</b>. A null-terminated string that specifies a title for a balloon notification. This title appears in a larger font immediately above the text. It can have a maximum of 64 characters, including the terminating null character, but should be restricted to 48 characters in English to accommodate localization.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal __ushort_64 szInfoTitle; internal __ushort_64 szInfoTitle;
/// <summary> /// <summary>
/// <para>Type: <b>DWORD</b></para> /// <para>Type: <b>DWORD</b></para>
/// <para><b>Windows 2000 and later</b>. Flags that can be set to modify the behavior and appearance of a balloon notification. The icon is placed to the left of the title. If the <b>szInfoTitle</b> member is zero-length, the icon is not shown.</para> /// <para><b>Windows 2000 and later</b>. Flags that can be set to modify the behavior and appearance of a balloon notification. The icon is placed to the left of the title. If the <b>szInfoTitle</b> member is zero-length, the icon is not shown.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal uint dwInfoFlags; internal uint dwInfoFlags;
/// <summary> /// <summary>
/// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para> /// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para>
/// <para></para> /// <para></para>
@@ -469,6 +516,7 @@ namespace Windows.Win32
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para> /// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
/// </summary> /// </summary>
internal global::System.Guid guidItem; internal global::System.Guid guidItem;
/// <summary> /// <summary>
/// <para>Type: <b>HICON</b></para> /// <para>Type: <b>HICON</b></para>
/// <para><b>Windows Vista and later</b>. The handle of a customized notification icon provided by the application that should be used independently of the notification area icon. If this member is non-NULL and the NIIF_USER flag is set in the <b>dwInfoFlags</b> member, this icon is used as the notification icon. If this member is <b>NULL</b>, the legacy behavior is carried out.</para> /// <para><b>Windows Vista and later</b>. The handle of a customized notification icon provided by the application that should be used independently of the notification area icon. If this member is non-NULL and the NIIF_USER flag is set in the <b>dwInfoFlags</b> member, this icon is used as the notification icon. If this member is <b>NULL</b>, the legacy behavior is carried out.</para>
@@ -479,13 +527,16 @@ namespace Windows.Win32
internal struct __ushort_256 internal struct __ushort_256
{ {
internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255; internal ushort _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255;
/// <summary>Always <c>256</c>.</summary> /// <summary>Always <c>256</c>.</summary>
internal int Length => 256; internal int Length => 256;
/// <summary> /// <summary>
/// Gets a ref to an individual element of the inline array. /// Gets a ref to an individual element of the inline array.
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it. /// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
/// </summary> /// </summary>
internal ref ushort this[int index] => ref AsSpan()[index]; internal ref ushort this[int index] => ref AsSpan()[index];
/// <summary> /// <summary>
/// Gets this inline array as a span. /// Gets this inline array as a span.
/// </summary> /// </summary>
@@ -500,6 +551,7 @@ namespace Windows.Win32
{ {
[FieldOffset(0)] [FieldOffset(0)]
internal uint uTimeout; internal uint uTimeout;
[FieldOffset(0)] [FieldOffset(0)]
internal uint uVersion; internal uint uVersion;
} }
+4 -4
View File
@@ -23,13 +23,13 @@ public class KeyInterop
VirtualKey.Right, VirtualKey.Right,
VirtualKey.Application, VirtualKey.Application,
VirtualKey.RightWindows, VirtualKey.RightWindows,
VirtualKey.LeftWindows ]; VirtualKey.LeftWindows];
public static void Press(VirtualKey key) => SendKey(key, true); public static void Press(VirtualKey key) => SendKey(key, true);
public static void Release(VirtualKey key) => SendKey(key, false); public static void Release(VirtualKey key) => SendKey(key, false);
public static unsafe void Type(VirtualKey key, public static unsafe void Type(VirtualKey key,
params VirtualKey[] modifierKeys) params VirtualKey[] modifierKeys)
{ {
foreach (VirtualKey modiferKey in modifierKeys) foreach (VirtualKey modiferKey in modifierKeys)
@@ -46,7 +46,7 @@ public class KeyInterop
} }
} }
private static unsafe void SendKey(VirtualKey key, private static unsafe void SendKey(VirtualKey key,
bool pressed) bool pressed)
{ {
INPUT input = new() INPUT input = new()
@@ -80,4 +80,4 @@ public class KeyInterop
PInvoke.SendInput(new Span<INPUT>(ref input), Marshal.SizeOf(input)); PInvoke.SendInput(new Span<INPUT>(ref input), Marshal.SizeOf(input));
} }
} }
+1 -1
View File
@@ -14,4 +14,4 @@
</DataTemplate> </DataTemplate>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>
+9 -8
View File
@@ -1,14 +1,15 @@
using Hyperbar.Windows.Controls; using Hyperbar.Extensions;
using Hyperbar.Widget.Contextual;
using Hyperbar.Windows.Controls;
using Hyperbar.Windows.Primary;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Hyperbar.Widget.Contextual;
using Hyperbar.Windows.Primary;
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public partial class App : public partial class App :
Application Application
{ {
public App() => InitializeComponent(); public App() => InitializeComponent();
@@ -28,7 +29,7 @@ public partial class App :
}) })
.ConfigureServices((context, services) => .ConfigureServices((context, services) =>
{ {
services.AddSingleton<IServiceFactory>(provider => services.AddSingleton<IServiceFactory>(provider =>
new ServiceFactory((type, parameters) => ActivatorUtilities.CreateInstance(provider, type, parameters!))); new ServiceFactory((type, parameters) => ActivatorUtilities.CreateInstance(provider, type, parameters!)));
services.AddHostedService<AppService>(); services.AddHostedService<AppService>();
@@ -48,7 +49,7 @@ public partial class App :
{ {
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>()) foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
{ {
if (widgetContext.ServiceProvider.GetService<IWidgetViewModel>() is if (widgetContext.ServiceProvider.GetService<IWidgetViewModel>() is
IWidgetViewModel viewModel) IWidgetViewModel viewModel)
{ {
yield return viewModel; yield return viewModel;
@@ -56,11 +57,11 @@ public partial class App :
} }
} }
return Resolve(provider); return Resolve(provider);
}); });
}) })
.Build(); .Build();
await host.RunAsync(); await host.RunAsync();
} }
} }
@@ -5,7 +5,7 @@ namespace Hyperbar.Windows;
public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view, public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view,
[FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel, [FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel,
DesktopFlyout desktopFlyout) : DesktopFlyout desktopFlyout) :
IInitializer IInitializer
{ {
public Task InitializeAsync() public Task InitializeAsync()
@@ -17,4 +17,4 @@ public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] Comman
return Task.CompletedTask; return Task.CompletedTask;
} }
} }
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection; using Hyperbar.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
namespace Hyperbar.Windows namespace Hyperbar.Windows
@@ -2,7 +2,6 @@
namespace Hyperbar.Windows namespace Hyperbar.Windows
{ {
public interface ITemplateGeneratorFactory public interface ITemplateGeneratorFactory
{ {
DataTemplate Create(); DataTemplate Create();
@@ -3,7 +3,7 @@ using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public class TemplateGeneratorControl : public class TemplateGeneratorControl :
ContentControl ContentControl
{ {
public TemplateGeneratorControl() public TemplateGeneratorControl()
@@ -18,4 +18,4 @@ public class TemplateGeneratorControl :
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name); Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
} }
} }
} }
@@ -3,17 +3,17 @@ using Microsoft.UI.Xaml.Markup;
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public class TemplateGeneratorFactory : public class TemplateGeneratorFactory :
ITemplateGeneratorFactory ITemplateGeneratorFactory
{ {
public DataTemplate Create() public DataTemplate Create()
{ {
string xamlString = @" string xamlString = @"
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' <DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:desktop='using:Hyperbar.Windows'> xmlns:desktop='using:Hyperbar.Windows'>
<desktop:TemplateGeneratorControl /> <desktop:TemplateGeneratorControl />
</DataTemplate>"; </DataTemplate>";
return (DataTemplate)XamlReader.Load(xamlString); return (DataTemplate)XamlReader.Load(xamlString);
} }
} }
+1 -1
View File
@@ -10,4 +10,4 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
</UserControl> </UserControl>
+2 -2
View File
@@ -3,7 +3,7 @@ using Microsoft.UI.Xaml.Input;
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public sealed partial class CommandView : public sealed partial class CommandView :
UserControl UserControl
{ {
public CommandView() => InitializeComponent(); public CommandView() => InitializeComponent();
@@ -12,4 +12,4 @@ public sealed partial class CommandView :
{ {
base.OnKeyDown(e); base.OnKeyDown(e);
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public partial class CommandViewModel : public partial class CommandViewModel :
ObservableCollectionViewModel<IWidgetViewModel>, ObservableCollectionViewModel<IWidgetViewModel>,
ITemplatedViewModel ITemplatedViewModel
{ {
@@ -13,4 +13,4 @@ public partial class CommandViewModel :
} }
public ITemplateFactory TemplateFactory { get; } public ITemplateFactory TemplateFactory { get; }
} }
+1 -1
View File
@@ -17,4 +17,4 @@
Height="{StaticResource ButtonHeight}" Height="{StaticResource ButtonHeight}"
Command="{Binding Click}" Command="{Binding Click}"
Content="{Binding Icon}" /> Content="{Binding Icon}" />
</UserControl> </UserControl>
@@ -2,8 +2,8 @@ using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.Windows; namespace Hyperbar.Windows;
public sealed partial class WidgetButtonView : public sealed partial class WidgetButtonView :
UserControl UserControl
{ {
public WidgetButtonView() => InitializeComponent(); public WidgetButtonView() => InitializeComponent();
} }
+1 -1
View File
@@ -10,4 +10,4 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
</UserControl> </UserControl>
+1 -1
View File
@@ -7,4 +7,4 @@ public sealed partial class WidgetView :
IWidgetView IWidgetView
{ {
public WidgetView() => InitializeComponent(); public WidgetView() => InitializeComponent();
} }
@@ -6,8 +6,8 @@ namespace Hyperbar;
public class ConfigurationWriter<TConfiguration>(string path, public class ConfigurationWriter<TConfiguration>(string path,
string section, string section,
JsonSerializerOptions? serializerOptions = null) : JsonSerializerOptions? serializerOptions = null) :
IConfigurationWriter<TConfiguration> IConfigurationWriter<TConfiguration>
where TConfiguration : where TConfiguration :
class, new() class, new()
{ {
@@ -1,7 +1,7 @@
namespace Hyperbar; namespace Hyperbar;
public interface IConfigurationWriter<TConfiguration> public interface IConfigurationWriter<TConfiguration>
where TConfiguration : where TConfiguration :
class, new() class, new()
{ {
void Write(Action<TConfiguration> updateDelegate); void Write(Action<TConfiguration> updateDelegate);
@@ -2,11 +2,11 @@
namespace Hyperbar; namespace Hyperbar;
public interface IWritableConfiguration<out TConfiguration> : public interface IWritableConfiguration<out TConfiguration> :
IOptionsSnapshot<TConfiguration> IOptionsSnapshot<TConfiguration>
where TConfiguration : where TConfiguration :
class, new() class, new()
{ {
void Write(Action<TConfiguration> updateAction, void Write(Action<TConfiguration> updateAction,
bool reload = true); bool reload = true);
} }
@@ -5,16 +5,16 @@ namespace Hyperbar;
public class WritableConfiguration<TConfiguration>(IConfigurationWriter<TConfiguration> writer, public class WritableConfiguration<TConfiguration>(IConfigurationWriter<TConfiguration> writer,
IOptionsMonitor<TConfiguration> options, IOptionsMonitor<TConfiguration> options,
IConfiguration configuration) : IConfiguration configuration) :
IWritableConfiguration<TConfiguration> IWritableConfiguration<TConfiguration>
where TConfiguration : where TConfiguration :
class, new() class, new()
{ {
public TConfiguration Value => options.CurrentValue; public TConfiguration Value => options.CurrentValue;
public TConfiguration Get(string? name) => options.Get(name); public TConfiguration Get(string? name) => options.Get(name);
public void Write(Action<TConfiguration> updateDelegate, public void Write(Action<TConfiguration> updateDelegate,
bool reload = true) bool reload = true)
{ {
writer.Write(updateDelegate); writer.Write(updateDelegate);
@@ -23,4 +23,4 @@ public class WritableConfiguration<TConfiguration>(IConfigurationWriter<TConfigu
configurationRoot.Reload(); configurationRoot.Reload();
} }
} }
} }
@@ -5,7 +5,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Text.Json; using System.Text.Json;
namespace Hyperbar; namespace Hyperbar.Extensions;
public static class IServiceCollectionExtensions public static class IServiceCollectionExtensions
{ {
@@ -20,14 +20,14 @@ public static class IServiceCollectionExtensions
public static IServiceCollection AddConfiguration<TConfiguration>(this IServiceCollection services, public static IServiceCollection AddConfiguration<TConfiguration>(this IServiceCollection services,
string section, string section,
string path = "Settings.json", string path = "Settings.json",
Action<JsonSerializerOptions>? serializerDelegate = null) Action<JsonSerializerOptions>? serializerDelegate = null)
where TConfiguration : where TConfiguration :
class, new() class, new()
{ {
services.AddOptions(); _ = services.AddOptions();
services.AddSingleton<IConfigureOptions<TConfiguration>>(new ConfigureNamedOptions<TConfiguration>("", args => { })); _ = services.AddSingleton<IConfigureOptions<TConfiguration>>(new ConfigureNamedOptions<TConfiguration>("", args => { }));
services.AddTransient<IConfigurationWriter<TConfiguration>>(provider => _ = services.AddTransient<IConfigurationWriter<TConfiguration>>(provider =>
{ {
string? jsonFilePath = null; string? jsonFilePath = null;
if (provider.GetService<IHostEnvironment>() is IHostEnvironment hostEnvironment) if (provider.GetService<IHostEnvironment>() is IHostEnvironment hostEnvironment)
@@ -50,7 +50,7 @@ public static class IServiceCollectionExtensions
return new ConfigurationWriter<TConfiguration>(jsonFilePath, section, defaultSerializerOptions); return new ConfigurationWriter<TConfiguration>(jsonFilePath, section, defaultSerializerOptions);
}); });
services.AddTransient<IWritableConfiguration<TConfiguration>, WritableConfiguration<TConfiguration>>(); _ = services.AddTransient<IWritableConfiguration<TConfiguration>, WritableConfiguration<TConfiguration>>();
return services; return services;
} }
@@ -62,14 +62,14 @@ public static class IServiceCollectionExtensions
Type templateType = typeof(IWidgetView); Type templateType = typeof(IWidgetView);
string key = contentType.Name; string key = contentType.Name;
services.AddTransient(typeof(IWidgetViewModel), contentType); _ = services.AddTransient(typeof(IWidgetViewModel), contentType);
services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!); services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!);
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType); _ = services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
services.TryAddKeyedTransient<IWidgetView>(key, (provider, key) => provider.GetService<IWidgetView>()!); services.TryAddKeyedTransient(key, (provider, key) => provider.GetService<IWidgetView>()!);
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor _ = services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor
{ {
ContentType = contentType, ContentType = contentType,
TemplateType = templateType, TemplateType = templateType,
@@ -88,13 +88,13 @@ public static class IServiceCollectionExtensions
string key = contentType.Name; string key = contentType.Name;
services.AddTransient(typeof(IWidgetViewModel), contentType); _ = services.AddTransient(typeof(IWidgetViewModel), contentType);
services.TryAddTransient(templateType); services.TryAddTransient(templateType);
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType); _ = services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
services.TryAddKeyedTransient(templateType, key); services.TryAddKeyedTransient(templateType, key);
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor _ = services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor
{ {
ContentType = contentType, ContentType = contentType,
TemplateType = templateType, TemplateType = templateType,
@@ -112,13 +112,13 @@ public static class IServiceCollectionExtensions
key ??= contentType.Name; key ??= contentType.Name;
services.AddTransient(contentType); _ = services.AddTransient(contentType);
services.TryAddTransient(templateType); services.TryAddTransient(templateType);
services.AddKeyedTransient(contentType, key); _ = services.AddKeyedTransient(contentType, key);
services.AddKeyedTransient(templateType, key); _ = services.AddKeyedTransient(templateType, key);
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor _ = services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor
{ {
ContentType = contentType, ContentType = contentType,
TemplateType = templateType, TemplateType = templateType,
@@ -127,4 +127,4 @@ public static class IServiceCollectionExtensions
return services; return services;
} }
} }
+1 -1
View File
@@ -3,4 +3,4 @@
public interface IServiceFactory public interface IServiceFactory
{ {
TService Create<TService>(params object?[] parameters); TService Create<TService>(params object?[] parameters);
} }
+3 -3
View File
@@ -1,8 +1,8 @@
namespace Hyperbar; namespace Hyperbar;
public class ServiceFactory(Func<Type, object?[], object> factory) : public class ServiceFactory(Func<Type, object?[], object> factory) :
IServiceFactory IServiceFactory
{ {
public TService Create<TService>(params object?[] parameters) => public TService Create<TService>(params object?[] parameters) =>
(TService)factory(typeof(TService), parameters); (TService)factory(typeof(TService), parameters);
} }
+1 -1
View File
@@ -17,4 +17,4 @@ public class AppService(IEnumerable<IInitializer> initializers) :
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
-1
View File
@@ -7,5 +7,4 @@ public interface IInitializer
public interface IDataTemplateSelector public interface IDataTemplateSelector
{ {
} }
+1 -1
View File
@@ -5,4 +5,4 @@ namespace Hyperbar;
public interface IWidgetBuilder public interface IWidgetBuilder
{ {
void Create(IServiceCollection services); void Create(IServiceCollection services);
} }
+1 -1
View File
@@ -3,4 +3,4 @@
public interface IWidgetContext public interface IWidgetContext
{ {
IServiceProvider ServiceProvider { get; } IServiceProvider ServiceProvider { get; }
} }
@@ -1,7 +1,7 @@
namespace Hyperbar; namespace Hyperbar;
public class CommandClassHandlerWrapper<TRequest, TResponse> public class CommandClassHandlerWrapper<TRequest, TResponse>
where TRequest : where TRequest :
class, class,
ICommand<TResponse> ICommand<TResponse>
{ {
@@ -16,7 +16,7 @@ public class CommandClassHandlerWrapper<TRequest, TResponse>
{ {
MessageHandlerDelegate<TRequest, TResponse> handlerCopy = handler; MessageHandlerDelegate<TRequest, TResponse> handlerCopy = handler;
IPipelineBehavior<TRequest, TResponse> pipelineCopy = pipeline; IPipelineBehavior<TRequest, TResponse> pipelineCopy = pipeline;
handler = (TRequest message, CancellationToken cancellationToken) => handler = (TRequest message, CancellationToken cancellationToken) =>
pipelineCopy.Handle(message, handlerCopy, cancellationToken); pipelineCopy.Handle(message, handlerCopy, cancellationToken);
} }
@@ -24,4 +24,4 @@ public class CommandClassHandlerWrapper<TRequest, TResponse>
} }
public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) => handler(request, cancellationToken); public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) => handler(request, cancellationToken);
} }
+1 -2
View File
@@ -2,5 +2,4 @@
public interface ICommand : ICommand<Unit>; public interface ICommand : ICommand<Unit>;
public interface ICommand<out TResponse> : IMessage; public interface ICommand<out TResponse> : IMessage;
+18 -5
View File
@@ -1,13 +1,26 @@
namespace Hyperbar; namespace Hyperbar;
public record KeyAcceleratorCommand(string Key, string[]? Modifiers = null) :
ICommand;
public class KeyAcceleratorCommandHanler :
ICommandHandler<KeyAcceleratorCommand>
{
public ValueTask<Unit> Handle(KeyAcceleratorCommand command,
CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
public interface ICommandHandler<in TCommand> : ICommandHandler<TCommand, Unit> public interface ICommandHandler<in TCommand> : ICommandHandler<TCommand, Unit>
where TCommand : where TCommand :
ICommand<Unit>; ICommand<Unit>;
public interface ICommandHandler<in TCommand, TResponse> public interface ICommandHandler<in TCommand, TResponse>
where TCommand : where TCommand :
ICommand<TResponse> ICommand<TResponse>
{ {
ValueTask<TResponse> Handle(TCommand command, ValueTask<TResponse> Handle(TCommand command,
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }
+6 -7
View File
@@ -2,9 +2,9 @@
public interface IMediator public interface IMediator
{ {
ValueTask Publish<TNotification>(TNotification notification, ValueTask Publish<TNotification>(TNotification notification,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
where TNotification : where TNotification :
INotification; INotification;
ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request,
@@ -13,12 +13,11 @@ public interface IMediator
ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
ValueTask<object?> Send(object message, CancellationToken ValueTask<object?> Send(object message, CancellationToken
cancellationToken = default); cancellationToken = default);
void Subscribe(object subscriber); void Subscribe(object subscriber);
} }
+1 -2
View File
@@ -1,4 +1,3 @@
namespace Hyperbar; namespace Hyperbar;
public interface IMessage; public interface IMessage;
+1 -2
View File
@@ -1,4 +1,3 @@
namespace Hyperbar; namespace Hyperbar;
public interface INotification : IMessage; public interface INotification : IMessage;
+4 -5
View File
@@ -1,10 +1,9 @@
namespace Hyperbar; namespace Hyperbar;
public interface INotificationHandler<in TNotification> public interface INotificationHandler<in TNotification>
where TNotification : where TNotification :
INotification INotification
{ {
ValueTask Handle(TNotification notification, ValueTask Handle(TNotification notification,
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }
+4 -5
View File
@@ -1,12 +1,11 @@
namespace Hyperbar; namespace Hyperbar;
public interface IPipelineBehavior<TMessage, TResponse> public interface IPipelineBehavior<TMessage, TResponse>
where TMessage : where TMessage :
notnull, notnull,
IMessage IMessage
{ {
ValueTask<TResponse> Handle(TMessage message, ValueTask<TResponse> Handle(TMessage message,
MessageHandlerDelegate<TMessage, TResponse> next, MessageHandlerDelegate<TMessage, TResponse> next,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
} }
+1 -1
View File
@@ -1,3 +1,3 @@
namespace Hyperbar; namespace Hyperbar;
public interface IQuery<out TResponse> : IMessage; public interface IQuery<out TResponse> : IMessage;
+3 -3
View File
@@ -1,9 +1,9 @@
namespace Hyperbar; namespace Hyperbar;
public interface IQueryHandler<in TQuery, TResponse> public interface IQueryHandler<in TQuery, TResponse>
where TQuery : where TQuery :
IQuery<TResponse> IQuery<TResponse>
{ {
ValueTask<TResponse> Handle(TQuery query, ValueTask<TResponse> Handle(TQuery query,
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }
+1 -1
View File
@@ -2,4 +2,4 @@
public interface IRequest<out TResponse> : IMessage; public interface IRequest<out TResponse> : IMessage;
public interface IRequest : IRequest<Unit>; public interface IRequest : IRequest<Unit>;
+5 -6
View File
@@ -4,14 +4,13 @@ public interface IRequestHandler<in TRequest, TResponse>
where TRequest : where TRequest :
IRequest<TResponse> IRequest<TResponse>
{ {
ValueTask<TResponse> Handle(TRequest request, ValueTask<TResponse> Handle(TRequest request,
CancellationToken cancellationToken); CancellationToken cancellationToken);
} }
public interface IRequestHandler<in TRequest> : public interface IRequestHandler<in TRequest> :
IRequestHandler<TRequest, Unit> IRequestHandler<TRequest, Unit>
where TRequest : where TRequest :
IRequest<Unit> IRequest<Unit>
{ {
}
}
+9 -9
View File
@@ -3,17 +3,17 @@ using System.Runtime.CompilerServices;
namespace Hyperbar; namespace Hyperbar;
public class Mediator(IServiceProvider provider) : public class Mediator(IServiceProvider provider) :
IMediator IMediator
{ {
private readonly ConditionalWeakTable<Type, dynamic> handlers = []; private readonly ConditionalWeakTable<Type, dynamic> handlers = [];
public ValueTask Publish<TNotification>(TNotification notification, public ValueTask Publish<TNotification>(TNotification notification,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
where TNotification : where TNotification :
INotification INotification
{ {
List<INotificationHandler<TNotification>> handlers = List<INotificationHandler<TNotification>> handlers =
provider.GetServices<INotificationHandler<TNotification>>().ToList(); provider.GetServices<INotificationHandler<TNotification>>().ToList();
foreach (KeyValuePair<Type, dynamic> handler in this.handlers) foreach (KeyValuePair<Type, dynamic> handler in this.handlers)
@@ -36,7 +36,7 @@ public class Mediator(IServiceProvider provider) :
return default; return default;
} }
public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
dynamic? handler = provider.GetService(typeof(RequestClassHandlerWrapper<,>) dynamic? handler = provider.GetService(typeof(RequestClassHandlerWrapper<,>)
@@ -50,7 +50,7 @@ public class Mediator(IServiceProvider provider) :
return default; return default;
} }
public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
dynamic? handler = provider.GetService(typeof(CommandClassHandlerWrapper<,>) dynamic? handler = provider.GetService(typeof(CommandClassHandlerWrapper<,>)
@@ -64,7 +64,7 @@ public class Mediator(IServiceProvider provider) :
return default; return default;
} }
public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
dynamic? handler = provider.GetService(typeof(QueryClassHandlerWrapper<,>) dynamic? handler = provider.GetService(typeof(QueryClassHandlerWrapper<,>)
@@ -146,4 +146,4 @@ public class Mediator(IServiceProvider provider) :
} }
} }
} }
} }
+1 -1
View File
@@ -4,4 +4,4 @@ public delegate ValueTask<TResponse> MessageHandlerDelegate<TMessage, TResponse>
CancellationToken cancellationToken) CancellationToken cancellationToken)
where TMessage : where TMessage :
notnull, notnull,
IMessage; IMessage;
@@ -1,7 +1,7 @@
namespace Hyperbar; namespace Hyperbar;
public class QueryClassHandlerWrapper<TRequest, TResponse> public class QueryClassHandlerWrapper<TRequest, TResponse>
where TRequest : where TRequest :
class, class,
IQuery<TResponse> IQuery<TResponse>
{ {
@@ -25,4 +25,4 @@ public class QueryClassHandlerWrapper<TRequest, TResponse>
public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) => public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) =>
handler(request, cancellationToken); handler(request, cancellationToken);
} }
@@ -1,8 +1,8 @@
namespace Hyperbar; namespace Hyperbar;
public class RequestClassHandlerWrapper<TRequest, TResponse> public class RequestClassHandlerWrapper<TRequest, TResponse>
where TRequest : where TRequest :
class, class,
IRequest<TResponse> IRequest<TResponse>
{ {
private readonly MessageHandlerDelegate<TRequest, TResponse> handler; private readonly MessageHandlerDelegate<TRequest, TResponse> handler;
@@ -16,7 +16,7 @@ public class RequestClassHandlerWrapper<TRequest, TResponse>
MessageHandlerDelegate<TRequest, TResponse> handlerCopy = handler; MessageHandlerDelegate<TRequest, TResponse> handlerCopy = handler;
IPipelineBehavior<TRequest, TResponse> pipelineCopy = pipeline; IPipelineBehavior<TRequest, TResponse> pipelineCopy = pipeline;
handler = (TRequest message, CancellationToken cancellationToken) => handler = (TRequest message, CancellationToken cancellationToken) =>
pipelineCopy.Handle(message, handlerCopy, cancellationToken); pipelineCopy.Handle(message, handlerCopy, cancellationToken);
} }
@@ -24,4 +24,4 @@ public class RequestClassHandlerWrapper<TRequest, TResponse>
} }
public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) => handler(request, cancellationToken); public ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken) => handler(request, cancellationToken);
} }
+4 -5
View File
@@ -1,8 +1,8 @@
namespace Hyperbar; namespace Hyperbar;
public readonly struct Unit : public readonly struct Unit :
IEquatable<Unit>, IEquatable<Unit>,
IComparable<Unit>, IComparable<Unit>,
IComparable IComparable
{ {
private static readonly Unit value = new(); private static readonly Unit value = new();
@@ -26,5 +26,4 @@ public readonly struct Unit :
public static bool operator !=(Unit _, Unit __) => false; public static bool operator !=(Unit _, Unit __) => false;
public override string ToString() => "()"; public override string ToString() => "()";
} }
@@ -8,5 +8,4 @@ public record ContentTemplateDescriptor :
public required Type TemplateType { get; set; } public required Type TemplateType { get; set; }
public required object Key { get; set; } public required object Key { get; set; }
} }
@@ -7,5 +7,4 @@ public interface IContentTemplateDescriptor
object Key { get; set; } object Key { get; set; }
Type TemplateType { get; set; } Type TemplateType { get; set; }
} }
+1 -1
View File
@@ -3,4 +3,4 @@
public interface ITemplateFactory public interface ITemplateFactory
{ {
object? Create(object key); object? Create(object key);
} }
+1 -1
View File
@@ -3,4 +3,4 @@
public interface ITemplatedViewModel public interface ITemplatedViewModel
{ {
ITemplateFactory TemplateFactory { get; } ITemplateFactory TemplateFactory { get; }
} }
@@ -2,5 +2,4 @@
public interface IWidgetComponentViewModel public interface IWidgetComponentViewModel
{ {
} }
+1 -2
View File
@@ -2,5 +2,4 @@
public interface IWidgetView public interface IWidgetView
{ {
}
}
+1 -2
View File
@@ -2,5 +2,4 @@
public interface IWidgetViewModel public interface IWidgetViewModel
{ {
}
}
@@ -13,7 +13,7 @@ public class ObservableCollectionViewModel<TItem>(IServiceFactory serviceFactory
return item; return item;
} }
public TItem Add<T>(params object?[] parameters) public TItem Add<T>(params object?[] parameters)
where T : TItem where T : TItem
{ {
T? item = serviceFactory.Create<T>(parameters); T? item = serviceFactory.Create<T>(parameters);
@@ -44,5 +44,4 @@ public class ObservableCollectionViewModel<TItem>(IServiceFactory serviceFactory
public class ObservableCollectionViewModel(IServiceFactory serviceFactory) : public class ObservableCollectionViewModel(IServiceFactory serviceFactory) :
ObservableCollectionViewModel<object>(serviceFactory) ObservableCollectionViewModel<object>(serviceFactory)
{ {
}
}
+1 -1
View File
@@ -22,4 +22,4 @@ public partial class WidgetButtonViewModel :
click = new RelayCommand(action); click = new RelayCommand(action);
} }
} }
} }
@@ -8,4 +8,4 @@ public partial class WidgetComponentViewModelBase(ITemplateFactory templateFacto
ITemplatedViewModel ITemplatedViewModel
{ {
public ITemplateFactory TemplateFactory => templateFactory; public ITemplateFactory TemplateFactory => templateFactory;
} }
+1 -1
View File
@@ -7,4 +7,4 @@ public class WidgetViewModelBase(ITemplateFactory templateFactory,
ITemplatedViewModel ITemplatedViewModel
{ {
public ITemplateFactory TemplateFactory => templateFactory; public ITemplateFactory TemplateFactory => templateFactory;
} }