public void Set(double Value) { var old = this.Value; #region Measuring if (this.Value != Value) { this.Value = Value; if (Measuring != null) { Measuring.Invoke(this, new StableMeasureEventArgs(Value)); } } #endregion if (IsStart) { if (!IsComplete) { #region Complete Start if (Math.Abs(Value - old) < ErrorRange) { IsComplete = true; CompleteTIme = DateTime.Now; } #endregion } else { #region Complete Instance if (Math.Abs(Value - old) > ErrorRange) { IsComplete = false; } else { var dv = (DateTime.Now - CompleteTIme).TotalMilliseconds; if (dv > MeasureTime) { IsComplete = IsStart = false; if (Measured != null) { Measured.Invoke(this, new StableMeasureEventArgs(Value)); } } } #endregion } } else { #region Start if (Math.Abs(old - Value) > ErrorRange) { IsStart = true; StarTime = DateTime.Now; } #endregion } }
protected override Size MeasureOverride(Size constraint) { //if (IsMeasureValid == false) Measuring?.Invoke(this, EventArgs.Empty); return(base.MeasureOverride(constraint)); }