diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp.App/Program.cs b/src/GuiApp/Avalonia/FileTime.GuiApp.App/Program.cs index b76c324..4aa6f13 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp.App/Program.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp.App/Program.cs @@ -18,18 +18,6 @@ public static class Program public static string AppDataRoot { get; private set; } public static string EnvironmentName { get; private set; } - static Program() - { -#if DEBUG - InitDevelopment(); -#else - InitRelease(); -#endif - InitLogging(); - - Log.Logger.Information("Early app starting..."); - } - private static void InitDevelopment() { EnvironmentName = "Development"; @@ -92,6 +80,15 @@ public static class Program [STAThread] public static void Main(string[] args) { +#if DEBUG + InitDevelopment(); +#else + InitRelease(); +#endif + InitLogging(); + + Log.Logger.Information("Early app starting..."); + AppDomain.CurrentDomain.FirstChanceException -= OnFirstChanceException; AppDomain.CurrentDomain.UnhandledException -= OnAppDomainUnhandledException; TaskScheduler.UnobservedTaskException -= OnTaskSchedulerUnobservedTaskException; @@ -117,13 +114,13 @@ public static class Program .UseReactiveUI() .LogToTrace(); - private static void OnTaskSchedulerUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) + private static void OnTaskSchedulerUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) => HandleUnhandledException(sender, e.Exception); - private static void OnAppDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) + private static void OnAppDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) => HandleUnhandledException(sender, e.ExceptionObject as Exception); - private static void OnFirstChanceException(object? sender, FirstChanceExceptionEventArgs e) + private static void OnFirstChanceException(object? sender, FirstChanceExceptionEventArgs e) => HandleUnhandledException(sender, e.Exception); private static void HandleUnhandledException(object? sender, Exception? ex, [CallerMemberName] string caller = "") @@ -135,7 +132,7 @@ public static class Program sender?.GetType().ToString() ?? "null", sender?.ToString() ?? "null", ex); - + Log.CloseAndFlush(); } } \ No newline at end of file diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/ViewModels/MainWindowDesignViewModel.cs b/src/GuiApp/Avalonia/FileTime.GuiApp/ViewModels/MainWindowDesignViewModel.cs index ae4892e..8f2b1ff 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/ViewModels/MainWindowDesignViewModel.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/ViewModels/MainWindowDesignViewModel.cs @@ -10,7 +10,7 @@ namespace FileTime.GuiApp.ViewModels; public class MainWindowDesignViewModel : IMainWindowViewModel { public bool Loading => false; - public IObservable MainFont { get; } = new BehaviorSubject(""); + public IObservable MainFont { get; } = new BehaviorSubject(null); public string Title => "FileTime Design Preview"; public IGuiAppState AppState { get; } public IItemPreviewService ItemPreviewService { get; } diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml index dcca1b8..c5ae642 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml @@ -11,6 +11,7 @@ RequestedThemeVariant="Dark" Title="FileTime" TransparencyLevelHint="Blur" + d:DataContext="vm:MainWindowDesignViewModel" d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"