mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Change app name from "Desktop Magic" to "DesktopMagic" and some QOL improvments
This commit is contained in:
@@ -14,13 +14,17 @@ public partial class App : Application
|
||||
{
|
||||
public const string AppGuid = "{{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0879}";
|
||||
|
||||
public const string AppName = "Desktop Magic";
|
||||
public const string AppName = "DesktopMagic";
|
||||
|
||||
// This is the previous name of the application, used to migrate the application data folder
|
||||
private const string PreviousAppName = "Desktop Magic";
|
||||
|
||||
private static readonly string logFilePath = Path.Combine(ApplicationDataPath, $"{AppName}.log");
|
||||
|
||||
private readonly Thread? eventThread;
|
||||
|
||||
private readonly EventWaitHandle eventWaitHandle;
|
||||
public static string ApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
|
||||
|
||||
public static string PluginsPath => Path.Combine(ApplicationDataPath, "Plugins");
|
||||
|
||||
public static Logger Logger { get; } = new Logger()
|
||||
{
|
||||
@@ -62,7 +66,7 @@ public partial class App : Application
|
||||
}
|
||||
};
|
||||
|
||||
public static string ApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
|
||||
private static string PreviousApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", PreviousAppName);
|
||||
|
||||
public App()
|
||||
{
|
||||
@@ -114,15 +118,27 @@ public partial class App : Application
|
||||
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(PreviousApplicationDataPath))
|
||||
{
|
||||
Directory.Move(PreviousApplicationDataPath, ApplicationDataPath);
|
||||
Logger.LogInfo("Migrated ApplicationData Folder", source: "Setup");
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ApplicationDataPath))
|
||||
{
|
||||
_ = Directory.CreateDirectory(ApplicationDataPath);
|
||||
Logger.LogInfo("Created ApplicationData Folder", source: "Setup");
|
||||
}
|
||||
|
||||
if (!Directory.Exists(PluginsPath))
|
||||
{
|
||||
_ = Directory.CreateDirectory(PluginsPath);
|
||||
Logger.LogInfo("Created Plugins Folder", source: "Setup");
|
||||
}
|
||||
Logger.LogInfo("Created ApplicationData Folder", source: "Main");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = MessageBox.Show(ex.ToString());
|
||||
_ = MessageBox.Show(ex.ToString(), AppName, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Logger.Log(ex.Message, "Setup", LogSeverity.Error);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
MinHeight="520"
|
||||
MinWidth="570"
|
||||
WindowState="Minimized"
|
||||
StateChanged="Window_StateChanged"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<busyIndicator:BusyMask x:Name="BusyIndicator" IsBusy="{Binding IsLoading}" IndicatorType="Cogs" BusyContent="Please wait..." BusyContentMargin="0,20,0,0" IsBusyAtStartup="False">
|
||||
|
||||
@@ -9,12 +9,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
@@ -65,7 +62,7 @@ namespace DesktopMagic
|
||||
new System.Windows.Forms.ToolStripMenuItem("Toggle Edit Mode", null, (s, e) => { EditCheckBox.IsChecked = !EditCheckBox.IsChecked; EditCheckBox_Click(null, null); }),
|
||||
new System.Windows.Forms.ToolStripMenuItem("Plugin Manager", 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("Exit", null, (s, e) => Close()),
|
||||
new System.Windows.Forms.ToolStripMenuItem("Quit", null, (s, e) => Quit()),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -81,7 +78,7 @@ namespace DesktopMagic
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = MessageBox.Show(ex.ToString());
|
||||
_ = MessageBox.Show(ex.ToString(), App.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +90,6 @@ namespace DesktopMagic
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(App.ApplicationDataPath + "\\Plugins"))
|
||||
{
|
||||
_ = Directory.CreateDirectory(App.ApplicationDataPath + "\\Plugins");
|
||||
}
|
||||
App.Logger.LogInfo("Created Plugins Folder", source: "Main");
|
||||
|
||||
//Write To Log File and Load Elements
|
||||
|
||||
App.Logger.LogInfo("Loading Plugin names", source: "Main");
|
||||
@@ -114,7 +105,7 @@ namespace DesktopMagic
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.LogError(ex.Message, source: "Main");
|
||||
_ = MessageBox.Show(ex.ToString());
|
||||
_ = MessageBox.Show(ex.ToString(), App.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +119,7 @@ namespace DesktopMagic
|
||||
plugins.Add(buildInPlugin.Id, new(buildInPlugin, string.Empty));
|
||||
}
|
||||
|
||||
string pluginsPath = App.ApplicationDataPath + "\\Plugins";
|
||||
|
||||
foreach (string directory in Directory.GetDirectories(pluginsPath))
|
||||
foreach (string directory in Directory.GetDirectories(App.PluginsPath))
|
||||
{
|
||||
string? pluginDllPath = Directory.GetFiles(directory, "main.dll").FirstOrDefault();
|
||||
string? pluginMetadataPath = Directory.GetFiles(directory, "metadata.json").FirstOrDefault();
|
||||
@@ -289,9 +278,23 @@ namespace DesktopMagic
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
MessageBoxResult msbRes = MessageBox.Show((string)FindResource("wantToCloseProgram"), App.AppName, MessageBoxButton.YesNo);
|
||||
e.Cancel = msbRes != MessageBoxResult.Yes;
|
||||
SaveSettings();
|
||||
|
||||
if (blockWindowsClosing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
EditCheckBox.IsChecked = false;
|
||||
EditCheckBox_Click(null, null);
|
||||
ShowInTaskbar = false;
|
||||
Visibility = Visibility.Collapsed;
|
||||
|
||||
foreach (Window item in Windows)
|
||||
{
|
||||
WindowPos.SendWpfWindowBack(item);
|
||||
WindowPos.SendWpfWindowBack(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
@@ -305,22 +308,6 @@ namespace DesktopMagic
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void Window_StateChanged(object? sender, EventArgs? e)
|
||||
{
|
||||
if (WindowState == WindowState.Minimized)
|
||||
{
|
||||
EditCheckBox.IsChecked = false;
|
||||
EditCheckBox_Click(null, null);
|
||||
ShowInTaskbar = false;
|
||||
Visibility = Visibility.Collapsed;
|
||||
foreach (Window item in Windows)
|
||||
{
|
||||
WindowPos.SendWpfWindowBack(item);
|
||||
WindowPos.SendWpfWindowBack(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Windows
|
||||
|
||||
#region Options
|
||||
@@ -387,9 +374,15 @@ namespace DesktopMagic
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit()
|
||||
{
|
||||
blockWindowsClosing = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = Process.Start("explorer.exe", App.ApplicationDataPath + "\\Plugins");
|
||||
_ = Process.Start("explorer.exe", App.PluginsPath);
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
@@ -507,7 +500,7 @@ namespace DesktopMagic
|
||||
{
|
||||
if (Settings.Layouts.Any(l => l.Name.Trim() == inputDialog.ResponseText.Trim()))
|
||||
{
|
||||
_ = MessageBox.Show((string)FindResource("layoutAlreadyExists"));
|
||||
_ = MessageBox.Show((string)FindResource("layoutAlreadyExists"), App.AppName, MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -627,14 +620,13 @@ namespace DesktopMagic
|
||||
|
||||
if (!showWindow && minimize)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
Window_StateChanged(null, null);
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
Window_StateChanged(null, null);
|
||||
RestoreWindow();
|
||||
}
|
||||
|
||||
mainWindowDataContext.IsLoading = false;
|
||||
}
|
||||
|
||||
@@ -670,7 +662,7 @@ namespace DesktopMagic
|
||||
PluginManager pluginManager = new PluginManager();
|
||||
pluginManager.ShowDialog();
|
||||
LoadPlugins();
|
||||
LoadLayout(false);
|
||||
LoadLayout(Visibility != Visibility.Visible);
|
||||
}
|
||||
|
||||
private void SetLanguageDictionary()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:dataContexts="clr-namespace:DesktopMagic.DataContexts"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=dataContexts:PluginManagerDataContext}"
|
||||
Title="PluginManager"
|
||||
Title="Plugin Manager"
|
||||
Height="450"
|
||||
Width="800"
|
||||
MinHeight="520"
|
||||
|
||||
Reference in New Issue
Block a user