Add project files.
@@ -0,0 +1,56 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
|
||||
public class DesktopFlyout :
|
||||
DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ContentProperty =
|
||||
DependencyProperty.Register(nameof(Content),
|
||||
typeof(object), typeof(DesktopFlyout),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty PlacementProperty =
|
||||
DependencyProperty.Register(nameof(Placement),
|
||||
typeof(DesktopFlyoutPlacement), typeof(DesktopFlyout),
|
||||
new PropertyMetadata(DesktopFlyoutPlacement.Left, OnPlacementPropertyChanged));
|
||||
|
||||
private readonly DesktopFlyoutHost host;
|
||||
private readonly DesktopFlyoutPresenter presenter;
|
||||
|
||||
public DesktopFlyout()
|
||||
{
|
||||
presenter = new DesktopFlyoutPresenter
|
||||
{
|
||||
Parent = this
|
||||
};
|
||||
|
||||
host = new DesktopFlyoutHost(presenter);
|
||||
host.Activate();
|
||||
}
|
||||
|
||||
public object Content
|
||||
{
|
||||
get => GetValue(ContentProperty);
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public DesktopFlyoutPlacement Placement
|
||||
{
|
||||
get => (DesktopFlyoutPlacement)GetValue(PlacementProperty);
|
||||
set => SetValue(PlacementProperty, value);
|
||||
}
|
||||
|
||||
private static void OnPlacementPropertyChanged(DependencyObject dependencyObject,
|
||||
DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (dependencyObject is DesktopFlyout sender)
|
||||
{
|
||||
sender.OnPlacementPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlacementPropertyChanged() => UpdatePlacement();
|
||||
|
||||
private void UpdatePlacement() => host.UpdatePlacement(Placement);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Hyperbar.Desktop.Win32;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.Foundation;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
|
||||
internal class DesktopFlyoutHost : Window
|
||||
{
|
||||
private readonly DesktopFlyoutPresenter presenter;
|
||||
private DesktopFlyoutPlacement placement;
|
||||
private Popup popup;
|
||||
|
||||
public DesktopFlyoutHost(DesktopFlyoutPresenter presenter)
|
||||
{
|
||||
Border root = new();
|
||||
root.Loaded += OnLoaded;
|
||||
|
||||
this.presenter = presenter;
|
||||
presenter.SizeChanged += OnChildSizeChanged;
|
||||
|
||||
Content = root;
|
||||
|
||||
this.SetOpacity(0);
|
||||
this.SetStyle(WindowStyle.SysMenu | WindowStyle.Visible);
|
||||
this.SetTopMost(true);
|
||||
this.SetIsShownInSwitchers(false);
|
||||
}
|
||||
|
||||
internal void UpdatePlacement(DesktopFlyoutPlacement placement)
|
||||
{
|
||||
this.placement = placement;
|
||||
|
||||
// Not ready
|
||||
if (popup is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// presenter.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
|
||||
double height = presenter.DesiredSize.Height;
|
||||
double width = presenter.DesiredSize.Width;
|
||||
|
||||
switch (placement)
|
||||
{
|
||||
case DesktopFlyoutPlacement.Left:
|
||||
this.Snap(WindowPlacement.Left, 0, 0);
|
||||
break;
|
||||
case DesktopFlyoutPlacement.Top:
|
||||
this.Snap(WindowPlacement.Top, width, height);
|
||||
break;
|
||||
case DesktopFlyoutPlacement.Right:
|
||||
this.Snap(WindowPlacement.Right, 0, 0);
|
||||
break;
|
||||
case DesktopFlyoutPlacement.Bottom:
|
||||
this.Snap(WindowPlacement.Bottom, width, height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
presenter.TemplateSettings.SetValue(DesktopFlyoutPresenterTemplateSettings.HeightProperty, height);
|
||||
presenter.TemplateSettings.SetValue(DesktopFlyoutPresenterTemplateSettings.WidthProperty, width);
|
||||
|
||||
presenter.TemplateSettings.SetValue(DesktopFlyoutPresenterTemplateSettings.NegativeHeightProperty, -height);
|
||||
presenter.TemplateSettings.SetValue(DesktopFlyoutPresenterTemplateSettings.NegativeWidthProperty, -width);
|
||||
|
||||
presenter.UpdatePlacementState(placement);
|
||||
}
|
||||
|
||||
private void OnChildSizeChanged(object sender,
|
||||
SizeChangedEventArgs args) => UpdatePlacement(this.placement);
|
||||
|
||||
private void OnLoaded(object sender,
|
||||
RoutedEventArgs args)
|
||||
{
|
||||
popup = new Popup
|
||||
{
|
||||
Child = presenter,
|
||||
XamlRoot = Content.XamlRoot,
|
||||
ShouldConstrainToRootBounds = false,
|
||||
IsOpen = true,
|
||||
};
|
||||
|
||||
UpdatePlacement(placement);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
|
||||
public enum DesktopFlyoutPlacement
|
||||
{
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
Bottom
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
|
||||
public class DesktopFlyoutPresenter :
|
||||
ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty TemplateSettingsProperty =
|
||||
DependencyProperty.Register(nameof(TemplateSettings),
|
||||
typeof(DesktopFlyoutPresenterTemplateSettings), typeof(DesktopFlyoutPresenter),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
internal new DesktopFlyout Parent;
|
||||
|
||||
public DesktopFlyoutPresenter()
|
||||
{
|
||||
DefaultStyleKey = typeof(DesktopFlyoutPresenter);
|
||||
TemplateSettings = new DesktopFlyoutPresenterTemplateSettings();
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
SetBinding(ContentProperty, new Binding
|
||||
{
|
||||
Source = Parent,
|
||||
Mode = BindingMode.TwoWay,
|
||||
Path = new PropertyPath(nameof(Parent.Content)),
|
||||
});
|
||||
}
|
||||
|
||||
public DesktopFlyoutPresenterTemplateSettings TemplateSettings
|
||||
{
|
||||
get => (DesktopFlyoutPresenterTemplateSettings)GetValue(TemplateSettingsProperty);
|
||||
set => SetValue(TemplateSettingsProperty, value);
|
||||
}
|
||||
|
||||
internal void UpdatePlacementState(DesktopFlyoutPlacement placement) => VisualStateManager.GoToState(this, $"{placement}Placement", true);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Hyperbar.Desktop.Controls">
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<StaticResource x:Key="CommandBarFlyoutBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="CommandBarFlyoutForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="CommandBarFlyoutBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<StaticResource x:Key="CommandBarFlyoutBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="CommandBarFlyoutForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="CommandBarFlyoutBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<Style TargetType="controls:DesktopFlyoutPresenter">
|
||||
<Setter Property="Background" Value="{ThemeResource CommandBarFlyoutBackground}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource CommandBarFlyoutForeground}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource CommandBarFlyoutBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource CommandBarFlyoutBorderThemeThickness}" />
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DesktopFlyoutPresenter">
|
||||
<Border x:Name="Container">
|
||||
<Border
|
||||
x:Name="BackgroundElement"
|
||||
Height="48"
|
||||
MinWidth="40"
|
||||
Margin="24"
|
||||
Background="{TemplateBinding Background}"
|
||||
BackgroundSizing="InnerBorderEdge"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
FlowDirection="{TemplateBinding FlowDirection}">
|
||||
<Border.Transitions>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition x:Name="EntranceThemeTransition" FromVerticalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.NegativeHeight}" />
|
||||
</TransitionCollection>
|
||||
</Border.Transitions>
|
||||
<ContentControl
|
||||
Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTransitions="{TemplateBinding ContentTransitions}" />
|
||||
</Border>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="PlacementStates">
|
||||
<VisualState x:Name="DefaultPlacement" />
|
||||
<VisualState x:Name="BottomPlacement">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="EntranceThemeTransition.FromHorizontalOffset" Value="0" />
|
||||
<Setter Target="EntranceThemeTransition.FromVerticalOffset" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.Height}" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="TopPlacement">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="EntranceThemeTransition.FromHorizontalOffset" Value="0" />
|
||||
<Setter Target="EntranceThemeTransition.FromVerticalOffset" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.NegativeHeight}" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="LeftPlacement">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="EntranceThemeTransition.FromHorizontalOffset" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.NegativeWidth}" />
|
||||
<Setter Target="EntranceThemeTransition.FromVerticalOffset" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="RightPlacement">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="EntranceThemeTransition.FromHorizontalOffset" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.Width}" />
|
||||
<Setter Target="EntranceThemeTransition.FromVerticalOffset" Value="0" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,49 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
|
||||
public class DesktopFlyoutPresenterTemplateSettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty HeightProperty =
|
||||
DependencyProperty.Register(nameof(Height),
|
||||
typeof(double), typeof(DesktopFlyoutPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty NegativeHeightProperty =
|
||||
DependencyProperty.Register(nameof(NegativeHeight),
|
||||
typeof(double), typeof(DesktopFlyoutPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty NegativeWidthProperty =
|
||||
DependencyProperty.Register(nameof(NegativeWidth),
|
||||
typeof(double), typeof(DesktopFlyoutPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty WidthProperty =
|
||||
DependencyProperty.Register(nameof(Width),
|
||||
typeof(double), typeof(DesktopFlyoutPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public double Height
|
||||
{
|
||||
get => (double)GetValue(HeightProperty);
|
||||
set => SetValue(HeightProperty, value);
|
||||
}
|
||||
public double NegativeHeight
|
||||
{
|
||||
get => (double)GetValue(NegativeHeightProperty);
|
||||
set => SetValue(NegativeHeightProperty, value);
|
||||
}
|
||||
|
||||
public double NegativeWidth
|
||||
{
|
||||
get => (double)GetValue(NegativeWidthProperty);
|
||||
set => SetValue(NegativeWidthProperty, value);
|
||||
}
|
||||
|
||||
public double Width
|
||||
{
|
||||
get => (double)GetValue(WidthProperty);
|
||||
set => SetValue(WidthProperty, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop.Controls</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="CommandFlyout\CommandFlyoutPresenter.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<None Update="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="CommandFlyout\CommandFlyoutPresenter.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Hyperbar.Desktop.Controls/DesktopFlyout/DesktopFlyoutPresenter.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.Graphics.Gdi;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
|
||||
public static class HwndExtensions
|
||||
{
|
||||
[Flags]
|
||||
private enum WindowStyles
|
||||
{
|
||||
WS_EX_LAYERED = 0x80000
|
||||
}
|
||||
|
||||
public static void SetWindowOpacity(this IntPtr hWnd,
|
||||
byte value)
|
||||
{
|
||||
HWND hWND = new(hWnd);
|
||||
WindowStyles windowLong = (WindowStyles)PInvoke.GetWindowLong(hWND, WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE);
|
||||
if (!windowLong.HasFlag(WindowStyles.WS_EX_LAYERED))
|
||||
{
|
||||
PInvoke.SetWindowLong(hWND, WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (int)(windowLong | WindowStyles.WS_EX_LAYERED));
|
||||
}
|
||||
|
||||
if (!PInvoke.SetLayeredWindowAttributes(hWND, 0u, value, LAYERED_WINDOW_ATTRIBUTES_FLAGS.LWA_ALPHA))
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetWindowStyle(this IntPtr hwnd,
|
||||
WindowStyle newStyle)
|
||||
{
|
||||
int windowLong = PInvoke.GetWindowLong(new HWND(hwnd), WINDOW_LONG_PTR_INDEX.GWL_STYLE);
|
||||
if (PInvoke.SetWindowLong(new HWND(hwnd), WINDOW_LONG_PTR_INDEX.GWL_STYLE, (int)newStyle) != windowLong)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
|
||||
}
|
||||
|
||||
PInvoke.SetWindowPos(new HWND(hwnd), new HWND(0), 0, 0, 0, 0, SET_WINDOW_POS_FLAGS.SWP_DRAWFRAME | SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOOWNERZORDER | SET_WINDOW_POS_FLAGS.SWP_NOSIZE | SET_WINDOW_POS_FLAGS.SWP_NOZORDER);
|
||||
}
|
||||
|
||||
public static void SnapWindow(this IntPtr hwnd,
|
||||
WindowPlacement placement,
|
||||
double? width = null,
|
||||
double? height = null)
|
||||
{
|
||||
HMONITOR hwndDesktop = PInvoke.MonitorFromWindow(new(hwnd), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
|
||||
MONITORINFO info = new()
|
||||
{
|
||||
cbSize = 40
|
||||
};
|
||||
|
||||
PInvoke.GetMonitorInfo(hwndDesktop, ref info);
|
||||
|
||||
uint dpi = PInvoke.GetDpiForWindow(new HWND(hwnd));
|
||||
PInvoke.GetWindowRect(new HWND(hwnd), out RECT windowRect);
|
||||
|
||||
double scalingFactor = dpi / 96d;
|
||||
int actualWidth = width.HasValue ? (int)(width * scalingFactor) : windowRect.right - windowRect.left;
|
||||
int actualHeight = height.HasValue ? (int)(height * scalingFactor) : windowRect.bottom - windowRect.top;
|
||||
|
||||
int left = 0;
|
||||
int top = 0;
|
||||
|
||||
switch (placement)
|
||||
{
|
||||
case WindowPlacement.Left:
|
||||
left = 0;
|
||||
top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2;
|
||||
break;
|
||||
case WindowPlacement.Top:
|
||||
left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2;
|
||||
top = 0;
|
||||
break;
|
||||
case WindowPlacement.Right:
|
||||
left = info.rcWork.left + info.rcWork.right - actualWidth;
|
||||
top = (info.rcWork.bottom + info.rcWork.top) / 2 - actualHeight / 2;
|
||||
break;
|
||||
case WindowPlacement.Bottom:
|
||||
left = (info.rcWork.left + info.rcWork.right) / 2 - actualWidth / 2;
|
||||
top = info.rcWork.bottom + info.rcWork.top - actualHeight;
|
||||
break;
|
||||
}
|
||||
|
||||
PInvoke.SetWindowPos(new HWND(hwnd), new HWND(), left, top, actualWidth, actualHeight, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using Windows.UI.Popups;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
|
||||
public static class WindowExtensions
|
||||
{
|
||||
public static IntPtr GetHandle(this Window window) =>
|
||||
window is not null ? WindowNative.GetWindowHandle(window) : default;
|
||||
|
||||
public static void SetIsShownInSwitchers(this Window window,
|
||||
bool value) => window.AppWindow.IsShownInSwitchers = value;
|
||||
|
||||
public static void SetOpacity(this Window window,
|
||||
byte value) => window.GetHandle().SetWindowOpacity(value);
|
||||
|
||||
public static void SetStyle(this Window window,
|
||||
WindowStyle style) => window.GetHandle().SetWindowStyle(style);
|
||||
|
||||
public static void SetTopMost(this Window window,
|
||||
bool value)
|
||||
{
|
||||
AppWindow appWindow = window.AppWindow;
|
||||
if (appWindow.Presenter is OverlappedPresenter presenter)
|
||||
{
|
||||
presenter.IsAlwaysOnTop = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Snap(this Window window,
|
||||
WindowPlacement placement,
|
||||
double? width = null,
|
||||
double? height = null) => window.GetHandle().SnapWindow(placement, width, height);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
|
||||
public enum WindowPlacement
|
||||
{
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
Bottom
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
|
||||
[Flags]
|
||||
public enum WindowStyle
|
||||
{
|
||||
Border = 0x800000,
|
||||
Caption = 0xC00000,
|
||||
Child = 0x40000000,
|
||||
ChildWindow = 0x40000000,
|
||||
ChildChildren = 0x2000000,
|
||||
ClipSiblings = 0x4000000,
|
||||
Disabled = 0x8000000,
|
||||
DlgFrame = 0x400000,
|
||||
Group = 0x20000,
|
||||
HScroll = 0x100000,
|
||||
Iconic = 0x20000000,
|
||||
Maximize = 0x1000000,
|
||||
MaximizeBox = 0x10000,
|
||||
Minimize = 0x20000000,
|
||||
MinimizeBox = 0x20000,
|
||||
Overlapped = 0,
|
||||
OverlappedWindow = 0xCF0000,
|
||||
SizeBox = 0x40000,
|
||||
SysMenu = 0x80000,
|
||||
TabStop = 0x10000,
|
||||
ThickFrame = 0x40000,
|
||||
Tiled = 0,
|
||||
TiledWindow = 0xCF0000,
|
||||
Visible = 0x10000000,
|
||||
VScroll = 0x200000
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop.Win32</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.506-beta">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,507 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace Windows.Win32
|
||||
{
|
||||
/// <content>
|
||||
/// Contains extern methods from "Shell32.dll".
|
||||
/// </content>
|
||||
internal static partial class PInvoke
|
||||
{
|
||||
/// <inheritdoc cref = "SHAppBarMessage(uint, APPBARDATA32*)"/>
|
||||
internal static unsafe nuint SHAppBarMessage(uint dwMessage, ref APPBARDATA32 pData)
|
||||
{
|
||||
fixed (APPBARDATA32* pDataLocal = &pData)
|
||||
{
|
||||
nuint __result = PInvoke.SHAppBarMessage(dwMessage, pDataLocal);
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
/// <inheritdoc cref = "SHAppBarMessage(uint, APPBARDATA64*)"/>
|
||||
internal static unsafe nuint SHAppBarMessage(uint dwMessage, ref APPBARDATA64 pData)
|
||||
{
|
||||
fixed (APPBARDATA64* pDataLocal = &pData)
|
||||
{
|
||||
nuint __result = PInvoke.SHAppBarMessage(dwMessage, pDataLocal);
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sends an appbar message to the system.</summary>
|
||||
/// <param name="dwMessage">Type: <b>DWORD</b></param>
|
||||
/// <param name="pData">
|
||||
/// <para>Type: <b>PAPPBARDATA</b></para>
|
||||
/// <para>A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/ns-shellapi-appbardata">APPBARDATA</a> structure. The content of the structure on entry and on exit depends on the value set in the <i>dwMessage</i> parameter. See the individual message pages for specifics.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shappbarmessage#parameters">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <para>Type: <b>UINT_PTR</b></para>
|
||||
/// <para>This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar message sent. Links to those documents are given in the See Also section.</para>
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shappbarmessage">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[DllImport("Shell32", ExactSpelling = true)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||
internal static extern unsafe nuint SHAppBarMessage(uint dwMessage, APPBARDATA32* pData);
|
||||
|
||||
/// <summary>Sends an appbar message to the system.</summary>
|
||||
/// <param name="dwMessage">Type: <b>DWORD</b></param>
|
||||
/// <param name="pData">
|
||||
/// <para>Type: <b>PAPPBARDATA</b></para>
|
||||
/// <para>A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/ns-shellapi-appbardata">APPBARDATA</a> structure. The content of the structure on entry and on exit depends on the value set in the <i>dwMessage</i> parameter. See the individual message pages for specifics.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shappbarmessage#parameters">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <para>Type: <b>UINT_PTR</b></para>
|
||||
/// <para>This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar message sent. Links to those documents are given in the See Also section.</para>
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shappbarmessage">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[DllImport("Shell32", ExactSpelling = true)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||
internal static extern unsafe nuint SHAppBarMessage(uint dwMessage, APPBARDATA64* pData);
|
||||
|
||||
/// <inheritdoc cref = "Shell_NotifyIcon(uint, NOTIFYICONDATAW32*)"/>
|
||||
internal static unsafe bool Shell_NotifyIcon(uint dwMessage, in NOTIFYICONDATAW32 lpData)
|
||||
{
|
||||
fixed (NOTIFYICONDATAW32* lpDataLocal = &lpData)
|
||||
{
|
||||
bool __result = PInvoke.Shell_NotifyIcon(dwMessage, lpDataLocal);
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
/// <inheritdoc cref = "Shell_NotifyIcon(uint, NOTIFYICONDATAW32*)"/>
|
||||
internal static unsafe bool Shell_NotifyIcon(uint dwMessage, in NOTIFYICONDATAW64 lpData)
|
||||
{
|
||||
fixed (NOTIFYICONDATAW64* lpDataLocal = &lpData)
|
||||
{
|
||||
bool __result = PInvoke.Shell_NotifyIcon(dwMessage, lpDataLocal);
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sends a message to the taskbar's status area.</summary>
|
||||
/// <param name="dwMessage">Type: <b>DWORD</b></param>
|
||||
/// <param name="lpData">
|
||||
/// <para>Type: <b>PNOTIFYICONDATA</b></para>
|
||||
/// <para>A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/ns-shellapi-notifyicondataa">NOTIFYICONDATA</a> structure. The content of the structure depends on the value of <i>dwMessage</i>. It can define an icon to add to the notification area, cause that icon to display a notification, or identify an icon to modify or delete.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shell_notifyiconw#parameters">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <para>Type: <b>BOOL</b></para>
|
||||
/// <para>Returns <b>TRUE</b> if successful, or <b>FALSE</b> otherwise. If <i>dwMessage</i> is set to NIM_SETVERSION, the function returns <b>TRUE</b> if the version was successfully changed, or <b>FALSE</b> if the requested version is not supported.</para>
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shell_notifyiconw">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[DllImport("Shell32", ExactSpelling = true, EntryPoint = "Shell_NotifyIconW")]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||
internal static extern unsafe bool Shell_NotifyIcon(uint dwMessage, NOTIFYICONDATAW32* lpData);
|
||||
|
||||
/// <summary>Sends a message to the taskbar's status area.</summary>
|
||||
/// <param name="dwMessage">Type: <b>DWORD</b></param>
|
||||
/// <param name="lpData">
|
||||
/// <para>Type: <b>PNOTIFYICONDATA</b></para>
|
||||
/// <para>A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/shellapi/ns-shellapi-notifyicondataa">NOTIFYICONDATA</a> structure. The content of the structure depends on the value of <i>dwMessage</i>. It can define an icon to add to the notification area, cause that icon to display a notification, or identify an icon to modify or delete.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shell_notifyiconw#parameters">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <para>Type: <b>BOOL</b></para>
|
||||
/// <para>Returns <b>TRUE</b> if successful, or <b>FALSE</b> otherwise. If <i>dwMessage</i> is set to NIM_SETVERSION, the function returns <b>TRUE</b> if the version was successfully changed, or <b>FALSE</b> if the requested version is not supported.</para>
|
||||
/// </returns>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/nf-shellapi-shell_notifyiconw">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[DllImport("Shell32", ExactSpelling = true, EntryPoint = "Shell_NotifyIconW")]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||
internal static extern unsafe bool Shell_NotifyIcon(uint dwMessage, NOTIFYICONDATAW64* lpData);
|
||||
}
|
||||
|
||||
/// <summary>Contains information about a system appbar message.</summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
internal partial struct APPBARDATA32
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Type: <b>DWORD</b></para>
|
||||
/// <para>The size of the structure, in bytes.</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>
|
||||
internal uint cbSize;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HWND hWnd;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint uCallbackMessage;
|
||||
/// <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>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>
|
||||
/// </summary>
|
||||
internal uint uEdge;
|
||||
/// <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></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>
|
||||
/// </summary>
|
||||
internal RECT rc;
|
||||
/// <summary>
|
||||
/// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </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>
|
||||
/// </summary>
|
||||
internal LPARAM lParam;
|
||||
}
|
||||
|
||||
/// <summary>Contains information about a system appbar message.</summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata">Learn more about this API from docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
internal partial struct APPBARDATA64
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Type: <b>DWORD</b></para>
|
||||
/// <para>The size of the structure, in bytes.</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>
|
||||
internal uint cbSize;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HWND hWnd;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-appbardata#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint uCallbackMessage;
|
||||
/// <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>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>
|
||||
/// </summary>
|
||||
internal uint uEdge;
|
||||
/// <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></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>
|
||||
/// </summary>
|
||||
internal RECT rc;
|
||||
/// <summary>
|
||||
/// <para>Type: <b>LPARAM</b> A message-dependent value. This member is used with these messages: </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>
|
||||
/// </summary>
|
||||
internal LPARAM lParam;
|
||||
}
|
||||
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;
|
||||
/// <summary>Always <c>128</c>.</summary>
|
||||
internal int Length => 128;
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal ref ushort this[int index] => ref AsSpan()[index];
|
||||
/// <summary>
|
||||
/// Gets this inline array as a span.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned span outlive the stack frame that defines it.
|
||||
/// </remarks>
|
||||
internal Span<ushort> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 128);
|
||||
}
|
||||
|
||||
/// <summary>Contains information that the system needs to display notifications in the notification area. Used by Shell_NotifyIcon.</summary>
|
||||
/// <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>If you set the <b>NIF_INFO</b> flag in the <b>uFlags</b> member, the balloon-style notification is used. For more discussion of these notifications, see <a href="https://docs.microsoft.com/windows/desktop/Controls/using-tooltip-contro">Balloon tooltips</a>.</para>
|
||||
/// <para>No more than one balloon notification at a time can be displayed for the taskbar. If an application attempts to display a notification when one is already being displayed, the new notification is queued and displayed when the older notification goes away. In versions of Windows before Windows Vista, the new notification would not appear until the existing notification has been visible for at least the system minimum timeout length, regardless of the original notification's <b>uTimeout</b> value. If the user does not appear to be using the computer, the system does not count this time toward the timeout.</para>
|
||||
/// <para>Several members of this structure are only supported for Windows 2000 and later. To enable these members, include one of the following lines in your header:</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
internal partial struct NOTIFYICONDATAW32
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Type: <b>DWORD</b></para>
|
||||
/// <para>The size of this structure, in bytes.</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>
|
||||
internal uint cbSize;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HWND hWnd;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint uID;
|
||||
/// <summary>Type: <b>UINT</b></summary>
|
||||
internal uint uFlags;
|
||||
/// <summary>
|
||||
/// <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>When the <b>uVersion</b> member is either 0 or NOTIFYICON_VERSION, the <i>wParam</i> parameter of the message contains the identifier of the taskbar icon in which the event occurred. This identifier can be 32 bits in length. The <i>lParam</i> parameter holds the mouse or keyboard message associated with the event. For example, when the pointer moves over a taskbar icon, <i>lParam</i> is set to <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-mousemove">WM_MOUSEMOVE</a>.</para>
|
||||
/// <para>When the <b>uVersion</b> member is NOTIFYICON_VERSION_4, applications continue to receive notification events in the form of application-defined messages through the <b>uCallbackMessage</b> member, but the interpretation of the <i>lParam</i> and <i>wParam</i> parameters of that message is changed as follows:</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</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>
|
||||
internal uint uCallbackMessage;
|
||||
/// <summary>
|
||||
/// <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>If only a 16x16 pixel icon is provided, it is scaled to a larger size in a system set to a high dpi value. This can lead to an unattractive result. It is recommended that you provide both a 16x16 pixel icon and a 32x32 icon in your resource file. Use <a href="https://docs.microsoft.com/windows/desktop/api/commctrl/nf-commctrl-loadiconmetric">LoadIconMetric</a> to ensure that the correct icon is loaded and scaled appropriately. See Remarks for a code example.</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>
|
||||
internal HICON hIcon;
|
||||
/// <summary>
|
||||
/// <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>For Windows 2000 and later, <b>szTip</b> can have a maximum of 128 characters, including the terminating null character.</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>
|
||||
internal __ushort_128 szTip;
|
||||
/// <summary>Type: <b>DWORD</b></summary>
|
||||
internal uint dwState;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint dwStateMask;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal __ushort_256 szInfo;
|
||||
internal _Anonymous_e__Union Anonymous;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal __ushort_64 szInfoTitle;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint dwInfoFlags;
|
||||
/// <summary>
|
||||
/// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</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>
|
||||
internal global::System.Guid guidItem;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HICON hBalloonIcon;
|
||||
|
||||
|
||||
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;
|
||||
/// <summary>Always <c>256</c>.</summary>
|
||||
internal int Length => 256;
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal ref ushort this[int index] => ref AsSpan()[index];
|
||||
/// <summary>
|
||||
/// Gets this inline array as a span.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned span outlive the stack frame that defines it.
|
||||
/// </remarks>
|
||||
internal Span<ushort> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 256);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 1)]
|
||||
internal partial struct _Anonymous_e__Union
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal uint uTimeout;
|
||||
[FieldOffset(0)]
|
||||
internal uint uVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
/// <summary>Always <c>64</c>.</summary>
|
||||
internal int Length => 64;
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal ref ushort this[int index] => ref AsSpan()[index];
|
||||
/// <summary>
|
||||
/// Gets this inline array as a span.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned span outlive the stack frame that defines it.
|
||||
/// </remarks>
|
||||
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>
|
||||
/// <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>If you set the <b>NIF_INFO</b> flag in the <b>uFlags</b> member, the balloon-style notification is used. For more discussion of these notifications, see <a href="https://docs.microsoft.com/windows/desktop/Controls/using-tooltip-contro">Balloon tooltips</a>.</para>
|
||||
/// <para>No more than one balloon notification at a time can be displayed for the taskbar. If an application attempts to display a notification when one is already being displayed, the new notification is queued and displayed when the older notification goes away. In versions of Windows before Windows Vista, the new notification would not appear until the existing notification has been visible for at least the system minimum timeout length, regardless of the original notification's <b>uTimeout</b> value. If the user does not appear to be using the computer, the system does not count this time toward the timeout.</para>
|
||||
/// <para>Several members of this structure are only supported for Windows 2000 and later. To enable these members, include one of the following lines in your header:</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</para>
|
||||
/// <para><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </remarks>
|
||||
internal partial struct NOTIFYICONDATAW64
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Type: <b>DWORD</b></para>
|
||||
/// <para>The size of this structure, in bytes.</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>
|
||||
internal uint cbSize;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HWND hWnd;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint uID;
|
||||
/// <summary>Type: <b>UINT</b></summary>
|
||||
internal uint uFlags;
|
||||
/// <summary>
|
||||
/// <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>When the <b>uVersion</b> member is either 0 or NOTIFYICON_VERSION, the <i>wParam</i> parameter of the message contains the identifier of the taskbar icon in which the event occurred. This identifier can be 32 bits in length. The <i>lParam</i> parameter holds the mouse or keyboard message associated with the event. For example, when the pointer moves over a taskbar icon, <i>lParam</i> is set to <a href="https://docs.microsoft.com/windows/desktop/inputdev/wm-mousemove">WM_MOUSEMOVE</a>.</para>
|
||||
/// <para>When the <b>uVersion</b> member is NOTIFYICON_VERSION_4, applications continue to receive notification events in the form of application-defined messages through the <b>uCallbackMessage</b> member, but the interpretation of the <i>lParam</i> and <i>wParam</i> parameters of that message is changed as follows:</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</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>
|
||||
internal uint uCallbackMessage;
|
||||
/// <summary>
|
||||
/// <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>If only a 16x16 pixel icon is provided, it is scaled to a larger size in a system set to a high dpi value. This can lead to an unattractive result. It is recommended that you provide both a 16x16 pixel icon and a 32x32 icon in your resource file. Use <a href="https://docs.microsoft.com/windows/desktop/api/commctrl/nf-commctrl-loadiconmetric">LoadIconMetric</a> to ensure that the correct icon is loaded and scaled appropriately. See Remarks for a code example.</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>
|
||||
internal HICON hIcon;
|
||||
/// <summary>
|
||||
/// <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>For Windows 2000 and later, <b>szTip</b> can have a maximum of 128 characters, including the terminating null character.</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>
|
||||
internal __ushort_128 szTip;
|
||||
/// <summary>Type: <b>DWORD</b></summary>
|
||||
internal uint dwState;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint dwStateMask;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal __ushort_256 szInfo;
|
||||
internal _Anonymous_e__Union Anonymous;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal __ushort_64 szInfoTitle;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal uint dwInfoFlags;
|
||||
/// <summary>
|
||||
/// <para>Type: <b>GUID</b> <b>Windows XP and later</b>.</para>
|
||||
/// <para></para>
|
||||
/// <para>This doc was truncated.</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>
|
||||
internal global::System.Guid guidItem;
|
||||
/// <summary>
|
||||
/// <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><see href="https://docs.microsoft.com/windows/win32/api//shellapi/ns-shellapi-notifyicondataw#members">Read more on docs.microsoft.com</see>.</para>
|
||||
/// </summary>
|
||||
internal HICON hBalloonIcon;
|
||||
|
||||
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;
|
||||
/// <summary>Always <c>256</c>.</summary>
|
||||
internal int Length => 256;
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal ref ushort this[int index] => ref AsSpan()[index];
|
||||
/// <summary>
|
||||
/// Gets this inline array as a span.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned span outlive the stack frame that defines it.
|
||||
/// </remarks>
|
||||
internal Span<ushort> AsSpan() => MemoryMarshal.CreateSpan(ref _0, 256);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal partial struct _Anonymous_e__Union
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
internal uint uTimeout;
|
||||
[FieldOffset(0)]
|
||||
internal uint uVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
FindWindow
|
||||
//SHAppBarMessage
|
||||
SystemParametersInfo
|
||||
//Shell_NotifyIcon
|
||||
CreateWindowEx
|
||||
DefWindowProc
|
||||
RegisterClass
|
||||
RegisterWindowMessage
|
||||
DestroyWindow
|
||||
SetForegroundWindow
|
||||
GetDoubleClickTime
|
||||
GetPhysicalCursorPos
|
||||
GetCursorPos
|
||||
GetActiveWindow
|
||||
GetDpiForWindow
|
||||
SetForegroundWindow
|
||||
GetDpiForWindow
|
||||
SetWindowPos
|
||||
MonitorFromWindow
|
||||
GetWindowRect
|
||||
GetMonitorInfo
|
||||
CreateIcon
|
||||
GetModuleHandle
|
||||
GetDesktopWindow
|
||||
GetClientRect
|
||||
LoadIcon
|
||||
UpdateLayeredWindow
|
||||
SetLayeredWindowAttributes
|
||||
GetDpiForMonitor
|
||||
ShowWindow
|
||||
LoadImage
|
||||
SendMessage
|
||||
SetWindowLong
|
||||
GetWindowLong
|
||||
UpdateLayeredWindow
|
||||
DestroyIcon
|
||||
GetSystemMetrics
|
||||
EnumDisplayMonitors
|
||||
MONITORINFOEXW
|
||||
SetWindowSubclass
|
||||
RemoveWindowSubclass
|
||||
DefSubclassProc
|
||||
GetWindowPlacement
|
||||
SetWindowPlacement
|
||||
D3D11CreateDevice
|
||||
D3D11_SDK_VERSION
|
||||
IDXGIAdapter
|
||||
IDXGIDevice
|
||||
IDXGIFactory2
|
||||
CreateDirect3D11SurfaceFromDXGISurface
|
||||
CreateDispatcherQueueController
|
||||
DwmEnableBlurBehindWindow
|
||||
DwmExtendFrameIntoClientArea
|
||||
CreateRectRgn
|
||||
CreateSolidBrush
|
||||
FillRect
|
||||
GetDC
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Application
|
||||
x:Class="Hyperbar.Desktop.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:desktop="using:Hyperbar.Desktop">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<DataTemplate x:Key="DefaultDataTemplate">
|
||||
<desktop:TemplateGeneratorControl />
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,37 @@
|
||||
using Hyperbar.Desktop.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public partial class App :
|
||||
Application
|
||||
{
|
||||
public App() => InitializeComponent();
|
||||
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
IHost? host = Host.CreateDefaultBuilder()
|
||||
.UseContentRoot(AppContext.BaseDirectory)
|
||||
.ConfigureServices(args =>
|
||||
{
|
||||
args.AddTransient<IInitializer, AppInitializer>();
|
||||
args.AddTransient<DesktopFlyout>();
|
||||
|
||||
args.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
args.AddTransient<ITemplateGeneratorFactory, TemplateGeneratorFactory>();
|
||||
|
||||
args.AddDataTemplate<CommandViewModel, CommandView>("Commands");
|
||||
args.AddDataTemplate<ContextualCommandViewModel, ContextualCommandView>();
|
||||
|
||||
args.AddHostedService<AppService>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
await host.RunAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Hyperbar.Desktop.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class AppInitializer([FromKeyedServices("Commands")] CommandView view,
|
||||
[FromKeyedServices("Commands")] CommandViewModel viewModel,
|
||||
DesktopFlyout desktopFlyout) :
|
||||
IInitializer
|
||||
{
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
view.DataContext = viewModel;
|
||||
|
||||
desktopFlyout.Placement = DesktopFlyoutPlacement.Top;
|
||||
desktopFlyout.Content = view;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 432 B |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 637 B |
|
After Width: | Height: | Size: 283 B |
|
After Width: | Height: | Size: 456 B |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,60 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="ContextualCommandView.xaml" />
|
||||
<None Remove="Views\CommandView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="CommandHostView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="ContextualCommandView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\CommandView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="24ccddba-447f-4d37-891d-523e8d820f45"
|
||||
Publisher="CN=dan_c"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="24ccddba-447f-4d37-891d-523e8d820f45" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Hyperbar.Desktop</DisplayName>
|
||||
<PublisherDisplayName>dan_c</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="Hyperbar.Desktop"
|
||||
Description="Hyperbar.Desktop"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Hyperbar.Desktop (Package)": {
|
||||
"commandName": "MsixPackage"
|
||||
},
|
||||
"Hyperbar.Desktop (Unpackaged)": {
|
||||
"commandName": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop
|
||||
{
|
||||
public interface ITemplateGeneratorFactory
|
||||
{
|
||||
DataTemplate Create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class TemplateFactory(ITemplateGeneratorFactory factory,
|
||||
IEnumerable<IDataTemplateDescriptor> descriptors,
|
||||
IServiceProvider provider) :
|
||||
DataTemplateSelector,
|
||||
ITemplateFactory
|
||||
{
|
||||
protected override DataTemplate SelectTemplateCore(object item) => factory.Create();
|
||||
|
||||
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) => factory.Create();
|
||||
|
||||
public object? Create(object key)
|
||||
{
|
||||
if (descriptors.FirstOrDefault(x => x.Key == key) is IDataTemplateDescriptor descriptor)
|
||||
{
|
||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType, descriptor.Key) is { } template)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class TemplateGeneratorControl :
|
||||
ContentControl
|
||||
{
|
||||
public TemplateGeneratorControl()
|
||||
{
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
}
|
||||
|
||||
private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
|
||||
{
|
||||
if (DataContext is ITemplatedViewModel templatedViewModel)
|
||||
{
|
||||
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class TemplateGeneratorFactory :
|
||||
ITemplateGeneratorFactory
|
||||
{
|
||||
public DataTemplate Create()
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:desktop='using:Hyperbar.Desktop'>
|
||||
<desktop:TemplateGeneratorControl />
|
||||
</DataTemplate>";
|
||||
|
||||
return (DataTemplate)XamlReader.Load(xamlString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Page
|
||||
x:Class="Hyperbar.Desktop.CommandView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ItemsControl ItemTemplateSelector="{Binding TemplateFactory}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
</ItemsControl>
|
||||
</Page>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public sealed partial class CommandView : Page
|
||||
{
|
||||
public CommandView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public partial class CommandViewModel :
|
||||
ObservableCollectionViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public CommandViewModel(ITemplateFactory templateFactory)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
|
||||
this.Add(new ContextualCommandViewModel(templateFactory));
|
||||
this.Add(new ContextualCommandViewModel(templateFactory));
|
||||
this.Add(new ContextualCommandViewModel(templateFactory));
|
||||
this.Add(new ContextualCommandViewModel(templateFactory));
|
||||
this.Add(new ContextualCommandViewModel(templateFactory));
|
||||
|
||||
var d = Items;
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Page
|
||||
x:Class="Hyperbar.Desktop.ContextualCommandView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Hyperbar.Desktop"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Button />
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public sealed partial class ContextualCommandView : Page
|
||||
{
|
||||
public ContextualCommandView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Hyperbar.Desktop;
|
||||
|
||||
public class ContextualCommandViewModel :
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ContextualCommandViewModel(ITemplateFactory templateFactory)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="Hyperbar.Desktop.app"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
|
||||
It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
|
||||
For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop", "Hyperbar.Desktop\Hyperbar.Desktop.csproj", "{5C4824EE-23AB-495C-B55A-1F7C2A489698}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Controls", "Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj", "{48ECC6A3-94FF-405D-9DB5-46A725C1B117}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Win32", "Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj", "{8A4BBC50-970C-4FA8-9F21-0FA63269222F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar", "Hyperbar\Hyperbar.csproj", "{E5795878-C7E3-4386-86FA-33681BCF8D5B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|Any CPU.Deploy.0 = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x64.Build.0 = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x86.Build.0 = Debug|x86
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|Any CPU.Build.0 = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|Any CPU.Deploy.0 = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x64.ActiveCfg = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x64.Build.0 = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x64.Deploy.0 = Release|x64
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x86.ActiveCfg = Release|x86
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x86.Build.0 = Release|x86
|
||||
{5C4824EE-23AB-495C-B55A-1F7C2A489698}.Release|x86.Deploy.0 = Release|x86
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|x64.Build.0 = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{48ECC6A3-94FF-405D-9DB5-46A725C1B117}.Release|x86.Build.0 = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{8A4BBC50-970C-4FA8-9F21-0FA63269222F}.Release|x86.Build.0 = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E5795878-C7E3-4386-86FA-33681BCF8D5B}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {57977BCA-A89A-4D04-A700-3F8044CBA533}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public class ObservableCollectionViewModel :
|
||||
ObservableCollection<object>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class AppService(IEnumerable<IInitializer> initializers) :
|
||||
IHostedService
|
||||
{
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var initializer in initializers)
|
||||
{
|
||||
await initializer.InitializeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public record DataTemplateDescriptor :
|
||||
IDataTemplateDescriptor
|
||||
{
|
||||
public required Type DataType { get; set; }
|
||||
|
||||
public required Type TemplateType { get; set; }
|
||||
|
||||
public required object Key { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IDataTemplateDescriptor
|
||||
{
|
||||
Type DataType { get; set; }
|
||||
object Key { get; set; }
|
||||
Type TemplateType { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IInitializer
|
||||
{
|
||||
Task InitializeAsync();
|
||||
}
|
||||
|
||||
public interface IDataTemplateSelector
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddDataTemplate<TData, TTemplate>(this IServiceCollection services,
|
||||
object? key = null)
|
||||
{
|
||||
Type dataType = typeof(TData);
|
||||
Type templateType = typeof(TTemplate);
|
||||
|
||||
key ??= dataType.Name;
|
||||
|
||||
services.AddKeyedTransient(dataType, key);
|
||||
services.AddKeyedTransient(templateType, key);
|
||||
|
||||
services.AddTransient<IDataTemplateDescriptor>(provider => new DataTemplateDescriptor
|
||||
{
|
||||
DataType = dataType,
|
||||
TemplateType = templateType,
|
||||
Key = key
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface ITemplateFactory
|
||||
{
|
||||
object? Create(object key);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface ITemplatedViewModel
|
||||
{
|
||||
ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||