mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
- Show version number in window title
- Add `PluginName` property to `IPluginData` - Add `PluginPath` property to `IPluginData`
This commit is contained in:
@@ -17,6 +17,7 @@ namespace DesktopMagic
|
||||
|
||||
private static string ApplicationName = "Google Calendar API .NET " + MainWindow.AppName;
|
||||
|
||||
[Obsolete]
|
||||
public (List<string>, List<string>) GetEvents()
|
||||
{
|
||||
List<string> upcomingEventNames = new List<string>();
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Windows.Media;
|
||||
using System.Text.Json;
|
||||
using Stone_Red_Utilities.Logging;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DesktopMagic
|
||||
{
|
||||
@@ -78,7 +79,7 @@ namespace DesktopMagic
|
||||
InitializeComponent();
|
||||
|
||||
SetLanguageDictionary();
|
||||
this.Title = AppName;
|
||||
this.Title = $"{AppName} - {Assembly.GetExecutingAssembly().GetName().Version}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -974,7 +975,7 @@ namespace DesktopMagic
|
||||
|
||||
private void OpenPluginsFolderButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = System.Diagnostics.Process.Start("explorer.exe", applicationDataPath + "\\Plugins");
|
||||
_ = Process.Start("explorer.exe", applicationDataPath + "\\Plugins");
|
||||
}
|
||||
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace DesktopMagic
|
||||
|
||||
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
|
||||
|
||||
public string PluginName => window.PluginName;
|
||||
|
||||
public string PluginPath => window.PluginFolderPath;
|
||||
|
||||
public void UpdateWindow() => window.UpdatePluginWindow();
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,8 @@ namespace DesktopMagic
|
||||
private System.Timers.Timer valueTimer;
|
||||
|
||||
private Plugin pluginClassInstance;
|
||||
private readonly string pluginName = "";
|
||||
private string pluginFolderPath = "";
|
||||
public string PluginName { get; private set; }
|
||||
public string PluginFolderPath { get; private set; }
|
||||
private bool stop = false;
|
||||
|
||||
public event Action PluginLoaded;
|
||||
@@ -60,7 +60,7 @@ namespace DesktopMagic
|
||||
t.Elapsed += Elapsed;
|
||||
t.Start();
|
||||
|
||||
this.pluginName = pluginName;
|
||||
this.PluginName = pluginName;
|
||||
|
||||
key = Registry.CurrentUser.CreateSubKey(@"Software\" + MainWindow.AppName);
|
||||
this.Top = double.Parse(key.GetValue(pluginName + "WindowTop", 100).ToString());
|
||||
@@ -117,9 +117,9 @@ namespace DesktopMagic
|
||||
|
||||
private void LoadPlugin()
|
||||
{
|
||||
pluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{MainWindow.AppName}\\Plugins\\{pluginName}";
|
||||
PluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{MainWindow.AppName}\\Plugins\\{PluginName}";
|
||||
|
||||
if (!File.Exists($"{pluginFolderPath}\\{pluginName}.dll"))
|
||||
if (!File.Exists($"{PluginFolderPath}\\{PluginName}.dll"))
|
||||
{
|
||||
_ = MessageBox.Show("File does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Exit();
|
||||
@@ -142,7 +142,7 @@ namespace DesktopMagic
|
||||
|
||||
private void ExecuteSource()
|
||||
{
|
||||
byte[] assemblyBytes = File.ReadAllBytes($"{pluginFolderPath}\\{pluginName}.dll");
|
||||
byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\{PluginName}.dll");
|
||||
Assembly dll = Assembly.Load(assemblyBytes);
|
||||
Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin));
|
||||
|
||||
@@ -189,6 +189,8 @@ namespace DesktopMagic
|
||||
}
|
||||
|
||||
private void LoadOptions(object instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.WriteLine(instance.GetType().FullName);
|
||||
FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField);
|
||||
@@ -211,13 +213,22 @@ namespace DesktopMagic
|
||||
}
|
||||
|
||||
settingElements = settingElements.OrderBy(x => x.OrderIndex).ToList();
|
||||
if (MainWindow.PluginsSettings.ContainsKey(pluginName))
|
||||
if (MainWindow.PluginsSettings.ContainsKey(PluginName))
|
||||
{
|
||||
MainWindow.PluginsSettings[pluginName] = settingElements;
|
||||
MainWindow.PluginsSettings[PluginName] = settingElements;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.PluginsSettings.Add(pluginName, settingElements);
|
||||
MainWindow.PluginsSettings.Add(PluginName, settingElements);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
stop = true;
|
||||
MainWindow.Logger.Log(ex.ToString(), "Plugin");
|
||||
_ = MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,14 +300,14 @@ namespace DesktopMagic
|
||||
|
||||
private void Window_LocationChanged(object sender, EventArgs e)
|
||||
{
|
||||
key.SetValue(pluginName + "WindowTop", this.Top);
|
||||
key.SetValue(pluginName + "WindowLeft", this.Left);
|
||||
key.SetValue(PluginName + "WindowTop", this.Top);
|
||||
key.SetValue(PluginName + "WindowLeft", this.Left);
|
||||
}
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
key.SetValue(pluginName + "WindowHeight", this.Height);
|
||||
key.SetValue(pluginName + "WindowWidth", this.Width);
|
||||
key.SetValue(PluginName + "WindowHeight", this.Height);
|
||||
key.SetValue(PluginName + "WindowWidth", this.Width);
|
||||
tileBar.CaptionHeight = this.ActualHeight - 10;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
- [IPluginData](#T-DesktopMagicPluginAPI-IPluginData 'DesktopMagicPluginAPI.IPluginData')
|
||||
- [Color](#P-DesktopMagicPluginAPI-IPluginData-Color 'DesktopMagicPluginAPI.IPluginData.Color')
|
||||
- [Font](#P-DesktopMagicPluginAPI-IPluginData-Font 'DesktopMagicPluginAPI.IPluginData.Font')
|
||||
- [PluginName](#P-DesktopMagicPluginAPI-IPluginData-PluginName 'DesktopMagicPluginAPI.IPluginData.PluginName')
|
||||
- [PluginPath](#P-DesktopMagicPluginAPI-IPluginData-PluginPath 'DesktopMagicPluginAPI.IPluginData.PluginPath')
|
||||
- [WindowPosition](#P-DesktopMagicPluginAPI-IPluginData-WindowPosition 'DesktopMagicPluginAPI.IPluginData.WindowPosition')
|
||||
- [WindowSize](#P-DesktopMagicPluginAPI-IPluginData-WindowSize 'DesktopMagicPluginAPI.IPluginData.WindowSize')
|
||||
- [UpdateWindow()](#M-DesktopMagicPluginAPI-IPluginData-UpdateWindow 'DesktopMagicPluginAPI.IPluginData.UpdateWindow')
|
||||
@@ -325,6 +327,20 @@ Gets the color of the main application.
|
||||
|
||||
Gets the font of the main application.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-IPluginData-PluginName'></a>
|
||||
### PluginName `property`
|
||||
|
||||
##### Summary
|
||||
|
||||
Gets the name of the plugin.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-IPluginData-PluginPath'></a>
|
||||
### PluginPath `property`
|
||||
|
||||
##### Summary
|
||||
|
||||
Gets the path of the parent directory of the plugin.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-IPluginData-WindowPosition'></a>
|
||||
### WindowPosition `property`
|
||||
|
||||
|
||||
@@ -281,6 +281,16 @@
|
||||
Gets the window position of the plugin window.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.IPluginData.PluginName">
|
||||
<summary>
|
||||
Gets the name of the plugin.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.IPluginData.PluginPath">
|
||||
<summary>
|
||||
Gets the path of the parent directory of the plugin.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
|
||||
<summary>
|
||||
Updates the plugin window.
|
||||
|
||||
@@ -27,6 +27,16 @@ namespace DesktopMagicPluginAPI
|
||||
/// </summary>
|
||||
Point WindowPosition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the plugin.
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the parent directory of the plugin.
|
||||
/// </summary>
|
||||
string PluginPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates the plugin window.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user