Skip to content

Commit 242f6a8

Browse files
Merge pull request #4 from Stone-Red-Code/develop
Develop
2 parents d4cd384 + f7f75a4 commit 242f6a8

12 files changed

Lines changed: 160 additions & 156 deletions
-278 KB
Binary file not shown.

installer/Installer.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#expr Exec('cmd.exe /C ', 'dotnet build -o "' + SourcePath + '\publish" -c Release ' + SourcePath + '..\src\DesktopMagic\')
55

66
#define MyAppName "DesktopMagic"
7-
#define MyAppVersion GetVersionNumbersString("/publish/DesktopMagic.exe")
7+
#define MyAppVersion GetStringFileInfo("/publish/DesktopMagic.exe","ProductVersion")
88
#define MyAppPublisher "Stone_Red"
99
#define MyAppExeName "DesktopMagic.exe"
1010

src/DesktopMagic/App.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
<ResourceDictionary.MergedDictionaries>
99
<ResourceDictionary Source="Resources\Strings\StringResources.en.xaml" />
1010
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Grey" SecondaryColor="LightBlue" />
11-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
11+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
1212
<ResourceDictionary Source="pack://application:,,,/BusyIndicator;component/Theme/Default.xaml" />
13+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ObsoleteBrushes.xaml" />
14+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ObsoleteStyles.xaml" />
1315
<ResourceDictionary Source="Resources\Images\ImageResources.xaml" />
1416
</ResourceDictionary.MergedDictionaries>
1517
<Thickness x:Key="DefaultMargin" Top="6" Left="6" Right="6" Bottom ="6"></Thickness>

src/DesktopMagic/App.xaml.cs

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
global using Stone_Red_Utilities.Logging;
2-
3-
using Stone_Red_C_Sharp_Utilities.Logging;
1+
using CuteUtils.Logging;
42

53
using System;
64
using System.IO;
@@ -17,28 +15,65 @@ public partial class App : Application
1715
public const string AppGuid = "{{61FE5CE9-47C3-4255-A1F4-5BCF4ACA0879}";
1816

1917
public const string AppName = "Desktop Magic";
20-
private readonly string logFilePath;
18+
19+
private static readonly string logFilePath = Path.Combine(ApplicationDataPath, $"{AppName}.log");
2120

2221
private readonly Thread? eventThread;
22+
2323
private readonly EventWaitHandle eventWaitHandle;
2424

25-
private readonly Logger logger = new Logger();
26-
public static string ApplicationDataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
25+
public static Logger Logger { get; } = new Logger()
26+
{
27+
Config = new()
28+
{
29+
FatalConfig = new OutputConfig()
30+
{
31+
ConsoleColor = ConsoleColor.DarkRed,
32+
LogTarget = LogTarget.DebugConsole | LogTarget.File,
33+
FilePath = logFilePath
34+
},
35+
ErrorConfig = new OutputConfig()
36+
{
37+
ConsoleColor = ConsoleColor.Red,
38+
LogTarget = LogTarget.DebugConsole | LogTarget.File,
39+
FilePath = logFilePath
40+
},
41+
WarnConfig = new OutputConfig()
42+
{
43+
ConsoleColor = ConsoleColor.Yellow,
44+
LogTarget = LogTarget.DebugConsole | LogTarget.File,
45+
FilePath = logFilePath
46+
},
47+
InfoConfig = new OutputConfig()
48+
{
49+
ConsoleColor = ConsoleColor.White,
50+
LogTarget = LogTarget.DebugConsole | LogTarget.File,
51+
FilePath = logFilePath
52+
},
53+
DebugConfig = new OutputConfig()
54+
{
55+
ConsoleColor = ConsoleColor.Gray,
56+
LogTarget = LogTarget.DebugConsole,
57+
},
58+
FormatConfig = new FormatConfig()
59+
{
60+
DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:HH:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}"
61+
}
62+
}
63+
};
2764

28-
public static Logger Logger => ((App)Current).logger;
65+
public static string ApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
2966

3067
public App()
3168
{
32-
logFilePath = ApplicationDataPath + "\\log.log";
33-
3469
// Setup global event handler
3570
eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew);
3671

3772
//check if creating new was successful
3873
if (!createdNew)
3974
{
4075
Setup(false);
41-
Logger.Log("Shutting down because other instance already running.", "Setup", LogSeverity.Warn);
76+
Logger.LogWarn("Shutting down because other instance already running.", source: "Setup");
4277
//Shutdown Application
4378
_ = eventWaitHandle.Set();
4479
Current.Shutdown();
@@ -71,50 +106,13 @@ private void Setup(bool clearLogFile)
71106
{
72107
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
73108

74-
Logger.Config = new LogConfig()
75-
{
76-
FatalConfig = new OutputConfig()
77-
{
78-
Color = ConsoleColor.DarkRed,
79-
LogTarget = LogTarget.DebugConsole | LogTarget.File,
80-
FilePath = logFilePath
81-
},
82-
ErrorConfig = new OutputConfig()
83-
{
84-
Color = ConsoleColor.Red,
85-
LogTarget = LogTarget.DebugConsole | LogTarget.File,
86-
FilePath = logFilePath
87-
},
88-
WarnConfig = new OutputConfig()
89-
{
90-
Color = ConsoleColor.Yellow,
91-
LogTarget = LogTarget.DebugConsole | LogTarget.File,
92-
FilePath = logFilePath
93-
},
94-
InfoConfig = new OutputConfig()
95-
{
96-
Color = ConsoleColor.White,
97-
LogTarget = LogTarget.DebugConsole | LogTarget.File,
98-
FilePath = logFilePath
99-
},
100-
DebugConfig = new OutputConfig()
101-
{
102-
Color = ConsoleColor.Gray,
103-
LogTarget = LogTarget.DebugConsole,
104-
},
105-
FormatConfig = new FormatConfig()
106-
{
107-
DebugConsoleFormat = $"> {{{LogFormatType.DateTime}:HH:mm:ss}} | {{{LogFormatType.LogSeverity},-5}} | {{{LogFormatType.Message}}}\nat {{{LogFormatType.LineNumber}}} | {{{LogFormatType.FilePath}}}"
108-
}
109-
};
110-
111109
try
112110
{
113111
if (!Directory.Exists(ApplicationDataPath))
114112
{
115113
_ = Directory.CreateDirectory(ApplicationDataPath);
116114
}
117-
Logger.Log("Created ApplicationData Folder", "Main");
115+
Logger.LogInfo("Created ApplicationData Folder", source: "Main");
118116
}
119117
catch (Exception ex)
120118
{
@@ -127,12 +125,12 @@ private void Setup(bool clearLogFile)
127125
Logger.ClearLogFile(LogSeverity.Info);
128126
}
129127

130-
Logger.Log("Log setup complete", "Setup");
128+
Logger.LogInfo("Setup complete", source: "Setup");
131129
}
132130

133131
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
134132
{
135133
Exception exception = (Exception)e.ExceptionObject;
136-
Logger.Log(exception + (e.IsTerminating ? "\t Process terminating!" : ""), exception.Source, LogSeverity.Fatal);
134+
Logger.LogFatal(exception + (e.IsTerminating ? "\t Process terminating!" : ""), source: exception.Source ?? "Unknown");
137135
}
138136
}

src/DesktopMagic/BuiltInWindowElements/MusicVisualizerPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private void FftCalculated(object? sender, FftEventArgs e)
272272
}
273273
catch (Exception ex)
274274
{
275-
App.Logger.Log(ex.Message, "Music Visualizer", LogSeverity.Error);
275+
App.Logger.LogError(ex.Message, source: "Music Visualizer");
276276
}
277277
}
278278

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>WinExe</OutputType>
5-
<UseWPF>true</UseWPF>
6-
<RootNamespace>DesktopMagic</RootNamespace>
7-
<ApplicationIcon>icon.ico</ApplicationIcon>
8-
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
9-
<Authors>Stone_Red</Authors>
10-
<Version>1.0.1.0</Version>
11-
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
12-
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
13-
<AssemblyVersion>1.0.1.0</AssemblyVersion>
14-
<FileVersion>1.0.1.0</FileVersion>
15-
<TargetFramework>net8.0-windows7.0</TargetFramework>
16-
<Nullable>enable</Nullable>
17-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<UseWPF>true</UseWPF>
6+
<RootNamespace>DesktopMagic</RootNamespace>
7+
<ApplicationIcon>icon.ico</ApplicationIcon>
8+
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
9+
<Authors>Stone_Red</Authors>
10+
<Version>1.0.1.240501</Version>
11+
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
12+
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
13+
<AssemblyVersion>1.0.1.0501</AssemblyVersion>
14+
<FileVersion>1.0.1.0501</FileVersion>
15+
<TargetFramework>net8.0-windows7.0</TargetFramework>
16+
<Nullable>enable</Nullable>
17+
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
18+
</PropertyGroup>
1819

19-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
</PropertyGroup>
20+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
</PropertyGroup>
2223

23-
<ItemGroup>
24-
<None Remove="icon.ico" />
25-
<None Remove="icons8_volunteering_26_85L_icon.ico" />
26-
<None Remove="icon_Dark.ico" />
27-
<None Remove="Resources\Images\modio-cog-blue.png" />
28-
<None Remove="Resources\Images\modio-logo-bluedark.png" />
29-
</ItemGroup>
24+
<ItemGroup>
25+
<None Remove="icon.ico" />
26+
<None Remove="icons8_volunteering_26_85L_icon.ico" />
27+
<None Remove="icon_Dark.ico" />
28+
<None Remove="Resources\Images\modio-cog-blue.png" />
29+
<None Remove="Resources\Images\modio-logo-bluedark.png" />
30+
</ItemGroup>
3031

31-
<ItemGroup>
32-
<Resource Include="Resources\Images\modio-cog-blue.png">
33-
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
34-
</Resource>
35-
</ItemGroup>
32+
<ItemGroup>
33+
<Resource Include="Resources\Images\modio-cog-blue.png">
34+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
35+
</Resource>
36+
</ItemGroup>
3637

37-
<ItemGroup>
38-
<PackageReference Include="BusyIndicators" Version="2.1.2" />
39-
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
40-
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
41-
<PackageReference Include="Modio.NET" Version="1.1.1" />
42-
<PackageReference Include="NAudio" Version="2.2.1" />
43-
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.2" />
44-
<PackageReference Include="System.Management" Version="8.0.0" />
45-
</ItemGroup>
38+
<ItemGroup>
39+
<PackageReference Include="BusyIndicators" Version="2.1.2" />
40+
<PackageReference Include="CuteUtils" Version="1.0.0" />
41+
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.0" />
42+
<PackageReference Include="MaterialDesignThemes" Version="5.0.0" />
43+
<PackageReference Include="Modio.NET" Version="1.1.1" />
44+
<PackageReference Include="NAudio" Version="2.2.1" />
45+
<PackageReference Include="System.Management" Version="8.0.0" />
46+
</ItemGroup>
4647

47-
<ItemGroup>
48-
<ProjectReference Include="..\DesktopMagicPluginAPI\DesktopMagic.Api.csproj" />
49-
</ItemGroup>
48+
<ItemGroup>
49+
<ProjectReference Include="..\DesktopMagicPluginAPI\DesktopMagic.Api.csproj" />
50+
</ItemGroup>
5051

51-
<ItemGroup>
52-
<Resource Include="icon_Dark.ico">
53-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
54-
</Resource>
55-
<Resource Include="icon.ico">
56-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
57-
</Resource>
58-
<Resource Include="Resources\Images\modio-logo-bluedark.png" />
59-
</ItemGroup>
52+
<ItemGroup>
53+
<Resource Include="icon_Dark.ico">
54+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
55+
</Resource>
56+
<Resource Include="icon.ico">
57+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
58+
</Resource>
59+
<Resource Include="Resources\Images\modio-logo-bluedark.png" />
60+
</ItemGroup>
6061
</Project>

src/DesktopMagic/GlobalSuppressions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
1010
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
1111
[assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")]
12+
[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")]

src/DesktopMagic/Helpers/SettingElementGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void Generate(SettingElement settingElement, DockPanel dockPanel, TextBlo
222222

223223
private void DisplayException(string message)
224224
{
225-
App.Logger.Log(message, "PluginInput");
225+
App.Logger.LogInfo(message, source: "PluginInput");
226226
_ = MessageBox.Show("File execution error:\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
227227
int index = MainWindow.WindowNames.IndexOf(optionsComboBox.SelectedItem.ToString() ?? string.Empty);
228228

src/DesktopMagic/MainWindow.xaml.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Collections.Generic;
1010
using System.Diagnostics;
1111
using System.IO;
12+
using System.IO.Packaging;
1213
using System.Linq;
1314
using System.Reflection;
1415
using System.Text.Json;
@@ -63,9 +64,9 @@ public MainWindow()
6364
SetLanguageDictionary();
6465

6566
#if DEBUG
66-
Title = $"{App.AppName} - Dev {Assembly.GetExecutingAssembly().GetName().Version}";
67+
Title = $"{App.AppName} - Dev {System.Windows.Forms.Application.ProductVersion}";
6768
#else
68-
Title = $"{App.AppName} - {Assembly.GetExecutingAssembly().GetName().Version}";
69+
Title = $"{App.AppName} - {System.Windows.Forms.Application.ProductVersion}";
6970
#endif
7071
}
7172
catch (Exception ex)
@@ -86,23 +87,23 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
8687
{
8788
_ = Directory.CreateDirectory(App.ApplicationDataPath + "\\Plugins");
8889
}
89-
App.Logger.Log("Created Plugins Folder", "Main");
90+
App.Logger.LogInfo("Created Plugins Folder", source: "Main");
9091

9192
//Write To Log File and Load Elements
9293

93-
App.Logger.Log("Loading Plugin names", "Main");
94+
App.Logger.LogInfo("Loading Plugin names", source: "Main");
9495
LoadPlugins();
95-
App.Logger.Log("Loading Layout names", "Main");
96+
App.Logger.LogInfo("Loading Layout names", source: "Main");
9697
LoadSettings();
97-
App.Logger.Log("Loading Layout", "Main");
98+
App.Logger.LogInfo("Loading Layout", source: "Main");
9899
LoadLayout();
99100

100101
loaded = true;
101-
App.Logger.Log("Window Loaded", "Main");
102+
App.Logger.LogInfo("Window Loaded", source: "Main");
102103
}
103104
catch (Exception ex)
104105
{
105-
App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
106+
App.Logger.LogError(ex.Message, source: "Main");
106107
_ = MessageBox.Show(ex.ToString());
107108
}
108109
}
@@ -126,27 +127,27 @@ private void LoadPlugins()
126127

127128
if (pluginDllPath is null)
128129
{
129-
App.Logger.Log($"Plugin \"{directory}\" has no \"main.dll\"", "Main", LogSeverity.Error);
130+
App.Logger.LogError($"Plugin \"{directory}\" has no \"main.dll\"", source: "Main");
130131
continue;
131132
}
132133

133134
if (pluginMetadataPath is null)
134135
{
135-
App.Logger.Log($"Plugin \"{directory}\" has no \"metadata.json\"", "Main", LogSeverity.Warn);
136+
App.Logger.LogWarn($"Plugin \"{directory}\" has no \"metadata.json\"", source: "Main");
136137
continue;
137138
}
138139

139140
PluginMetadata? pluginMetadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(pluginMetadataPath));
140141

141142
if (pluginMetadata is null)
142143
{
143-
App.Logger.Log($"Plugin \"{directory}\" has no valid \"metadata.json\"", "Main", LogSeverity.Error);
144+
App.Logger.LogError($"Plugin \"{directory}\" has no valid \"metadata.json\"", source: "Main");
144145
continue;
145146
}
146147

147148
if (plugins.ContainsKey(pluginMetadata.Id))
148149
{
149-
App.Logger.Log($"Plugin \"{directory}\" has the same id as another plugin", "Main", LogSeverity.Error);
150+
App.Logger.LogError($"Plugin \"{directory}\" has the same id as another plugin", source: "Main");
150151
continue;
151152
}
152153

@@ -204,7 +205,7 @@ private void LoadPlugin(uint pluginId)
204205
}
205206
catch (Exception ex)
206207
{
207-
App.Logger.Log(ex.Message, "Main", LogSeverity.Error);
208+
App.Logger.LogError(ex.Message, source: "Main");
208209
}
209210
}
210211
return;

0 commit comments

Comments
 (0)