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));
        }
Exemple #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());
        }