Exemplo n.º 1
0
        private void OnWindowVisibilityChanged(object sender, VisibilityChangedEventArgs e)
        {
            if (!AppCallbacks.Instance.IsInitialized())
            {
                return;
            }

            if (e.Visible)
            {
                AppCallbacks.Instance.InvokeOnAppThread(() =>
                {
                    GameManager.Instance.InitialiseSound();
                }, false);
                AppCallbacks.Instance.UnityPause(0);
                return;
            }
            else
            {
                AppCallbacks.Instance.UnityPause(1);

                var smallContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText01();
                var wideContent  = TileContentFactory.CreateTileWide310x150ImageAndText02();
                var largeContent = TileContentFactory.CreateTileSquare310x310ImageAndText01();

                AppCallbacks.Instance.InvokeOnAppThread(() =>
                {
                    var score = GameManager.Instance.GetScore();

                    AppCallbacks.Instance.InvokeOnUIThread(() =>
                    {
                        smallContent.Branding         = TileBranding.None;
                        smallContent.TextHeading.Text = "Score : " + score.ToString();
                        smallContent.Image.Src        = "ms-appx:///Assets/SquareTile.png";

                        wideContent.Branding                    = TileBranding.None; // Set this to TileBranding.Name if you wish to display your game name on the tile.
                        wideContent.TextCaption1.Text           = "Score : " + score.ToString();
                        wideContent.Image.Src                   = "ms-appx:///Assets/WideLogo.png";
                        wideContent.RequireSquare150x150Content = false;

                        largeContent.Branding                  = TileBranding.None;
                        largeContent.Image.Src                 = "ms-appx:///Assets/SquareTile.png";
                        largeContent.TextCaptionWrap.Text      = "Score : " + score.ToString();
                        largeContent.RequireWide310x150Content = false;

                        var updaterWide = TileUpdateManager.CreateTileUpdaterForApplication();
                        updaterWide.Update(wideContent.CreateNotification());

                        var updaterLarge = TileUpdateManager.CreateTileUpdaterForApplication();
                        updaterLarge.Update(largeContent.CreateNotification());
                        //updater.Update(smallContent.CreateNotification());
                    }, false);
                }, false);
            }
        }
Exemplo n.º 2
0
        public async Task SetTileTransparency()
        {
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            if (updater == null)
            {
                return;
            }
            updater.EnableNotificationQueue(true);
            updater.Clear();

            var tileType = _settingsService.UseTransparentTile ? Transparent : string.Empty;

            var mainWideContent = TileContentFactory.CreateTileWide310x150ImageAndText02();

            mainWideContent.Image.Src = string.Format(WideTileLocation, tileType);
            mainWideContent.Branding  = TileBranding.None;

            var mainSquareContent = CreateMainTile(string.Format(MediumTileLocation, tileType), TileBranding.None);

            mainWideContent.Square150x150Content = mainSquareContent;
            updater.Update(mainWideContent.CreateNotification());

            var secondaryTiles = await SecondaryTile.FindAllAsync();

            foreach (var tile in secondaryTiles)
            {
                var arguments = new Uri(tile.Arguments).QueryDictionary();
                var source    = arguments["source"];
                var uri       = GetTileUrl(source);
                updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId);

                mainSquareContent = CreateMainTile(uri, TileBranding.Name);

                updater.Update(mainSquareContent.CreateNotification());
            }
        }