mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
242f6a8388 | ||
|
|
f7f75a4580 | ||
|
|
475623f333 | ||
|
|
aa1733e0c6 | ||
|
|
5804bade47 | ||
|
|
ca9f426bba | ||
|
|
4cd8c51592 |
Binary file not shown.
@@ -4,7 +4,7 @@
|
|||||||
#expr Exec('cmd.exe /C ', 'dotnet build -o "' + SourcePath + '\publish" -c Release ' + SourcePath + '..\src\DesktopMagic\')
|
#expr Exec('cmd.exe /C ', 'dotnet build -o "' + SourcePath + '\publish" -c Release ' + SourcePath + '..\src\DesktopMagic\')
|
||||||
|
|
||||||
#define MyAppName "DesktopMagic"
|
#define MyAppName "DesktopMagic"
|
||||||
#define MyAppVersion GetVersionNumbersString("/publish/DesktopMagic.exe")
|
#define MyAppVersion GetStringFileInfo("/publish/DesktopMagic.exe","ProductVersion")
|
||||||
#define MyAppPublisher "Stone_Red"
|
#define MyAppPublisher "Stone_Red"
|
||||||
#define MyAppExeName "DesktopMagic.exe"
|
#define MyAppExeName "DesktopMagic.exe"
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Resources\Strings\StringResources.en.xaml" />
|
<ResourceDictionary Source="Resources\Strings\StringResources.en.xaml" />
|
||||||
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Grey" SecondaryColor="LightBlue" />
|
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Grey" SecondaryColor="LightBlue" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/BusyIndicator;component/Theme/Default.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/BusyIndicator;component/Theme/Default.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ObsoleteBrushes.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ObsoleteStyles.xaml" />
|
||||||
<ResourceDictionary Source="Resources\Images\ImageResources.xaml" />
|
<ResourceDictionary Source="Resources\Images\ImageResources.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<Thickness x:Key="DefaultMargin" Top="6" Left="6" Right="6" Bottom ="6"></Thickness>
|
<Thickness x:Key="DefaultMargin" Top="6" Left="6" Right="6" Bottom ="6"></Thickness>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
global using Stone_Red_Utilities.Logging;
|
using CuteUtils.Logging;
|
||||||
|
|
||||||
using Stone_Red_C_Sharp_Utilities.Logging;
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -17,20 +15,57 @@ public partial class App : Application
|
|||||||
public const string AppGuid = "{{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0879}";
|
public const string AppGuid = "{{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0879}";
|
||||||
|
|
||||||
public const string AppName = "Desktop Magic";
|
public const string AppName = "Desktop Magic";
|
||||||
private readonly string logFilePath;
|
|
||||||
|
private static readonly string logFilePath = Path.Combine(ApplicationDataPath, $"{AppName}.log");
|
||||||
|
|
||||||
private readonly Thread? eventThread;
|
private readonly Thread? eventThread;
|
||||||
|
|
||||||
private readonly EventWaitHandle eventWaitHandle;
|
private readonly EventWaitHandle eventWaitHandle;
|
||||||
|
|
||||||
private readonly Logger logger = new Logger();
|
public static Logger Logger { get; } = new Logger()
|
||||||
public static string ApplicationDataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
|
{
|
||||||
|
Config = new()
|
||||||
|
{
|
||||||
|
FatalConfig = new OutputConfig()
|
||||||
|
{
|
||||||
|
ConsoleColor = ConsoleColor.DarkRed,
|
||||||
|
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
||||||
|
FilePath = logFilePath
|
||||||
|
},
|
||||||
|
ErrorConfig = new OutputConfig()
|
||||||
|
{
|
||||||
|
ConsoleColor = ConsoleColor.Red,
|
||||||
|
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
||||||
|
FilePath = logFilePath
|
||||||
|
},
|
||||||
|
WarnConfig = new OutputConfig()
|
||||||
|
{
|
||||||
|
ConsoleColor = ConsoleColor.Yellow,
|
||||||
|
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
||||||
|
FilePath = logFilePath
|
||||||
|
},
|
||||||
|
InfoConfig = new OutputConfig()
|
||||||
|
{
|
||||||
|
ConsoleColor = ConsoleColor.White,
|
||||||
|
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
||||||
|
FilePath = logFilePath
|
||||||
|
},
|
||||||
|
DebugConfig = new OutputConfig()
|
||||||
|
{
|
||||||
|
ConsoleColor = ConsoleColor.Gray,
|
||||||
|
LogTarget = LogTarget.DebugConsole,
|
||||||
|
},
|
||||||
|
FormatConfig = new FormatConfig()
|
||||||
|
{
|
||||||
|
DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:HH:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public static Logger Logger => ((App)Current).logger;
|
public static string ApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
|
||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
logFilePath = ApplicationDataPath + "\\log.log";
|
|
||||||
|
|
||||||
// Setup global event handler
|
// Setup global event handler
|
||||||
eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew);
|
eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew);
|
||||||
|
|
||||||
@@ -38,7 +73,7 @@ public partial class App : Application
|
|||||||
if (!createdNew)
|
if (!createdNew)
|
||||||
{
|
{
|
||||||
Setup(false);
|
Setup(false);
|
||||||
Logger.Log("Shutting down because other instance already running.", "Setup", LogSeverity.Warn);
|
Logger.LogWarn("Shutting down because other instance already running.", source: "Setup");
|
||||||
//Shutdown Application
|
//Shutdown Application
|
||||||
_ = eventWaitHandle.Set();
|
_ = eventWaitHandle.Set();
|
||||||
Current.Shutdown();
|
Current.Shutdown();
|
||||||
@@ -71,50 +106,13 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
Logger.Config = new LogConfig()
|
|
||||||
{
|
|
||||||
FatalConfig = new OutputConfig()
|
|
||||||
{
|
|
||||||
Color = ConsoleColor.DarkRed,
|
|
||||||
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
|
||||||
FilePath = logFilePath
|
|
||||||
},
|
|
||||||
ErrorConfig = new OutputConfig()
|
|
||||||
{
|
|
||||||
Color = ConsoleColor.Red,
|
|
||||||
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
|
||||||
FilePath = logFilePath
|
|
||||||
},
|
|
||||||
WarnConfig = new OutputConfig()
|
|
||||||
{
|
|
||||||
Color = ConsoleColor.Yellow,
|
|
||||||
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
|
||||||
FilePath = logFilePath
|
|
||||||
},
|
|
||||||
InfoConfig = new OutputConfig()
|
|
||||||
{
|
|
||||||
Color = ConsoleColor.White,
|
|
||||||
LogTarget = LogTarget.DebugConsole | LogTarget.File,
|
|
||||||
FilePath = logFilePath
|
|
||||||
},
|
|
||||||
DebugConfig = new OutputConfig()
|
|
||||||
{
|
|
||||||
Color = ConsoleColor.Gray,
|
|
||||||
LogTarget = LogTarget.DebugConsole,
|
|
||||||
},
|
|
||||||
FormatConfig = new FormatConfig()
|
|
||||||
{
|
|
||||||
DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:HH:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(ApplicationDataPath))
|
if (!Directory.Exists(ApplicationDataPath))
|
||||||
{
|
{
|
||||||
_ = Directory.CreateDirectory(ApplicationDataPath);
|
_ = Directory.CreateDirectory(ApplicationDataPath);
|
||||||
}
|
}
|
||||||
Logger.Log("Created ApplicationData Folder", "Main");
|
Logger.LogInfo("Created ApplicationData Folder", source: "Main");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -127,12 +125,12 @@ public partial class App : Application
|
|||||||
Logger.ClearLogFile(LogSeverity.Info);
|
Logger.ClearLogFile(LogSeverity.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Log("Log setup complete", "Setup");
|
Logger.LogInfo("Setup complete", source: "Setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
Exception exception = (Exception)e.ExceptionObject;
|
Exception exception = (Exception)e.ExceptionObject;
|
||||||
Logger.Log(exception + (e.IsTerminating ? "\t Process terminating!" : ""), exception.Source, LogSeverity.Fatal);
|
Logger.LogFatal(exception + (e.IsTerminating ? "\t Process terminating!" : ""), source: exception.Source ?? "Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ internal class MusicVisualizerPlugin : Plugin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.Log(ex.Message, "Music Visualizer", LogSeverity.Error);
|
App.Logger.LogError(ex.Message, source: "Music Visualizer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +1,61 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<RootNamespace>DesktopMagic</RootNamespace>
|
<RootNamespace>DesktopMagic</RootNamespace>
|
||||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||||
<Authors>Stone_Red</Authors>
|
<Authors>Stone_Red</Authors>
|
||||||
<Version>1.0.1.0</Version>
|
<Version>1.0.1.240501</Version>
|
||||||
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
|
||||||
<AssemblyVersion>1.0.1.0</AssemblyVersion>
|
<AssemblyVersion>1.0.1.0501</AssemblyVersion>
|
||||||
<FileVersion>1.0.1.0</FileVersion>
|
<FileVersion>1.0.1.0501</FileVersion>
|
||||||
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="icon.ico" />
|
<None Remove="icon.ico" />
|
||||||
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
||||||
<None Remove="icon_Dark.ico" />
|
<None Remove="icon_Dark.ico" />
|
||||||
<None Remove="Resources\Images\modio-cog-blue.png" />
|
<None Remove="Resources\Images\modio-cog-blue.png" />
|
||||||
<None Remove="Resources\Images\modio-logo-bluedark.png" />
|
<None Remove="Resources\Images\modio-logo-bluedark.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Resources\Images\modio-cog-blue.png">
|
<Resource Include="Resources\Images\modio-cog-blue.png">
|
||||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BusyIndicators" Version="2.1.2" />
|
<PackageReference Include="BusyIndicators" Version="2.1.2" />
|
||||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
<PackageReference Include="CuteUtils" Version="1.0.0" />
|
||||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.0" />
|
||||||
<PackageReference Include="Modio.NET" Version="1.1.1" />
|
<PackageReference Include="MaterialDesignThemes" Version="5.0.0" />
|
||||||
<PackageReference Include="NAudio" Version="2.2.1" />
|
<PackageReference Include="Modio.NET" Version="1.1.1" />
|
||||||
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.2" />
|
<PackageReference Include="NAudio" Version="2.2.1" />
|
||||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DesktopMagicPluginAPI\DesktopMagic.Api.csproj" />
|
<ProjectReference Include="..\DesktopMagicPluginAPI\DesktopMagic.Api.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="icon_Dark.ico">
|
<Resource Include="icon_Dark.ico">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource Include="icon.ico">
|
<Resource Include="icon.ico">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource Include="Resources\Images\modio-logo-bluedark.png" />
|
<Resource Include="Resources\Images\modio-logo-bluedark.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -9,3 +9,4 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
|
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
|
||||||
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
|
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
|
||||||
[assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")]
|
[assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")]
|
||||||
|
[assembly: SuppressMessage("Major Code Smell", "S3885:\"Assembly.Load\" should be used", Justification = "Assembly.Load does not load dependencies", Scope = "member", Target = "~M:DesktopMagic.PluginWindow.ExecuteSource")]
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ internal class SettingElementGenerator(ComboBox optionsComboBox)
|
|||||||
|
|
||||||
private void DisplayException(string message)
|
private void DisplayException(string message)
|
||||||
{
|
{
|
||||||
App.Logger.Log(message, "PluginInput");
|
App.Logger.LogInfo(message, source: "PluginInput");
|
||||||
_ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString() ?? string.Empty);
|
int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString() ?? string.Empty);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Packaging;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@@ -63,9 +64,9 @@ namespace DesktopMagic
|
|||||||
SetLanguageDictionary();
|
SetLanguageDictionary();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Title = $"{App.AppName} - Dev {Assembly.GetExecutingAssembly().GetName().Version}";
|
Title = $"{App.AppName} - Dev {System.Windows.Forms.Application.ProductVersion}";
|
||||||
#else
|
#else
|
||||||
Title = $"{App.AppName} - {Assembly.GetExecutingAssembly().GetName().Version}";
|
Title = $"{App.AppName} - {System.Windows.Forms.Application.ProductVersion}";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -86,23 +87,23 @@ namespace DesktopMagic
|
|||||||
{
|
{
|
||||||
_ = Directory.CreateDirectory(App.ApplicationDataPath + "\\Plugins");
|
_ = Directory.CreateDirectory(App.ApplicationDataPath + "\\Plugins");
|
||||||
}
|
}
|
||||||
App.Logger.Log("Created Plugins Folder", "Main");
|
App.Logger.LogInfo("Created Plugins Folder", source: "Main");
|
||||||
|
|
||||||
//Write To Log File and Load Elements
|
//Write To Log File and Load Elements
|
||||||
|
|
||||||
App.Logger.Log("Loading Plugin names", "Main");
|
App.Logger.LogInfo("Loading Plugin names", source: "Main");
|
||||||
LoadPlugins();
|
LoadPlugins();
|
||||||
App.Logger.Log("Loading Layout names", "Main");
|
App.Logger.LogInfo("Loading Layout names", source: "Main");
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
App.Logger.Log("Loading Layout", "Main");
|
App.Logger.LogInfo("Loading Layout", source: "Main");
|
||||||
LoadLayout();
|
LoadLayout();
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
App.Logger.Log("Window Loaded", "Main");
|
App.Logger.LogInfo("Window Loaded", source: "Main");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
|
App.Logger.LogError(ex.Message, source: "Main");
|
||||||
_ = MessageBox.Show(ex.ToString());
|
_ = MessageBox.Show(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,13 +127,13 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
if (pluginDllPath is null)
|
if (pluginDllPath is null)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"Plugin \"{directory}\" has no \"main.dll\"", "Main", LogSeverity.Error);
|
App.Logger.LogError($"Plugin \"{directory}\" has no \"main.dll\"", source: "Main");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginMetadataPath is null)
|
if (pluginMetadataPath is null)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"Plugin \"{directory}\" has no \"metadata.json\"", "Main", LogSeverity.Warn);
|
App.Logger.LogWarn($"Plugin \"{directory}\" has no \"metadata.json\"", source: "Main");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +141,13 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
if (pluginMetadata is null)
|
if (pluginMetadata is null)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"Plugin \"{directory}\" has no valid \"metadata.json\"", "Main", LogSeverity.Error);
|
App.Logger.LogError($"Plugin \"{directory}\" has no valid \"metadata.json\"", source: "Main");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugins.ContainsKey(pluginMetadata.Id))
|
if (plugins.ContainsKey(pluginMetadata.Id))
|
||||||
{
|
{
|
||||||
App.Logger.Log($"Plugin \"{directory}\" has the same id as another plugin", "Main", LogSeverity.Error);
|
App.Logger.LogError($"Plugin \"{directory}\" has the same id as another plugin", source: "Main");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ namespace DesktopMagic
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
|
App.Logger.LogError(ex.Message, source: "Main");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate>
|
<ControlTemplate>
|
||||||
<TextBlock Text="No plugins found!" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<TextBlock Text="No plugins found!" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
@@ -68,30 +68,32 @@
|
|||||||
|
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding InstalledPluginsSearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="InstalledPluginsSearchTextBox_TextChanged" materialDesign:HintAssist.Hint="Search..." materialDesign:TextFieldAssist.HasLeadingIcon="True" materialDesign:TextFieldAssist.LeadingIcon="Search" />
|
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding InstalledPluginsSearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="InstalledPluginsSearchTextBox_TextChanged" materialDesign:HintAssist.Hint="Search..." materialDesign:TextFieldAssist.HasLeadingIcon="True" materialDesign:TextFieldAssist.LeadingIcon="Search" />
|
||||||
|
|
||||||
<ItemsControl Grid.Row="2" Grid.Column="1" ItemsSource="{Binding InstalledPlugins}">
|
<ScrollViewer Grid.Row="2" Grid.Column="1" VerticalScrollBarVisibility="Auto">
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl ItemsSource="{Binding InstalledPlugins}">
|
||||||
<DataTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<Border BorderBrush="LightGray" BorderThickness="1">
|
<DataTemplate>
|
||||||
<local:ModEntry />
|
<Border BorderBrush="LightGray" BorderThickness="1">
|
||||||
</Border>
|
<local:ModEntry />
|
||||||
</DataTemplate>
|
</Border>
|
||||||
</ItemsControl.ItemTemplate>
|
</DataTemplate>
|
||||||
<ItemsControl.Style>
|
</ItemsControl.ItemTemplate>
|
||||||
<Style TargetType="ItemsControl">
|
<ItemsControl.Style>
|
||||||
<Style.Triggers>
|
<Style TargetType="ItemsControl">
|
||||||
<Trigger Property="HasItems" Value="false">
|
<Style.Triggers>
|
||||||
<Setter Property="Template">
|
<Trigger Property="HasItems" Value="false">
|
||||||
<Setter.Value>
|
<Setter Property="Template">
|
||||||
<ControlTemplate>
|
<Setter.Value>
|
||||||
<TextBlock Text="No plugins found!" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<ControlTemplate>
|
||||||
</ControlTemplate>
|
<TextBlock Text="No plugins found!" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
</Setter.Value>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter.Value>
|
||||||
</Trigger>
|
</Setter>
|
||||||
</Style.Triggers>
|
</Trigger>
|
||||||
</Style>
|
</Style.Triggers>
|
||||||
</ItemsControl.Style>
|
</Style>
|
||||||
</ItemsControl>
|
</ItemsControl.Style>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
<Border Grid.Row="3" Grid.ColumnSpan="2" Padding="0 5 0 0" BorderThickness="0 2 0 0" BorderBrush="DarkGray">
|
<Border Grid.Row="3" Grid.ColumnSpan="2" Padding="0 5 0 0" BorderThickness="0 2 0 0" BorderBrush="DarkGray">
|
||||||
<Image Source="{StaticResource ModioLogoBlueDark}" Cursor="Hand" Height="30" MouseUp="Image_MouseUp" HorizontalAlignment="Left" />
|
<Image Source="{StaticResource ModioLogoBlueDark}" Cursor="Hand" Height="30" MouseUp="Image_MouseUp" HorizontalAlignment="Left" />
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace DesktopMagic.Plugins;
|
|||||||
|
|
||||||
public class PluginMetadata
|
public class PluginMetadata
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public uint Id { get; set; }
|
public uint Id { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public partial class PluginWindow : Window
|
|||||||
|
|
||||||
private void Window_ContentRendered(object? sender, EventArgs e)
|
private void Window_ContentRendered(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - Starting plugin thread", "Plugin");
|
App.Logger.LogInfo($"\"{PluginMetadata.Name}\" - Starting plugin thread", source: "Plugin");
|
||||||
pluginThread = new Thread(LoadPlugin);
|
pluginThread = new Thread(LoadPlugin);
|
||||||
pluginThread.Start();
|
pluginThread.Start();
|
||||||
}
|
}
|
||||||
@@ -172,11 +172,11 @@ public partial class PluginWindow : Window
|
|||||||
|
|
||||||
private void LoadPlugin()
|
private void LoadPlugin()
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - Loading plugin", "Plugin");
|
App.Logger.LogInfo($"\"{PluginMetadata.Name}\" - Loading plugin", source: "Plugin");
|
||||||
|
|
||||||
if (pluginClassInstance is null && !File.Exists($"{PluginFolderPath}\\main.dll"))
|
if (pluginClassInstance is null && !File.Exists($"{PluginFolderPath}\\main.dll"))
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - File \"main.dll\" does not exist", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - File \"main.dll\" does not exist", source: "Plugin");
|
||||||
_ = MessageBox.Show("File \"main.dll\" does not exist!", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File \"main.dll\" does not exist!", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
|
||||||
Exit();
|
Exit();
|
||||||
@@ -189,7 +189,7 @@ public partial class PluginWindow : Window
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - {ex}", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - {ex}", source: "Plugin");
|
||||||
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
Exit();
|
Exit();
|
||||||
return;
|
return;
|
||||||
@@ -202,13 +202,12 @@ public partial class PluginWindow : Window
|
|||||||
object? instance = pluginClassInstance;
|
object? instance = pluginClassInstance;
|
||||||
if (instance is null)
|
if (instance is null)
|
||||||
{
|
{
|
||||||
byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\main.dll");
|
Assembly dll = Assembly.LoadFrom($"{PluginFolderPath}\\main.dll");
|
||||||
Assembly dll = Assembly.Load(assemblyBytes);
|
|
||||||
Type? instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin));
|
Type? instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin));
|
||||||
|
|
||||||
if (instanceType is null)
|
if (instanceType is null)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", source: "Plugin");
|
||||||
_ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show($"The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
|
||||||
Exit();
|
Exit();
|
||||||
@@ -224,7 +223,7 @@ public partial class PluginWindow : Window
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - The \"Plugin\" class could not be found! It has to inherit from \"{typeof(Plugin).FullName}\"", source: "Plugin");
|
||||||
_ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show($"The \"Plugin\" class has to inherit from \"{typeof(Plugin).FullName}\"", $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
Exit();
|
Exit();
|
||||||
return;
|
return;
|
||||||
@@ -285,7 +284,7 @@ public partial class PluginWindow : Window
|
|||||||
|
|
||||||
private void LoadOptions(object instance)
|
private void LoadOptions(object instance)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - Loading plugin options", "Plugin");
|
App.Logger.LogInfo($"\"{PluginMetadata.Name}\" - Loading plugin options", source: "Plugin");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -323,7 +322,7 @@ public partial class PluginWindow : Window
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - {ex}", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - {ex}", source: "Plugin");
|
||||||
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
@@ -368,7 +367,7 @@ public partial class PluginWindow : Window
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - {ex}", "Plugin", LogSeverity.Error);
|
App.Logger.LogError($"\"{PluginMetadata.Name}\" - {ex}", source: "Plugin");
|
||||||
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File execution error:\n" + ex, $"Error \"{PluginMetadata.Name}\"", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
Exit();
|
Exit();
|
||||||
return;
|
return;
|
||||||
@@ -382,7 +381,7 @@ public partial class PluginWindow : Window
|
|||||||
|
|
||||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
App.Logger.Log($"\"{PluginMetadata.Name}\" - Stopping plugin", "Plugin");
|
App.Logger.LogInfo($"\"{PluginMetadata.Name}\" - Stopping plugin", source: "Plugin");
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
pluginClassInstance?.Stop();
|
pluginClassInstance?.Stop();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user