Beispiel #1
0
        public static CustomControl CreateDropdownControl(Control parent, string label, object[] entries, int selection, Action <CustomControl> changedCallback)
        {
            var control = new DropdownControl(label, changedCallback, entries, selection);

            control.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            parent.Controls.Add(control);
            customControls.Add(label, control);
            return(control);
        }
Beispiel #2
0
        public static CustomControl CreateControl(Control parent, string label, object property, Action <CustomControl> changedCallback)
        {
            CustomControl control = null;

            var type = property.GetType();

            if (type == typeof(int))
            {
                control = NumberControl.ForInteger(label, changedCallback, (int)property);
            }
            else if (type == typeof(uint))
            {
                control = NumberControl.ForInteger(label, changedCallback, (uint)property, uint.MinValue, uint.MaxValue);
            }
            else if (type == typeof(short))
            {
                control = NumberControl.ForInteger(label, changedCallback, (short)property, short.MinValue, short.MaxValue);
            }
            else if (type == typeof(ushort))
            {
                control = NumberControl.ForInteger(label, changedCallback, (ushort)property, ushort.MinValue, ushort.MaxValue);
            }
            else if (type == typeof(byte))
            {
                control = NumberControl.ForInteger(label, changedCallback, (byte)property, byte.MinValue, byte.MaxValue);
            }
            else if (type == typeof(decimal) || type == typeof(float) || type == typeof(double))
            {
                control = NumberControl.ForDecimal(label, changedCallback, Convert.ToDecimal(property));
            }
            else if (type == typeof(bool))
            {
                control = new CheckControl(label, changedCallback, (bool)property);
            }
            else if (type == typeof(Color))
            {
                control = new ColorControl(label, changedCallback, (Color)property);
            }
            else if (type == typeof(object[]))
            {
                control = new DropdownControl(label, changedCallback, property as object[], 0);
            }

            if (control != null)
            {
                control.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                parent.Controls.Add(control);
                customControls.Add(label, control);
            }

            return(control);
        }