示例#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);
                }
            });
        }
示例#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);
     }
 }
示例#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);
        }
示例#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);
                }
示例#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);
                }
示例#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);
                }
示例#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);
                    }
                }
示例#8
0
 private void CloseItemCore(TC item)
 {
     ScreenExtensions.TryDeactivate(item, true);
     items.Remove(item);
 }
示例#9
0
 /// <summary>
 /// Called when activating.
 /// </summary>
 protected override void OnActivate()
 {
     ScreenExtensions.TryActivate(ActiveItem);
 }
示例#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);
 }