static Core() { LauncherPrefs = new LauncherPrefs(); }
public void Initialize() { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Logger.Debug($"Syn3 Updater {Assembly.GetEntryAssembly()?.GetName().Version} ({LauncherPrefs.ReleaseTypeInstalled}) is Starting"); if (!Environment.GetCommandLineArgs().Contains("/launcher")) { try { Process.Start("Launcher.exe"); Application.Current.Shutdown(); } catch (Win32Exception e) { Logger.Debug("Something went wrong launching 'Launcher.exe', skipping launcher!"); Logger.Debug(e.GetFullMessage()); } } ConfigFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\CyanLabs\\Syn3Updater"; ConfigFile = ConfigFolderPath + "\\settings.json"; if (!Directory.Exists(ConfigFolderPath)) { Directory.CreateDirectory(ConfigFolderPath); } if (File.Exists(ConfigFile)) { try { Settings = JsonConvert.DeserializeObject <JsonSettings>(File.ReadAllText(ConfigFile)); } catch (JsonReaderException) { File.Delete(ConfigFile); Settings = new JsonSettings(); } } else { Logger.Debug("No settings file found, initializing JSON settings"); Settings = new JsonSettings(); } if (File.Exists(ConfigFolderPath + "\\launcherPrefs.json")) { try { LauncherPrefs = JsonConvert.DeserializeObject <LauncherPrefs>(File.ReadAllText(ConfigFolderPath + "\\launcherPrefs.json")); } catch (JsonReaderException) { File.Delete(ConfigFolderPath + "\\launcherPrefs.json"); LauncherPrefs = new LauncherPrefs(); } } else { LauncherPrefs = new LauncherPrefs(); } // ReSharper disable once IdentifierTypo // ReSharper disable once UnusedVariable Logger.Debug("Determining language to use for the application"); List <LanguageModel> langs = LanguageManager.Languages; CultureInfo ci = CultureInfo.InstalledUICulture; if (string.IsNullOrWhiteSpace(Settings.Lang)) { Logger.Debug($"Language is not set, inferring language from system culture. Lang={ci.TwoLetterISOLanguageName}"); Settings.Lang = ci.TwoLetterISOLanguageName; } Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Lang); Logger.Debug($"Language is set to {Settings.Lang}"); if (string.IsNullOrWhiteSpace(Settings.DownloadPath)) { string downloads = SystemHelper.GetPath(SystemHelper.KnownFolder.Downloads); Logger.Debug($"Download location is not set, defaulting to {downloads}\\Syn3Updater\\"); Settings.DownloadPath = $@"{downloads}\Syn3Updater\"; } Logger.Debug("Determining download path to use for the application"); DownloadPath = Instance.Settings.DownloadPath; try { if (!Directory.Exists(DownloadPath)) { Logger.Debug("Download location does not exist"); Directory.CreateDirectory(DownloadPath); } Logger.Debug($"Download path is set to {DownloadPath}"); } catch (DirectoryNotFoundException) { string downloads = SystemHelper.GetPath(SystemHelper.KnownFolder.Downloads); Logger.Debug($"Download location was invalid, defaulting to {downloads}\\Syn3Updater\\"); Settings.DownloadPath = $@"{downloads}\Syn3Updater\"; DownloadPath = Instance.Settings.DownloadPath; } catch (IOException) { string downloads = SystemHelper.GetPath(SystemHelper.KnownFolder.Downloads); Logger.Debug($"Download location was invalid, defaulting to {downloads}\\Syn3Updater\\"); Settings.DownloadPath = $@"{downloads}\Syn3Updater\"; DownloadPath = Instance.Settings.DownloadPath; } string version = Instance.Settings.CurrentSyncVersion.ToString(); string decimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; Logger.Debug($"Current Sync Version set to {version}, Decimal seperator set to {decimalSeparator}"); try { if (version.Length == 7) { SyncVersion = $"{version[0]}{decimalSeparator}{version[1]}{decimalSeparator}{version.Substring(2, version.Length - 2)}"; } else { SyncVersion = $"0{decimalSeparator}0{decimalSeparator}00000"; } } catch (IndexOutOfRangeException e) { Logger.Debug(e.GetFullMessage()); } Logger.Debug("Launching main window"); if (_mainWindow == null) { _mainWindow = new MainWindow(); } if (!_mainWindow.IsVisible) { _mainWindow.Show(); } if (_mainWindow.WindowState == WindowState.Minimized) { _mainWindow.WindowState = WindowState.Normal; } }
private ApplicationManager() { LauncherPrefs = new LauncherPrefs(); Settings = new JsonSettings(); }
private AppMan() { LauncherPrefs = new LauncherPrefs(); MainSettings = new JsonMainSettings(); }