/// <summary>
                /// Activates the specified item.
                /// </summary>
                /// <param name="item">The item to activate.</param>
                public override void ActivateItem(T item)
                {
                    if (item != null && ReferenceEquals(item, ActiveItem))
                    {
                        if (IsActive)
                        {
                            ScreenHelper.TryActivate(item);
                            OnActivationProcessed(item, true);
                        }

                        return;
                    }

                    ChangeActiveItem(item, false);
                }
 /// <summary>
 /// Called when deactivating.
 /// </summary>
 /// <param name="close">Inidicates whether this instance will be closed.</param>
 protected override void OnDeactivate(bool close)
 {
     if (close)
     {
         foreach (var x in _items.OfType <IDeactivate>())
         {
             x.Deactivate(true);
         }
         _items.Clear();
     }
     else
     {
         ScreenHelper.TryDeactivate(ActiveItem, false);
     }
 }
Exemplo n.º 3
0
                /// <summary>
                /// Activates the specified item.
                /// </summary>
                /// <param name="item">The item to activate.</param>
                public override void ActivateItem(T item)
                {
                    if (item == null)
                    {
                        return;
                    }

                    item = EnsureItem(item);

                    if (IsActive)
                    {
                        ScreenHelper.TryActivate(item);
                    }

                    OnActivationProcessed(item, true);
                }
                private void CloseItemCore(T item)
                {
                    if (ReferenceEquals(item, ActiveItem))
                    {
                        var index = _items.IndexOf(item);
                        var next  = DetermineNextItemToActivate(_items, index);

                        ChangeActiveItem(next, true);
                    }
                    else
                    {
                        ScreenHelper.TryDeactivate(item, true);
                    }

                    _items.Remove(item);
                }
Exemplo n.º 5
0
                /// <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 async void DeactivateItem(T item, bool close)
                {
                    if (item == null)
                    {
                        return;
                    }

                    if (!close)
                    {
                        ScreenHelper.TryDeactivate(item, false);
                    }
                    else
                    {
                        var result = await CloseStrategy.ExecuteAsync(new[] { item });

                        if (result.CanClose)
                        {
                            CloseItemCore(item);
                        }
                    }
                }
Exemplo n.º 6
0
        /// <summary>
        /// Activates the specified item.
        /// </summary>
        /// <param name="item">The item to activate.</param>
        public override async void ActivateItem(T item)
        {
            if (item != null && ReferenceEquals(item, ActiveItem))
            {
                if (IsActive)
                {
                    ScreenHelper.TryActivate(item);
                    OnActivationProcessed(item, true);
                }
                return;
            }

            var result = await CloseStrategy.ExecuteAsync(new[] { ActiveItem });

            if (result.Item1)
            {
                ChangeActiveItem(item, true);
            }
            else
            {
                OnActivationProcessed(item, false);
            }
        }
Exemplo n.º 7
0
 private void CloseItemCore(T item)
 {
     ScreenHelper.TryDeactivate(item, true);
     _items.Remove(item);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Called when deactivating.
 /// </summary>
 /// <param name="close">Inidicates whether this instance will be closed.</param>
 protected override void OnDeactivate(bool close)
 {
     ScreenHelper.TryDeactivate(ActiveItem, close);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Called when activating.
 /// </summary>
 protected override void OnActivate()
 {
     ScreenHelper.TryActivate(ActiveItem);
 }