public void ItemClick(object sender, ItemClickEventArgs e)
        {
            if (e.ClickedItem is NavBarDataItem data)
            {
                switch (data.PageName)
                {
                case "Menu":
                    MenuOpen = !MenuOpen;
                    break;

                default:
                    if (data.PageName != null)
                    {
                        var descriptor = PageUtil.GetDescriptorFromTypeFullName(data.PageName);
                        if (descriptor != null)
                        {
                            PageService.NavigateTo(descriptor.Type);
                        }
                    }
                    break;
                }

                UpdateSelectedNavBarButton(data.PageName);
            }
        }
        public void UpdateDefaultPageIcon(string pageTypeFullName)
        {
            var descriptor = PageUtil.GetDescriptorFromTypeFullName(pageTypeFullName);

            InvokeOnUIThread(() =>
            {
                if (TopNavBarItems[1].PageName != typeof(TilePage).FullName)
                {
                    TopNavBarItems.RemoveAt(1);
                }

                if (!string.IsNullOrEmpty(descriptor?.Category))
                {
                    TopNavBarItems.Insert(1, new NavBarDataItem
                    {
                        Content  = descriptor.Title,
                        Icon     = descriptor.Tag,
                        PageName = descriptor.Type.FullName
                    });
                }
            });
        }
Example #3
0
        private void PopulateCommandBar()
        {
            UpdateNavButtons();

            AddCommandBarButton(new CommandBarButton
            {
                Icon = new FontIcon
                {
                    Glyph = "\uE946"
                },
                Label   = Common.GetLocalizedText("CommandBarDeviceInfoButton"),
                Handler = DisplayDeviceInfoDialog,
            });

            AddCommandBarButton(new CommandBarButton
            {
                Icon    = new SymbolIcon(Symbol.FullScreen),
                Label   = Common.GetLocalizedText("CommandBarFullscreenButton"),
                Handler = (s, e) => ViewModel.ToggleFullscreenMode(),
            });

            if (App.MultiViewManager.IsMultiViewAvailable())
            {
                AddCommandBarButton(new CommandBarButton
                {
                    Icon    = new SymbolIcon(Symbol.NewWindow),
                    Label   = Common.GetLocalizedText("CommandBarMultiviewButton"),
                    Handler = async(s, e) =>
                    {
                        await App.MultiViewManager.CreateAndShowViewAsync(
                            typeof(MainPage),
                            _contentFrame.CurrentSourcePageType);
                    },
                });
            }

            string pageFullName = _contentFrame.CurrentSourcePageType?.FullName;
            var    descriptor   = PageUtil.GetDescriptorFromTypeFullName(pageFullName);

            // Check if page is eligible for "Set Default" action
            if (descriptor != null &&
                App.Settings.AppDefaultPage != pageFullName)
            {
                AddSecondaryCommandBarButton(new CommandBarButton
                {
                    Icon    = new SymbolIcon(Symbol.Home),
                    Label   = Common.GetLocalizedText("CommandBarSetDefaultButton"),
                    Handler = (s, e) =>
                    {
                        var pageTypeFullName        = _contentFrame.CurrentSourcePageType.FullName;
                        App.Settings.AppDefaultPage = pageTypeFullName;
                        ViewModel.UpdateSelectedNavBarButton(pageTypeFullName);

                        ShowNotification(string.Format(Common.GetLocalizedText("SetDefaultPageSuccessFormat"), descriptor.Title), symbol: descriptor.Icon);
                    },
                });
            }

            AddSecondaryCommandBarButton(new CommandBarButton
            {
                Icon    = new SymbolIcon(Symbol.Save),
                Label   = Common.GetLocalizedText("CommandBarSaveLogButton"),
                Handler = SaveLogButton_Click,
            });

            AddSecondaryCommandBarButton(new CommandBarButton
            {
                Icon    = new SymbolIcon(Symbol.Document),
                Label   = Common.GetLocalizedText("CommandBarSessionLogButton"),
                Handler = (s, e) =>
                {
                    NavigateTo(typeof(SessionLogPage));
                },
            });
        }