From 4a27534e396edb5c1c276b9b81b584f3a3368624 Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Sat, 6 Jan 2024 09:57:23 +0000 Subject: [PATCH] Make custom widgets independent of any WinUI framework concerns. Although one can add WinUI concerns to ther widget if they want to build a fully customized widget. In theory, it may also be possible to host a widget of WPF, Avalonia, or Blazor. --- .../ContextualCommandWidgetBuilder.cs | 15 ---- .../ContextualCommandWidgetConfiguration.cs | 5 -- .../ContextualCommandWidgetView.xaml | 9 --- .../ContextualCommandWidgetView.xaml.cs | 15 ---- .../ContextualWidgetBuilder.cs | 15 ++++ .../ContextualWidgetConfiguration.cs | 5 ++ ...wModel.cs => ContextualWidgetViewModel.cs} | 6 +- ...proj => Hyperbar.Widget.Contextual.csproj} | 0 .../Hyperbar.Widget.Primary.csproj | 14 ++++ .../Hyperbar.Windows.Primary.csproj | 28 ------- .../PrimaryCommandConfiguration.cs | 7 -- .../PrimaryCommandWidgetBuilder.cs | 15 ---- .../PrimaryCommandWidgetView.xaml.cs | 8 -- .../PrimaryCommandWidgetViewModel.cs | 23 ------ .../PrimaryWidgetBuilder.cs | 15 ++++ .../PrimaryWidgetConfiguration.cs | 8 ++ .../PrimaryWidgetViewModel.cs | 14 ++++ Hyperbar.Windows/App.xaml.cs | 18 ++--- Hyperbar.Windows/Hyperbar.Windows.csproj | 8 +- .../IServiceCollectionExtensions.cs | 6 +- Hyperbar.Windows/Templates/TemplateFactory.cs | 4 +- Hyperbar.Windows/Views/CommandView.xaml | 4 +- Hyperbar.Windows/Views/CommandView.xaml.cs | 3 +- Hyperbar.Windows/Views/CommandViewModel.cs | 2 +- .../Views/WidgetView.xaml | 10 +-- Hyperbar.Windows/Views/WidgetView.xaml.cs | 10 +++ Hyperbar.sln | 4 +- .../IServiceCollectionExtensions.cs | 73 +++++++++++++------ Hyperbar/Extensions/IWidgetView.cs | 6 ++ Hyperbar/Hyperbar.csproj | 3 - .../Lifecycles/ICommandWidgetViewModel.cs | 7 -- ...mandWidgetBuilder.cs => IWidgetBuilder.cs} | 2 +- .../Lifecycles/IWidgetComponentViewModel.cs | 6 ++ ...mandWidgetContext.cs => IWidgetContext.cs} | 2 +- Hyperbar/Lifecycles/IWidgetViewModel.cs | 6 ++ .../ObservableCollectionViewModel.cs | 14 +++- Hyperbar/Lifecycles/WidgetButtonViewModel.cs | 6 ++ ...mmandWidgetContext.cs => WidgetContext.cs} | 4 +- Hyperbar/Lifecycles/WidgetViewModelBase.cs | 11 +++ ...riptor.cs => ContentTemplateDescriptor.cs} | 6 +- ...iptor.cs => IContentTemplateDescriptor.cs} | 6 +- 41 files changed, 218 insertions(+), 205 deletions(-) delete mode 100644 Hyperbar.Windows.Contextual/ContextualCommandWidgetBuilder.cs delete mode 100644 Hyperbar.Windows.Contextual/ContextualCommandWidgetConfiguration.cs delete mode 100644 Hyperbar.Windows.Contextual/ContextualCommandWidgetView.xaml delete mode 100644 Hyperbar.Windows.Contextual/ContextualCommandWidgetView.xaml.cs create mode 100644 Hyperbar.Windows.Contextual/ContextualWidgetBuilder.cs create mode 100644 Hyperbar.Windows.Contextual/ContextualWidgetConfiguration.cs rename Hyperbar.Windows.Contextual/{ContextualCommandWidgetViewModel.cs => ContextualWidgetViewModel.cs} (51%) rename Hyperbar.Windows.Contextual/{Hyperbar.Windows.Contextual.csproj => Hyperbar.Widget.Contextual.csproj} (100%) create mode 100644 Hyperbar.Windows.Primary/Hyperbar.Widget.Primary.csproj delete mode 100644 Hyperbar.Windows.Primary/Hyperbar.Windows.Primary.csproj delete mode 100644 Hyperbar.Windows.Primary/PrimaryCommandConfiguration.cs delete mode 100644 Hyperbar.Windows.Primary/PrimaryCommandWidgetBuilder.cs delete mode 100644 Hyperbar.Windows.Primary/PrimaryCommandWidgetView.xaml.cs delete mode 100644 Hyperbar.Windows.Primary/PrimaryCommandWidgetViewModel.cs create mode 100644 Hyperbar.Windows.Primary/PrimaryWidgetBuilder.cs create mode 100644 Hyperbar.Windows.Primary/PrimaryWidgetConfiguration.cs create mode 100644 Hyperbar.Windows.Primary/PrimaryWidgetViewModel.cs rename Hyperbar.Windows.Primary/PrimaryCommandWidgetView.xaml => Hyperbar.Windows/Views/WidgetView.xaml (53%) create mode 100644 Hyperbar.Windows/Views/WidgetView.xaml.cs create mode 100644 Hyperbar/Extensions/IWidgetView.cs delete mode 100644 Hyperbar/Lifecycles/ICommandWidgetViewModel.cs rename Hyperbar/Lifecycles/{ICommandWidgetBuilder.cs => IWidgetBuilder.cs} (77%) create mode 100644 Hyperbar/Lifecycles/IWidgetComponentViewModel.cs rename Hyperbar/Lifecycles/{ICommandWidgetContext.cs => IWidgetContext.cs} (68%) create mode 100644 Hyperbar/Lifecycles/IWidgetViewModel.cs create mode 100644 Hyperbar/Lifecycles/WidgetButtonViewModel.cs rename Hyperbar/Lifecycles/{CommandWidgetContext.cs => WidgetContext.cs} (51%) create mode 100644 Hyperbar/Lifecycles/WidgetViewModelBase.cs rename Hyperbar/Templates/{DataTemplateDescriptor.cs => ContentTemplateDescriptor.cs} (52%) rename Hyperbar/Templates/{IDataTemplateDescriptor.cs => IContentTemplateDescriptor.cs} (56%) diff --git a/Hyperbar.Windows.Contextual/ContextualCommandWidgetBuilder.cs b/Hyperbar.Windows.Contextual/ContextualCommandWidgetBuilder.cs deleted file mode 100644 index 03bdb78..0000000 --- a/Hyperbar.Windows.Contextual/ContextualCommandWidgetBuilder.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Hyperbar.Lifecycles; -using Microsoft.Extensions.DependencyInjection; - -namespace Hyperbar.Windows.Contextual; - -public class ContextualCommandWidgetBuilder : - ICommandWidgetBuilder -{ - public void Create(IServiceCollection services) - { - services - .AddWritableConfiguration() - .AddCommandTemplate(); - } -} diff --git a/Hyperbar.Windows.Contextual/ContextualCommandWidgetConfiguration.cs b/Hyperbar.Windows.Contextual/ContextualCommandWidgetConfiguration.cs deleted file mode 100644 index 90f0ddf..0000000 --- a/Hyperbar.Windows.Contextual/ContextualCommandWidgetConfiguration.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Hyperbar.Windows.Contextual; - -public class ContextualCommandWidgetConfiguration -{ -} diff --git a/Hyperbar.Windows.Contextual/ContextualCommandWidgetView.xaml b/Hyperbar.Windows.Contextual/ContextualCommandWidgetView.xaml deleted file mode 100644 index 191d57a..0000000 --- a/Hyperbar.Windows.Contextual/ContextualCommandWidgetView.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - -