Esempio n. 1
0
        public virtual void Init()
        {
            GlobalizationManager = new GlobalizationManager(Resources.MergedDictionaries);
            StyleManager         = new StyleManager(Resources.MergedDictionaries);

            // Load the default style
            CreateAvailableStyles();
            StyleManager.SwitchStyle(StyleManager.DefaultStyle);

            // Get current 5 character language and load the appropriate Globalization file
            CreateAvailableLanguages();
            try
            {
                GlobalizationManager.SwitchLanguage(Thread.CurrentThread.CurrentCulture.Name, true);
            }
            catch (CultureNotFoundException)
            {
                // Try the fallback
                GlobalizationManager.SwitchLanguage(GlobalizationManager.FallBackLanguage, true);
            }

            // Create the FallbackResourceDictionary
            FallbackResourceDictionary = new FallbackResourceDictionary()
            {
                Name = "Fallback"
            };
            Resources.MergedDictionaries.Add(FallbackResourceDictionary);
        }
        public virtual void Init()
        {
            GlobalizationManager = new GlobalizationManager(Resources.MergedDictionaries);
            StyleManager = new StyleManager(Resources.MergedDictionaries);

            // Load the default style
            CreateAvailableStyles();
            StyleManager.SwitchStyle(StyleManager.DefaultStyle);

            // Get current 5 character language and load the appropriate Globalization file
            CreateAvailableLanguages();
            try
            {
                GlobalizationManager.SwitchLanguage(Thread.CurrentThread.CurrentCulture.Name, true);
            }
            catch(CultureNotFoundException)
            {
                // Try the fallback
                GlobalizationManager.SwitchLanguage("en-US", true);
            }

            // Create the FallbackResourceDictionary
            FallbackResourceDictionary = new FallbackResourceDictionary() { Name = "Fallback" };
            Resources.MergedDictionaries.Add(FallbackResourceDictionary);
        }
        public void Remove(string inResourceDictionaryName)
        {
            EnhancedResourceDictionary erdToRemove = null;

            foreach (EnhancedResourceDictionary erd in MergedDictionaries)
            {
                if (erd.Name == inResourceDictionaryName)
                {
                    erdToRemove = erd;
                }
            }
            MergedDictionaries.Remove(erdToRemove);
        }
        public void Remove(string inResourceDictionaryName)
        {
            EnhancedResourceDictionary erdToRemove = null;

            //enumerate through all resource dictionaries
            foreach (ResourceDictionary rd in MergedDictionaries)
            {
                //Only operate on globalized enahncedresourcedictionary types
                var erd = rd as EnhancedResourceDictionary;
                if (erd != null)
                {
                    if (erd.Name == inResourceDictionaryName)
                    {
                        erdToRemove = erd;
                    }
                }
            }
            MergedDictionaries.Remove(erdToRemove);
        }
Esempio n. 5
0
        public virtual void Init()
        {
            GlobalizationManager = new GlobalizationManager(Resources.MergedDictionaries);
            StyleManager         = new StyleManager(Resources.MergedDictionaries);

            // Get current 5 character language and load the appropriate Globalization file
            CreateAvailableLanguages();
            try
            {
                GlobalizationManager.SwitchLanguage(Thread.CurrentThread.CurrentCulture.Name, true);
            }
            catch (Exception ex)
            {
                // Try the fallback
                GlobalizationManager.SwitchLanguage(GlobalizationManager.FallBackLanguage, true);
                Debug.WriteLine($"{nameof(GlobalizationManager.SwitchLanguage)} error.\r\n{ex.Message}");
            }

            // Load the default style
            CreateAvailableStyles();
            try
            {
                StyleManager.SwitchStyle(StyleManager.FallBackStyle, true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{nameof(StyleManager.SwitchStyle)} error.\r\n{ex.Message}");
            }

            // Create the FallbackResourceDictionary
            FallbackResourceDictionary = new FallbackResourceDictionary()
            {
                Name = "Fallback"
            };
            Resources.MergedDictionaries.Add(FallbackResourceDictionary);
        }