Пример #1
0
        private static void LoadLocale(Config config)
        {
            Locale locale = Utilities.ResourceHelper.GetLocale(config.Language);

            // in case the config xml gets hosed, or a user goes a-tamperin'
            if (locale == null) {
                locale = Utilities.ResourceHelper.GetLocale("en-us");
            }

            locale.Init();
        }
Пример #2
0
 public static void InitDefaults(Config config)
 {
     config.FirstRun = true;
     config.FlashCount = 4;
 }
Пример #3
0
		public static void Init() {
			if(!Directory.Exists(_path)) {
				Directory.CreateDirectory(_path);
			}

			Config config = new Config();
			String xml = null;
			FileInfo file = new FileInfo(Path.Combine(_path, _fileName));

			if(file.Exists) {
				using(StreamReader sr = file.OpenText()) {
					xml = sr.ReadToEnd();
				}

				if(!String.IsNullOrEmpty(xml)) {
					config = Utilities.Serializer.DeserializeContract<Config>(xml);
				}
			}
			else {
				InitDefaults(config);
				config.Save();
			}

			if(config.StartupState == StartupState.None) {
				// we need to check for the legacy <firstrun> node. if it exists and is false, we're on the second run.

				XmlDocument document = new XmlDocument();
				document.LoadXml(xml);

				XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable);
				manager.AddNamespace("n", "http://schemas.datacontract.org/2004/07/GmailNotifierPlus");

				XmlNode node = document.SelectSingleNode("n:config/n:firstrun", manager);

				if(node == null) {
					config.StartupState = StartupState.First;
				}
				else {
					config.StartupState = StartupState.Second;
				}
			}

			config.Language = config.Language;

			Config.Current = config;

			// Fire up the locale information and init localization
			Dictionary<String, String> locales = Utilities.ResourceHelper.AvailableLocales;

			LoadLocale(config);

			for(var i = 0; i < config.Accounts.Count; i++) {
				config.Accounts[i].Init();
			}

			// Check to see if recent document tracking is turned on.
			// If it isn't we cannot add custom categories to the jumplist.

			try {
				using(RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", false)) {
					object trackDocs = key.GetValue("Start_TrackDocs"); //DWORD value. 
					if(trackDocs != null) {
						int tracking = Convert.ToInt32(trackDocs);
						config.RecentDocsTracked = tracking == 1;
					}
					else {
						// if the value doesn't exist, that means it's turned on (but will probably not put out, s**t.).
						config.RecentDocsTracked = true;
					}
					key.Close();
				}
			}
			catch(System.Security.SecurityException) {
			}


		}
Пример #4
0
        public static void Init()
        {
            if (!Directory.Exists(_path)) {
                Directory.CreateDirectory(_path);
            }

            Config config = new Config();
            String xml = null;
            FileInfo file = new FileInfo(Path.Combine(_path, _fileName));

            if (file.Exists) {
                using (StreamReader sr = file.OpenText()) {
                    xml = sr.ReadToEnd();
                }

                if (!String.IsNullOrEmpty(xml)) {
                    config = Utilities.Serializer.DeserializeContract<Config>(xml);
                }
            }
            else {
                InitDefaults(config);
                config.Save();
            }

            config.Language = config.Language.ToLower();

            Config.Current = config;

            // Fire up the locale information and init localization
            Dictionary<String, String> locales = Utilities.ResourceHelper.AvailableLocales;

            LoadLocale(config);

            for (var i = 0; i < config.Accounts.Count; i++) {
                config.Accounts[i].Init();
            }

            // Check to see if recent document tracking is turned on.
            // If it isn't we cannot add custom categories to the jumplist.

            try {
                using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", false)) {
                    object trackDocs = key.GetValue("Start_TrackDocs"); //DWORD value.
                    if (trackDocs != null) {
                        int tracking = Convert.ToInt32(trackDocs);
                        config.RecentDocsTracked = tracking == 1;
                    }
                    key.Close();
                }
            }
            catch (System.Security.SecurityException) {
            }
        }
Пример #5
0
		public static void InitDefaults(Config config) {
			//config.FirstRun = true;
			config.StartupState = GmailNotifierPlus.StartupState.First;
			config.FlashCount = 4;
		}