From 731cf3cdf37efde9ff3d3beda422673017842b30 Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Sun, 4 Feb 2024 14:08:38 +0000 Subject: [PATCH] More work --- .../DesktopApplicationBar.cs} | 24 ++++---- .../DesktopApplicationBarHost.cs} | 18 +++--- .../DesktopApplicationBarPlacemenet.cs} | 2 +- .../DesktopApplicationBarPresenter.cs | 40 ++++++++++++ .../DesktopApplicationBarPresenter.xaml | 53 ++++++++++++++++ ...pplicationBarPresenterTemplateSettings.cs} | 10 +-- .../DesktopBar/DesktopBarPresenter.cs | 40 ------------ .../DesktopBar/DesktopBarPresenter.xaml | 61 ------------------- Hyperbar.Controls.Windows/Themes/Generic.xaml | 2 +- Hyperbar.UI.Windows/GridExtension.cs | 46 ++++++++++++++ Hyperbar.UI.Windows/TemplateGenerator.cs | 20 +++--- .../TemplateGeneratorControl.cs | 3 +- .../IServiceCollectionExtensions.cs | 2 - Hyperbar.Widget.Windows/WidgetBarView.xaml.cs | 9 --- Hyperbar.Widget/IWidgetHostViewModel.cs | 3 + Hyperbar.Widget/WidgetBarViewModel.cs | 12 ---- Hyperbar.Widget/WidgetStartedHandler.cs | 2 +- Hyperbar.Widget/WidgetViewModelEnumerator.cs | 2 +- Hyperbar.Windows/App.xaml.cs | 8 ++- .../{Lifecycles => }/AppConfiguration.cs | 2 +- .../{Lifecycles => }/AppInitializer.cs | 7 +-- .../ApplicationBarView.xaml | 14 ++++- Hyperbar.Windows/ApplicationBarView.xaml.cs | 9 +++ Hyperbar.Windows/ApplicationBarViewModel.cs | 20 ++++++ .../ConfigurationChangedHandler.cs | 2 +- .../{Lifecycles => }/Dispatcher.cs | 0 Hyperbar.Windows/Hyperbar.Windows.csproj | 21 +++++++ .../IServiceCollectionExtensions.cs | 0 Hyperbar.Windows/PrimaryView.xaml | 17 ++++++ Hyperbar.Windows/PrimaryView.xaml.cs | 28 +++++++++ Hyperbar.Windows/PrimaryViewModel.cs | 19 ++++++ Hyperbar.Windows/SecondaryView.xaml | 17 ++++++ Hyperbar.Windows/SecondaryView.xaml.cs | 28 +++++++++ Hyperbar.Windows/SecondaryViewModel.cs | 17 ++++++ 34 files changed, 381 insertions(+), 177 deletions(-) rename Hyperbar.Controls.Windows/{DesktopBar/DesktopBar.cs => DesktopApplicationBar/DesktopApplicationBar.cs} (57%) rename Hyperbar.Controls.Windows/{DesktopBar/DesktopBarHost.cs => DesktopApplicationBar/DesktopApplicationBarHost.cs} (77%) rename Hyperbar.Controls.Windows/{DesktopBar/DesktopBarPlacemenet.cs => DesktopApplicationBar/DesktopApplicationBarPlacemenet.cs} (65%) create mode 100644 Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.cs create mode 100644 Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.xaml rename Hyperbar.Controls.Windows/{DesktopBar/DesktopBarPresenterTemplateSettings.cs => DesktopApplicationBar/DesktopApplicationBarPresenterTemplateSettings.cs} (75%) delete mode 100644 Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.cs delete mode 100644 Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.xaml create mode 100644 Hyperbar.UI.Windows/GridExtension.cs delete mode 100644 Hyperbar.Widget.Windows/WidgetBarView.xaml.cs create mode 100644 Hyperbar.Widget/IWidgetHostViewModel.cs delete mode 100644 Hyperbar.Widget/WidgetBarViewModel.cs rename Hyperbar.Windows/{Lifecycles => }/AppConfiguration.cs (59%) rename Hyperbar.Windows/{Lifecycles => }/AppInitializer.cs (63%) rename Hyperbar.Widget.Windows/WidgetBarView.xaml => Hyperbar.Windows/ApplicationBarView.xaml (56%) create mode 100644 Hyperbar.Windows/ApplicationBarView.xaml.cs create mode 100644 Hyperbar.Windows/ApplicationBarViewModel.cs rename Hyperbar.Windows/{Lifecycles => }/ConfigurationChangedHandler.cs (81%) rename Hyperbar.Windows/{Lifecycles => }/Dispatcher.cs (100%) rename Hyperbar.Windows/{Lifecycles => }/IServiceCollectionExtensions.cs (100%) create mode 100644 Hyperbar.Windows/PrimaryView.xaml create mode 100644 Hyperbar.Windows/PrimaryView.xaml.cs create mode 100644 Hyperbar.Windows/PrimaryViewModel.cs create mode 100644 Hyperbar.Windows/SecondaryView.xaml create mode 100644 Hyperbar.Windows/SecondaryView.xaml.cs create mode 100644 Hyperbar.Windows/SecondaryViewModel.cs diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBar.cs b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBar.cs similarity index 57% rename from Hyperbar.Controls.Windows/DesktopBar/DesktopBar.cs rename to Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBar.cs index c5e0ef2..ab11ae6 100644 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBar.cs +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBar.cs @@ -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(); } diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarHost.cs b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarHost.cs similarity index 77% rename from Hyperbar.Controls.Windows/DesktopBar/DesktopBarHost.cs rename to Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarHost.cs index 237fe8f..9b05866 100644 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarHost.cs +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarHost.cs @@ -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; diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPlacemenet.cs b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPlacemenet.cs similarity index 65% rename from Hyperbar.Controls.Windows/DesktopBar/DesktopBarPlacemenet.cs rename to Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPlacemenet.cs index 288f85e..cd1fff6 100644 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPlacemenet.cs +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPlacemenet.cs @@ -1,6 +1,6 @@ namespace Hyperbar.Controls.Windows; -public enum DesktopBarPlacemenet +public enum DesktopApplicationBarPlacemenet { Left, Top, diff --git a/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.cs b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.cs new file mode 100644 index 0000000..41e03cf --- /dev/null +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.cs @@ -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); +} \ No newline at end of file diff --git a/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.xaml b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.xaml new file mode 100644 index 0000000..a34bd12 --- /dev/null +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenter.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + 0 + + \ No newline at end of file diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenterTemplateSettings.cs b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenterTemplateSettings.cs similarity index 75% rename from Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenterTemplateSettings.cs rename to Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenterTemplateSettings.cs index f020a44..0e52fba 100644 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenterTemplateSettings.cs +++ b/Hyperbar.Controls.Windows/DesktopApplicationBar/DesktopApplicationBarPresenterTemplateSettings.cs @@ -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 diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.cs b/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.cs deleted file mode 100644 index 7f6f731..0000000 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.cs +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.xaml b/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.xaml deleted file mode 100644 index 67994ab..0000000 --- a/Hyperbar.Controls.Windows/DesktopBar/DesktopBarPresenter.xaml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - 0 - - \ No newline at end of file diff --git a/Hyperbar.Controls.Windows/Themes/Generic.xaml b/Hyperbar.Controls.Windows/Themes/Generic.xaml index c2ed101..5a2c0b1 100644 --- a/Hyperbar.Controls.Windows/Themes/Generic.xaml +++ b/Hyperbar.Controls.Windows/Themes/Generic.xaml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/Hyperbar.UI.Windows/GridExtension.cs b/Hyperbar.UI.Windows/GridExtension.cs new file mode 100644 index 0000000..1bb0386 --- /dev/null +++ b/Hyperbar.UI.Windows/GridExtension.cs @@ -0,0 +1,46 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Data; + +namespace Hyperbar.UI.Windows; + +public class GridExtension +{ + public static readonly DependencyProperty GridColumnBindingPathProperty = + DependencyProperty.RegisterAttached("GridColumnBindingPath", + typeof(string), typeof(GridExtension), + new PropertyMetadata(null, OnGridBindingPathPropertyChanged)); + + public static readonly DependencyProperty GridRowBindingPathProperty = + DependencyProperty.RegisterAttached("GridRowBindingPath", + typeof(string), typeof(GridExtension), + new PropertyMetadata(null, OnGridBindingPathPropertyChanged)); + + public static string GetGridColumnBindingPath(DependencyObject dependencyObject) => + (string)dependencyObject.GetValue(GridColumnBindingPathProperty); + + public static string GetGridRowBindingPath(DependencyObject dependencyObject) => + (string)dependencyObject.GetValue(GridRowBindingPathProperty); + + public static void SetGridColumnBindingPath(DependencyObject dependencyObject, string value) => + dependencyObject.SetValue(GridColumnBindingPathProperty, value); + public static void SetGridRowBindingPath(DependencyObject dependencyObject, string value) => + dependencyObject.SetValue(GridRowBindingPathProperty, value); + + private static void OnGridBindingPathPropertyChanged(DependencyObject dependencyObject, + DependencyPropertyChangedEventArgs args) + { + if (args.NewValue is string propertyPath) + { + DependencyProperty gridProperty = + args.Property == GridColumnBindingPathProperty + ? Grid.ColumnProperty + : Grid.RowProperty; + + BindingOperations.SetBinding( + dependencyObject, + gridProperty, + new Binding { Path = new PropertyPath(propertyPath) }); + } + } +} diff --git a/Hyperbar.UI.Windows/TemplateGenerator.cs b/Hyperbar.UI.Windows/TemplateGenerator.cs index 9ce0596..63849b3 100644 --- a/Hyperbar.UI.Windows/TemplateGenerator.cs +++ b/Hyperbar.UI.Windows/TemplateGenerator.cs @@ -11,12 +11,10 @@ public class TemplateGenerator : DataTemplateSelector string xamlString = @" - - - + "; return (DataTemplate)XamlReader.Load(xamlString); @@ -27,12 +25,10 @@ public class TemplateGenerator : DataTemplateSelector string xamlString = @" - - - + "; return (DataTemplate)XamlReader.Load(xamlString); diff --git a/Hyperbar.UI.Windows/TemplateGeneratorControl.cs b/Hyperbar.UI.Windows/TemplateGeneratorControl.cs index 880c589..2185a28 100644 --- a/Hyperbar.UI.Windows/TemplateGeneratorControl.cs +++ b/Hyperbar.UI.Windows/TemplateGeneratorControl.cs @@ -11,7 +11,8 @@ public class TemplateGeneratorControl : DataContextChanged += OnDataContextChanged; } - private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) + private void OnDataContextChanged(FrameworkElement sender, + DataContextChangedEventArgs args) { if (DataContext is ITemplatedViewModel templatedViewModel) { diff --git a/Hyperbar.Widget.Windows/IServiceCollectionExtensions.cs b/Hyperbar.Widget.Windows/IServiceCollectionExtensions.cs index f072acc..cc7d2d2 100644 --- a/Hyperbar.Widget.Windows/IServiceCollectionExtensions.cs +++ b/Hyperbar.Widget.Windows/IServiceCollectionExtensions.cs @@ -10,8 +10,6 @@ public static class IServiceCollectionExtensions { public static IServiceCollection AddWidgetWindows(this IServiceCollection services) { - services.AddContentTemplate(); - // We need to feed information to the Widgets about our Windows host, // so the Windows host can make discussions how to display and interact with the widgets. diff --git a/Hyperbar.Widget.Windows/WidgetBarView.xaml.cs b/Hyperbar.Widget.Windows/WidgetBarView.xaml.cs deleted file mode 100644 index 308718b..0000000 --- a/Hyperbar.Widget.Windows/WidgetBarView.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.UI.Xaml.Controls; - -namespace Hyperbar.Widget.Windows; - -public sealed partial class WidgetBarView : - UserControl -{ - public WidgetBarView() => InitializeComponent(); -} \ No newline at end of file diff --git a/Hyperbar.Widget/IWidgetHostViewModel.cs b/Hyperbar.Widget/IWidgetHostViewModel.cs new file mode 100644 index 0000000..5e5dbbc --- /dev/null +++ b/Hyperbar.Widget/IWidgetHostViewModel.cs @@ -0,0 +1,3 @@ +namespace Hyperbar.Widget; + +public interface IWidgetHostViewModel; diff --git a/Hyperbar.Widget/WidgetBarViewModel.cs b/Hyperbar.Widget/WidgetBarViewModel.cs deleted file mode 100644 index 60bb272..0000000 --- a/Hyperbar.Widget/WidgetBarViewModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Hyperbar.Widget; - -[NotificationHandler(nameof(WidgetViewModel))] -public partial class WidgetViewModel(ITemplateFactory templateFactory, - IServiceFactory serviceFactory, - IMediator mediator, - IDisposer disposer) : - ObservableCollectionViewModel(serviceFactory, mediator, disposer), - ITemplatedViewModel -{ - public ITemplateFactory TemplateFactory => templateFactory; -} diff --git a/Hyperbar.Widget/WidgetStartedHandler.cs b/Hyperbar.Widget/WidgetStartedHandler.cs index 338d20a..2aa988e 100644 --- a/Hyperbar.Widget/WidgetStartedHandler.cs +++ b/Hyperbar.Widget/WidgetStartedHandler.cs @@ -13,7 +13,7 @@ public class WidgetStartedHandler(IMediator mediator) : if (host.Services.GetService() is IWidgetViewModel viewModel) { await mediator.PublishAsync(new Created(viewModel), - nameof(WidgetViewModel), cancellationToken); + nameof(IWidgetHostViewModel), cancellationToken); } } } diff --git a/Hyperbar.Widget/WidgetViewModelEnumerator.cs b/Hyperbar.Widget/WidgetViewModelEnumerator.cs index 34777a1..e6c2c75 100644 --- a/Hyperbar.Widget/WidgetViewModelEnumerator.cs +++ b/Hyperbar.Widget/WidgetViewModelEnumerator.cs @@ -14,7 +14,7 @@ public class WidgetViewModelEnumerator(IWidgetHost host, foreach (IWidgetViewModel viewModel in viewModels) { await mediator.PublishAsync(new Created(viewModel), - nameof(WidgetViewModel), cancellationToken); + nameof(IWidgetHostViewModel), cancellationToken); } } } diff --git a/Hyperbar.Windows/App.xaml.cs b/Hyperbar.Windows/App.xaml.cs index 68e13bd..24af633 100644 --- a/Hyperbar.Windows/App.xaml.cs +++ b/Hyperbar.Windows/App.xaml.cs @@ -43,11 +43,15 @@ public partial class App : services.AddHandler(); services.AddConfiguration(args => { - args.Placement = DesktopBarPlacemenet.Top; + args.Placement = DesktopApplicationBarPlacemenet.Top; }); + services.AddSingleton(); + services.AddContentTemplate(); + services.AddContentTemplate(); + services.AddContentTemplate(); + services.AddTransient(); - services.AddSingleton(); }) .Build(); diff --git a/Hyperbar.Windows/Lifecycles/AppConfiguration.cs b/Hyperbar.Windows/AppConfiguration.cs similarity index 59% rename from Hyperbar.Windows/Lifecycles/AppConfiguration.cs rename to Hyperbar.Windows/AppConfiguration.cs index 2132d2b..6751fd0 100644 --- a/Hyperbar.Windows/Lifecycles/AppConfiguration.cs +++ b/Hyperbar.Windows/AppConfiguration.cs @@ -4,5 +4,5 @@ namespace Hyperbar.Windows; public class AppConfiguration { - public DesktopBarPlacemenet Placement { get; set; } + public DesktopApplicationBarPlacemenet Placement { get; set; } } diff --git a/Hyperbar.Windows/Lifecycles/AppInitializer.cs b/Hyperbar.Windows/AppInitializer.cs similarity index 63% rename from Hyperbar.Windows/Lifecycles/AppInitializer.cs rename to Hyperbar.Windows/AppInitializer.cs index e8f9a97..05981c2 100644 --- a/Hyperbar.Windows/Lifecycles/AppInitializer.cs +++ b/Hyperbar.Windows/AppInitializer.cs @@ -1,13 +1,12 @@ using Hyperbar.Controls.Windows; using Hyperbar.Widget; -using Hyperbar.Widget.Windows; using Microsoft.Extensions.DependencyInjection; namespace Hyperbar.Windows; -public class AppInitializer([FromKeyedServices(nameof(WidgetViewModel))] WidgetBarView view, - [FromKeyedServices(nameof(WidgetViewModel))] WidgetViewModel viewModel, - DesktopBar desktopFlyout, +public class AppInitializer([FromKeyedServices(nameof(ApplicationBarViewModel))] ApplicationBarView view, + [FromKeyedServices(nameof(ApplicationBarViewModel))] ApplicationBarViewModel viewModel, + DesktopApplicationBar desktopFlyout, AppConfiguration configuration) : IInitializer { diff --git a/Hyperbar.Widget.Windows/WidgetBarView.xaml b/Hyperbar.Windows/ApplicationBarView.xaml similarity index 56% rename from Hyperbar.Widget.Windows/WidgetBarView.xaml rename to Hyperbar.Windows/ApplicationBarView.xaml index 157e17f..d54d8cf 100644 --- a/Hyperbar.Widget.Windows/WidgetBarView.xaml +++ b/Hyperbar.Windows/ApplicationBarView.xaml @@ -1,13 +1,18 @@ - + + + + + + @@ -15,5 +20,10 @@ + + + \ No newline at end of file diff --git a/Hyperbar.Windows/ApplicationBarView.xaml.cs b/Hyperbar.Windows/ApplicationBarView.xaml.cs new file mode 100644 index 0000000..7053826 --- /dev/null +++ b/Hyperbar.Windows/ApplicationBarView.xaml.cs @@ -0,0 +1,9 @@ +using Microsoft.UI.Xaml.Controls; + +namespace Hyperbar.Windows; + +public sealed partial class ApplicationBarView : + UserControl +{ + public ApplicationBarView() => InitializeComponent(); +} \ No newline at end of file diff --git a/Hyperbar.Windows/ApplicationBarViewModel.cs b/Hyperbar.Windows/ApplicationBarViewModel.cs new file mode 100644 index 0000000..b57f670 --- /dev/null +++ b/Hyperbar.Windows/ApplicationBarViewModel.cs @@ -0,0 +1,20 @@ +namespace Hyperbar.Widget; + +[NotificationHandler(nameof(IWidgetHostViewModel))] +public partial class ApplicationBarViewModel : + ObservableCollectionViewModel, + ITemplatedViewModel +{ + public ApplicationBarViewModel(ITemplateFactory templateFactory, + IServiceFactory serviceFactory, + IMediator mediator, + IDisposer disposer) : base(serviceFactory, mediator, disposer) + { + TemplateFactory = templateFactory; + + Add(0); + Add(1); + } + + public ITemplateFactory TemplateFactory { get; } +} \ No newline at end of file diff --git a/Hyperbar.Windows/Lifecycles/ConfigurationChangedHandler.cs b/Hyperbar.Windows/ConfigurationChangedHandler.cs similarity index 81% rename from Hyperbar.Windows/Lifecycles/ConfigurationChangedHandler.cs rename to Hyperbar.Windows/ConfigurationChangedHandler.cs index a128ec9..c72e7e7 100644 --- a/Hyperbar.Windows/Lifecycles/ConfigurationChangedHandler.cs +++ b/Hyperbar.Windows/ConfigurationChangedHandler.cs @@ -2,7 +2,7 @@ namespace Hyperbar.Windows; -public class AppConfigurationChangedHandler(DesktopBar desktopFlyout, +public class AppConfigurationChangedHandler(DesktopApplicationBar desktopFlyout, AppConfiguration configuration) : INotificationHandler> { diff --git a/Hyperbar.Windows/Lifecycles/Dispatcher.cs b/Hyperbar.Windows/Dispatcher.cs similarity index 100% rename from Hyperbar.Windows/Lifecycles/Dispatcher.cs rename to Hyperbar.Windows/Dispatcher.cs diff --git a/Hyperbar.Windows/Hyperbar.Windows.csproj b/Hyperbar.Windows/Hyperbar.Windows.csproj index 67f6af9..19536b3 100644 --- a/Hyperbar.Windows/Hyperbar.Windows.csproj +++ b/Hyperbar.Windows/Hyperbar.Windows.csproj @@ -13,6 +13,11 @@ enable true + + + + + @@ -48,4 +53,20 @@ + + + MSBuild:Compile + + + + + MSBuild:Compile + + + + + $(DefaultXamlRuntime) + Designer + + \ No newline at end of file diff --git a/Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs b/Hyperbar.Windows/IServiceCollectionExtensions.cs similarity index 100% rename from Hyperbar.Windows/Lifecycles/IServiceCollectionExtensions.cs rename to Hyperbar.Windows/IServiceCollectionExtensions.cs diff --git a/Hyperbar.Windows/PrimaryView.xaml b/Hyperbar.Windows/PrimaryView.xaml new file mode 100644 index 0000000..6becf37 --- /dev/null +++ b/Hyperbar.Windows/PrimaryView.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/Hyperbar.Windows/PrimaryView.xaml.cs b/Hyperbar.Windows/PrimaryView.xaml.cs new file mode 100644 index 0000000..19a1642 --- /dev/null +++ b/Hyperbar.Windows/PrimaryView.xaml.cs @@ -0,0 +1,28 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Hyperbar.Windows +{ + public sealed partial class PrimaryView : UserControl + { + public PrimaryView() + { + this.InitializeComponent(); + } + } +} diff --git a/Hyperbar.Windows/PrimaryViewModel.cs b/Hyperbar.Windows/PrimaryViewModel.cs new file mode 100644 index 0000000..e6504aa --- /dev/null +++ b/Hyperbar.Windows/PrimaryViewModel.cs @@ -0,0 +1,19 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace Hyperbar.Widget; + +[NotificationHandler(nameof(IWidgetHostViewModel))] +public partial class PrimaryViewModel(ITemplateFactory templateFactory, + IServiceFactory serviceFactory, + IMediator mediator, + IDisposer disposer, + int index) : + ObservableCollectionViewModel(serviceFactory, mediator, disposer), + IWidgetHostViewModel, + ITemplatedViewModel +{ + [ObservableProperty] + private int index = index; + + public ITemplateFactory TemplateFactory => templateFactory; +} \ No newline at end of file diff --git a/Hyperbar.Windows/SecondaryView.xaml b/Hyperbar.Windows/SecondaryView.xaml new file mode 100644 index 0000000..87ccd0e --- /dev/null +++ b/Hyperbar.Windows/SecondaryView.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/Hyperbar.Windows/SecondaryView.xaml.cs b/Hyperbar.Windows/SecondaryView.xaml.cs new file mode 100644 index 0000000..5d4c245 --- /dev/null +++ b/Hyperbar.Windows/SecondaryView.xaml.cs @@ -0,0 +1,28 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Hyperbar.Windows +{ + public sealed partial class SecondaryView : UserControl + { + public SecondaryView() + { + this.InitializeComponent(); + } + } +} diff --git a/Hyperbar.Windows/SecondaryViewModel.cs b/Hyperbar.Windows/SecondaryViewModel.cs new file mode 100644 index 0000000..a8beb69 --- /dev/null +++ b/Hyperbar.Windows/SecondaryViewModel.cs @@ -0,0 +1,17 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace Hyperbar.Widget; + +public partial class SecondaryViewModel(ITemplateFactory templateFactory, + IServiceFactory serviceFactory, + IMediator mediator, + IDisposer disposer, + int index) : + ObservableCollectionViewModel(serviceFactory, mediator, disposer), + ITemplatedViewModel +{ + [ObservableProperty] + private int index = index; + + public ITemplateFactory TemplateFactory => templateFactory; +} \ No newline at end of file