mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Upgrade Avalonia
This commit is contained in:
1 parent
e03d6b20e9
commit
ee6d295fd8
24 files changed
+337
-311
No files matched your search
@@ -1,29 +1,29 @@
|
||||
using System;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Threading;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Input.Platform;
|
||||
using IContainer = DryIoc.IContainer;
|
||||
using Avalonia.Threading;
|
||||
using DryIoc;
|
||||
|
||||
namespace Artemis.UI.Shared;
|
||||
|
||||
/// <summary>
|
||||
/// Static UI helpers.
|
||||
/// Static UI helpers.
|
||||
/// </summary>
|
||||
public static class UI
|
||||
{
|
||||
private static readonly BehaviorSubject<bool> MicaEnabledSubject = new(false);
|
||||
|
||||
public static EventLoopScheduler BackgroundScheduler = new(ts => new Thread(ts));
|
||||
|
||||
static UI()
|
||||
{
|
||||
KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox).StartWith(true);
|
||||
}
|
||||
|
||||
public static EventLoopScheduler BackgroundScheduler = new EventLoopScheduler(ts => new Thread(ts));
|
||||
|
||||
internal static void ClearCache()
|
||||
{
|
||||
DeviceVisualizer.BitmapCache.Clear();
|
||||
MicaEnabled = MicaEnabledSubject.AsObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,4 +40,24 @@ public static class UI
|
||||
/// Gets a boolean indicating whether hotkeys are to be disabled.
|
||||
/// </summary>
|
||||
public static IObservable<bool> KeyBindingsEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether the Mica effect should be enabled.
|
||||
/// </summary>
|
||||
public static IObservable<bool> MicaEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Changes whether Mica should be enabled.
|
||||
/// </summary>
|
||||
/// <param name="enabled"></param>
|
||||
public static void SetMicaEnabled(bool enabled)
|
||||
{
|
||||
if (MicaEnabledSubject.Value != enabled)
|
||||
Dispatcher.UIThread.Invoke(() => MicaEnabledSubject.OnNext(enabled));
|
||||
}
|
||||
|
||||
internal static void ClearCache()
|
||||
{
|
||||
DeviceVisualizer.BitmapCache.Clear();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user