public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var service = provider.GetService (typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService; DoubleSlideParametersAttribute att = (DoubleSlideParametersAttribute)context.PropertyDescriptor.Attributes[typeof(DoubleSlideParametersAttribute)]; DoubleTrackBar track = new DoubleTrackBar(); track.Precision = att.Precision; track.Maximum = att.SliderMax; track.Minimum = att.SliderMin; track.Width = 127; track.Height = 15; double freq = track.Maximum / 50d; if (freq < 1) { freq = 1; } track.TickFrequency = (int)freq; if (double.TryParse(context.PropertyDescriptor.Converter.ConvertToString(value), out double result)) { track.Value = result; } if (att.SliderDynamicSetValue) { track.Tag = context; } track.ValueChanged += Track_ValueChanged; service.DropDownControl(track); if (valueChanged) { return(context.PropertyDescriptor.Converter.ConvertFromString(track.Value.ToString())); } else { return(value); } }
private void Track_ValueChanged(object sender, EventArgs e) { valueChanged = true; DoubleTrackBar track = (DoubleTrackBar)sender; toolTip.SetToolTip(track, track.Value.ToString()); ITypeDescriptorContext ctx = (ITypeDescriptorContext)track.Tag; if (ctx != null) { var val = ctx.PropertyDescriptor.Converter.ConvertFromString(track.Value.ToString()); try { //InstrumentManager.ExclusiveLockObject.EnterWriteLock(); ctx.PropertyDescriptor.SetValue(ctx.Instance, val); } finally { //InstrumentManager.ExclusiveLockObject.ExitWriteLock(); } } }