diff --git a/FoliCon/ViewModels/MainWindowViewModel.cs b/FoliCon/ViewModels/MainWindowViewModel.cs index bbf2644..2383be8 100644 --- a/FoliCon/ViewModels/MainWindowViewModel.cs +++ b/FoliCon/ViewModels/MainWindowViewModel.cs @@ -233,57 +233,16 @@ public FoliconThemes Theme public MainWindowViewModel(IDialogService dialogService) { - ProcessUtils.CheckWebView2(); - ShowPreviewer = new DelegateCommand(() => - { - _dialogService.ShowPreviewer(_ => { }); - }); - Logger.Info("Application Started, Initializing MainWindowViewModel."); _dialogService = dialogService; - Services.Tracker.Configure() - .Property(p => p.IsRatingVisible, false) - .Property(p => p.IsPosterMockupUsed, true) - .Property(p => p.IsPosterWindowShown, false) - .Property(p => p.AppLanguage, Languages.English) - .Property(p => p.Theme, FoliconThemes.System) - .Property(p => p.EnableErrorReporting, false) - .PersistOn(nameof(PropertyChanged)); - Services.Tracker.Track(this); - var selectedLanguage = AppLanguage; - var cultureInfo = CultureUtils.GetCultureInfoByLanguage(selectedLanguage); - LangProvider.Culture = cultureInfo; - Thread.CurrentThread.CurrentCulture = cultureInfo; - Thread.CurrentThread.CurrentUICulture = cultureInfo; - Kernel32.SetThreadUILanguage((ushort)Thread.CurrentThread.CurrentUICulture.LCID); - InitializeProperties(); + Logger.Info("Application Started, Initializing MainWindowViewModel."); + ProcessUtils.CheckWebView2(); + TrackProperties(); + SetCultureInfo(); InitializeDelegates(); NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; - - - var cmdArgs = ProcessUtils.GetCmdArgs(); - if (!cmdArgs.TryGetValue("path", out var arg)) - { - return; - } - - SelectedFolder = arg; - var mode = cmdArgs["mode"]; - if (mode != "Professional" && - new List { MediaTypes.Mtv, MediaTypes.Tv, MediaTypes.Movie, MediaTypes.Game }.Contains(mode)) - { - IconMode = "Poster"; - SearchMode = mode; - } - else - { - IconMode = "Professional"; - } - Logger.Info("Command Line argument initialized, selected folder: {SelectedFolder}, mode: {IconMode}", - SelectedFolder, IconMode); - SearchAndMakeMethod(); - + ProcessCommandLineArgs(); } - + private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e) { Logger.Debug("Network Availability Changed, Updating StatusBar."); @@ -738,6 +697,7 @@ private void InitializeDelegates() ProcessUtils.StartProcess(SelectedFolder + Path.DirectorySeparatorChar); } }); + ShowPreviewer = new DelegateCommand(() => { _dialogService.ShowPreviewer(_ => { }); }); Logger.ForDebugEvent().Message("Delegates Initialized for MainWindow").Log(); } @@ -1009,6 +969,55 @@ private async Task InitializeClientObjects() Logger.Debug("Client Objects Initialized."); } + private void TrackProperties() + { + Services.Tracker.Configure() + .Property(p => p.IsRatingVisible, false) + .Property(p => p.IsPosterMockupUsed, true) + .Property(p => p.IsPosterWindowShown, false) + .Property(p => p.AppLanguage, Languages.English) + .Property(p => p.Theme, FoliconThemes.System) + .Property(p => p.EnableErrorReporting, false) + .PersistOn(nameof(PropertyChanged)); + Services.Tracker.Track(this); + } + + private void SetCultureInfo() + { + var selectedLanguage = AppLanguage; + var cultureInfo = CultureUtils.GetCultureInfoByLanguage(selectedLanguage); + LangProvider.Culture = cultureInfo; + Thread.CurrentThread.CurrentCulture = cultureInfo; + Thread.CurrentThread.CurrentUICulture = cultureInfo; + Kernel32.SetThreadUILanguage((ushort)Thread.CurrentThread.CurrentUICulture.LCID); + } + + private void ProcessCommandLineArgs() + { + var cmdArgs = ProcessUtils.GetCmdArgs(); + if (!cmdArgs.TryGetValue("path", out var selectedFolder)) + { + return; + } + + SelectedFolder = selectedFolder; + var mode = cmdArgs["mode"]; + if (mode != "Professional" && + new List { MediaTypes.Mtv, MediaTypes.Tv, MediaTypes.Movie, MediaTypes.Game }.Contains(mode)) + { + IconMode = "Poster"; + SearchMode = mode; + } + else + { + IconMode = "Professional"; + } + + Logger.Info("Command Line argument initialized, selected folder: {SelectedFolder}, mode: {IconMode}", + SelectedFolder, IconMode); + SearchAndMakeMethod(); + } + private void AboutMethod() { _dialogService.ShowAboutBox(_ => { });