mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-25 06:14:31 +00:00
8ff960189e
- Update: Added "Copy Password" to Mafile context menu (if available) - Update: "Save Password" now pre-fills the current password in the "Login Again" dialog when encryption is enabled - Fix: Prevented overlapping confirmation cycles in AutoConfirmer - Fix: Added a Snackbar notification when a confirmation cycle is skipped due to a too frequent timer interval - Fix: Fixed a rare bug where the previous proxy was used instead of the current one during session refresh - Fix: Corrected "Session Permanently Expired" message showing on unrelated errors (e.g. network issues) - UI-Fix: Fixed visual glitch where proxy input appeared non-empty when switching to a mafile-specific proxy - Cleanup: Refactored and cleaned up codebase, improved styling and formatting via ReSharper
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Windows;
|
|
using System.Windows.Interop;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shell;
|
|
using NebulaAuth.Model;
|
|
using Color = System.Drawing.Color;
|
|
|
|
namespace NebulaAuth.Core;
|
|
|
|
public static class ThemeManager
|
|
{
|
|
public static System.Windows.Media.Color DefaultBackgroundColor = System.Windows.Media.Color.FromRgb(30, 32, 37);
|
|
private static readonly Window MainWindow = Application.Current.MainWindow!;
|
|
|
|
static ThemeManager()
|
|
{
|
|
Settings.Instance.PropertyChanged += SettingsOnPropertyChanged;
|
|
}
|
|
|
|
private static void SettingsOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName == nameof(Settings.BackgroundColor))
|
|
{
|
|
UpdateBackground();
|
|
}
|
|
else if (e.PropertyName == nameof(Settings.IconColor))
|
|
{
|
|
UpdateIcon();
|
|
}
|
|
}
|
|
|
|
private static void UpdateIcon()
|
|
{
|
|
var color = Settings.Instance.IconColor;
|
|
if (color == null)
|
|
{
|
|
MainWindow.TaskbarItemInfo = null;
|
|
}
|
|
else
|
|
{
|
|
var c = color.Value;
|
|
var diameter = 14;
|
|
var bitmap = new Bitmap(diameter, diameter);
|
|
var graphics = Graphics.FromImage(bitmap);
|
|
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
var brush = new SolidBrush(Color.FromArgb(c.A, c.R, c.G, c.B));
|
|
graphics.FillEllipse(brush, 0, 0, diameter, diameter);
|
|
var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
|
|
BitmapSizeOptions.FromEmptyOptions());
|
|
|
|
MainWindow.TaskbarItemInfo = new TaskbarItemInfo();
|
|
MainWindow.TaskbarItemInfo.Overlay = bitmapSource;
|
|
}
|
|
}
|
|
|
|
private static void UpdateBackground()
|
|
{
|
|
var color = Settings.Instance.BackgroundColor ?? DefaultBackgroundColor;
|
|
Application.Current.Resources["WindowBackground"] = new SolidColorBrush(color);
|
|
}
|
|
|
|
public static void InitializeTheme()
|
|
{
|
|
UpdateIcon();
|
|
UpdateBackground();
|
|
}
|
|
} |