protected void ResetUIRanges() { this.numericUpDown.Minimum = ToNudValue(Property.MinValue); this.numericUpDown.Maximum = ToNudValue(Property.MaxValue); this.slider.Minimum = ToSliderValue(Property.MinValue); this.slider.Maximum = ToSliderValue(Property.MaxValue); this.slider.TickFrequency = PropertyControlUtil.GetGoodSliderTickFrequency(this.slider); }
protected override double FromSliderValue(int sliderValue) { if (this.useExponentialScale) { return(PropertyControlUtil.FromSliderValueExp(sliderValue, Property.MinValue, Property.MaxValue, DecimalPlaces)); } else { double fromIntScale = Math.Pow(10, -DecimalPlaces); double valueDouble = (double)sliderValue * fromIntScale; return(valueDouble); } }
protected override int ToSliderValue(double propertyValue) { if (this.useExponentialScale) { return(PropertyControlUtil.ToSliderValueExp(propertyValue, Property.MinValue, Property.MaxValue, DecimalPlaces)); } else { double toIntScale = Math.Pow(10, DecimalPlaces); double sliderValueDouble = propertyValue * toIntScale; int sliderValueInt = (int)sliderValueDouble; return(sliderValueInt); } }
protected void ResetUIRanges() { this.sliderX.Minimum = ToSliderValueX(Property.MinValueX); this.sliderX.Maximum = ToSliderValueX(Property.MaxValueX); this.sliderX.TickFrequency = PropertyControlUtil.GetGoodSliderTickFrequency(this.sliderX); this.numericUpDownX.Minimum = ToNudValueX(Property.MinValueX); this.numericUpDownX.Maximum = ToNudValueX(Property.MaxValueX); this.sliderY.Minimum = ToSliderValueY(Property.MinValueY); this.sliderY.Maximum = ToSliderValueY(Property.MaxValueY); this.sliderY.TickFrequency = PropertyControlUtil.GetGoodSliderTickFrequency(this.sliderY); this.numericUpDownY.Minimum = ToNudValueY(Property.MinValueY); this.numericUpDownY.Maximum = ToNudValueY(Property.MaxValueY); }
protected override void OnLayout(LayoutEventArgs levent) { int vMargin = UI.ScaleHeight(4); int hMargin = UI.ScaleWidth(4); this.header.Location = new Point(0, 0); this.header.Width = ClientSize.Width; this.header.Height = string.IsNullOrEmpty(DisplayName) ? 0 : this.header.GetPreferredSize(new Size(this.header.Width, 0)).Height; this.resetButton.Width = UI.ScaleWidth(20); this.resetButton.Location = new Point( ClientSize.Width - this.resetButton.Width, this.header.Bottom + vMargin); int nudWidth = UI.ScaleWidth(70); this.numericUpDown.PerformLayout(); this.numericUpDown.Width = nudWidth; this.numericUpDown.Location = new Point( (this.resetButton.Visible ? (this.resetButton.Left - hMargin) : ClientSize.Width) - this.numericUpDown.Width, this.header.Bottom + vMargin); this.resetButton.Height = this.numericUpDown.Height; this.slider.Location = new Point(0, this.header.Bottom + vMargin); this.slider.Size = new Size( this.numericUpDown.Left - hMargin, PropertyControlUtil.GetGoodSliderHeight(this.slider)); this.descriptionText.Location = new Point( 0, (string.IsNullOrEmpty(this.Description) ? 0 : vMargin) + Utility.Max(this.resetButton.Bottom, this.slider.Bottom, this.numericUpDown.Bottom)); this.descriptionText.Width = ClientSize.Width; this.descriptionText.Height = string.IsNullOrEmpty(this.descriptionText.Text) ? 0 : this.descriptionText.GetPreferredSize(new Size(this.descriptionText.Width, 1)).Height; ClientSize = new Size(ClientSize.Width, this.descriptionText.Bottom); base.OnLayout(levent); }
protected override void OnLayout(LayoutEventArgs levent) { int vMargin = UI.ScaleHeight(4); int hMargin = UI.ScaleWidth(4); this.header.Location = new Point(0, 0); this.header.Width = ClientSize.Width; this.header.Height = string.IsNullOrEmpty(DisplayName) ? 0 : this.header.GetPreferredSize(new Size(this.header.Width, 0)).Height; int nudWidth = UI.ScaleWidth(70); // X slider, nud, reset button int xTop = this.header.Bottom + vMargin; this.resetButtonX.Width = UI.ScaleWidth(20); this.resetButtonX.Location = new Point( ClientSize.Width - this.resetButtonX.Width, xTop); this.numericUpDownX.PerformLayout(); this.numericUpDownX.Width = nudWidth; this.numericUpDownX.Location = new Point( (this.resetButtonX.Visible ? (this.resetButtonX.Left - hMargin) : ClientSize.Width) - this.numericUpDownX.Width, xTop); this.resetButtonX.Height = this.numericUpDownX.Height; this.sliderX.Location = new Point(0, xTop); this.sliderX.Size = new Size( this.numericUpDownX.Left - hMargin, PropertyControlUtil.GetGoodSliderHeight(this.sliderX)); // Y slider, nud, reset button int yTop = vMargin + Utility.Max(this.resetButtonX.Bottom, this.numericUpDownX.Bottom, this.sliderX.Bottom); this.resetButtonY.Width = UI.ScaleWidth(20); this.resetButtonY.Location = new Point( ClientSize.Width - this.resetButtonY.Width, yTop); this.numericUpDownY.PerformLayout(); this.numericUpDownY.Width = nudWidth; this.numericUpDownY.Location = new Point( (this.resetButtonY.Visible ? (this.resetButtonY.Left - hMargin) : ClientSize.Width) - this.numericUpDownY.Width, yTop); this.resetButtonY.Height = this.numericUpDownY.Height; this.sliderY.Location = new Point(0, yTop); this.sliderY.Size = new Size( this.numericUpDownY.Left - hMargin, PropertyControlUtil.GetGoodSliderHeight(this.sliderY)); // Description this.descriptionText.Location = new Point(0, Utility.Max(this.resetButtonY.Bottom, this.sliderY.Bottom, this.numericUpDownY.Bottom)); this.descriptionText.Width = ClientSize.Width; this.descriptionText.Height = string.IsNullOrEmpty(this.descriptionText.Text) ? 0 : this.descriptionText.GetPreferredSize(new Size(this.descriptionText.Width, 1)).Height; ClientSize = new Size(ClientSize.Width, this.descriptionText.Bottom); base.OnLayout(levent); }