public void CommandChangeOpacityTest() { Pentagon pentagon = new Pentagon(); double opacity = 7; double expectedOpacity = pentagon.Opacity; UndoRedoManager undoRedoManager = new UndoRedoManager(); ChangeOpacity changeOpacity = new ChangeOpacity(pentagon, opacity); undoRedoManager.Execute(changeOpacity); Assert.AreEqual(pentagon.Opacity, opacity); undoRedoManager.Undo(); Assert.AreEqual(pentagon.Opacity, expectedOpacity); }
private void FadeStep() { switch (state) { case FadingState.Show: if (!visible) { visible = true; Show?.Invoke(); opacity = 0; ChangeOpacity?.Invoke(this, opacity); } else if (opacity < ShownMinus) { opacity += StepIn; ChangeOpacity?.Invoke(this, opacity); } else if (opacity != Shown) { opacity = Shown; ChangeOpacity?.Invoke(this, Shown); StartStopTimer(FadingState.Idle); } break; case FadingState.ShowTransparent: if (!visible) { visible = true; Show?.Invoke(); opacity = 0; ChangeOpacity?.Invoke(this, opacity); } else if (opacity < TransparentMinus) { opacity += StepIn; ChangeOpacity?.Invoke(this, opacity); } else if (opacity > TransparentPlus) { opacity -= StepOut; ChangeOpacity?.Invoke(this, opacity); } else if (opacity != Transparent) { ChangeOpacity?.Invoke(this, Transparent); StartStopTimer(FadingState.Idle); } break; case FadingState.Hide: if (opacity > StepOut) { opacity -= StepOut; ChangeOpacity?.Invoke(this, opacity); } else if (visible) { opacity = 0; ChangeOpacity?.Invoke(this, opacity); visible = false; Hide?.Invoke(); StartStopTimer(FadingState.Idle); } break; case FadingState.Idle: default: StartStopTimer(FadingState.Idle); break; } }