feat: Theme toggler

This commit is contained in:
rabbitism
2024-02-06 19:57:11 +08:00
committed by rabbitism
parent 84ad981297
commit 5f35f574a9
11 changed files with 182 additions and 5 deletions

View File

@@ -20,4 +20,22 @@ internal static class EventHelper
if(button is not null) button.Click -= handler;
}
}
public static void RegisterEvent<TArgs>(RoutedEvent<TArgs> routedEvent, EventHandler<TArgs> handler, params Button?[] controls)
where TArgs : RoutedEventArgs
{
foreach (var control in controls)
{
control?.AddHandler(routedEvent, handler);
}
}
public static void UnregisterEvent<TArgs>(RoutedEvent<TArgs> routedEvent, EventHandler<TArgs> handler, params Button?[] controls)
where TArgs : RoutedEventArgs
{
foreach (var control in controls)
{
control?.RemoveHandler(routedEvent, handler);
}
}
}

View File

@@ -0,0 +1,14 @@
using Avalonia;
namespace Ursa.Common;
public static class PropertyHelper
{
public static void SetValue<TValue>(AvaloniaProperty<TValue> property, TValue value, params AvaloniaObject?[] elements)
{
foreach (var element in elements)
{
element?.SetValue(property, value);
}
}
}