diff --git a/RevitLookup.UI/Win32/Utilities.cs b/RevitLookup.UI/Win32/Utilities.cs index db934637b..274b93067 100644 --- a/RevitLookup.UI/Win32/Utilities.cs +++ b/RevitLookup.UI/Win32/Utilities.cs @@ -16,7 +16,7 @@ namespace Wpf.Ui.Win32; /// // ReSharper disable InconsistentNaming // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -internal class Utilities +public class Utilities { private static readonly PlatformID _osPlatform = Environment.OSVersion.Platform; diff --git a/RevitLookup/Core/ComponentModel/Descriptors/ColorDescriptor.cs b/RevitLookup/Core/ComponentModel/Descriptors/ColorDescriptor.cs index 3e58ce765..183019e14 100644 --- a/RevitLookup/Core/ComponentModel/Descriptors/ColorDescriptor.cs +++ b/RevitLookup/Core/ComponentModel/Descriptors/ColorDescriptor.cs @@ -18,15 +18,28 @@ // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. -using Autodesk.Revit.DB; +using RevitLookup.Core.Contracts; using RevitLookup.Core.Objects; +using Color = Autodesk.Revit.DB.Color; namespace RevitLookup.Core.ComponentModel.Descriptors; -public sealed class ColorDescriptor : Descriptor +public sealed class ColorDescriptor : Descriptor, IDescriptorExtension { + private readonly Color _color; + public ColorDescriptor(Color color) { + _color = color; Name = color.IsValid ? $"RGB: {color.Red} {color.Green} {color.Blue}" : "The color represents uninitialized/invalid value"; } + + public void RegisterExtensions(IExtensionManager manager) + { + manager.Register(_color, extension => + { + extension.Name = "HEX"; + extension.Result = $"#{extension.Value.Red:X2}{extension.Value.Green:X2}{extension.Value.Blue:X2}"; + }); + } } \ No newline at end of file diff --git a/RevitLookup/ViewModels/Pages/SettingsViewModel.cs b/RevitLookup/ViewModels/Pages/SettingsViewModel.cs index ca24518e3..431cd692d 100644 --- a/RevitLookup/ViewModels/Pages/SettingsViewModel.cs +++ b/RevitLookup/ViewModels/Pages/SettingsViewModel.cs @@ -19,14 +19,21 @@ // (Rights in Technical Data and Computer Software), as applicable. using CommunityToolkit.Mvvm.ComponentModel; +using RevitLookup.Services; using RevitLookup.Services.Contracts; using Wpf.Ui; using Wpf.Ui.Appearance; using Wpf.Ui.Controls; +using static Wpf.Ui.Win32.Utilities; namespace RevitLookup.ViewModels.Pages; -public sealed partial class SettingsViewModel(ISettingsService settingsService, INavigationService navigationService, IWindow window) : ObservableObject +public sealed partial class SettingsViewModel( + ISettingsService settingsService, + INavigationService navigationService, + NotificationService notificationService, + IWindow window) + : ObservableObject { [ObservableProperty] private ApplicationTheme _theme = settingsService.Theme; [ObservableProperty] private WindowBackdropType _background = settingsService.Background; @@ -54,7 +61,13 @@ public sealed partial class SettingsViewModel(ISettingsService settingsService, partial void OnThemeChanged(ApplicationTheme value) { settingsService.Theme = value; - ApplicationThemeManager.Apply(settingsService.Theme, settingsService.Background); + if (IsOSWindows11OrNewer) + { + ApplicationThemeManager.Apply(settingsService.Theme, settingsService.Background); + return; + } + + notificationService.ShowSuccess("Theme changed", "Changes will take effect for new windows"); } partial void OnBackgroundChanged(WindowBackdropType value)