Пример #1
0
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List <string> res = new List <string>();

            res.Add("");
            try
            {
                foreach (Attribute attr in context.PropertyDescriptor.Attributes)
                {
                    var lm = attr as ListMethodAttribute;
                    if (lm == null)
                    {
                        continue;
                    }
                    MethodInfo mtd = context.Instance.GetType().GetMethod(lm.MethodName, new Type[] { });
                    if (mtd != null)
                    {
                        object vals = mtd.Invoke(context.Instance, new object[] { });
                        res.AddRange((IEnumerable <string>)vals);
                    }
                }
            }
            catch { }

            System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(res);
            return(svc);
        }
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (frmsvr != null)
            {
                ListBox lst = new ListBox();
                lst.BorderStyle           = BorderStyle.None;
                lst.SelectedIndexChanged += new EventHandler(OnListBoxChanged);

                if (context.PropertyDescriptor.Converter.GetStandardValuesSupported(context))
                {
                    List <object> tlist = new List <object> ();
                    System.ComponentModel.TypeConverter.StandardValuesCollection svc = context.PropertyDescriptor.Converter.GetStandardValues(context);
                    object[] arr = new object[svc.Count];
                    svc.CopyTo(arr, 0);
                    arr[0]         = NULL_VALUE;
                    lst.DataSource = arr;
                }

                frmsvr.DropDownControl(lst);
                if (lst.SelectedItem is NullValueEditorObject)
                {
                    return(DefaultableBooleanUIEditor.NULL_VALUE.Value);
                }
                else
                {
                    return(lst.SelectedItem);
                }
            }
            return(value);
        }
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            bool[] bools = new bool[] { true, false };

            System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools);

            return(svc);
        }
Пример #4
0
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List <string> langs = new List <string>();

            foreach (LangInfo lang in LangManager.Languages)
            {
                langs.Add(lang.Identifier);
            }
            System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(langs);
            return(svc);
        }
Пример #5
0
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     string[] ps    = Enum.GetNames(typeof(PrecisionType));
     string[] names = new string[ps.Length];
     for (int i = 0; i < ps.Length; i++)
     {
         names[i] = EnumItemDescAttribute.GetDisplayValue(ps[i], typeof(PrecisionType), Thread.CurrentThread.CurrentUICulture);
     }
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(names);
     return(svc);
 }
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
        {
            List <string> values = new List <string>();

            values.Add("6.0.0.0");
            values.Add("7.0.0.0");
            values.Add("8.0.0.0");
            values.Add("9.0.28.0");

            System.ComponentModel.TypeConverter.StandardValuesCollection res = new System.ComponentModel.TypeConverter.StandardValuesCollection(values);
            return(res);
        }
Пример #7
0
 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     if (context.PropertyDescriptor.PropertyType == typeof(bool?))
     {
         bool?[] bools = new bool?[] { true, false, null };
         System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools);
         return(svc);
     }
     else
     {
         bool[] bools = new bool[] { true, false };
         System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools);
         return(svc);
     }
 }
Пример #8
0
        public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            bool expandVersions = false;

            foreach (var attr in context.PropertyDescriptor.Attributes)
            {
                if (attr is ExpandDialectVersionsAttribute)
                {
                    expandVersions = true;
                }
            }
            List <ISqlDialect> dials = DialectAddonType.GetAllDialects(expandVersions);

            System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(dials);
            return(svc);
        }
 public SqlFileConnectionProperties(string defaultInstanceName)
 {
     _defaultDataSource = ".";
     if (defaultInstanceName != null && defaultInstanceName.Length > 0)
     {
         _defaultDataSource += "\\" + defaultInstanceName;
     }
     else
     {
         DataSourceConverter conv = new DataSourceConverter();
         System.ComponentModel.TypeConverter.StandardValuesCollection coll = conv.GetStandardValues(null);
         if (coll.Count > 0)
         {
             _defaultDataSource = coll[0] as string;
         }
     }
     LocalReset();
 }
Пример #10
0
 private System.ComponentModel.TypeConverter.StandardValuesCollection GetCachedStandardValues(System.ComponentModel.ITypeDescriptorContext context)
 {
     if (_StandardValues == null)
     {
         FriendlyNameToInstanceDescriptorMap = new System.Collections.Hashtable();
         System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
         arrayList.Add(DefaultRenderer);
         FriendlyNameToInstanceDescriptorMap["(Default)"] = CreateInstanceDescriptor(DefaultRenderer);
         System.Type[] typeArr = RendererType.Assembly.GetExportedTypes();
         for (int i = 0; i < typeArr.Length; i++)
         {
             System.Type type = typeArr[i];
             if (((type == RendererType) || type.IsSubclassOf(RendererType)) && !type.IsAbstract)
             {
                 string s = Skybound.ComponentModel.DisplayNameAttribute.GetFriendlyName(type);
                 FriendlyNameToInstanceDescriptorMap[s] = new System.ComponentModel.Design.Serialization.InstanceDescriptor(type.GetConstructor(System.Type.EmptyTypes), null, true);
                 arrayList.Add(System.Activator.CreateInstance(type, null));
             }
         }
         arrayList.Sort(this);
         _StandardValues = new System.ComponentModel.TypeConverter.StandardValuesCollection(arrayList);
     }
     return(_StandardValues);
 }
 private System.ComponentModel.TypeConverter.StandardValuesCollection GetCachedStandardValues(System.ComponentModel.ITypeDescriptorContext context)
 {
     if (_StandardValues == null)
     {
         FriendlyNameToInstanceDescriptorMap = new System.Collections.Hashtable();
         System.Collections.ArrayList arrayList = new System.Collections.ArrayList();
         arrayList.Add(DefaultRenderer);
         FriendlyNameToInstanceDescriptorMap["(Default)"] = CreateInstanceDescriptor(DefaultRenderer);
         System.Type[] typeArr = RendererType.Assembly.GetExportedTypes();
         for (int i = 0; i < typeArr.Length; i++)
         {
             System.Type type = typeArr[i];
             if (((type == RendererType) || type.IsSubclassOf(RendererType)) && !type.IsAbstract)
             {
                 string s = Skybound.ComponentModel.DisplayNameAttribute.GetFriendlyName(type);
                 FriendlyNameToInstanceDescriptorMap[s] = new System.ComponentModel.Design.Serialization.InstanceDescriptor(type.GetConstructor(System.Type.EmptyTypes), null, true);
                 arrayList.Add(System.Activator.CreateInstance(type, null));
             }
         }
         arrayList.Sort(this);
         _StandardValues = new System.ComponentModel.TypeConverter.StandardValuesCollection(arrayList);
     }
     return _StandardValues;
 }
 protected override void Act()
 {
     providers = (System.ComponentModel.TypeConverter.StandardValuesCollection)dataProvider.GetStandardValues();
 }
Пример #13
0
 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(
         new List <AddonHolder>((GetAddonType(context).CommonSpace.GetFilteredAddons(RegisterItemUsage.DirectUse))));
     return(svc);
 }
Пример #14
0
 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     string[] vals = new string[] { "\r\n", "\n" };
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(vals);
     return(svc);
 }
 protected override void Act()
 {
     providers = (System.ComponentModel.TypeConverter.StandardValuesCollection)dataProvider.GetStandardValues();
 }
 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     bool[] bools = new bool[] { true, false };
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(bools);
     return svc;
 }
Пример #17
0
        public async Task ChangeRole(params string[] args)
        {
            if (args.Length < 2)
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "Insufficient Parameters",
                    Description = $"The way to use the command is `{await SqliteClass.PrefixGetter(Context.Guild.Id)}color <@role> <color>`",
                    Color       = Color.Red
                }.WithCurrentTimestamp());

                return;
            }
            var role = GetRole(args[0]);

            if (role == null)
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "That role is invalid",
                    Description = $"I couldn't parse `{args[0]}` as a role!",
                    Color       = Color.Red
                }.WithCurrentTimestamp());

                return;
            }
            if (!(Context.User as SocketGuildUser).Roles.Any(rl => rl.Position > role.Position) && Context.Guild.OwnerId != Context.User.Id && Context.User.Id != 701029647760097361 && Context.User.Id != 615873008959225856)
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "Oops!",
                    Description = "You're below the role you want to edit!",
                    Color       = Color.Red
                }.WithCurrentTimestamp());

                return;
            }
            if (args[1].ToLower() == "none" || args[1].ToLower() == "invisible")
            {
                await role.ModifyAsync(x => x.Color = new Color());
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "Done!!",
                    Description = $"The role {role.Name}'s color is removed!",
                    Color       = Blurple
                }.WithCurrentTimestamp());

                return;
            }
            System.Drawing.ColorConverter c   = new System.Drawing.ColorConverter();
            System.Drawing.Color          col = new System.Drawing.Color();
            bool hasC   = false;
            var  hArgs1 = args[1][0] != '#' ? $"#{args[1]}" : args[1];

            if (Regex.IsMatch(hArgs1, "^(#[0-9A-Fa-f]{3})$|^(#[0-9A-Fa-f]{6})$"))
            {
                col  = (System.Drawing.Color)c.ConvertFromString(hArgs1);
                hasC = true;
            }
            else
            {
                System.ComponentModel.TypeConverter.StandardValuesCollection svc = (System.Drawing.ColorConverter.StandardValuesCollection)c.GetStandardValues();
                foreach (System.Drawing.Color o in svc)
                {
                    if (o.Name.Equals(args[1], StringComparison.OrdinalIgnoreCase))
                    {
                        col  = (System.Drawing.Color)c.ConvertFromString(args[1]);
                        hasC = true;
                    }
                }
            }
            if (hasC == false)
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Title       = "What color??",
                    Description = $"Couldn't parse `{args[1]}` as a color!",
                    Color       = Color.Red
                }.WithCurrentTimestamp());

                return;
            }
            await role.ModifyAsync(x => x.Color = new Color(col.R, col.G, col.B));

            await ReplyAsync("", false, new EmbedBuilder
            {
                Title       = "Done!!",
                Description = $"The role {role.Name} is now set to the color of this embed!",
                Color       = new Color(col.R, col.G, col.B) == new Color(255, 255, 255) ? new Color(254, 254, 254) : new Color(col.R, col.G, col.B)
            }.WithCurrentTimestamp());

            return;
        }
Пример #18
0
 public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     char[] chs = new char[] { ' ', '\t' };
     System.ComponentModel.TypeConverter.StandardValuesCollection svc = new System.ComponentModel.TypeConverter.StandardValuesCollection(chs);
     return(svc);
 }