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