Esempio n. 1
0
 /// <summary>
 /// Called when deactivating.
 /// </summary>
 /// <param name="close">Inidicates 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);
     }
 }
Esempio n. 2
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);
                }
Esempio 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(T newItem, bool closePrevious)
        {
            ScreenExtensions.TryDeactivate(activeItem, closePrevious);

            newItem = EnsureItem(newItem);

            if (IsActive)
            {
                ScreenExtensions.TryActivate(newItem);
            }

            activeItem = newItem;
            NotifyOfPropertyChange("ActiveItem");
            OnActivationProcessed(activeItem, true);
        }
Esempio n. 4
0
                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);
                }
Esempio n. 5
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)
                    {
                        ScreenExtensions.TryActivate(item);
                    }

                    OnActivationProcessed(item, true);
                }
Esempio n. 6
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(T item, bool close)
                {
                    if (item == null)
                    {
                        return;
                    }

                    if (!close)
                    {
                        ScreenExtensions.TryDeactivate(item, false);
                    }
                    else
                    {
                        CloseStrategy.Execute(new[] { item }, (canClose, closable) => {
                            if (canClose)
                            {
                                CloseItemCore(item);
                            }
                        });
                    }
                }
Esempio n. 7
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;
            }

            CloseStrategy.Execute(new[] { ActiveItem }, (canClose, items) => {
                if (canClose)
                {
                    ChangeActiveItem(item, true);
                }
                else
                {
                    OnActivationProcessed(item, false);
                }
            });
        }
Esempio 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)
 {
     ScreenExtensions.TryDeactivate(ActiveItem, close);
 }
Esempio n. 9
0
 /// <summary>
 /// Called when activating.
 /// </summary>
 protected override void OnActivate()
 {
     ScreenExtensions.TryActivate(ActiveItem);
 }
Esempio n. 10
0
 void CloseItemCore(T item)
 {
     ScreenExtensions.TryDeactivate(item, true);
     items.Remove(item);
 }