private void ReadINIFile() { if (File.Exists("Updater.ini")) { INIManager UpdaterINI = new INIManager("Updater.ini"); DownLoader.Title = Title = UpdaterINI.GetPrivateString("UI", "Title", Title); WN.Content = UpdaterINI.GetPrivateString("UI", "WhatNew", WN.Content.ToString()); RemindMeLater.Content = UpdaterINI.GetPrivateString("UI", "RemindLater", RemindMeLater.Content.ToString()); UpdateNow.Content = UpdaterINI.GetPrivateString("UI", "UpdateNow", UpdateNow.Content.ToString()); AvailableVer.Content = UpdaterINI.GetPrivateString("UI", "Available", AvailableVer.Content.ToString()); CurrentVer.Content = UpdaterINI.GetPrivateString("UI", "Current", CurrentVer.Content.ToString()); DownLoader.PleaseWait.Content = UpdaterINI.GetPrivateString("UI", "PleaseWait", DownLoader.PleaseWait.Content.ToString()); Downloader.DownloadingUpdate = UpdaterINI.GetPrivateString("UI", "DownloadingFile", Downloader.DownloadingUpdate); Downloader.ExtractUpdate = UpdaterINI.GetPrivateString("UI", "ExtractingUpdate", Downloader.ExtractUpdate); switch (UpdaterINI.GetPrivateString("Updates", "Type")) { case "GitHub": MyStatic.Type = UpdateType.GitHubReleases; break; case "XMLS": MyStatic.Type = UpdateType.XMLServer; break; case "API": MyStatic.Type = UpdateType.WSXZApi; break; case "None": MyStatic.Type = UpdateType.None; break; } MyStatic.LinkOrToken = UpdaterINI.GetPrivateString("Updates", "LinkORToken"); MyStatic.RunAfterUpdate = UpdaterINI.GetPrivateString("Updates", "Run"); MyStatic.RunAfterUpdateParams = UpdaterINI.GetPrivateString("Updates", "RunParams"); MyStatic.LogLanguage = UpdaterINI.GetPrivateString("UI", "LogLang"); if (UpdaterINI.GetPrivateString("UI", "DarkTheme") == "1") { var uri = new Uri("DarkTheme.xaml", UriKind.Relative); ResourceDictionary resourceDict = Application.LoadComponent(uri) as ResourceDictionary; Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(resourceDict); } } }
private void WriteINIFile() //Bad { if (File.Exists("Updater.ini")) { INIManager UpdaterINI = new INIManager("Updater.ini"); UpdaterINI.WritePrivateString("UI", "Title", Title); UpdaterINI.WritePrivateString("UI", "WhatNew", WN.Content.ToString()); UpdaterINI.WritePrivateString("UI", "RemindLater", RemindMeLater.Content.ToString()); UpdaterINI.WritePrivateString("UI", "UpdateNow", UpdateNow.Content.ToString()); UpdaterINI.WritePrivateString("UI", "Available", AvailableVer.Content.ToString()); UpdaterINI.WritePrivateString("UI", "Current", CurrentVer.Content.ToString()); UpdaterINI.WritePrivateString("UI", "PleaseWait", DownLoader.PleaseWait.Content.ToString()); UpdaterINI.WritePrivateString("UI", "DownloadingFile", Downloader.DownloadingUpdate); UpdaterINI.WritePrivateString("UI", "ExtractingUpdate", Downloader.ExtractUpdate); UpdaterINI.WritePrivateString("UI", "DarkTheme", Application.Current.Resources.MergedDictionaries.Count.ToString()); UpdaterINI.WritePrivateString("UI", "LogLang", MyStatic.LogLanguage); UpdaterINI.WritePrivateString("Updates", "LinkORToken", MyStatic.LinkOrToken); UpdaterINI.WritePrivateString("Updates", "Run", MyStatic.RunAfterUpdate); UpdaterINI.WritePrivateString("Updates", "RunParams", MyStatic.RunAfterUpdateParams); switch (MyStatic.Type) { case UpdateType.GitHubReleases: UpdaterINI.WritePrivateString("Updates", "Type", "GitHub"); break; case UpdateType.XMLServer: UpdaterINI.WritePrivateString("Updates", "Type", "XMLS"); break; case UpdateType.WSXZApi: UpdaterINI.WritePrivateString("Updates", "Type", "API"); break; case UpdateType.None: UpdaterINI.WritePrivateString("Updates", "Type", "None"); UpdaterINI.WritePrivateString("Updates", "LinkORToken", "Undefined"); UpdaterINI.WritePrivateString("Updates", "Run", "Undefined"); break; } } }