Normalize the way of Resource access.
MODIFY
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
WalletWasabi.Gui/Behaviors/PasteAddressOnClickBehavior.cs
@@ -56,7 +56,8 @@ namespace WalletWasabi.Gui.Behaviors
public async Task<(bool isAddress, string address)> IsThereABitcoinAddressOnTheClipboardAsync()
{
- var network = ((Global)Application.Current.Resources[Global.GlobalResourceKey]).Network;
+ var global = Application.Current.Resources[Global.GlobalResourceKey] as Global;
+ var network = global.Network;
string text = await Application.Current.Clipboard.GetTextAsync();
if (string.IsNullOrEmpty(text) || text.Length > 100)
{

MODIFY
WalletWasabi.Gui/Converters/LurkingWifeModeStringConverter.cs
WalletWasabi.Gui/Converters/LurkingWifeModeStringConverter.cs
@@ -12,7 +12,7 @@ namespace WalletWasabi.Gui.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- var uiConfig = (UiConfig)Application.Current.Resources[Global.UiConfigResourceKey];
+ var uiConfig = Application.Current.Resources[Global.UiConfigResourceKey] as UiConfig;
if (uiConfig.LurkingWifeMode is true)
{
int len = 10;

MODIFY
WalletWasabi.Gui/Converters/PhaseColorConverter.cs
WalletWasabi.Gui/Converters/PhaseColorConverter.cs
@@ -17,7 +17,7 @@ namespace WalletWasabi.Gui.Converters
{
throw new ArgumentException($"Unknown '{parameter}' value");
}
- var global = (Global)Application.Current.Resources[Global.GlobalResourceKey];
+ var global = Application.Current.Resources[Global.GlobalResourceKey] as Global;
var phaseError = global.ChaumianClient.State.IsInErrorState;
return ((CcjRoundPhase)p <= (CcjRoundPhase)value)

MODIFY
WalletWasabi.Gui/Converters/PrivacyLevelValueConverter.cs
WalletWasabi.Gui/Converters/PrivacyLevelValueConverter.cs
@@ -34,7 +34,7 @@ namespace WalletWasabi.Gui.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- var config = (Config)Application.Current.Resources[Global.ConfigResourceKey];
+ var config = Application.Current.Resources[Global.ConfigResourceKey] as Config;
if (value is int integer)
{
string shield;

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -33,9 +33,13 @@ namespace WalletWasabi.Gui
{
public class Global
{
- public static string GlobalResourceKey = "Wasabi.Ui.Global";
- public static string ConfigResourceKey = "Wasabi.Ui.Config";
- public static string UiConfigResourceKey = "Wasabi.Ui.UiConfig";
+ public const string GlobalResourceKey = "Wasabi.Ui.Global";
+ public const string ConfigResourceKey = "Wasabi.Ui.Config";
+ public const string UiConfigResourceKey = "Wasabi.Ui.UiConfig";
+
+ public const string ThemeBackgroundBrushResourceKey = "ThemeBackgroundBrush";
+ public const string ApplicationAccentForegroundBrushResourceKey = "ApplicationAccentForegroundBrush";
+
public static Global Instance { get; } = new Global();
public string DataDir { get; }
public string TorLogsFile { get; }

Normalize the way of Resource access.