public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
                                         Type destinationType)
        {
            if (value is string)
            {
                var  lang = value as string;
                bool has  = false;
                foreach (string l in LanguageHolder.Instance().Languages)
                {
                    if (l.Equals(lang))
                    {
                        has = true;
                    }
                }

                if (!has)
                {
                    value = "English";
                }
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Пример #2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            fes = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (fes == null)
            {
                return(value);
            }

            var lb = new ListBox {
                Sorted = true, SelectionMode = SelectionMode.One, HorizontalScrollbar = true
            };

            foreach (string lang in LanguageHolder.Instance().Languages)
            {
                lb.Items.Add(lang);
            }

            int index = lb.Items.IndexOf(RConfig.Instance.Language);

            lb.SelectedIndex = index == -1 ? 0 : index;

            if (value != null)
            {
                index = lb.Items.IndexOf(value);
                if (index > 0)
                {
                    lb.SelectedIndex = index;
                }
            }

            lb.SelectedIndexChanged += lb_SelectedIndexChanged;
            fes.DropDownControl(lb);



            return(lb.SelectedItem.ToString());
        }
Пример #3
0
 public static LanguageHolder Instance()
 {
     return(_instance ?? (_instance = new LanguageHolder()));
 }
Пример #4
0
 public static LanguageHolder Instance()
 {
     return _instance ?? (_instance = new LanguageHolder()); 
 }