Fix log messages

This commit is contained in:
Stone_Red
2023-12-27 21:57:41 +01:00
parent 449e497ffa
commit 5b640280f2
5 changed files with 136 additions and 119 deletions
+4 -4
View File
@@ -23,10 +23,10 @@ public partial class App : Application
#else
private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif
private Thread? eventThread;
private EventWaitHandle eventWaitHandle;
private readonly Thread? eventThread;
private readonly EventWaitHandle eventWaitHandle;
private Logger logger = new Logger();
private readonly Logger logger = new Logger();
public static string ApplicationDataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", AppName);
public static Logger Logger
@@ -42,7 +42,7 @@ public partial class App : Application
public App()
{
logFilePath = ApplicationDataPath + "\\Log.log";
logFilePath = ApplicationDataPath + "\\log.log";
// Setup global event handler
eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew);
@@ -10,6 +10,7 @@ internal class MainWindowDataContext : INotifyPropertyChanged
public event PropertyChangedEventHandler? PropertyChanged;
private static DesktopMagicSettings settings = new();
private bool isLoading = true;
public DesktopMagicSettings Settings
{
@@ -21,6 +22,16 @@ internal class MainWindowDataContext : INotifyPropertyChanged
}
}
public bool IsLoading
{
get => isLoading;
set
{
isLoading = value;
OnPropertyChanged();
}
}
public static DesktopMagicSettings GetSettings()
{
return settings;
+5 -2
View File
@@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:busyIndicator="https://github.com/moh3ngolshani/BusyIndicator"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -22,7 +23,8 @@
StateChanged="Window_StateChanged"
Loaded="Window_Loaded">
<Grid x:Name="grid">
<busyIndicator:BusyMask x:Name="BusyIndicator" IsBusy="{Binding IsLoading}" IndicatorType="Cogs" BusyContent="Please wait..." BusyContentMargin="0,20,0,0" IsBusyAtStartup="False">
<Grid>
<TextBlock TextWrapping="Wrap" Text="0" VerticalAlignment="Top" FontFamily="Comic Sans MS" Loaded="TextBlock_Loaded" Foreground="Transparent" />
<Grid>
<Grid.RowDefinitions>
@@ -137,7 +139,7 @@
</StackPanel>
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
<Button x:Name="updatePluginsButton" Content="{DynamicResource updatePlugins}" Margin="0,0,0,5" HorizontalAlignment="Center" Width="170" Click="UpdatePluginsButton_Click" FontWeight="Regular" />
<Button x:Name="githubButton" Content="GitHub" HorizontalAlignment="Center" Width="170" Click="GithubButton_Click" FontWeight="Regular" Cursor="Hand" />
<Button x:Name="githubButton" Content="GitHub" HorizontalAlignment="Center" Width="170" Click="GitHubButton_Click" FontWeight="Regular" Cursor="Hand" />
</StackPanel>
<StackPanel Grid.Column="2" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
<Button x:Name="downloadPluginsButton" Content="{DynamicResource pluginManager}" Margin="0,0,0,5" HorizontalAlignment="Right" Width="170" Click="PluginManagerButton_Click" FontWeight="Regular" Cursor="Hand" />
@@ -147,4 +149,5 @@
</Grid>
</Grid>
</Grid>
</busyIndicator:BusyMask>
</Window>
+9 -6
View File
@@ -111,6 +111,7 @@ namespace DesktopMagic
private void LoadPlugins()
{
mainWindowDataContext.IsLoading = true;
plugins.Clear();
foreach (var buildInPlugin in builtInPlugins.Keys)
@@ -153,6 +154,7 @@ namespace DesktopMagic
plugins.Add(pluginMetadata.Id, new(pluginMetadata, directory));
}
mainWindowDataContext.IsLoading = false;
}
#endregion Load
@@ -194,7 +196,6 @@ namespace DesktopMagic
if (index >= 0)
{
//Not sure how to handle this
try
{
blockWindowsClosing = false;
@@ -428,8 +429,8 @@ namespace DesktopMagic
private void CornerRadiusTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
{
bool sucess = int.TryParse(cornerRadiusTextBox.Text, out int cornerRadius);
if (sucess)
bool success = int.TryParse(cornerRadiusTextBox.Text, out int cornerRadius);
if (success)
{
cornerRadiusTextBox.Foreground = Brushes.Black;
Settings.CurrentLayout.Theme.CornerRadius = cornerRadius;
@@ -442,8 +443,8 @@ namespace DesktopMagic
private void MarginTextBox_TextChanged(object? sender, TextChangedEventArgs? e)
{
bool sucess = int.TryParse(marginTextBox.Text, out int margin);
if (sucess)
bool success = int.TryParse(marginTextBox.Text, out int margin);
if (success)
{
marginTextBox.Foreground = Brushes.Black;
Settings.CurrentLayout.Theme.Margin = margin;
@@ -535,6 +536,7 @@ namespace DesktopMagic
private void LoadLayout(bool minimize = true)
{
mainWindowDataContext.IsLoading = true;
cornerRadiusTextBox.Text = Settings.CurrentLayout.Theme.CornerRadius.ToString();
marginTextBox.Text = Settings.CurrentLayout.Theme.Margin.ToString();
blockWindowsClosing = false;
@@ -607,6 +609,7 @@ namespace DesktopMagic
WindowState = WindowState.Normal;
Window_StateChanged(null, null);
}
mainWindowDataContext.IsLoading = false;
}
#endregion Layout
@@ -634,7 +637,7 @@ namespace DesktopMagic
RestoreWindow();
}
private void GithubButton_Click(object sender, RoutedEventArgs e)
private void GitHubButton_Click(object sender, RoutedEventArgs e)
{
string uri = "https://github.com/Stone-Red-Code/DesktopMagic";
ProcessStartInfo psi = new ProcessStartInfo
@@ -121,7 +121,7 @@ public partial class PluginWindow : Window
private void Window_ContentRendered(object? sender, EventArgs e)
{
App.Logger.Log($"\"{PluginMetadata}\" - Starting plugin thread", "Plugin");
App.Logger.Log($"\"{PluginMetadata.Name}\" - Starting plugin thread", "Plugin");
pluginThread = new Thread(LoadPlugin);
pluginThread.Start();
}