Exemplo n.º 1
0
        /// <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);
                }
            });
        }
Exemplo n.º 2
0
 /// <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);
     }
 }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
                /// <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);
                }
Exemplo n.º 5
0
                /// <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);
                }
Exemplo n.º 6
0
                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);
                }
Exemplo n.º 7
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 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);
                    }
                }
Exemplo n.º 8
0
 private void CloseItemCore(TC item)
 {
     ScreenExtensions.TryDeactivate(item, true);
     items.Remove(item);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Called when activating.
 /// </summary>
 protected override void OnActivate()
 {
     ScreenExtensions.TryActivate(ActiveItem);
 }
Exemplo n.º 10
0
 /// <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);
 }