/* * This work is licensed under the MIT License (MIT) * Copyright (c) 2014-2021 Davide Carpi * https://opensource.org/licenses/MIT */ using System; using SMath.Controls; namespace NumericUpDownRegion { /// /// History step. /// public class NumericUpDownHistoryStep : HistoryStepBase { private string SettingsVariable; private decimal Value; private decimal MaxValue; private bool UseMaxValue; private decimal MinValue; private bool UseMinValue; private int DecimalPlaces; private decimal Increment; private decimal Increment_ALT; private decimal Increment_SHIFT; private decimal Increment_ALTSHIFT; private IncrementType IncrementType_ALT; private IncrementType IncrementType_SHIFT; private IncrementType IncrementType_ALTSHIFT; public NumericUpDownHistoryStep(NumericUpDownRegion region) : base(region) { this.SettingsVariable = (string)region.SettingsVariable; this.Value = region.Value; this.MaxValue = region.MaxValue; this.UseMaxValue = region.UseMaxValue; this.MinValue = region.MinValue; this.UseMinValue = region.UseMinValue; this.DecimalPlaces = region.DecimalPlaces; this.Increment = region.Increment; this.Increment_ALT = region.Increment_ALT; this.Increment_SHIFT = region.Increment_SHIFT; this.Increment_ALTSHIFT = region.Increment_ALTSHIFT; this.IncrementType_ALT = region.IncrementType_ALT; this.IncrementType_SHIFT = region.IncrementType_SHIFT; this.IncrementType_ALTSHIFT = region.IncrementType_ALTSHIFT; } public override void Apply(RegionBase region) { NumericUpDownRegion numRegion = region as NumericUpDownRegion; numRegion.SettingsVariable = this.SettingsVariable; numRegion.Value = this.Value; numRegion.MaxValue = this.MaxValue; numRegion.UseMaxValue = this.UseMaxValue; numRegion.MinValue = this.MinValue; numRegion.UseMinValue = this.UseMinValue; numRegion.DecimalPlaces = this.DecimalPlaces; numRegion.Increment = this.Increment; numRegion.Increment_ALT = this.Increment_ALT; numRegion.Increment_SHIFT = this.Increment_SHIFT; numRegion.Increment_ALTSHIFT = this.Increment_ALTSHIFT; numRegion.IncrementType_ALT = this.IncrementType_ALT; numRegion.IncrementType_SHIFT = this.IncrementType_SHIFT; numRegion.IncrementType_ALTSHIFT = this.IncrementType_ALTSHIFT; numRegion.GetCanvas().ButtonEvent = ButtonEvents.None; numRegion.GetCanvas().ButtonHover = Buttons.None; numRegion.GetCanvas().UpdateValue(); numRegion.CallEvaluation(); base.Apply(region); } public override bool Equals(object obj) { var item = obj as NumericUpDownHistoryStep; if (item.SettingsVariable != this.SettingsVariable || item.Value != this.Value || item.MaxValue != this.MaxValue || item.UseMaxValue != this.UseMaxValue || item.MinValue != this.MinValue || item.UseMinValue != this.UseMinValue || item.DecimalPlaces != this.DecimalPlaces || item.Increment != this.Increment || item.Increment_ALT != this.Increment_ALT || item.Increment_SHIFT != this.Increment_SHIFT || item.Increment_ALTSHIFT != this.Increment_ALTSHIFT || item.IncrementType_ALT != this.IncrementType_ALT || item.IncrementType_SHIFT != this.IncrementType_SHIFT || item.IncrementType_ALTSHIFT != this.IncrementType_ALTSHIFT) return false; return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } } }