예제 #1
0
        public void HandleNavigated(ShellNavigatedEventArgs args)
        {
            if (AccumulateNavigatedEvents)
            {
                if (_accumulatedEvent == null)
                {
                    _accumulatedEvent = args;
                }
            }
            else
            {
                _accumulatedEvent = null;
                BaseShellItem baseShellItem = _shell.CurrentItem?.CurrentItem?.CurrentItem;

                if (baseShellItem != null)
                {
                    baseShellItem.OnAppearing(() =>
                    {
                        FireNavigatedEvents(args, _shell);
                    });
                }
                else
                {
                    FireNavigatedEvents(args, _shell);
                }

                void FireNavigatedEvents(ShellNavigatedEventArgs a, Shell shell)
                {
                    Navigated?.Invoke(this, args);
                    // reset active page route tree
                    Routing.ClearImplicitPageRoutes();
                    Routing.RegisterImplicitPageRoutes(_shell);
                }
            }
        }
예제 #2
0
        public static BaseShellItem SearchForPart(this BaseShellItem part, Func <BaseShellItem, bool> searchBy)
        {
            if (searchBy(part))
            {
                return(part);
            }

            BaseShellItem baseShellItem = null;

            switch (part)
            {
            case IShellItemController item:
                foreach (var section in item.GetItems())
                {
                    baseShellItem = SearchForPart(section, searchBy);
                    if (baseShellItem != null)
                    {
                        return(baseShellItem);
                    }
                }
                break;

            case IShellSectionController section:
                foreach (var content in section.GetItems())
                {
                    baseShellItem = SearchForPart(content, searchBy);
                    if (baseShellItem != null)
                    {
                        return(baseShellItem);
                    }
                }
                break;
            }

            return(null);
        }
예제 #3
0
 public static BaseShellItem SearchForRoute(this BaseShellItem shell, string route) =>
 SearchForPart(shell, (p) => p.Route == route);
예제 #4
0
 public static T SearchForRoute <T>(this BaseShellItem shell, string route) where T : BaseShellItem =>
 (T)SearchForRoute(shell, route);
예제 #5
0
        public void HandleNavigated(ShellNavigatedEventArgs args)
        {
            _waitingForWindow?.Dispose();
            _waitingForWindow = null;

            // we don't want to fire Navigated until shell is attached to an actual window
            if (_shell.Window == null || _shell.CurrentPage == null)
            {
                _shell.PropertyChanged += WaitForWindowToSet;
                var shellContent = _shell?.CurrentItem?.CurrentItem?.CurrentItem;

                if (shellContent != null)
                {
                    shellContent.ChildAdded += WaitForWindowToSet;
                }

                _waitingForWindow = new ActionDisposable(() =>
                {
                    _shell.PropertyChanged -= WaitForWindowToSet;
                    if (shellContent != null)
                    {
                        shellContent.ChildAdded -= WaitForWindowToSet;
                    }
                });

                void WaitForWindowToSet(object sender, EventArgs e)
                {
                    if (_shell.Window != null &&
                        _shell.CurrentPage != null)
                    {
                        _waitingForWindow?.Dispose();
                        _waitingForWindow = null;

                        _shell.CurrentItem?.SendAppearing();
                        HandleNavigated(args);
                    }
                }

                return;
            }

            if (AccumulateNavigatedEvents)
            {
                if (_accumulatedEvent == null)
                {
                    _accumulatedEvent = args;
                }
            }
            else
            {
                _accumulatedEvent = null;
                BaseShellItem baseShellItem = _shell.CurrentItem?.CurrentItem?.CurrentItem;

                if (baseShellItem != null)
                {
                    baseShellItem.OnAppearing(() =>
                    {
                        FireNavigatedEvents(args, _shell);
                    });
                }
                else
                {
                    FireNavigatedEvents(args, _shell);
                }

                void FireNavigatedEvents(ShellNavigatedEventArgs a, Shell shell)
                {
                    Navigated?.Invoke(this, args);
                    // reset active page route tree
                    Routing.ClearImplicitPageRoutes();
                    Routing.RegisterImplicitPageRoutes(_shell);
                }
            }
        }
예제 #6
0
        protected override bool IsShellElementVisible(BaseShellItem item)
        {
            IShellContentController controller = (IShellContentController)item;

            return(controller.Page == null || controller.Page.IsVisible);
        }