private void UpdateRects() { Size textSize; Size valueSize; using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) { textSize = NativeText.MeasureLogString(_showText ? Text : "", SkinManager.getLogFontByType(_fontType)); valueSize = NativeText.MeasureLogString(_showValue ? RangeMax.ToString() + _valueSuffix : "", SkinManager.getLogFontByType(_fontType)); } _valueRectangle = new Rectangle(Width - valueSize.Width - _thumbRadiusHoverPressed / 4, 0, valueSize.Width + _thumbRadiusHoverPressed / 4, Height); _textRectangle = new Rectangle(0, 0, textSize.Width + _thumbRadiusHoverPressed / 4, Height); _sliderRectangle = new Rectangle(_textRectangle.Right, 0, _valueRectangle.Left - _textRectangle.Right, _thumbRadius); _mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(_rangeMax - _rangeMin) * (double)(_sliderRectangle.Width) - _thumbRadius / 2)); RecalcutlateIndicator(); }
private void buttonText_Click(object sender, EventArgs e) { CustomDialog.KeyboardDialog kdlg = new CustomDialog.KeyboardDialog(); kdlg.ValLower = RangeMin; kdlg.ValUpper = RangeMax; kdlg.DispMode = KeyboardDialog.KB_MODE.NUMBER; //数値 string strrange = RangeMax.ToString(StringForm); int digits = strrange.IndexOf('.'); kdlg.LengthInt = (digits < 0) ? strrange.Length : digits; kdlg.LengthDec = (digits < 0) ? 0 : (strrange.Length - digits - 1); kdlg.AllLength = Math.Max(strrange.Length, RangeMin.ToString(StringForm).Length); string msgfmt = CommonProc.MessageText("G001"); msgfmt = msgfmt.Replace("%param", paramName); msgfmt = msgfmt.Replace("%min", RangeMin.ToString(StringForm)); msgfmt = msgfmt.Replace("%max", RangeMax.ToString(StringForm)); kdlg.Message_Text = msgfmt; kdlg.InputArea = _buttonText.Text; kdlg.AllowNone = allowNone; if (kdlg.ShowDialog() == DialogResult.OK) { if (allowNone && kdlg.InputArea == "") { Value = double.NaN; } else { Value = double.Parse(kdlg.InputArea); } if (ValueChanged != null) { ValueChanged(sender, e); } } kdlg.Dispose(); Invalidate(); }