Exemplo n.º 1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                if (value is string)
                {
                    PropertySlideAttribute att = context.PropertyDescriptor.Attributes.Find <PropertySlideAttribute>();
                    SlideText box = new SlideText();
                    box.ValueStr = value as string;
                    box.initFromAtt(att);
                    edSvc.DropDownControl(box);
                    return(box.ValueStr);
                }
            }
            return(value);
        }
Exemplo n.º 2
0
        public void initFromAtt(PropertySlideAttribute att)
        {
            if (att == null)
            {
                return;
            }

            toFloat               = att.toFloat;
            trackBar1.Maximum     = att.max;
            trackBar1.Minimum     = att.min;
            trackBar1.SmallChange = att.step;
            trackBar1.Value       = att.defaul;
            if (textBox1.Text != "")
            {
                var val = getText();
                if (val < trackBar1.Minimum || val > trackBar1.Maximum)
                {
                    throw new Exception("Value should lay between " + trackBar1.Minimum / toFloat + " and " + trackBar1.Maximum / toFloat);
                }
                trackBar1.Value = val;
            }
        }