Skip to content

Commit

Permalink
Restore Windows 10 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Dec 3, 2023
1 parent fa51d90 commit 5301493
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion RevitLookup.UI/Win32/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Wpf.Ui.Win32;
/// </summary>
// ReSharper disable InconsistentNaming
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
internal class Utilities
public class Utilities
{
private static readonly PlatformID _osPlatform = Environment.OSVersion.Platform;

Expand Down
17 changes: 15 additions & 2 deletions RevitLookup/Core/ComponentModel/Descriptors/ColorDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
});
}
}
17 changes: 15 additions & 2 deletions RevitLookup/ViewModels/Pages/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5301493

Please sign in to comment.