private void MarkAllAsChanged() { foreach (var settingsProvider in m_SettingsProviders) { SettingsPropertyCollection col1 = settingsProvider.Settings.Properties; IEnumerator enume1 = col1.GetEnumerator(); while (enume1.MoveNext()) { var current = (SettingsProperty)enume1.Current; if (current.IsReadOnly) { continue; } settingsProvider.Settings[current.Name] = settingsProvider.Settings[current.Name]; } //SettingsPropertyValueCollection col2 = settingsProvider.Settings.PropertyValues; //IEnumerator enume2 = col2.GetEnumerator(); //while (enume2.MoveNext()) //{ // var current = (SettingsPropertyValue)enume2.Current; // settingsProvider.Settings[current.Name] = current.PropertyValue; //} } }
private void resetList() { AggregatedSettings = new List <SettingWrapper>(); foreach (var settingsProvider in m_SettingsAggregator.Settings) { settingsProvider.PropertyChanged += Settings_PropertyChanged; SettingsPropertyCollection col1 = settingsProvider.Properties; IEnumerator enume1 = col1.GetEnumerator(); while (enume1.MoveNext()) { var current = (SettingsProperty)enume1.Current; AggregatedSettings.Add(new SettingWrapper(settingsProvider, current)); //(current.IsReadOnly ? "[readonly] " : "") //+ current.Name + " = " + settingsProvider.Settings[current.Name] // + "(" + current.DefaultValue + ") // [" + current.PropertyType + "] "); } } //SettingsExpanded.Add("---"); //foreach (var settingsProvider in SettingsProviders) //{ // SettingsPropertyValueCollection col2 = settingsProvider.Settings.PropertyValues; // IEnumerator enume2 = col2.GetEnumerator(); // while (enume2.MoveNext()) // { // var current = (SettingsPropertyValue)enume2.Current; // SettingsExpanded.Add(current.Name + " = " + current.PropertyValue + "---" + current.SerializedValue + " (" + (current.UsingDefaultValue ? "default" : "user") + ")"); // } //} }
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection) { SettingsPropertyValueCollection ret = new SettingsPropertyValueCollection(); //Get the user name string userName = context["UserName"] as string; //Get the DirectoryEntry for the user name using (DirectoryEntry userEntry = GetUserEntryByUserName(userName)) { //Get each property IEnumerator en = collection.GetEnumerator(); while (en.MoveNext()) { //Property to get string propertyToGet = (en.Current as SettingsProperty).Name; //Get the .NET type for the property, change attrValue to the correct type Type detinationType = (en.Current as SettingsProperty).PropertyType; //Get the SerializeAs of the property SettingsSerializeAs serializeAs = (en.Current as SettingsProperty).SerializeAs; //Create a SettingsPropertyValue and for setting its value SettingsPropertyValue spv = new SettingsPropertyValue((en.Current as SettingsProperty)); //Build the current property recursively because it might be a complex object. if (serializeAs == SettingsSerializeAs.ProviderSpecific) { spv.PropertyValue = GetPropertyRecursively(userEntry, propertyToGet, detinationType, serializeAs, AttributeList); spv.Deserialized = true; } else { spv.SerializedValue = GetPropertyRecursively(userEntry, propertyToGet, detinationType, serializeAs, AttributeList); spv.Deserialized = false; } //Add the settingsPropertyValue to return collection ret.Add(spv); } //Set last actvity date if (LastActivityDateAttribute != null) { userEntry.InvokeSet(LastActivityDateAttribute, DateTime.Now); } } return(ret); }
/// <summary> /// Called after OnStartup() /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnApplicationStartup(object sender, StartupEventArgs e) { if (Tobi.Common.Settings.Default.UpgradeSettings) { if (!ApplicationDeployment.IsNetworkDeployed) { // ClickOnce automatically Upgrades. Settings.Default.Upgrade(); Tobi.Common.Settings.Default.Upgrade(); } Tobi.Common.Settings.Default.UpgradeSettings = true; // ensure settings aggregator does its job of upgrading the other providers } try { SettingsPropertyCollection col1 = Settings.Default.Properties; IEnumerator enume1 = col1.GetEnumerator(); while (enume1.MoveNext()) { var current = (SettingsProperty)enume1.Current; Console.WriteLine("--- " + current.Name + ":"); Console.WriteLine(current.DefaultValue); Console.WriteLine(Settings.Default[current.Name]); } //Settings.Default.Reload(); } catch (ConfigurationErrorsException ex) { HandleConfigurationErrorsException(ex); } Console.WriteLine("<RESOURCE SET LANGs>"); var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (var culture in cultures) { try { var rs = Tobi_Lang.ResourceManager.GetResourceSet(culture, true, false); if (rs != null) { Console.WriteLine(culture.Name + " ==> " + culture.NativeName); } } catch (Exception) { // ignored } } Console.WriteLine("</RESOURCE SET LANGs>"); #if DEBUG var keys = Tobi_Lang.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true) .Cast <DictionaryEntry>() .Select(entry => entry.Key) .Cast <string>(); var resources = keys.ToDictionary(key => key, key => Tobi_Lang.ResourceManager.GetString(key, CultureInfo.GetCultureInfo("fr"))); var str = Tobi_Lang.LangStringKey1; #endif try { #if DEBUG SetCulture("fr"); str = Tobi_Lang.LangStringKey1; SetCulture("hi"); str = Tobi_Lang.LangStringKey1; #endif SetCulture(Settings.Default.Lang); } catch (ConfigurationErrorsException ex) { HandleConfigurationErrorsException(ex); #if DEBUG MessageBox.Show(ex.Message); Process.GetCurrentProcess().Kill(); return; #endif } #if NET40 catch (CultureNotFoundException ex2) { #if DEBUG Debugger.Break(); #endif Settings.Default.Lang = "en"; SetCulture(Settings.Default.Lang); } #else catch (ArgumentException ex2) { #if DEBUG Debugger.Break(); #endif Settings.Default.Lang = "en"; SetCulture(Settings.Default.Lang); } #endif #if DEBUG str = Tobi_Lang.LangStringKey1; #endif if (false && ApplicationDeployment.IsNetworkDeployed) { string lang = Thread.CurrentThread.CurrentUICulture.ToString(); ApplicationDeployment deploy = ApplicationDeployment.CurrentDeployment; try { if (!deploy.IsFileGroupDownloaded(lang)) //deploy.IsFirstRun { deploy.DownloadFileGroup(lang); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); MessageBox.Show(ex.Message); // Log error. Do not report this error to the user, because a satellite // assembly may not exist if the user's culture and the application's // default culture match. } } //to use on individual forms: this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag); FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage( CultureInfo.CurrentUICulture.IetfLanguageTag))); Timeline.DesiredFrameRateProperty.OverrideMetadata( typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 } ); //AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly; SplashScreen = new SplashScreen(Assembly.GetExecutingAssembly(), "TobiSplashScreen.png"); SplashScreen.Show(false); ShutdownMode = ShutdownMode.OnMainWindowClose; runBootstrapper(); }