Esempio n. 1
0
        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            String[] parameters  = parameter.ToString().Split('.');
            String   viewName    = parameters[0];
            String   elementName = parameters[1];

            LanguageDictionary languagePack = value as LanguageDictionary;

            // Use DependencyProperty.UnsetValue to indicate conversion failure
            // In this case, the FallbackValue property will be used
            return((languagePack != null &&
                    languagePack.ContainsSection(viewName) &&
                    languagePack[viewName].ContainsKey(elementName))
                ? languagePack[viewName][elementName] : DependencyProperty.UnsetValue);
        }
Esempio n. 2
0
        public static void BindLanguagePack(this Form form, LanguageDictionary languageDictionary)
        {
            if (languageDictionary.ContainsSection(form.Name))
            {
                if (languageDictionary[form.Name].ContainsKey("this"))
                {
                    form.Text = languageDictionary[form.Name]["this"];
                }

                foreach (KeyValuePair <String, String> pair in languageDictionary[form.Name])
                {
                    Control[] controls = form.Controls.Find(pair.Key, true);

                    if (controls.Length > 0)
                    {
                        controls[0].Text = pair.Value;
                    }
                }
            }
        }