/// <summary> /// Activates the specified item. /// </summary> /// <param name="item">The item to activate.</param> public override void ActivateItem(TC item) { if (item != null && item.Equals(ActiveItem)) { if (IsActive) { ScreenExtensions.TryActivate(item); OnActivationProcessed(item, true); } return; } CloseStrategy.Execute(new[] { ActiveItem }, (canClose, items) => { if (canClose) { ChangeActiveItem(item, true); } else { OnActivationProcessed(item, false); } }); }
/// <summary> /// Called when deactivating. /// </summary> /// <param name="close">Indicates whether this instance will be closed.</param> protected override void OnDeactivate(bool close) { if (close) { items.OfType <IDeactivate>().Apply(x => x.Deactivate(true)); items.Clear(); } else { ScreenExtensions.TryDeactivate(ActiveItem, false); } }
/// <summary> /// Changes the active item. /// </summary> /// <param name="newItem">The new item to activate.</param> /// <param name="closePrevious">Indicates whether or not to close the previous active item.</param> protected virtual void ChangeActiveItem(TC newItem, bool closePrevious) { ScreenExtensions.TryDeactivate(activeItem, closePrevious); newItem = EnsureItem(newItem); if (IsActive) { ScreenExtensions.TryActivate(newItem); } activeItem = newItem; NotifyOfPropertyChange("ActiveItem"); OnActivationProcessed(activeItem, true); }
/// <summary> /// Activates the specified item. /// </summary> /// <param name="item">The item to activate.</param> public override void ActivateItem(T item) { if (item != null && item.Equals(ActiveItem)) { if (IsActive) { ScreenExtensions.TryActivate(item); OnActivationProcessed(item, true); } return; } ChangeActiveItem(item, false); }
/// <summary> /// Activates the specified item. /// </summary> /// <param name="item">The item to activate.</param> public override void ActivateItem(TC item) { if (item == null) { return; } item = EnsureItem(item); if (IsActive) { ScreenExtensions.TryActivate(item); } OnActivationProcessed(item, true); }
private void CloseItemCore(T item) { if (item.Equals(ActiveItem)) { var index = items.IndexOf(item); var next = DetermineNextItemToActivate(items, index); ChangeActiveItem(next, true); } else { ScreenExtensions.TryDeactivate(item, true); } items.Remove(item); }
/// <summary> /// Deactivates the specified item. /// </summary> /// <param name="item">The item to close.</param> /// <param name="close">Indicates whether or not to close the item after deactivating it.</param> public override void DeactivateItem(TC item, bool close) { if (item == null) { return; } if (close) { CloseStrategy.Execute(new[] { item }, (canClose, closable) => { if (canClose) { CloseItemCore(item); } }); } else { ScreenExtensions.TryDeactivate(item, false); } }
private void CloseItemCore(TC item) { ScreenExtensions.TryDeactivate(item, true); items.Remove(item); }
/// <summary> /// Called when activating. /// </summary> protected override void OnActivate() { ScreenExtensions.TryActivate(ActiveItem); }
/// <summary> /// Called when deactivating. /// </summary> /// <param name="close">Indicates whether this instance will be closed.</param> protected override void OnDeactivate(bool close) { ScreenExtensions.TryDeactivate(ActiveItem, close); }