Пример #1
0
        protected void ApplyLanguage(ToolStripItem applyTo)
        {
            IGreenshotLanguageBindable languageBindable = applyTo as IGreenshotLanguageBindable;

            if (languageBindable != null)
            {
                ApplyLanguage(applyTo, languageBindable.LanguageKey);
            }
        }
        protected void ApplyLanguage(Control applyTo)
        {
            IGreenshotLanguageBindable languageBindable = applyTo as IGreenshotLanguageBindable;

            if (languageBindable == null)
            {
                // check if it's a menu!
                if (applyTo is ToolStrip)
                {
                    ToolStrip toolStrip = applyTo as ToolStrip;
                    foreach (ToolStripItem item in toolStrip.Items)
                    {
                        ApplyLanguage(item);
                    }
                }
                return;
            }

            string languageKey = languageBindable.LanguageKey;

            // Apply language text to the control
            ApplyLanguage(applyTo, languageKey);
            // Repopulate the combox boxes
            if (typeof(IGreenshotConfigBindable).IsAssignableFrom(applyTo.GetType()))
            {
                if (typeof(GreenshotComboBox).IsAssignableFrom(applyTo.GetType()))
                {
                    IGreenshotConfigBindable configBindable = applyTo as IGreenshotConfigBindable;
                    if (!string.IsNullOrEmpty(configBindable.SectionName) && !string.IsNullOrEmpty(configBindable.PropertyName))
                    {
                        IniSection section = IniConfig.GetIniSection(configBindable.SectionName);
                        if (section != null)
                        {
                            GreenshotComboBox comboxBox = applyTo as GreenshotComboBox;
                            // Only update the language, so get the actual value and than repopulate
                            Enum currentValue = (Enum)comboxBox.GetSelectedEnum();
                            comboxBox.Populate(section.Values[configBindable.PropertyName].ValueType);
                            comboxBox.SetValue(currentValue);
                        }
                    }
                }
            }
        }