public static DSTimerConfig LoadConfig(string file) { if (!File.Exists(file)) { var config = new DSTimerConfig(); config.m_currentPath = file; return(config); } XmlSerializer serializer = new XmlSerializer(typeof(DSTimerConfig)); using (Stream stream = new FileStream(file, FileMode.Open)) { var config = (DSTimerConfig)serializer.Deserialize(stream); config.m_currentPath = file; return(config); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Config = DSTimerConfig.LoadConfig(DSTimerConfig.DefaultPath); Config.SaveConfig(DSTimerConfig.DefaultPath); switch (Settings.Default.Language.ToLower()) { case "deutsch": Application.CurrentCulture = new CultureInfo("de-DE"); Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE"); Language = LanguageType.German; break; case "english": Application.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Language = LanguageType.English; break; } AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); TimeSyncHandler.SyncTime(); // Config file: //Console.WriteLine(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); //Version version = new Version(Settings.Default.UpdateVersion); //Application.ProductVersion Updater = new Updater(Application.ProductVersion, ProjectId, UpdaterPublicKey, Settings.Default.UpdateUrl); if (Language == LanguageType.Default) { Updater.Controller.Language = updateSystemDotNet.Languages.Deutsch; } else { Updater.Controller.Language = updateSystemDotNet.Languages.English; } Updater.ExitApplication += new EventHandler(Updater_ExitApplication); if (TimeSyncHandler.Now.AddHours(-24) > Updater.Controller.lastSuccessfullUpdateCheck) { if (Updater.RunUpdater()) { return; } } if (Settings.Default.LastStart.DayOfYear != TimeSyncHandler.Now.DayOfYear) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://dstools.agrafix.net/vote/161.html"); request.GetResponse(); } catch (Exception) { } } Settings.Default.LastStart = TimeSyncHandler.Now; Settings.Default.Save(); Application.Run(new FormMain()); }