/// <summary> /// Create validation attribute /// </summary> /// <returns>Return the validation attribute</returns> public override ValidationAttribute CreateValidationAttribute(ValidationAttributeParameter parameter) { return(new RangeAttribute(DataType, Minimum?.ToString(), Maximum?.ToString()) { ErrorMessage = FormatMessage(parameter.ErrorMessage) }); }
/// <include file='doc\NumericUpDown.uex' path='docs/doc[@for="NumericUpDown.ToString"]/*' /> /// <devdoc> /// Provides some interesting info about this control in String form. /// </devdoc> /// <internalonly/> public override string ToString() { string s = base.ToString(); s += ", Minimum = " + Minimum.ToString() + ", Maximum = " + Maximum.ToString(); return(s); }
private void UpdateMaxLength() { if (textBox != null) { textBox.MaxLength = (AsHex == true) ? Maximum.ToString("X").Length : Maximum.ToString().Length; } }
/// <summary> /// Saves properties /// </summary> /// <param name="writer">XmlWriter</param> public void Save(XmlWriter writer) { if (writer == null) { return; } bool writeheader = false; if (writer.WriteState != WriteState.Element) { writeheader = true; } if (writeheader) { writer.WriteStartElement("criticalhit"); } writer.WriteAttributeString("minimum", Minimum.ToString()); writer.WriteAttributeString("maximum", Maximum.ToString()); writer.WriteAttributeString("multiplier", Multiplier.ToString()); if (writeheader) { writer.WriteEndElement(); } }
protected override void OnCreateControl() { base.OnCreateControl(); minValue.Text = Minimum.ToString(); maxValue.Text = Maximum.ToString(); curentValue.Text = Value.ToString(); minValue.Location = new Point(0, Height - 26); maxValue.Location = new Point(Width - maxValue.Width - 3, Height - 26); int d = 28; int ofset = 15; int x = -(curentValue.Width / 2) + ofset + (((Value - Minimum) * (Width - d)) / Math.Abs(Minimum - Maximum)); int y = Height - curentValue.Height; Point p = new Point(x, y); curentValue.Location = p; if (Minimum * Maximum < 0) { x = -(ziroValue.Width / 2) + ofset + (((-Minimum) * (Width - d)) / Math.Abs(Minimum - Maximum)); y = Height - ziroValue.Height; ziroValue.Location = new Point(x, y); } else { ziroValue.Visible = false; } }
protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { ReadOnly = true; // Draw the cell border base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, DataGridViewPaintParts.Border); try { // Draw the ProgressBar to an in-memory bitmap Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height); Rectangle bmpBounds = new Rectangle(0, 0, cellBounds.Width, cellBounds.Height); _progressBar.Size = cellBounds.Size; _progressBar.DrawToBitmap(bmp, bmpBounds); // Draw the bitmap on the cell g.DrawImage(bmp, cellBounds); // Replace special value placeholders var editedMessage = _text.Replace(MessageSpecialValue.CurrentValue, Value.ToString()) .Replace(MessageSpecialValue.Maximum, Maximum.ToString()) .Replace(MessageSpecialValue.Minimum, Minimum.ToString()); // Write text over bar base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, editedMessage, errorText, cellStyle, advancedBorderStyle, DataGridViewPaintParts.ContentForeground); } catch (ArgumentOutOfRangeException) { // Row probably couldn't be accessed } }
public void AddValidation(ClientModelValidationContext context) { MergeAttribute(context.Attributes, "data-val", "true"); MergeAttribute(context.Attributes, "data-val-range", string.Format(ErrorMessageString, context.ModelMetadata.DisplayName, Minimum, Maximum)); MergeAttribute(context.Attributes, "data-val-range-max", Maximum.ToString()); MergeAttribute(context.Attributes, "data-val-range-min", Minimum.ToString()); }
private void NumericTextBox_LostFocus(object sender, RoutedEventArgs e) { var textBox = (TextBox)sender; if (!int.TryParse(textBox.Text, out var value)) { textBox.Text = Minimum.ToString(); return; } if (value < Minimum) { textBox.Text = Minimum.ToString(); } else if (value > Maximum) { textBox.Text = Maximum.ToString(); } else { var rem = (value - Minimum) % Step; if (rem > 0) { textBox.Text = (value - rem).ToString(); } } }
public override Panel GenerateMainControl(int id) { Panel panel = base.GenerateMainControl(id); TextBox box = new TextBox(); box.Enabled = true; box.ID = "WebPortEntryBox-" + id; box.CssClass = "form-control"; box.Attributes.Add("style", "margin-top:5px;margin-bottom:5px"); box.Attributes.Add("data-toggle", "tooltip"); box.Attributes.Add("data-placement", "right"); box.Attributes.Add("data-title", Description); box.Attributes.Add("type", "number"); box.Attributes.Add("min", Minimum.ToString()); box.Attributes.Add("max", Maximum.ToString()); panel.Controls.Add(box); RangeValidator validator = new RangeValidator(); validator.Type = ValidationDataType.Integer; validator.MinimumValue = Minimum.ToString(); validator.MaximumValue = Maximum.ToString(); validator.Enabled = true; validator.ControlToValidate = box.ID; panel.Controls.Add(validator); panel.Controls.Add(box); IntBox = box; panel.Controls.Add(new LiteralControl("<br/>")); return(panel); }
private void HandledText() { if (Type == Project1UIInputType.Number) { var match = Regex.Match(Text, @"([0-9]{1,9}\.?[0-9]{1,9}|[0-9]{1,9})"); if (match.Success) { Text = match.Value; if (double.Parse(Text) < 0) { Text = "0"; } if (double.Parse(Text) > Maximum) { if (Maximum == double.MaxValue) { Text = "9999999999"; } else { Text = Maximum.ToString(); } } } else { Text = "0"; } } }
/// <summary> /// updates the textbox, that it fits the value /// </summary> private void UpdateTextBox() { this._textbox.MaxLength = Math.Max( Maximum.ToString().Length, Minimum.ToString().Length) + 2; this._textbox.Text = Value.ToString(); }
public override string ToString() { string minimum; if (Minimum.HasValue) { minimum = Minimum.ToString(); } else if (MinimumDateTime.HasValue) { minimum = MinimumDateTime.ToString(); } else { minimum = "-"; } string maximum; if (Maximum.HasValue) { maximum = Maximum.ToString(); } else if (MaximumDateTime.HasValue) { maximum = MaximumDateTime.ToString(); } else { maximum = "-"; } return(string.Format("Min: {0} Max: {1}", minimum, maximum)); }
protected override void OnInitialized(EventArgs e) { maxLength = Maximum.HasValue ? Maximum.ToString().Length : int.MaxValue; base.OnInitialized(e); DataObject.AddPastingHandler(this, (s, args) => { args.CancelCommand(); }); }
public override string ToString() { return(string.Format("{0}, Minimum: {1}, Maximum: {2}, Value: {3}", GetType().FullName, Minimum.ToString(), Maximum.ToString(), Value.ToString())); }
private void contextMenuStripBody_Opening(object sender, CancelEventArgs e) { skipEvent = true; toolStripComboBoxDecimalPlaces.SelectedIndex = DecimalPlaces >= 0 ? DecimalPlaces + 1: 0; toolStripTextBoxMaximum.Text = Maximum.ToString(); toolStripTextBoxMimimum.Text = Minimum.ToString(); skipEvent = false; }
public HTML5RatingField() : base(5) { base[0] = Minimum.ToString(); base[1] = Maximum.ToString(); base[2] = Rating.ToString(); base[3] = Votes.ToString(); base[4] = Step.ToString(); }
public override string ToString() { string str = base.ToString(); return(str + ", Minimum: " + Minimum.ToString(CultureInfo.CurrentCulture) + ", Maximum: " + Maximum.ToString(CultureInfo.CurrentCulture) + ", Value: " + Value.ToString(CultureInfo.CurrentCulture)); }
public float GetAxisDrawWidth() { using (Graphics g = Graphics.FromImage(_sizingBitmap)) { SizeF labelSize = g.MeasureString(Maximum.ToString(Format), Font); var axisWidth = DefaultTickWidth + (int)labelSize.Width; return(axisWidth); } }
public override string ToString() { return(string.Format(@"Units: {0} Minimum: {1} Maximum: {2}", UnitsAreMM ? "MM" : "Inches", Minimum.ToString(), Maximum.ToString() )); }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("Name", Name); writer.WriteAttributeString("IsAbstract", IsAbstract); writer.WriteStartElement("Cardinality"); writer.WriteElementString("Minimum", Minimum.ToString()); writer.WriteElementString("Maximum", Maximum.ToString()); writer.WriteEndElement(); }
public string ToString(string format) { var value = (Minimum == DateTime.MinValue ? String.Empty : Minimum.ToString(format)) + "-" + (Maximum == DateTime.MaxValue ? String.Empty : Maximum.ToString(format)); if (value == "-") { return(String.Empty); } return(value); }
private void TextBox_LostFocus(object Sender, RoutedEventArgs E) { if (!IsNumeric) { return; } double floatValue; bool badEntry; if (String.IsNullOrWhiteSpace(Text)) { Text = m_OldText; } if (IsFloat) { badEntry = !double.TryParse(Text, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out floatValue); } else { int value; badEntry = !int.TryParse(Text, NumberStyles.Number | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out value); floatValue = value; } if (!badEntry) { if (floatValue > Maximum) { Text = Maximum.ToString(CultureInfo.InvariantCulture); Select(Text.Length, 0); } else if (floatValue < Minimum) { Text = Minimum.ToString(CultureInfo.InvariantCulture); Select(Text.Length, 0); } else { Text = floatValue.ToString(CultureInfo.InvariantCulture); Select(Text.Length, 0); } } else { Text = m_OldText; } }
private SizeF LabelSize(Graphics g) { SizeF v = g.MeasureString(Value.ToString(_numberFormat), Font); SizeF max = g.MeasureString(Maximum.ToString(_numberFormat), Font); SizeF min = g.MeasureString(Maximum.ToString(_numberFormat), Font); SizeF result = v; result.Height = Math.Max(Math.Max(v.Height, max.Height), min.Height); result.Width = Math.Max(Math.Max(v.Width, max.Width), min.Width); return(result); }
protected override void OnRender(int x, int y, int width, int height) { _btnW = System.Math.Max(_font.CharWidth('-'), _font.CharWidth('+')) + 8; int txtY = _h / 2 - _font.Height / 2; // Draw Shadow Core.Screen.DrawRectangle(Colors.White, 1, Left + 1, Top + 1, Width - 1, Height - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0); // Draw Border Core.Screen.DrawRectangle((Focused) ? Core.SystemColors.SelectionColor : Core.SystemColors.BorderColor, 1, Left, Top, Width - 1, Height - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0); // Draw Minus Button if (Enabled) { Core.Screen.DrawRectangle(0, 0, Left + 1, Top + 1, _btnW, Height - 3, 0, 0, _btnTop, Left, Top, _btnBtm, Left, Top + Height, 256); Core.Screen.DrawTextInRect("-", Left + 2, Top + txtY + 1, _btnW, _font.Height, Bitmap.DT_AlignmentCenter, _btnTxtShd, _font); } else { Core.Screen.DrawRectangle(0, 0, Left + 1, Top + 1, _btnW, Height - 3, 0, 0, _btnTop, Left, Top, _btnTop, Left, Top + Height, 256); } Core.Screen.DrawTextInRect("-", Left + 1, Top + txtY, _btnW, _font.Height, Bitmap.DT_AlignmentCenter, _btnTxt, _font); // Draw Number Core.Screen.DrawRectangle((Focused) ? Core.SystemColors.SelectionColor : Core.SystemColors.BorderColor, 1, Left + _btnW + 1, Top, Width - _btnW - _btnW - 3, Height - 1, 0, 0, _bkgTop, Left, Top, (Enabled) ? _bkgBtm : _bkgTop, Left, Top + Height, 256); Core.Screen.DrawTextInRect(IntToNString(Value, Maximum.ToString().Length), Left + _btnW + 4, Top + txtY, Width - _btnW - _btnW - 9, Height - 1, Bitmap.DT_AlignmentRight, (Enabled) ? _fore : _disabled, _font); // Draw Minus Button Core.Screen.DrawRectangle(0, 0, Left + Width - _btnW - 2, Top + 1, _btnW, Height - 3, 0, 0, _btnTop, Left, Top, (Enabled) ? _btnBtm : _btnTop, Left, Top + Height, 256); if (Enabled) { Core.Screen.DrawTextInRect("+", Left + Width - _btnW - 1, Top + txtY + 1, _btnW, _font.Height, Bitmap.DT_AlignmentCenter, _btnTxtShd, _font); } Core.Screen.DrawTextInRect("+", Left + Width - _btnW - 2, Top + txtY, _btnW, _font.Height, Bitmap.DT_AlignmentCenter, _btnTxt, _font); if (Focused) { Core.Screen.DrawRectangle(0, 0, x + 1, y + 1, width - 3, 1, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 90); Core.Screen.DrawRectangle(0, 0, x + 1, y + height - 3, width - 3, 1, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 90); Core.Screen.DrawRectangle(0, 0, x + 1, y + 2, 1, height - 5, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 90); Core.Screen.DrawRectangle(0, 0, x + width - 3, y + 2, 1, height - 5, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 90); Core.Screen.DrawRectangle(0, 0, x + 2, y + 2, width - 5, 1, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 40); Core.Screen.DrawRectangle(0, 0, x + 2, y + height - 4, width - 5, 1, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 40); Core.Screen.DrawRectangle(0, 0, x + 2, y + 4, 1, height - 7, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 40); Core.Screen.DrawRectangle(0, 0, x + width - 4, y + 3, 1, height - 7, 0, 0, Core.SystemColors.SelectionColor, 0, 0, Core.SystemColors.SelectionColor, 0, 0, 40); } }
protected override void UpdateElementsLayout() { _elems[0].Bounds = new Rectangle(0, 0, this.Width, SystemInformation.VerticalScrollBarWidth); _elems[1].Bounds = Rectangle.FromLTRB(0, this.Height - _elems[0].Bounds.Height, this.Width, this.Height); _elems[2].Bounds.Width = this.Width; using (Graphics gr = this.CreateGraphics()) { float height = Math.Max( gr.MeasureString(Maximum.ToString(), base.Font).Width, gr.MeasureString(Minimum.ToString(), base.Font).Width) + 4f; _elems[2].Bounds.Height = (int)height; } UpdateTrackerPosition(); }
/// <summary> /// Returns a string representation for this <see cref="CustomProgressBar" />. /// </summary> /// <returns>A <see cref="string" /> that describes this control.</returns> public override string ToString() { System.Text.StringBuilder builder = new System.Text.StringBuilder(); builder.Append(GetType().FullName); builder.Append(", Minimum: "); builder.Append(Minimum.ToString(CultureInfo.CurrentCulture)); builder.Append(", Maximum: "); builder.Append(Maximum.ToString(CultureInfo.CurrentCulture)); builder.Append(", Value: "); builder.Append(Value.ToString(CultureInfo.CurrentCulture)); return(builder.ToString()); }
protected override void OnTextBoxTextChanged(object source, EventArgs e) { TextBox textBox = source as TextBox; int val = 0; NextDigitClears = false; if (int.TryParse(textBox.Text, out val)) { textBox.Text = val.ToString("D" + Maximum.ToString().Length); } else { base.OnTextBoxTextChanged(source, e); } }
public string ToString(IFormatProvider format) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}: {1}\r\n", nameof(Minimum), Minimum.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Maximum), Maximum.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Range), Range.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Median), Median.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Mode), Mode.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Sum), Sum.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Average), Average.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(RootMeanSquare), RootMeanSquare.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(Variance), Variance.ToString(format)); sb.AppendFormat("{0}: {1}\r\n", nameof(StandardDeviation), StandardDeviation.ToString(format)); return(sb.ToString()); }
//public bool ContainsI(RForm val) { // return IndexOfI(val)>-1; //} //public int IndexOfI(RForm val) { // int iFound=-1; // if (arrobjects!=null) { // for (int iNow=0; iNow<Count; iNow++) { // if (RString.EqualsI(Peek(iNow),val)) { // iFound=iNow; // break; // } // } // } // return iFound; //}//end IndexOfI //public bool ContainsStartsWithI(RForm val) { // return IndexOfStartsWithI(val)>-1; //} //public int IndexOfStartsWithI(RForm val) { // int iFound=-1; // if (arrobjects!=null) { // for (int iNow=0; iNow<Count; iNow++) { // if (RRForm.CompareAtI(Peek(iNow),val,0,RRForm.SafeLength(val),true)) { // iFound=iNow; // break; // } // } // } // return iFound; //}//end IndexOfStartsWithI public string ToString() //RForm sFieldDelimiter, RForm sTextDelimiter) { //RForm objectReturn=""; //for (int iNow=0; iNow<iCount_PlusFirstIsOneAfterLast; iNow++) { // RForm objectNow=Peek(iNow); // if (RRForm.IsNotBlank(sTextDelimiter)) { // if (sNow.Contains(sTextDelimiter)) { // sNow=sNow.Replace(sTextDelimiter,sTextDelimiter+sTextDelimiter); // sNow=sTextDelimiter+sNow+sTextDelimiter; // } // } // sReturn+=(iNow==0?"":sFieldDelimiter)+sNow; //} { return("{Count:" + iCount_PlusFirstIsOneAfterLast.ToString() + "; Maximum:" + Maximum.ToString() + "}"); //return objectReturn; } //end ToString()
private void UpdateValueText() { if (_isChangingValueWithCode) { return; } _isChangingTextWithCode = true; if (this.Value != null) { if (!CanNegNum && Value < 0) { _isChangingTextWithCode = false; this.Text = Math.Max(Minimum, 0).ToString(this.ValueFormat); } else if (this.Value <= Maximum && this.Value >= Minimum) { this.Text = this.Value.Value.ToString(this.ValueFormat); } else if (this.Value > Maximum) { _isChangingTextWithCode = false; this.Text = Maximum.ToString(this.ValueFormat); } else if (this.Value < Minimum) { _isChangingTextWithCode = false; this.Text = Minimum.ToString(this.ValueFormat); } } else { if (AllowNullValue) { this.Text = ""; } else { _isChangingTextWithCode = false; this.Text = Minimum.ToString(this.ValueFormat); } } this.SelectionStart = this.Text.Length; _isChangingTextWithCode = false; }