mirror of https://github.com/AMT-Cheif/Stylet.git
Start screens in Deactivated, not Initial
This means there's no further confusion around screens being deactivated without first being activated. This is also closer to the Caliburn.Micro model. The Initial state used to be useful for determining the first transition to Activated, but that turned out not to work, see recent commits.
This commit is contained in:
parent
0089029ea8
commit
a321c6f94a
|
@ -28,8 +28,9 @@ namespace Stylet
|
|||
public enum ScreenState
|
||||
{
|
||||
/// <summary>
|
||||
/// Screen has been created, but has never had any further transitions
|
||||
/// Deprecated: Screens now start in Deactivated
|
||||
/// </summary>
|
||||
[Obsolete("Screens now start in the Deactivated state")]
|
||||
Initial,
|
||||
|
||||
/// <summary>
|
||||
|
@ -38,7 +39,7 @@ namespace Stylet
|
|||
Active,
|
||||
|
||||
/// <summary>
|
||||
/// Screen is deactivated. It has either been hidden in favour of another Screen, or the entire window has been minimised
|
||||
/// Screen is deactivated. It is either new, has been hidden in favour of another Screen, or the entire window has been minimised
|
||||
/// </summary>
|
||||
Deactivated,
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Stylet
|
|||
|
||||
#region IScreenState
|
||||
|
||||
private ScreenState _state = ScreenState.Initial;
|
||||
private ScreenState _state = ScreenState.Deactivated;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current state of the Screen
|
||||
|
|
|
@ -102,6 +102,12 @@ namespace StyletUnitTests
|
|||
Assert.IsFalse(this.screen.IsActive);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ScreenIsInitiallyDeactivated()
|
||||
{
|
||||
Assert.AreEqual(ScreenState.Deactivated, this.screen.State);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ActivateActivatesIfNotAlreadyActive()
|
||||
{
|
||||
|
@ -182,13 +188,13 @@ namespace StyletUnitTests
|
|||
|
||||
Assert.AreEqual(1, changedEventArgs.Count);
|
||||
Assert.AreEqual(ScreenState.Active, changedEventArgs[0].NewState);
|
||||
Assert.AreEqual(ScreenState.Initial, changedEventArgs[0].PreviousState);
|
||||
Assert.AreEqual(ScreenState.Deactivated, changedEventArgs[0].PreviousState);
|
||||
|
||||
Assert.AreEqual(ScreenState.Initial, this.screen.PreviousState);
|
||||
Assert.AreEqual(ScreenState.Deactivated, this.screen.PreviousState);
|
||||
Assert.AreEqual(ScreenState.Active, this.screen.NewState);
|
||||
|
||||
Assert.AreEqual(1, activatedEventArgs.Count);
|
||||
Assert.AreEqual(ScreenState.Initial, activatedEventArgs[0].PreviousState);
|
||||
Assert.AreEqual(ScreenState.Deactivated, activatedEventArgs[0].PreviousState);
|
||||
Assert.IsTrue(activatedEventArgs[0].IsInitialActivate);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue