mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-07 23:39:19 +02:00
Change GetLanguageDictionary method to LanguageDictionary property
This commit is contained in:
@@ -66,6 +66,26 @@ public partial class App : Application
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static ResourceDictionary LanguageDictionary
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ResourceDictionary dict = [];
|
||||||
|
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
|
||||||
|
|
||||||
|
if (currentCulture.Contains("de"))
|
||||||
|
{
|
||||||
|
dict.Source = new Uri("..\\Resources\\Strings\\StringResources.de.xaml", UriKind.Relative);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dict.Source = new Uri("..\\Resources\\Strings\\StringResources.en.xaml", UriKind.Relative);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string PreviousApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", PreviousAppName);
|
private static string PreviousApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", PreviousAppName);
|
||||||
|
|
||||||
public App()
|
public App()
|
||||||
@@ -98,23 +118,6 @@ public partial class App : Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceDictionary GetLanguageDictionary()
|
|
||||||
{
|
|
||||||
ResourceDictionary dict = [];
|
|
||||||
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
|
|
||||||
|
|
||||||
if (currentCulture.Contains("de"))
|
|
||||||
{
|
|
||||||
dict.Source = new Uri("..\\Resources\\Strings\\StringResources.de.xaml", UriKind.Relative);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dict.Source = new Uri("..\\Resources\\Strings\\StringResources.en.xaml", UriKind.Relative);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CloseHandler(object sender, EventArgs e)
|
protected void CloseHandler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
eventWaitHandle.Close();
|
eventWaitHandle.Close();
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ internal class PluginEntryDataContext(PluginMetadata pluginMetadata, ICommand co
|
|||||||
|
|
||||||
public string? Description => pluginMetadata.Description;
|
public string? Description => pluginMetadata.Description;
|
||||||
|
|
||||||
public string Author => pluginMetadata.Author ?? (string)App.GetLanguageDictionary()["unknown"];
|
public string Author => pluginMetadata.Author ?? (string)App.LanguageDictionary["unknown"];
|
||||||
|
|
||||||
public string? Version => pluginMetadata.Version ?? (string)App.GetLanguageDictionary()["unknown"];
|
public string? Version => pluginMetadata.Version ?? (string)App.LanguageDictionary["unknown"];
|
||||||
|
|
||||||
public string? Logo => pluginMetadata.IconUri?.ToString();
|
public string? Logo => pluginMetadata.IconUri?.ToString();
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ internal class PluginEntryDataContext(PluginMetadata pluginMetadata, ICommand co
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(pluginMetadata.ProfileUri?.ToString()))
|
if (string.IsNullOrWhiteSpace(pluginMetadata.ProfileUri?.ToString()))
|
||||||
{
|
{
|
||||||
return new(PackIconKind.FolderOutline, (string)App.GetLanguageDictionary()["folder"], path is not null, new CommandHandler(() => Process.Start("explorer.exe", path!)));
|
return new(PackIconKind.FolderOutline, (string)App.LanguageDictionary["folder"], path is not null, new CommandHandler(() => Process.Start("explorer.exe", path!)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -80,8 +80,8 @@ internal class PluginEntryDataContext(PluginMetadata pluginMetadata, ICommand co
|
|||||||
{
|
{
|
||||||
return mode switch
|
return mode switch
|
||||||
{
|
{
|
||||||
Mode.Install => (string)App.GetLanguageDictionary()["install"],
|
Mode.Install => (string)App.LanguageDictionary["install"],
|
||||||
Mode.Uninstall => (string)App.GetLanguageDictionary()["uninstall"],
|
Mode.Uninstall => (string)App.LanguageDictionary["uninstall"],
|
||||||
_ => throw new NotImplementedException()
|
_ => throw new NotImplementedException()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public partial class ColorDialog : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Resources.MergedDictionaries.Add(App.GetLanguageDictionary());
|
Resources.MergedDictionaries.Add(App.LanguageDictionary);
|
||||||
|
|
||||||
label.Content = content;
|
label.Content = content;
|
||||||
Title = title;
|
Title = title;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public partial class InputDialog : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Resources.MergedDictionaries.Add(App.GetLanguageDictionary());
|
Resources.MergedDictionaries.Add(App.LanguageDictionary);
|
||||||
|
|
||||||
label.Content = content;
|
label.Content = content;
|
||||||
Title = title;
|
Title = title;
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
private readonly Dictionary<PluginMetadata, Type> builtInPlugins = new()
|
private readonly Dictionary<PluginMetadata, Type> builtInPlugins = new()
|
||||||
{
|
{
|
||||||
{new((string)App.GetLanguageDictionary()["musicVisualizer"], 1), typeof(MusicVisualizerPlugin)},
|
{new((string)App.LanguageDictionary["musicVisualizer"], 1), typeof(MusicVisualizerPlugin)},
|
||||||
{new((string)App.GetLanguageDictionary()["time"],2), typeof(TimePlugin)},
|
{new((string)App.LanguageDictionary["time"],2), typeof(TimePlugin)},
|
||||||
{new((string)App.GetLanguageDictionary()["date"],3), typeof(DatePlugin)},
|
{new((string)App.LanguageDictionary["date"],3), typeof(DatePlugin)},
|
||||||
{new((string)App.GetLanguageDictionary()["cpuUsage"], 4), typeof(CpuMonitorPlugin)}
|
{new((string)App.LanguageDictionary["cpuUsage"], 4), typeof(CpuMonitorPlugin)}
|
||||||
};
|
};
|
||||||
|
|
||||||
private bool loaded = false;
|
private bool loaded = false;
|
||||||
@@ -58,17 +58,17 @@ namespace DesktopMagic
|
|||||||
{
|
{
|
||||||
Items =
|
Items =
|
||||||
{
|
{
|
||||||
new System.Windows.Forms.ToolStripMenuItem((string)App.GetLanguageDictionary()["open"], null, (s, e) => RestoreWindow()),
|
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["open"], null, (s, e) => RestoreWindow()),
|
||||||
new System.Windows.Forms.ToolStripMenuItem((string)App.GetLanguageDictionary()["toggleEditMode"], null, (s, e) => { EditCheckBox.IsChecked = !EditCheckBox.IsChecked; EditCheckBox_Click(null, null); }),
|
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary ["toggleEditMode"], null, (s, e) => { EditCheckBox.IsChecked = !EditCheckBox.IsChecked; EditCheckBox_Click(null, null); }),
|
||||||
new System.Windows.Forms.ToolStripMenuItem((string)App.GetLanguageDictionary()["pluginManager"], null, (s, e) => PluginManagerButton_Click(null!, null!)),
|
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["pluginManager"], null, (s, e) => PluginManagerButton_Click(null!, null!)),
|
||||||
new System.Windows.Forms.ToolStripMenuItem("GitHub", null, (s, e) => GitHubButton_Click(null!, null!)),
|
new System.Windows.Forms.ToolStripMenuItem("GitHub", null, (s, e) => GitHubButton_Click(null!, null!)),
|
||||||
new System.Windows.Forms.ToolStripMenuItem((string)App.GetLanguageDictionary()["quit"], null, (s, e) => Quit()),
|
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["quit"], null, (s, e) => Quit()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Resources.MergedDictionaries.Add(App.GetLanguageDictionary());
|
Resources.MergedDictionaries.Add(App.LanguageDictionary);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Title = $"{App.AppName} - Dev {System.Windows.Forms.Application.ProductVersion}";
|
Title = $"{App.AppName} - Dev {System.Windows.Forms.Application.ProductVersion}";
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public partial class PluginManager : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Resources.MergedDictionaries.Add(App.GetLanguageDictionary());
|
Resources.MergedDictionaries.Add(App.LanguageDictionary);
|
||||||
|
|
||||||
DataContext = pluginManagerDataContext;
|
DataContext = pluginManagerDataContext;
|
||||||
searchTimer.Tick += async (sender, e) =>
|
searchTimer.Tick += async (sender, e) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user