コード例 #1
0
        public AppShellView()
        {
            this.InitializeComponent();

            coreApplicationView = CoreApplication.GetCurrentView();
            //if (coreApplicationView != null)
            //    coreApplicationView.TitleBar.ExtendViewIntoTitleBar = true;

            applicationView = ApplicationView.GetForCurrentView();
            applicationView.TitleBar.BackgroundColor         = Colors.Transparent;
            applicationView.TitleBar.ButtonBackgroundColor   = Colors.Transparent;
            applicationView.TitleBar.InactiveBackgroundColor = Colors.Transparent;

            uiSettings = new Windows.UI.ViewManagement.UISettings();

            NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.MenuItemsSourceProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.NavigationItems)));

            inlineNavigationService = WindowManager.GetNavigationManagerForCurrentView().RegisterFrameAsNavigationService(InlineFrame, FrameLevel.Two);
            windowService           = WindowManager.GetWindowServiceForCurrentView();
            UpdateSelectedNavigationItems();
            NepApp.UI.SetNavigationService(inlineNavigationService);
            inlineNavigationService.Navigated += InlineNavigationService_Navigated;

            NepApp.UI.SetOverlayParentAndSnackBarContainer(OverlayPanel, snackBarGrid);
            App.RegisterUIDialogs();

            nowPlayingOverlayCoordinator = new AppShellViewModelNowPlayingOverlayCoordinator(this);


            NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.HeaderProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.ViewTitle)));

            NowPlayingButton.SetBinding(Button.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));

            NepApp.MediaPlayer.MediaEngagementChanged += MediaPlayer_MediaEngagementChanged;
            NepApp.MediaPlayer.IsPlayingChanged       += MediaPlayer_IsPlayingChanged;


            NepApp.UI.Overlay.OverlayedDialogShown  += Overlay_DialogShown;
            NepApp.UI.Overlay.OverlayedDialogHidden += Overlay_DialogHidden;

            Messenger.AddTarget(this);

            DeviceInformation.SubplatformChanged += DeviceInformation_SubplatformChanged;

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase") &&
                Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
            {
                //Add acrylic.

                Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
                myBrush.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.Opacity          = 0.6;
                myBrush.TintOpacity      = 0.5;

                bottomAppBar.Background = myBrush;
            }
            else
            {
                bottomAppBar.Background = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
            }
        }
コード例 #2
0
        public XboxShellView()
        {
            this.InitializeComponent();

            uiSettings = new Windows.UI.ViewManagement.UISettings();

            ///Set up navigation
            inlineNavigationService = WindowManager.GetNavigationManagerForCurrentView().RegisterFrameAsNavigationService(InlineFrame, FrameLevel.Two);
            NepApp.UI.SetNavigationService(inlineNavigationService);
            inlineNavigationService.Navigated        += InlineNavigationService_Navigated;
            inlineNavigationService.PreBackRequested += InlineNavigationService_PreBackRequested;
            PageTitleTextBlock.SetBinding(TextBlock.TextProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.ViewTitle)));

            nowPlayingOverlayCoordinator = new XboxShellViewModelNowPlayingOverlayCoordinator(this, inlineNavigationService);

            ///Set up dialogs
            NepApp.UI.SetOverlayParentAndSnackBarContainer(OverlayPanel, snackBarGrid);
            App.RegisterUIDialogs();
            NepApp.UI.Overlay.OverlayedDialogShown  += Overlay_DialogShown;
            NepApp.UI.Overlay.OverlayedDialogHidden += Overlay_DialogHidden;
            NepApp.UI.NoChromeStatusChanged         += UI_NoChromeStatusChanged;

            ///Set up media metadata
            NowPlayingTrackTextBlock.SetBinding(TextBlock.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));
            NowPlayingArtistTextBlock.SetBinding(TextBlock.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));
            NepApp.MediaPlayer.IsPlayingChanged += Media_IsPlayingChanged;
            //handler to allow the metadata to animate onto the screen for the first time.
            CurrentMediaMetadataPanel.SetBinding(Control.VisibilityProperty, NepApp.CreateBinding(NepApp.MediaPlayer, nameof(NepApp.MediaPlayer.IsMediaEngaged), binding =>
            {
                binding.Converter = new Crystal3.UI.Converters.BooleanToVisibilityConverter();
            }));

            ///Set up messaging
            Messenger.AddTarget(this);

            SetInlineFrameMarginPaddingForOverflowScrolling();

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
            {
                //Add acrylic.

                Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
                myBrush.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.Opacity          = 0.6;
                myBrush.TintOpacity      = 0.5;

                HeaderGrid.Background = myBrush;

                Windows.UI.Xaml.Media.AcrylicBrush myBrush2 = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush2.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.Backdrop;
                myBrush2.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush2.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush2.Opacity          = 0.6;
                myBrush2.TintOpacity      = 0.5;

                TransportControlGrid.Background  = myBrush;
                TransportControlGrid.BorderBrush = myBrush;
            }
            else
            {
                HeaderGrid.Background            = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
                TransportControlGrid.Background  = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
                TransportControlGrid.BorderBrush = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
            }
        }