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));
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
 public static LanguageHolder Instance()
 {
     return(_instance ?? (_instance = new LanguageHolder()));
 }
Exemplo n.º 4
0
 public static LanguageHolder Instance()
 {
     return _instance ?? (_instance = new LanguageHolder()); 
 }