From f0630f2740fb50e3e8fa94bf39324b89570d51a3 Mon Sep 17 00:00:00 2001 From: Christoph Hofmann Date: Sat, 23 Mar 2024 23:34:50 +0100 Subject: [PATCH] The most significant changes involve modifications to the `StrongReferenceMessenger.Default.Send` and `StrongReferenceMessenger.Default.Register` method calls in `MainWindow.xaml.cs`, `MainViewModel.cs`, and `SitemapViewModel.cs`. These methods now include additional arguments related to the sitemap name. Additionally, the `StrongReferenceMessenger.Default.Unregister` method call was removed from `MainViewModel.cs`. Lastly, several build properties were removed from `openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig`, indicating potential changes in the project configuration or build process. List of changes: 1. The namespaces `System` and `System.Threading.Tasks` were removed and then added back in `MainWindow.xaml.cs` and `SitemapViewModel.cs`. This could be due to reordering of the namespaces. 2. The `StrongReferenceMessenger.Default.Send` method calls in `MainWindow.xaml.cs` were modified to include `Vm.SelectedSitemap.Name` as an additional argument. 3. The `StrongReferenceMessenger.Default.Register` method calls in `MainViewModel.cs` and `SitemapViewModel.cs` were modified to include the sitemap name as an additional argument. 4. The `StrongReferenceMessenger.Default.Unregister` method call in `MainViewModel.cs` was removed. 5. The `StrongReferenceMessenger.Default.Send` method calls in `SitemapViewModel.cs` were modified to include `Model.Name` as an additional argument. 6. Several build properties were removed from `openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig`. This could be due to changes in the project configuration or build process. --- src/openHAB.Windows/MainWindow.xaml.cs | 8 ++++---- src/openHAB.Windows/ViewModel/MainViewModel.cs | 7 ++----- .../ViewModel/SitemapViewModel.cs | 16 ++++++++-------- ...ows.GeneratedMSBuildEditorConfig.editorconfig | 8 -------- 4 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 src/openHAB.Windows/openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig diff --git a/src/openHAB.Windows/MainWindow.xaml.cs b/src/openHAB.Windows/MainWindow.xaml.cs index 3d291b2c..f9a063e6 100644 --- a/src/openHAB.Windows/MainWindow.xaml.cs +++ b/src/openHAB.Windows/MainWindow.xaml.cs @@ -1,5 +1,3 @@ -using System; -using System.Threading.Tasks; using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.WinUI; using Microsoft.Extensions.Logging; @@ -15,6 +13,8 @@ using openHAB.Windows.Services; using openHAB.Windows.View; using openHAB.Windows.ViewModel; +using System; +using System.Threading.Tasks; using Windows.ApplicationModel; namespace openHAB.Windows @@ -74,7 +74,7 @@ private void BreadcrumbBar_ItemClicked(BreadcrumbBar sender, BreadcrumbBarItemCl return; } - StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, widget, EventTriggerSource.Breadcrumb)); + StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, widget, EventTriggerSource.Breadcrumb), Vm.SelectedSitemap.Name); } private async Task ShowErrorMessage(object recipient, ConnectionErrorMessage message) @@ -159,7 +159,7 @@ private void SitemapNavigation_SelectionChanged( private void SitemapTextBlock_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e) { - StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, null, EventTriggerSource.Root)); + StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, null, EventTriggerSource.Root), Vm.SelectedSitemap.Name); } } } diff --git a/src/openHAB.Windows/ViewModel/MainViewModel.cs b/src/openHAB.Windows/ViewModel/MainViewModel.cs index 6dff7696..9f87617a 100644 --- a/src/openHAB.Windows/ViewModel/MainViewModel.cs +++ b/src/openHAB.Windows/ViewModel/MainViewModel.cs @@ -54,9 +54,6 @@ public MainViewModel(IOpenHABClient openHABClient, ISettingsService settingsServ StrongReferenceMessenger.Default.Register(this, async (obj, operation) => await DataOperationStateAsync(operation)); - - StrongReferenceMessenger.Default.Register(this, (obj, operation) - => WidgetNavigatedEvent()); } /// @@ -116,7 +113,6 @@ public Sitemap SelectedSitemap { if (_selectedSitemap != value) { - StrongReferenceMessenger.Default.Unregister(this, value.Name); } @@ -128,7 +124,8 @@ public Sitemap SelectedSitemap settings.LastSitemap = _selectedSitemap.Name; _settingsService.Save(settings); - //StrongReferenceMessenger.Default.Send(new SitemapChanged(value.Model)); + StrongReferenceMessenger.Default.Register(this, SelectedSitemap.Name, (obj, operation) + => WidgetNavigatedEvent()); } SelectedMenuItem = value; diff --git a/src/openHAB.Windows/ViewModel/SitemapViewModel.cs b/src/openHAB.Windows/ViewModel/SitemapViewModel.cs index eae47ad0..0cf738f6 100644 --- a/src/openHAB.Windows/ViewModel/SitemapViewModel.cs +++ b/src/openHAB.Windows/ViewModel/SitemapViewModel.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.WinUI; using openHAB.Common; @@ -14,6 +9,11 @@ using openHAB.Core.Services; using openHAB.Windows.Messages; using openHAB.Windows.Services; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; namespace openHAB.Windows.ViewModel { @@ -69,7 +69,7 @@ private SitemapViewModel(Sitemap model, List widgetViewModels) StrongReferenceMessenger.Default.Register(this, (obj, operation) => DataOperationState(operation)); - StrongReferenceMessenger.Default.Register(this, (recipient, msg) => + StrongReferenceMessenger.Default.Register(this, Model.Name, (recipient, msg) => { if (msg.Trigger == EventTriggerSource.Breadcrumb) { @@ -369,7 +369,7 @@ await App.DispatcherQueue.EnqueueAsync(async () => } WidgetNavigationService.Navigate(SelectedWidget); - StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, widget, EventTriggerSource.Widget)); + StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, widget, EventTriggerSource.Widget), Model.Name); List widgets = ConvertWidgetToViewModel(SelectedWidget.LinkedPage.Widgets); await SetWidgetsOnScreenAsync(widgets); @@ -402,7 +402,7 @@ private async Task WidgetGoBack(WidgetViewModel widget) SelectedWidget = widgetFromStack; WidgetNavigationService.Navigate(SelectedWidget); - StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, SelectedWidget, EventTriggerSource.Widget)); + StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, SelectedWidget, EventTriggerSource.Widget), Model.Name); List widgets = ConvertWidgetToViewModel(SelectedWidget.LinkedPage.Widgets); await SetWidgetsOnScreenAsync(widgets); diff --git a/src/openHAB.Windows/openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig b/src/openHAB.Windows/openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig deleted file mode 100644 index 479cd4c4..00000000 --- a/src/openHAB.Windows/openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -is_global = true -build_property.TargetFramework = -build_property.TargetPlatformMinVersion = 10.0.17763.0 -build_property.UsingMicrosoftNETSdkWeb = -build_property.ProjectTypeGuids = {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} -build_property.PublishSingleFile = -build_property.IncludeAllContentForSelfExtract = -build_property._SupportedPlatformList =