Beispiel #1
0
        private async void SecondTitleBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            Windows.UI.StartScreen.SecondaryTile tile = TilesHelper.GenerateSecondaryTile("SecondaryTitle", "Beansprout UWP", Colors.Transparent);
            tile.VisualElements.ShowNameOnSquare150x150Logo       =
                tile.VisualElements.ShowNameOnSquare310x310Logo   =
                    tile.VisualElements.ShowNameOnWide310x150Logo =
                        true;
            await tile.RequestCreateAsync();

            try {
                await TilesHelper.GetNewsAsync();
            } catch { /* Ignore */ }
        }
Beispiel #2
0
        /// <summary>
        /// 固定或更新SecondaryTile
        /// </summary>
        public async void PinSecondaryTile()
        {
            Uri uri = new Uri("ms-appx:///Assets/Square71x71Logo.scale-240.png");
            Windows.UI.StartScreen.SecondaryTile tile = new Windows.UI.StartScreen.SecondaryTile(title, "口袋贵金属", "/MainPage.xaml", uri, Windows.UI.StartScreen.TileSize.Wide310x150);
            tile.VisualElements.Wide310x150Logo = uri;
            tile.DisplayName = " ";

            await RefreshImage();

            bool isPin = await tile.RequestCreateAsync();
            if (isPin)
            {
                var updator = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForSecondaryTile(title);
                this.UpdateTile(updator);
            }
        }
Beispiel #3
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     var _Tile = new Windows.UI.StartScreen.SecondaryTile();
     _Tile.Arguments = this.Parameter;
     _Tile.TileId = this.Parameter;
  // old  _Tile.ShortName = string.Format("ShortName {0}",this.Parameter);
     _Tile.DisplayName = string.Format("DisplayName {0}", this.Parameter);
  // new   _Tile.VisualElements.
     //_Tile.Logo = new Uri("ms-appx:///assets/logo.png");
     //_Tile.SmallLogo = new Uri("ms-appx:///assets/SmallLogo.png");
     //_Tile.WideLogo = new Uri("ms-appx:///assets/logo.png");
     //_Tile.ForegroundText = Windows.UI.StartScreen.ForegroundText.Light;
     //_Tile.BackgroundColor = Windows.UI.Colors.DarkGreen;
     //_Tile.TileOptions = Windows.UI.StartScreen.TileOptions.ShowNameOnLogo;
     await _Tile.RequestCreateAsync();
 }
Beispiel #4
0
        private async System.Threading.Tasks.Task <bool> CreateSecondaryTileAsync(Video item)
        {
            string tileId = "VS100-" + item.VidoId;
            var    tile   = new Windows.UI.StartScreen.SecondaryTile()
            {
                TileId         = tileId,
                DisplayName    = item.Title,
                Arguments      = item.VidoId,
                RoamingEnabled = true,
            };

            tile.VisualElements.ForegroundText = Windows.UI.StartScreen.ForegroundText.Light;
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;

            // アプリローカルに保存
            var cl   = new HttpClient();
            var data = await cl.GetByteArrayAsync(new Uri(item.ThumUrl));

            var folder = Windows.Storage.ApplicationData.Current.LocalFolder;
            var path   = item.VidoId + ".jpg";

            try
            {
                var file = await folder.CreateFileAsync(path);

                using (var sw = await file.OpenStreamForWriteAsync())
                {
                    sw.Write(data, 0, data.Length);
                    sw.Flush();
                }
            }
            catch
            {
                // 同名のファイルがある場合は、そのまま使う
            }

            tile.VisualElements.Square150x150Logo = new Uri("ms-appdata:///local/" + path);
            tile.VisualElements.Square30x30Logo   = new Uri("ms-appdata:///local/" + path);

            return(await tile.RequestCreateForSelectionAsync(GetElementRect(this.btnMakeTile)));
        }
        private async void HandleAddTile(object obj)
        {
            var tileID = "SecondaryTile." + Request.Id.ToString();
            var shortName = Request.Title;
            var displayName = Request.Title;
            var secondaryTileArg = Request.Id.ToString();
            var squareLogo = new System.Uri("ms-appx:///Assets/StoreLogo.png");
            var wideLogo = new System.Uri("ms-appx:///Assets/WideLogo.png");
            var tileOptions = Windows.UI.StartScreen.TileOptions.ShowNameOnWideLogo | 
                Windows.UI.StartScreen.TileOptions.ShowNameOnLogo;

            var secondaryTile = new Windows.UI.StartScreen.SecondaryTile(
                tileID, shortName, displayName, secondaryTileArg, tileOptions, squareLogo, wideLogo);
            await secondaryTile.RequestCreateAsync();

            NotificationsManager.ShowToastNotification("Secondary tile added successfully!");
        }