/// <summary> /// Return true, when currentValue must be change, to fit to specified maxValue. /// Then store modified value to out newValue. /// </summary> /// <param name="currentValue"></param> /// <param name="maxValue"></param> /// <param name="force"></param> /// <param name="newValue"></param> /// <returns></returns> private bool MustChangeValue(DecimalNRange currentValue, DecimalNRange maxValue, bool force, out DecimalNRange newValue) { newValue = null; if (!currentValue.IsFilled || !maxValue.IsFilled) { return(false); } if (force) { newValue = maxValue.Clone; return(true); } newValue = currentValue * maxValue; return(newValue != currentValue); }
/// <summary> /// Read .MaximalBounds from DocumentArea, and create from its value for ValueMax to Axis and Scroll. /// </summary> private void AcceptMaximalBoundsFromDocument(bool force) { if (this._SuppressEvents) { return; } using (_SuppressedEvents.Scope(this)) { RectangleD max = this.DocumentArea.MaximalBounds; if (max.Width <= 0m || max.Height <= 0m) { return; } DecimalNRange maxH = new DecimalNRange(max.Left, max.Right); this.AxisH.ValueLimit = maxH.Clone; this.ScrollH.ValueTotal = maxH.Clone; DecimalNRange maxV = new DecimalNRange(max.Top, max.Bottom); this.AxisV.ValueLimit = maxV.Clone; this.ScrollV.ValueTotal = maxV.Clone; DecimalNRange value; if (MustChangeValue(this.AxisH.Value, maxH, force, out value)) { this.AxisH.Value = value; } if (MustChangeValue(this.ScrollH.Value, maxH, force, out value)) { this.ScrollH.Value = value; } if (MustChangeValue(this.AxisV.Value, maxV, force, out value)) { this.AxisV.Value = value; } if (MustChangeValue(this.ScrollV.Value, maxV, force, out value)) { this.ScrollV.Value = value; } } }