More work
This commit is contained in:
+12
-12
@@ -2,30 +2,30 @@
|
||||
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
public class DesktopBar :
|
||||
public class DesktopApplicationBar :
|
||||
DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty ContentProperty =
|
||||
DependencyProperty.Register(nameof(Content),
|
||||
typeof(object), typeof(DesktopBar),
|
||||
typeof(object), typeof(DesktopApplicationBar),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty PlacementProperty =
|
||||
DependencyProperty.Register(nameof(Placement),
|
||||
typeof(DesktopBarPlacemenet), typeof(DesktopBar),
|
||||
new PropertyMetadata(DesktopBarPlacemenet.Left, OnPlacementPropertyChanged));
|
||||
typeof(DesktopApplicationBarPlacemenet), typeof(DesktopApplicationBar),
|
||||
new PropertyMetadata(DesktopApplicationBarPlacemenet.Left, OnPlacementPropertyChanged));
|
||||
|
||||
private readonly DesktopBarHost host;
|
||||
private readonly DesktopBarPresenter presenter;
|
||||
private readonly DesktopApplicationBarHost host;
|
||||
private readonly DesktopApplicationBarPresenter presenter;
|
||||
|
||||
public DesktopBar()
|
||||
public DesktopApplicationBar()
|
||||
{
|
||||
presenter = new DesktopBarPresenter
|
||||
presenter = new DesktopApplicationBarPresenter
|
||||
{
|
||||
Parent = this
|
||||
};
|
||||
|
||||
host = new DesktopBarHost(presenter);
|
||||
host = new DesktopApplicationBarHost(presenter);
|
||||
host.Activate();
|
||||
}
|
||||
|
||||
@@ -35,16 +35,16 @@ public class DesktopBar :
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public DesktopBarPlacemenet Placement
|
||||
public DesktopApplicationBarPlacemenet Placement
|
||||
{
|
||||
get => (DesktopBarPlacemenet)GetValue(PlacementProperty);
|
||||
get => (DesktopApplicationBarPlacemenet)GetValue(PlacementProperty);
|
||||
set => SetValue(PlacementProperty, value);
|
||||
}
|
||||
|
||||
private static void OnPlacementPropertyChanged(DependencyObject dependencyObject,
|
||||
DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (dependencyObject is DesktopBar sender)
|
||||
if (dependencyObject is DesktopApplicationBar sender)
|
||||
{
|
||||
sender.OnPlacementPropertyChanged();
|
||||
}
|
||||
+9
-9
@@ -6,13 +6,13 @@ using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
internal class DesktopBarHost : Window
|
||||
internal class DesktopApplicationBarHost : Window
|
||||
{
|
||||
private readonly DesktopBarPresenter presenter;
|
||||
private readonly DesktopApplicationBarPresenter presenter;
|
||||
private readonly WindowSnapping windowSnapping;
|
||||
private DesktopBarPlacemenet placement;
|
||||
private DesktopApplicationBarPlacemenet placement;
|
||||
|
||||
public DesktopBarHost(DesktopBarPresenter presenter)
|
||||
public DesktopApplicationBarHost(DesktopApplicationBarPresenter presenter)
|
||||
{
|
||||
this.SetOpacity(0);
|
||||
this.SetStyle(WindowStyle.SysMenu | WindowStyle.Visible);
|
||||
@@ -31,7 +31,7 @@ internal class DesktopBarHost : Window
|
||||
Closed += OnClosed;
|
||||
}
|
||||
|
||||
internal void UpdatePlacement(DesktopBarPlacemenet placement)
|
||||
internal void UpdatePlacement(DesktopApplicationBarPlacemenet placement)
|
||||
{
|
||||
this.placement = placement;
|
||||
UpdatePlacement();
|
||||
@@ -44,19 +44,19 @@ internal class DesktopBarHost : Window
|
||||
|
||||
switch (placement)
|
||||
{
|
||||
case DesktopBarPlacemenet.Left:
|
||||
case DesktopApplicationBarPlacemenet.Left:
|
||||
windowSnapping.Snap(WindowSnappingPlacement.Left, (int)size);
|
||||
break;
|
||||
|
||||
case DesktopBarPlacemenet.Top:
|
||||
case DesktopApplicationBarPlacemenet.Top:
|
||||
windowSnapping.Snap(WindowSnappingPlacement.Top, (int)size);
|
||||
break;
|
||||
|
||||
case DesktopBarPlacemenet.Right:
|
||||
case DesktopApplicationBarPlacemenet.Right:
|
||||
windowSnapping.Snap(WindowSnappingPlacement.Right, (int)size);
|
||||
break;
|
||||
|
||||
case DesktopBarPlacemenet.Bottom:
|
||||
case DesktopApplicationBarPlacemenet.Bottom:
|
||||
windowSnapping.Snap(WindowSnappingPlacement.Bottom, (int)size);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
public enum DesktopBarPlacemenet
|
||||
public enum DesktopApplicationBarPlacemenet
|
||||
{
|
||||
Left,
|
||||
Top,
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
public class DesktopApplicationBarPresenter :
|
||||
ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty TemplateSettingsProperty =
|
||||
DependencyProperty.Register(nameof(TemplateSettings),
|
||||
typeof(DesktopApplicationBarPresenterTemplateSettings), typeof(DesktopApplicationBarPresenter),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
internal new DesktopApplicationBar? Parent;
|
||||
|
||||
public DesktopApplicationBarPresenter()
|
||||
{
|
||||
DefaultStyleKey = typeof(DesktopApplicationBarPresenter);
|
||||
TemplateSettings = new DesktopApplicationBarPresenterTemplateSettings();
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
SetBinding(ContentProperty, new Binding
|
||||
{
|
||||
Source = Parent,
|
||||
Mode = BindingMode.TwoWay,
|
||||
Path = new PropertyPath(nameof(Parent.Content)),
|
||||
});
|
||||
}
|
||||
|
||||
public DesktopApplicationBarPresenterTemplateSettings TemplateSettings
|
||||
{
|
||||
get => (DesktopApplicationBarPresenterTemplateSettings)GetValue(TemplateSettingsProperty);
|
||||
set => SetValue(TemplateSettingsProperty, value);
|
||||
}
|
||||
|
||||
internal void UpdatePlacementState(DesktopApplicationBarPlacemenet placement) => VisualStateManager.GoToState(this, $"{placement}Placement", true);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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.Controls.Windows">
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="DesktopApplicationBarPresenterBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<Thickness x:Key="DesktopApplicationBarPresenterBorderThemeThickness">0</Thickness>
|
||||
<Style TargetType="controls:DesktopApplicationBarPresenter">
|
||||
<Setter Property="Foreground" Value="{ThemeResource DesktopApplicationBarPresenterForeground}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource DesktopApplicationBarPresenterBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource DesktopApplicationBarPresenterBorderThemeThickness}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DesktopApplicationBarPresenter">
|
||||
<Border
|
||||
MinHeight="48"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BackgroundSizing="OuterBorderEdge"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
FlowDirection="{TemplateBinding FlowDirection}">
|
||||
<ContentControl
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTransitions="{TemplateBinding ContentTransitions}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
+5
-5
@@ -2,26 +2,26 @@
|
||||
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
public class DesktopBarPresenterTemplateSettings : DependencyObject
|
||||
public class DesktopApplicationBarPresenterTemplateSettings : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty HeightProperty =
|
||||
DependencyProperty.Register(nameof(Height),
|
||||
typeof(double), typeof(DesktopBarPresenterTemplateSettings),
|
||||
typeof(double), typeof(DesktopApplicationBarPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty NegativeHeightProperty =
|
||||
DependencyProperty.Register(nameof(NegativeHeight),
|
||||
typeof(double), typeof(DesktopBarPresenterTemplateSettings),
|
||||
typeof(double), typeof(DesktopApplicationBarPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty NegativeWidthProperty =
|
||||
DependencyProperty.Register(nameof(NegativeWidth),
|
||||
typeof(double), typeof(DesktopBarPresenterTemplateSettings),
|
||||
typeof(double), typeof(DesktopApplicationBarPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty WidthProperty =
|
||||
DependencyProperty.Register(nameof(Width),
|
||||
typeof(double), typeof(DesktopBarPresenterTemplateSettings),
|
||||
typeof(double), typeof(DesktopApplicationBarPresenterTemplateSettings),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public double Height
|
||||
@@ -1,40 +0,0 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Hyperbar.Controls.Windows;
|
||||
|
||||
public class DesktopBarPresenter :
|
||||
ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty TemplateSettingsProperty =
|
||||
DependencyProperty.Register(nameof(TemplateSettings),
|
||||
typeof(DesktopBarPresenterTemplateSettings), typeof(DesktopBarPresenter),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
internal new DesktopBar? Parent;
|
||||
|
||||
public DesktopBarPresenter()
|
||||
{
|
||||
DefaultStyleKey = typeof(DesktopBarPresenter);
|
||||
TemplateSettings = new DesktopBarPresenterTemplateSettings();
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
SetBinding(ContentProperty, new Binding
|
||||
{
|
||||
Source = Parent,
|
||||
Mode = BindingMode.TwoWay,
|
||||
Path = new PropertyPath(nameof(Parent.Content)),
|
||||
});
|
||||
}
|
||||
|
||||
public DesktopBarPresenterTemplateSettings TemplateSettings
|
||||
{
|
||||
get => (DesktopBarPresenterTemplateSettings)GetValue(TemplateSettingsProperty);
|
||||
set => SetValue(TemplateSettingsProperty, value);
|
||||
}
|
||||
|
||||
internal void UpdatePlacementState(DesktopBarPlacemenet placement) => VisualStateManager.GoToState(this, $"{placement}Placement", true);
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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.Controls.Windows">
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<StaticResource x:Key="DesktopBarPresenterBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="DesktopBarPresenterForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="DesktopBarPresenterBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<StaticResource x:Key="DesktopBarPresenterBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
<StaticResource x:Key="DesktopBarPresenterForeground" ResourceKey="TextFillColorPrimaryBrush" />
|
||||
<StaticResource x:Key="DesktopBarPresenterBorderBrush" ResourceKey="ControlStrokeColorDefaultBrush" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<Thickness x:Key="DesktopBarPresenterBorderThemeThickness">0</Thickness>
|
||||
<Style TargetType="controls:DesktopBarPresenter">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource DesktopBarPresenterForeground}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource DesktopBarPresenterBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource DesktopBarPresenterBorderThemeThickness}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DesktopBarPresenter">
|
||||
<Border x:Name="Container" Background="Transparent">
|
||||
<Border
|
||||
x:Name="BackgroundElement"
|
||||
MinWidth="48"
|
||||
MinHeight="48"
|
||||
Background="{TemplateBinding Background}"
|
||||
BackgroundSizing="OuterBorderEdge"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
FlowDirection="{TemplateBinding FlowDirection}">
|
||||
<ContentControl
|
||||
Height="40"
|
||||
Margin="4"
|
||||
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 x:Name="TopPlacement" />
|
||||
<VisualState x:Name="LeftPlacement" />
|
||||
<VisualState x:Name="RightPlacement" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +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.Controls.Windows/DesktopBar/DesktopBarPresenter.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user