public I18nService() { // Initialize Languages directories // -------------------------------- // Initialize variables this.builtinLanguagesDirectory = Path.Combine(ProcessExecutable.ExecutionFolder(), ApplicationPaths.BuiltinLanguagesFolder); this.customLanguagesDirectory = Path.Combine(SettingsClient.ApplicationFolder(), ApplicationPaths.CustomLanguagesFolder); // If the CustomLanguages subdirectory doesn't exist, create it if (!Directory.Exists(this.customLanguagesDirectory)) { Directory.CreateDirectory(System.IO.Path.Combine(this.customLanguagesDirectory)); } this.LoadLanguages(); // Configure the ColorSchemeTimer // ------------------------------ this.languageTimer.Interval = TimeSpan.FromSeconds(this.languageTimeoutSeconds).TotalMilliseconds; this.languageTimer.Elapsed += new ElapsedEventHandler(LanguageTimerElapsed); // Start the LanguageWatcher // ------------------------- this.languageWatcher = new FileSystemWatcher(this.customLanguagesDirectory) { EnableRaisingEvents = true }; this.languageWatcher.Changed += new FileSystemEventHandler(WatcherChangedHandler); this.languageWatcher.Deleted += new FileSystemEventHandler(WatcherChangedHandler); this.languageWatcher.Created += new FileSystemEventHandler(WatcherChangedHandler); this.languageWatcher.Renamed += new RenamedEventHandler(WatcherRenamedHandler); }
private SettingsClient() { this.timer = new System.Timers.Timer(100); // a 10th of a second this.timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); // Check in BaseSettings.xml if we're using the portable application this.baseSettingsDoc = XDocument.Load(this.baseSettingsFile); if (this.applicationFolder == null) { bool isPortable = false; // Set the path of Settings.xml if (this.TryGetBaseValue <bool>("Configuration", "IsPortable", ref isPortable)) { // Sets the application folder if (isPortable) { this.applicationFolder = System.IO.Path.Combine(ProcessExecutable.ExecutionFolder(), ProcessExecutable.Name()); } else { this.applicationFolder = System.IO.Path.Combine(LegacyPaths.AppData(), ProcessExecutable.Name()); } } else { // By default, we save in the user's Roaming folder this.applicationFolder = System.IO.Path.Combine(LegacyPaths.AppData(), ProcessExecutable.Name()); } this.TryCreateApplicationFolder(); } this.settingsFile = System.IO.Path.Combine(this.applicationFolder, "Settings.xml"); // Check if Settings.xml exists in the given path. If not, // create a new Settings.xml based on BaseSettings.xml if (!File.Exists(this.settingsFile)) { File.Copy(this.baseSettingsFile, this.settingsFile); } try { // Load Settings.xml in memory this.settingsDoc = XDocument.Load(this.settingsFile); } catch (System.Exception) { // After a crash, the Settings file is sometimes empty. If that // happens, copy the BaseSettings file (there is no way to restore // settings from a broken file anyway) and try to load the Settings // file again. File.Copy(this.baseSettingsFile, this.settingsFile, true); this.settingsDoc = XDocument.Load(this.settingsFile); } }
private SettingsClient() { this.timer = new System.Timers.Timer(100); // a 10th of a second this.timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); // Check in BaseSettings.xml if we're using the portable application this.baseSettingsDoc = XDocument.Load(this.baseSettingsFile); if (this.applicationFolder == null) { bool isPortable = false; // Set the path of Settings.xml if (this.TryGetBaseValue <bool>("Configuration", "IsPortable", ref isPortable)) { // Sets the application folder if (isPortable) { this.applicationFolder = System.IO.Path.Combine(ProcessExecutable.ExecutionFolder(), ProcessExecutable.Name()); } else { this.applicationFolder = System.IO.Path.Combine(WindowsPaths.AppData(), ProcessExecutable.Name()); } } else { // By default, we save in the user's Roaming folder this.applicationFolder = System.IO.Path.Combine(WindowsPaths.AppData(), ProcessExecutable.Name()); } this.TryCreateApplicationFolder(); } this.settingsFile = Path.Combine(this.applicationFolder, "Settings.xml"); // Make sure there is a settings file. if (!File.Exists(this.settingsFile)) { File.Copy(this.baseSettingsFile, this.settingsFile, true); } // Load the settings in memory this.LoadSettings(); }