From 41c375dff1822511a5f23c34bc12fe2a4040aa7b Mon Sep 17 00:00:00 2001 From: AtomCrafty Date: Thu, 10 Nov 2022 07:20:37 +0100 Subject: [PATCH 1/3] fix DevTools style list not updating correctly --- .../Diagnostics/ViewModels/ControlDetailsViewModel.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs index 631da80d8b..71da543d70 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.ComponentModel; using System.Linq; using System.Reflection; @@ -15,7 +14,7 @@ using Avalonia.VisualTree; namespace Avalonia.Diagnostics.ViewModels { - internal class ControlDetailsViewModel : ViewModelBase, IDisposable + internal class ControlDetailsViewModel : ViewModelBase, IDisposable, IClassesChangedListener { private readonly IAvaloniaObject _avaloniaObject; private IDictionary? _propertyIndex; @@ -46,7 +45,7 @@ namespace Avalonia.Diagnostics.ViewModels if (avaloniaObject is StyledElement styledElement) { - styledElement.Classes.CollectionChanged += OnClassesChanged; + styledElement.Classes.AddListener(this); var pseudoClassAttributes = styledElement.GetType().GetCustomAttributes(true); @@ -250,7 +249,7 @@ namespace Avalonia.Diagnostics.ViewModels if (_avaloniaObject is StyledElement se) { - se.Classes.CollectionChanged -= OnClassesChanged; + se.Classes.RemoveListener(this); } } @@ -325,7 +324,7 @@ namespace Avalonia.Diagnostics.ViewModels } } - private void OnClassesChanged(object? sender, NotifyCollectionChangedEventArgs e) + void IClassesChangedListener.Changed() { if (!SnapshotStyles) { From 7e6f5403aa2fe0d8a8ff641dbff3f21f3f0d4233 Mon Sep 17 00:00:00 2001 From: AtomCrafty Date: Thu, 10 Nov 2022 06:37:23 +0100 Subject: [PATCH 2/3] fix typos --- .../Diagnostics/{Convetions.cs => Conventions.cs} | 5 +---- .../Diagnostics/DevToolsOptions.cs | 4 ++-- .../Diagnostics/Screenshots/FilePickerHandler.cs | 2 +- .../Diagnostics/ViewModels/MainViewModel.cs | 12 +++++++----- .../Diagnostics/Views/ControlDetailsView.xaml | 10 +++++----- .../Diagnostics/Views/MainView.xaml | 4 ++-- 6 files changed, 18 insertions(+), 19 deletions(-) rename src/Avalonia.Diagnostics/Diagnostics/{Convetions.cs => Conventions.cs} (80%) diff --git a/src/Avalonia.Diagnostics/Diagnostics/Convetions.cs b/src/Avalonia.Diagnostics/Diagnostics/Conventions.cs similarity index 80% rename from src/Avalonia.Diagnostics/Diagnostics/Convetions.cs rename to src/Avalonia.Diagnostics/Diagnostics/Conventions.cs index b41755f239..9091b83ba2 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Convetions.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/Conventions.cs @@ -1,11 +1,8 @@ using System; -using System.Reflection; -using Avalonia.Controls; -using Avalonia.VisualTree; namespace Avalonia.Diagnostics { - static class Convetions + internal static class Conventions { public static string DefaultScreenshotsRoot => System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures, Environment.SpecialFolderOption.Create), diff --git a/src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs b/src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs index 5672641602..0558284142 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs @@ -36,11 +36,11 @@ namespace Avalonia.Diagnostics public bool ShowImplementedInterfaces { get; set; } = true; /// - /// Allow to customizze SreenshotHandler + /// Allow to customize SreenshotHandler /// /// Default handler is public IScreenshotHandler ScreenshotHandler { get; set; } - = Convetions.DefaultScreenshotHandler; + = Conventions.DefaultScreenshotHandler; /// /// Gets or sets whether DevTools should use the dark mode theme diff --git a/src/Avalonia.Diagnostics/Diagnostics/Screenshots/FilePickerHandler.cs b/src/Avalonia.Diagnostics/Diagnostics/Screenshots/FilePickerHandler.cs index 4153d2d38c..cfd7f9acf1 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Screenshots/FilePickerHandler.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/Screenshots/FilePickerHandler.cs @@ -40,7 +40,7 @@ namespace Avalonia.Diagnostics.Screenshots /// The default root folder is [Environment.SpecialFolder.MyPictures]/Screenshots. /// public string ScreenshotsRoot { get; } - = Convetions.DefaultScreenshotsRoot; + = Conventions.DefaultScreenshotsRoot; /// /// SaveFilePicker Title diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs index 9e8a5d8d9b..1cdebaae01 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs @@ -96,7 +96,9 @@ namespace Avalonia.Diagnostics.ViewModels changed = false; } if (changed) - RaiseAndSetIfChanged(ref _shouldVisualizeDirtyRects, value); + { + RaiseAndSetIfChanged(ref _shouldVisualizeDirtyRects, value); + } } } @@ -331,7 +333,7 @@ namespace Avalonia.Diagnostics.ViewModels private set => RaiseAndSetIfChanged(ref _showImplementedInterfaces , value); } - public void ToggleShowImplementedInterfaces(object parametr) + public void ToggleShowImplementedInterfaces(object parameter) { ShowImplementedInterfaces = !ShowImplementedInterfaces; if (Content is TreePageViewModel viewModel) @@ -340,15 +342,15 @@ namespace Avalonia.Diagnostics.ViewModels } } - public bool ShowDettailsPropertyType + public bool ShowDetailsPropertyType { get => _showPropertyType; private set => RaiseAndSetIfChanged(ref _showPropertyType , value); } - public void ToggleShowDettailsPropertyType(object paramter) + public void ToggleShowDetailsPropertyType(object parameter) { - ShowDettailsPropertyType = !ShowDettailsPropertyType; + ShowDetailsPropertyType = !ShowDetailsPropertyType; } } } diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml index a426b387f7..bf595d82a3 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml @@ -19,7 +19,7 @@