private void UpdateAdjustmentControls(ImageAdjustmentType adjustmentType, Int32 adjustmentValue) { EnumControls(this.Controls); void EnumControls(IEnumerable controls) { foreach (Control control in controls) { var controlAdjustmentType = ImageAdjustmentTypeExtensions.ToImageAdjustmentType(control); if (controlAdjustmentType == adjustmentType) { if (control is TrackBar trackBar) { this.UpdateAdjustmentControl(() => trackBar.Value = adjustmentValue); } else if (control is NumericUpDown numericUpDown) { this.UpdateAdjustmentControl(() => numericUpDown.Value = adjustmentValue); } } if (control.HasChildren) { EnumControls(control.Controls); } } } }
private void AddEvent(ImageAdjustmentType type, Int32 diff, Int32 value) { lock (this._adjustmentEvents) { if ((this._lastAdjustment != null) && (type == this._lastAdjustment.Type)) { Trace.WriteLine($"Skip {value}"); this._lastAdjustment.Diff = 0; this._lastAdjustment.Value = value; } else { Trace.WriteLine($"Add {value}"); this._lastAdjustment = new AdjustmentEvent() { Type = type, Diff = diff, Value = value }; this._adjustmentEvents.Push(this._lastAdjustment); } } this._adjustmentTimer.Stop(); this._adjustmentTimer.Start(); }
private Int32 UpdateImageProperty(ImageAdjustmentType adjustmentType, Int32 adjustmentDiff, Int32 adjustmentValue) { var newAdjustmentValue = 0 == adjustmentDiff ? adjustmentValue : (this._imageBuilder.ImageProperties.Get(adjustmentType) + adjustmentDiff); this._imageBuilder.ImageProperties.Set(adjustmentType, newAdjustmentValue); return(newAdjustmentValue); }
public void SetAdjustment(ImageAdjustmentType adjustmentType, Int32 adjustmentDiff, Int32 adjustmentValue) { switch (adjustmentType) { case ImageAdjustmentType.Contrast: this.AddEvent(adjustmentType, adjustmentDiff, adjustmentValue); break; default: // TODO return; } }
public void Set(ImageAdjustmentType imageAdjustmentType, Int32 imageAdjustmentValue) => this.adjustmentValues[imageAdjustmentType] = imageAdjustmentValue;
public Int32 Get(ImageAdjustmentType imageAdjustmentType) => this.adjustmentValues[imageAdjustmentType];
public Boolean IsModified(ImageAdjustmentType imageAdjustmentType) => this.adjustmentValues[imageAdjustmentType] != 0;