protected void AdjustToNewMinValue() { if (MaxValue.CompareTo(MinValue) < 0) { MaxValue = MinValue; } }
/// <summary> /// OnPreRender /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { if (this.Attributes["MaxValue"] == null) { this.Attributes.Add("MaxValue", MaxValue.ToString()); } else { this.Attributes["MaxValue"] = MaxValue.ToString(); } if (this.Attributes["MinValue"] == null) { this.Attributes.Add("MinValue", MinValue.ToString()); } else { this.Attributes["MinValue"] = MinValue.ToString(); } if (MaxValue < MinValue) { throw new ArgumentOutOfRangeException(string.Format("控件的最大值不能小于最小值,当前为:{0} - {1}", MinValue, MaxValue)); } base.OnPreRender(e); }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { if (sender is TextBox tb) { tb.Text = tb.Text.TrimStart('0'); try { UInt64 newValue = String.IsNullOrEmpty(tb.Text) ? 0 : Convert.ToUInt64(tb.Text, 16); if ((MaxValue != 0) && (newValue > MaxValue)) { HandlingOnValueChanged = false; this.Value = MaxValue; tb.Text = MaxValue.ToString("X"); tb.CaretIndex = tb.Text.Length; SystemSounds.Beep.Play(); } else { HandlingOnValueChanged = false; this.Value = newValue; int pos = tb.CaretIndex; tb.Text = tb.Text.ToUpper(); tb.CaretIndex = pos; } } catch { HandlingOnValueChanged = false; this.Value = MaxValue; tb.Text = MaxValue.ToString("X"); tb.CaretIndex = tb.Text.Length; SystemSounds.Beep.Play(); } } }
public void GivenDoubleArray_ShouldReturnLargestDouble() { double[] values = { 10.6, 25.9, 8.2, 9.56, 20.8, 6.9, 21.5 }; MaxValue <double> maximumNumber = new MaxValue <double>(values); double max = maximumNumber.GetMaximum(); Assert.AreEqual(25.9, max); }
public void MaxValueDateTimeIsValid() { DateTime target = DateTime.Now; DateTime comparisonValue = DateTime.Now.AddMinutes(1); MaxValue<DateTime> rule = new MaxValue<DateTime>("MaxValueRule", "The target is not valid. Must be equal or less than comparison value.", target, comparisonValue); Result result = rule.Execute(); Assert.IsTrue(result.IsValid); Assert.IsNotNullOrEmpty(result.Message); Assert.IsNotNull(result.RulePolicy); Assert.AreEqual(result.RulePolicy.Severity, Severity.Exception); }
public void calculateTestEmptyList() { MaxValue value = new MaxValue(); List <double> list_values = new List <double>(); Assert.AreEqual(0, value.calculate(list_values)); }
/// <summary> /// 속성 중 Attribute Node로 표현해야 한다. /// </summary> /// <param name="writer"></param> public override void GenerateXmlAttributes(System.Xml.XmlWriter writer) { base.GenerateXmlAttributes(writer); if (MinValue.HasValue) { writer.WriteAttributeString("MinValue", MinValue.ToString()); } if (MaxValue.HasValue) { writer.WriteAttributeString("MaxValue", MaxValue.ToString()); } if (Action.HasValue) { writer.WriteAttributeString("Action", Action.ToString()); } if (Param.IsNotWhiteSpace()) { writer.WriteAttributeString("Param", Param); } if (OccurOnce.HasValue) { writer.WriteAttributeString("OccurOnce", OccurOnce.ToString()); } }
public override void Draw(SpriteBatch spriteBatch) { // Text if (Globals.MRectangle.Intersects(new Rectangle((int)Position.X, (int)Position.Y, Width * 2, Height * 2))) { float value = (float)Math.Round(Value + 0.5); spriteBatch.DrawString(TextureManager.SpriteFont15, value + " /" + MaxValue.ToString("0"), new Vector2(Position.X + Width + 10 - TextureManager.SpriteFont15.MeasureString(Value.ToString("0") + " /" + MaxValue.ToString("0")).X / 2, Position.Y + Height / 2), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.1f); } // Draw bar for (int i = 0; i < bar.GetLength(0) * (Value / MaxValue); i++) { for (int j = 0; j < bar.GetLength(1); j++) { spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)Position.X + i * 2 + j * 2, (int)Position.Y + j * 2, 2, 2), null, BarColor * (j <= Height / 2 ? ((float)j / ((float)Height / 2f)) : (2f - ((float)j / ((float)Height / 2f)))), 0f, Vector2.Zero, SpriteEffects.None, Depth); } } // Border for (int i = 0; i < bar.GetLength(0); i++) { spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)Position.X + i * 2 + 2, (int)Position.Y + 2, 2, 2), null, Color.DarkGray, 0f, Vector2.Zero, SpriteEffects.None, 0.01f); spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)Position.X + i * 2 + bar.GetLength(1) * 2 - 2, (int)Position.Y + (bar.GetLength(1) - 1) * 2, 2, 2), null, Color.DarkGray, 0f, Vector2.Zero, SpriteEffects.None, 0.01f); } for (int i = 0; i < bar.GetLength(1) - 1; i++) { spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)Position.X + i * 2 + 2, (int)Position.Y + i * 2 + 2, 2, 2), null, Color.DarkGray, 0f, Vector2.Zero, SpriteEffects.None, 0.01f); spriteBatch.Draw(TextureManager.pixel, new Rectangle((int)Position.X + i * 2 + 2 + bar.GetLength(0) * 2, (int)Position.Y + i * 2 + 2, 2, 2), null, Color.DarkGray, 0f, Vector2.Zero, SpriteEffects.None, 0.01f); } }
public void calculateTestEmptystringArray() { MaxValue value = new MaxValue(); string[] values = new string[10]; Assert.AreEqual(0, value.calculate(values, 2)); }
/// <summary> /// 속성들을 Xml Attribute로 생성합니다. /// </summary> /// <param name="writer">Attribute를 쓸 Writer</param> public override void GenerateXmlAttributes(XmlWriter writer) { base.GenerateXmlAttributes(writer); if (MinValue.HasValue) { writer.WriteAttributeString("minValue", MinValue.ToString()); } if (MaxValue.HasValue) { writer.WriteAttributeString("maxValue", MaxValue.ToString()); } if (Label.IsNotWhiteSpace()) { writer.WriteAttributeString("label", Label); } if (Code.HasValue) { writer.WriteAttributeString("Code", Code.Value.ToHexString()); } if (Alpha.HasValue) { writer.WriteAttributeString("Alpha", Alpha.ToString()); } if (BorderColor.HasValue) { writer.WriteAttributeString("BorderColor", BorderColor.Value.ToHexString()); } if (BorderAlpha.HasValue) { writer.WriteAttributeString("BorderAlpha", BorderAlpha.ToString()); } }
public void OnRender() { _txtLeft.text = Value.ToString(); _txtRight.text = MaxValue.ToString(); _imgFill.fillAmount = Value * 1.0f / MaxValue; _imgFill.color = FillColor; }
public override int GetHashCode() { unchecked { return((MaxValue.GetHashCode() * 397) ^ MinValue.GetHashCode()); } }
protected sealed override void Calculate() { switch (BaseType) { case BaseValueType.Int64: case BaseValueType.Single: case BaseValueType.Double: { double offset = MinValue.GetDouble(); double diff = MaxValue.GetDouble() - offset; _SetDouble(offset + (diff * _rand.NextDouble())); break; } //case BaseValueType.Int64: { // byte[] b = new byte[sizeof(long)]; // _rand.NextBytes(b); // _SetInt64(BitConverter.ToInt64(b, 0)); // break; //} case BaseValueType.Int32: default: { _SetInt32(_rand.Next(MinValue.GetInt32(), MaxValue.GetInt32())); break; } } if (!ManualRand) { SetDirty(); } }
protected override void Render(HtmlTextWriter writer) { CssClass = "form-control " + CssClass; Attributes.Add("data-control", "Spinner"); Attributes.Add("data-control-required", campoobrigatorio.ToString()); if (MaxValue > int.MinValue) { Attributes.Add("data-control-maxvalue", MaxValue.ToString()); } if (MinValue > int.MinValue) { Attributes.Add("data-control-minvalue", MinValue.ToString()); } if (montagroup) { writer.Write(ComponentUtils.RenderControlOpen(campoobrigatorio ? "*" + Label : Label, ID, TypeControl, true, false, ToolTip)); } base.Render(writer); writer.Write("<div class='input-group-addon input-group-btn-vertical'><a href='javascript:void(0)' class='btn btn-default'><i class='fa fa-caret-up'></i></a><a href='javascript:void(0)' class='btn btn-default'><i class='fa fa-caret-down'></i></a></div>"); if (montagroup) { writer.Write(ComponentUtils.RenderControlClose("", TypeControl, true)); } }
protected override int?GetNumericPrecision() { switch (PrecisionSource.GetValueOrDefault()) { // When the precision is set to zero (0), the MoneyAttributeMetadata.Precision value is used. case 0: var numericPrecision = Math.Max(MinValue.ToString().Length, MaxValue.ToString().Length) + Precision.GetValueOrDefault(); return(numericPrecision); // When the precision is set to one (1), the Organization.PricingDecimalPrecision value is used. case 1: // todo need to support grabbing this info from the organization. For now just always using metadata. var orgPrecision = Math.Max(MinValue.ToString().Length, MaxValue.ToString().Length) + Precision.GetValueOrDefault(); return(orgPrecision); // When the precision is set to two (2), the TransactionCurrency.CurrencyPrecision value is used. case 2: // todo: need to grab this information from the transaction currency itself..! var currencyPrecision = Math.Max(MinValue.ToString().Length, MaxValue.ToString().Length) + Precision.GetValueOrDefault(); return(currencyPrecision); default: var defaultPrecision = Math.Max(MinValue.ToString().Length, MaxValue.ToString().Length) + Precision.GetValueOrDefault(); return(defaultPrecision); } }
/// <summary> /// Called when [preview text input]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="TextCompositionEventArgs" /> instance /// containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> private void OnPreviewTextInput(object sender, TextCompositionEventArgs e) { // Check number if (this.NumericOnlyCheck(e.Text)) { // Evaluate min value if (MinValue != null && Convert.ToDouble(this.Text + e.Text) < MinValue) { this.Text = MinValue.ToString(); this.SelectionStart = this.Text.Length; e.Handled = true; } // Evaluate max value if (MaxValue != null && Convert.ToDouble(this.Text + e.Text) > MaxValue) { this.Text = MaxValue.ToString(); this.SelectionStart = this.Text.Length; e.Handled = true; } } else { e.Handled = true; } }
internal void SetValue(object value, double maxValue, double direction, string directionTextual) { bool changed = false; if ((Value == null && value != null) || (Value != null && !Value.Equals(value))) { Value = value; changed = true; } if (!MaxValue.Equals(maxValue)) { MaxValue = maxValue; changed = true; } if ((DirectionTextual == null && directionTextual != null) || (DirectionTextual != null && !DirectionTextual.Equals(directionTextual))) { DirectionTextual = directionTextual; changed = true; } if (!Direction.Equals(direction)) { Direction = direction; changed = true; } if (changed) { InvokeValueChanged(); } }
/// <summary> /// Converts <see cref="AnalogChannel"/> to its string format. /// </summary> public override string ToString() { // An,ch_id,ph,ccbm,uu,a,b,skew,min,max List <string> values = new List <string> { Index.ToString(), Name, PhaseID, CircuitComponent, Units, Multiplier.ToString(CultureInfo.InvariantCulture), Adder.ToString(CultureInfo.InvariantCulture), Skew.ToString(CultureInfo.InvariantCulture), MinValue.ToString(CultureInfo.InvariantCulture), MaxValue.ToString(CultureInfo.InvariantCulture) }; // ...,primary,secondary,PS if (m_version >= 1999) { values.Add(PrimaryRatio.ToString(CultureInfo.InvariantCulture)); values.Add(SecondaryRatio.ToString(CultureInfo.InvariantCulture)); values.Add(ScalingIdentifier.ToString()); } return(string.Join(",", values)); }
/// <summary> /// Initializes the any option children defined for the instance. /// </summary> protected override void InitializeOptionalChildren(ISystemContext context) { base.InitializeOptionalChildren(context); if (DisplayMaxValue != null) { DisplayMaxValue.Initialize(context, DisplayMaxValue_InitializationString); } if (DisplayMinValue != null) { DisplayMinValue.Initialize(context, DisplayMinValue_InitializationString); } if (Exponent != null) { Exponent.Initialize(context, Exponent_InitializationString); } if (MaxValue != null) { MaxValue.Initialize(context, MaxValue_InitializationString); } if (MinValue != null) { MinValue.Initialize(context, MinValue_InitializationString); } if (ProcedureCommand != null) { ProcedureCommand.Initialize(context, ProcedureCommand_InitializationString); } }
protected override void Render(HtmlTextWriter writer) { writer.Write("<canvas id=\"" + this.ID.ToString() + "\" width=\"" + this.Width.ToString() + "\" height=\"" + this.Height.ToString() + "\"><script language=\"javascript\" type=\"text/javascript\">drawRadarGraph('" + this.ID.ToString() + "', " + dataJSString + "," + MaxValue.ToString() + ",'" + ColorString + "'," + NumMarks.ToString() + ",'" + this.Title.ToString() + "');</script></canvas>"); }
private SKRect[] MeasureVerticalLabels() { using (var paint = new SKPaint()) { paint.TextSize = VerticalTextSize; return(this.ChartEntries.Select(e => { if (string.IsNullOrEmpty(MaxValue.ToString())) { return SKRect.Empty; } var bounds = new SKRect(); var text = MaxValue.ToString(); paint.MeasureText(text, ref bounds); var unitBounds = new SKRect(); if (!string.IsNullOrEmpty(VerticalUnit)) { paint.MeasureText(VerticalUnit, ref unitBounds); } // Returns the biggest width of value or vertical unit bounds return bounds.Width > unitBounds.Width ? bounds : unitBounds; }).ToArray()); } }
public override int GetHashCode() { var hashCode = -2125747154; hashCode = hashCode * -1521134295 + Uid.GetHashCode(); hashCode = hashCode * -1521134295 + Ifnr.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Text); hashCode = hashCode * -1521134295 + MinValue.GetHashCode(); hashCode = hashCode * -1521134295 + MaxValue.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Datatype); hashCode = hashCode * -1521134295 + Group.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Modify); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Visible); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FunctionPointer); hashCode = hashCode * -1521134295 + PropertyBitMask.GetHashCode(); hashCode = hashCode * -1521134295 + ParentUserDirCode.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <ComboBoxInput> .Default.GetHashCode(ComboBox); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(TextBox); return(hashCode); }
protected override void Render(HtmlTextWriter oWriter) { string cssClass = " mask-" + this.NumberType.ToString().ToLowerInvariant(); this.CssClass = this.CssClass.Replace(cssClass, "") + cssClass; this.Attributes["data-v-min"] = MinValue.ToString().Replace(".", "").Replace(",", "."); this.Attributes["data-v-max"] = MaxValue.ToString().Replace(".", "").Replace(",", "."); this.Attributes["data-m-dec"] = this.NumberType == numberType.Int ? "0" : "2"; this.AddTooltip(string.Concat(SetText(MinValue), " - ", SetText(MaxValue)), false); if (ShowSlider) { try { base.Render(oWriter); oWriter.Write(string.Format(@" <span class='sliderleft'>{4}</span> <div class='slider slider-basic' data-xmin='{0}' data-xmax='{1}' data-xstep='{2}' data-xitem='{3}'></div> <span class='sliderright'>{5}</span>", this.MinValue.ToString().Replace(".", "").Replace(",", "."), this.MaxValue.ToString().Replace(".", "").Replace(",", "."), this.NumberType == numberType.Int ? SliderStep.ToString() : SliderStep.ToString().Replace(",", "."), this.ClientID, this.NumberType == numberType.Int ? MinValue.ToString() : MinValue.ToString("N2"), this.NumberType == numberType.Int ? MaxValue.ToString() : MaxValue.ToString("N2"))); } catch (Exception ex) { ExceptionManager.Publish(ex); } } else { base.Render(oWriter); } }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendLine(MaxValue.ToString()); builder.AppendLine(String.Join(" ", Taken)); return(builder.ToString()); }
public override void ToJSON(JObject ParentObject) { ParentObject[_ValueSubField.ToXmlNodeName(true)] = (!Double.IsNaN(Value)) ? Value.ToString() : string.Empty; ParentObject["minvalue"] = MinValue.ToString(); ParentObject["maxvalue"] = MaxValue.ToString(); ParentObject["precision"] = Precision; ParentObject["excludeRangeLimits"] = ExcludeRangeLimits; }
public void calculateTestWithValuesinStringArrayWithPosOutOfRange() { MaxValue value = new MaxValue(); string[] values = new string[2]; values[0] = "sceneId"; values[1] = "10.2"; Assert.AreEqual(0, value.calculate(values, 3)); }
public void GivenIntegerArray_ShouldReturnLargestInteger() { int[] values = { 3, 6, 7, 10, 4, 8 }; MaxValue <int> maximumNumber = new MaxValue <int>(values); int max = maximumNumber.GetMaximum(); Assert.AreEqual(10, max); }
public void calculateTestWithValuesinStringArray() { MaxValue value = new MaxValue(); string[] values = new string[2]; values[0] = "10.2"; values[1] = "SceneId"; Assert.AreEqual(10.2, value.calculate(values, 0)); }
public void GivenStringArrayShouldReturnLargestString() { string[] values = { "222", "498", "999", "333", "777", "888" }; MaxValue <string> maximumNumber = new MaxValue <string>(values); string max = maximumNumber.GetMaximum(); Assert.AreEqual("999", max); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { int hashCode = 17 + MaxValue.GetHashCode() ^ MinValue.GetHashCode() ^ AllowNull.GetHashCode() ^ ReadOnly.GetHashCode() + 31 * GetHashCode(PossibleValues); return((DefaultValue == null) ? hashCode : hashCode * 32 + DefaultValue.GetHashCode()); } }
/// <summary> /// 画表盘的刻度 /// </summary> private void DrawScale() { object[] tempdata = new object[this.gaugeCanvas.Children.Count]; this.gaugeCanvas.Children.CopyTo(tempdata, 0); foreach (var item in tempdata) { if (item is TextBlock && (item as TextBlock).Name != "currentValue" && (item as TextBlock).Name != "hideTest") { this.gaugeCanvas.Children.Remove((item as UIElement)); } } for (int i = 0; i <= 1800; i += 36) { //添加刻度线 Line lineScale = new Line(); if (i % 180 == 0) { lineScale.X1 = 125 - 113 * Math.Cos(i * Math.PI / 1800); lineScale.Y1 = 125 - 113 * Math.Sin(i * Math.PI / 1800); lineScale.Stroke = new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0)); lineScale.StrokeThickness = 3; //添加刻度值 TextBlock txtScale = new TextBlock(); txtScale.Text = Math.Round((i / 1800d * MaxValue), 1).ToString(); txtScale.FontSize = 8; txtScale.Foreground = new SolidColorBrush(Color.FromRgb(0xd9, 0xdF, 0xee)); if (i <= 900)//对坐标值进行一定的修正 { Canvas.SetLeft(txtScale, 120 - 105 * Math.Cos(i * Math.PI / 1800)); Canvas.SetTop(txtScale, 120 - 105 * Math.Sin(i * Math.PI / 1800)); } else { var moveLength = MaxValue.ToString().Length; Canvas.SetLeft(txtScale, 120 - (moveLength - 2) * 4 - 100 * Math.Cos(i * Math.PI / 1800)); Canvas.SetTop(txtScale, 116 - 100 * Math.Sin(i * Math.PI / 1800)); } this.gaugeCanvas.Children.Add(txtScale); } else { if (i % 36 == 0) { lineScale.X1 = 125 - 115 * Math.Cos(i * Math.PI / 1800); lineScale.Y1 = 125 - 115 * Math.Sin(i * Math.PI / 1800); lineScale.Stroke = new SolidColorBrush(Color.FromRgb(0xFF, 0x00, 0)); lineScale.StrokeThickness = 1; } } lineScale.X2 = 125 - 120 * Math.Cos(i * Math.PI / 1800); lineScale.Y2 = 125 - 120 * Math.Sin(i * Math.PI / 1800); this.gaugeCanvas.Children.Add(lineScale); } }
/// <summary> /// Creates the rule. /// </summary> /// <param name="target"> </param> /// <returns> </returns> public override RulePolicy CreateRule(object target) { Rule = new MaxValue<IComparable>(RuleName, FailMessage, (IComparable)target, (IComparable)comparisonObject); return Rule; }
public void MaxValueIntIsValid() { int target = 10; int comparisonValue = 10; MaxValue<int> rule = new MaxValue<int>("MaxValueRule", "The target is not valid. Must be equal or less than comparison value.", target, comparisonValue); Result result = rule.Execute(); Assert.IsTrue(result.IsValid); Assert.IsNotNullOrEmpty(result.Message); Assert.IsNotNull(result.RulePolicy); Assert.AreEqual(result.RulePolicy.Severity, Severity.Exception); }