當前位置: 首頁>>代碼示例>>C#>>正文


C# StartScreen.SecondaryTile類代碼示例

本文整理匯總了C#中Windows.UI.StartScreen.SecondaryTile的典型用法代碼示例。如果您正苦於以下問題:C# SecondaryTile類的具體用法?C# SecondaryTile怎麽用?C# SecondaryTile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SecondaryTile類屬於Windows.UI.StartScreen命名空間,在下文中一共展示了SecondaryTile類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Pin

        public async Task<bool> Pin(TileInfo info)
        {
            System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
            if (Exists(info))
                return true;

            var tile = new SecondaryTile()
            {
                TileId = info.TileId,
                DisplayName = info.DisplayName,
                Arguments = info.Arguments,
                PhoneticName = info.PhoneticName,
                LockScreenDisplayBadgeAndTileText = info.LockScreenDisplayBadgeAndTileText,
                LockScreenBadgeLogo = info.LockScreenBadgeLogo,
            };

            tile.VisualElements.BackgroundColor = info.VisualElements.BackgroundColor;
            tile.VisualElements.ForegroundText = info.VisualElements.ForegroundText;
            tile.VisualElements.ShowNameOnSquare150x150Logo = info.VisualElements.ShowNameOnSquare150x150Logo;
            tile.VisualElements.ShowNameOnSquare310x310Logo = info.VisualElements.ShowNameOnSquare310x310Logo;
            tile.VisualElements.ShowNameOnWide310x150Logo = info.VisualElements.ShowNameOnWide310x150Logo;
            tile.VisualElements.Square150x150Logo = info.VisualElements.Square150x150Logo;
            tile.VisualElements.Square30x30Logo = info.VisualElements.Square30x30Logo;
            tile.VisualElements.Square310x310Logo = info.VisualElements.Square310x310Logo;
            tile.VisualElements.Square70x70Logo = info.VisualElements.Square70x70Logo;
            tile.VisualElements.Wide310x150Logo = info.VisualElements.Wide310x150Logo;

            var result = await tile.RequestCreateForSelectionAsync(info.Rect(), info.RequestPlacement);
            return result;
        }
開發者ID:K-Tobin15,項目名稱:Tutorials,代碼行數:30,代碼來源:SecondaryTileService.cs

示例2: PinToStart

        /// <summary>
        /// Create and pin a secondary square Tile.
        /// </summary>
        /// <param name="tileId"></param>
        /// <param name="shortName"></param>
        /// <param name="image"></param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public async Task<bool> PinToStart(string tileId, string shortName, Uri image, string arguments)
        {
            // Create the unique tileId
            var id = Regex.Replace(tileId, @"[^\d\w\s]", "-").
                     Replace(" ", string.Empty) + ".LiveTile";

            //Check first if Tile exists
            if (!SecondaryTileExists(id))
            {
                //Create a secondary Tile
                var secondaryTile = new SecondaryTile(id, shortName, shortName, image, TileSize.Default);

#if WINDOWS_PHONE_APP     
                bool isPinned = await secondaryTile.RequestCreateAsync();
#else
                // Position of the modal dialog 
                GeneralTransform buttonTransform = App.Frame.TransformToVisual(null);
                Point point = buttonTransform.TransformPoint(new Point());
                var rect = new Rect(point, new Size(App.Frame.ActualWidth, App.Frame.ActualHeight));

                //Pin
                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Placement.Below);
#endif

                return isPinned;
            }

            return true;
        }
開發者ID:JavierErdozain,項目名稱:Events,代碼行數:37,代碼來源:TileService.cs

示例3: SetLiveTileToSingleImage

            static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName)
            {
                // Construct the tile content as a string
                string content = [email protected]"
                                <tile>
                                    <visual> 
                                        <binding template='TileSquareImage'>
                                           <image id='1' src='ms-appdata:///local/{mediumImageFileName}' />
                                        </binding> 
                                         <binding  template='TileWideImage' branding='none'>
                                           <image id='1' src='ms-appdata:///local/{wideImageFileName}' />
                                        </binding>
 
                                    </visual>
                                </tile>";

            SecondaryTile sec = new SecondaryTile("tile", "","prof2", new Uri("ms-appdata:///local/{mediumImageFileName}"), TileSize.Square150x150);
            await sec.RequestCreateAsync();
                // Load the string into an XmlDocument
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                // Then create the tile notification
                var notification = new TileNotification(doc);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(sec.TileId).Update(notification);

        }
開發者ID:Romaxaqaz,項目名稱:Onliner,代碼行數:27,代碼來源:LiveTileBuilder.cs

示例4: CreateTileIfNotExist

        public static async Task<bool> CreateTileIfNotExist(Feed feed)
        {
            // 既にタイルが存在する場合は何もしない
            if (SecondaryTile.Exists(feed.Id))
            {
                return false;
            }

            // セカンダリタイルを作成
            var tile = new SecondaryTile(
                // タイルのId
                feed.Id,
                // タイルの短い名前
                feed.Title,
                // タイルの表示名
                feed.Title,
                // タイルからアプリケーションを起動したときに渡される引數
                feed.Id,
                // タイルの名前の表示方法を指定
                TileOptions.ShowNameOnLogo,
                // タイルのロゴを指定
                new Uri("ms-appx:///Assets/Logo.png"));
            // ユーザーにタイルの作成をリクエスト
            return await tile.RequestCreateAsync();
        }
開發者ID:runceel,項目名稱:metroapps,代碼行數:25,代碼來源:FeedTileUtils.cs

示例5: Pin

		public async Task<bool> Pin(TileInfo tileInfo)
		{
			if (tileInfo == null)
			{
				throw new ArgumentNullException("tileInfo");
			}

			var isPinned = false;

			if (!SecondaryTile.Exists(tileInfo.TileId))
			{
				var secondaryTile = new SecondaryTile(
					tileInfo.TileId,
					tileInfo.DisplayName,
					tileInfo.Arguments,
					tileInfo.LogoUri,
					tileInfo.TileSize);

				if (tileInfo.WideLogoUri != null)
				{
					secondaryTile.VisualElements.Wide310x150Logo = tileInfo.WideLogoUri;
				}

				secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
				secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
				secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

				isPinned = await secondaryTile.RequestCreateForSelectionAsync(
						GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
			}

			return isPinned;
		}
開發者ID:brentedwards,項目名稱:Charmed,代碼行數:33,代碼來源:SecondaryPinner.cs

示例6: PinCategoryTile

        public async Task<bool> PinCategoryTile(Category category)
        {
            string tileId = category.ID.ToString();

            string arguements = tileId + "/" + "Category";

            string displayName = category.CategoryName;

            bool isPinned = false;

            if (!SecondaryTile.Exists(tileId))
            {
                var secondaryTile = new SecondaryTile();

                secondaryTile.TileId = tileId;

                secondaryTile.ShortName = "2nd tile";

                secondaryTile.DisplayName = displayName;

                secondaryTile.Arguments = arguements;

                secondaryTile.Logo = new Uri("ms-appdata:///local/картинка031.jpg");

                isPinned = await secondaryTile.RequestCreateAsync();

                return isPinned;
            }

            return isPinned;
        }
開發者ID:Snail34,項目名稱:MobileScanner,代碼行數:31,代碼來源:TileProvider.cs

示例7: PinUnPinCommandButton_Click

        /*string displayName = "Secondary tile pinned through app bar";
        string tileActivationArguments = MainPage.appbarTileId + " was pinned at=" + DateTime.Now.ToLocalTime().ToString();
        Uri square150x150Logo = new Windows.Foundation.Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
        TileSize newTileDesiredSize = TileSize.Square150x150;
        */


        private async void PinUnPinCommandButton_Click(object sender, RoutedEventArgs e)
        {

            this.SecondaryTileCommandBar.IsSticky = true;
            if (SecondaryTile.Exists("Amr"))
            {
                //UnPin
                SecondaryTile secTile = new SecondaryTile("Amr");
                Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
                var placment = Windows.UI.Popups.Placement.Above;
                bool IsUnPinned = await secTile.RequestDeleteForSelectionAsync(rect, placment);
                ToggleAppBarButton(IsUnPinned);
            }
            else
            {
                //Pin
                SecondaryTile secTile = new SecondaryTile("Amr", "Amr Alaa", "AAA", new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png"), TileSize.Square150x150);
                secTile.VisualElements.Square30x30Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");
                secTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secTile.VisualElements.ShowNameOnSquare310x310Logo = true;

                secTile.VisualElements.ForegroundText = ForegroundText.Dark;
                
                Windows.Foundation.Rect rect = new Rect(20, 20, 2000, 2000);
                var placment = Windows.UI.Popups.Placement.Above;
                bool isPinned = await secTile.RequestCreateForSelectionAsync(rect,placment);
                ToggleAppBarButton(isPinned);

            }

            this.BottomAppBar.IsSticky = false;
            
        }
開發者ID:AMRALAA10,項目名稱:oneAppAllOfWindows,代碼行數:40,代碼來源:Details.xaml.cs

示例8: UpdateMedium

        private async void UpdateMedium(TileBindingContentAdaptive mediumContent)
        {
            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = mediumContent
                    }
                }
            };

            try
            {
                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }

            catch
            {
                SecondaryTile tile = new SecondaryTile("SecondaryTile", "Example", "args", new Uri("ms-appx:///Assets/Logo.png"), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo = true;
                tile.VisualElements.BackgroundColor = Colors.Transparent;
                await tile.RequestCreateAsync();

                TileUpdateManager.CreateTileUpdaterForSecondaryTile("SecondaryTile").Update(new TileNotification(content.GetXml()));
            }
        }
開發者ID:androllen,項目名稱:NotificationsExtensions,代碼行數:30,代碼來源:TilesPage.xaml.cs

示例9: Pin

        public async void Pin()
        {
            var tileId = Artist.Id.ToString();

            var tile = new SecondaryTile(tileId)
            {
                DisplayName = Artist.Name,
                VisualElements =
                {
                    BackgroundColor = Color.FromArgb(255, 7, 96, 110),
                    Square150x150Logo = new Uri("ms-appx:///Assets/Logo.png"),
                    ShowNameOnSquare150x150Logo = true,
                    Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.png"),
                    ShowNameOnWide310x150Logo = true,
                    ForegroundText = ForegroundText.Light
                },
                Arguments = Artist.Id.ToString()
            };

            await tile.RequestCreateAsync();

            var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);
            var template = await GetTemplateDocumentAsync();

            var notification = new TileNotification(template);

            updater.Update(notification);
        }
開發者ID:krisgithub123,項目名稱:windows-10-demos,代碼行數:28,代碼來源:ReleaseDetailsViewModel.cs

示例10: PinSecondaryTileAsync

        public static async Task PinSecondaryTileAsync(string id, string displayName, string arguments, TileSize tileSize)
        {
            if(IsPinned(id))
            {
                return;
            }

            Uri logo = new Uri("ms-appx:///assets/Logo.scale-100.jpg");
            Uri wideLogo = new Uri("ms-appx:///assets/WideLogo.scale-100.jpg");

            SecondaryTile secondaryTile = new SecondaryTile(id,
                                                            displayName,
                                                            "MGTV://" + arguments,
                                                            logo,
                                                            tileSize);

            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

            secondaryTile.VisualElements.Wide310x150Logo = wideLogo;
            secondaryTile.VisualElements.Square150x150Logo = logo;

            secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

            await secondaryTile.RequestCreateAsync();
        }
開發者ID:Yardley999,項目名稱:MGTV,代碼行數:27,代碼來源:LiveTileHelper.cs

示例11: UpdateDefaultLogo_Click

        /// <summary>
        /// This is the click handler for the 'Update logo async' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UpdateDefaultLogo_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button != null)
            {
                if (Windows.UI.StartScreen.SecondaryTile.Exists(MainPage.logoSecondaryTileId))
                {
                    // Add the properties we want to update (logo in this example)
                    SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId);
                    secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/squareTileLogoUpdate-sdk.png");
                    bool isUpdated = await secondaryTile.UpdateAsync();

                    if (isUpdated)
                    {
                        rootPage.NotifyUser("Secondary tile logo updated.", NotifyType.StatusMessage);
                    }
                    else
                    {
                        rootPage.NotifyUser("Secondary tile logo not updated.", NotifyType.ErrorMessage);
                    }
                }
                else
                {
                    rootPage.NotifyUser("Please pin a secondary tile using scenario 1 before updating the Logo.", NotifyType.ErrorMessage);
                }
            }
        }
開發者ID:noriike,項目名稱:xaml-106136,代碼行數:32,代碼來源:UpdateAsync.xaml.cs

示例12: UnpinSecondaryTile_Click

 /// <summary>
 /// This is the click handler for the 'Unpin' button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void UnpinSecondaryTile_Click(object sender, RoutedEventArgs e)
 {
     Button button = sender as Button;
     if (button != null)
     {
         if (Windows.UI.StartScreen.SecondaryTile.Exists(MainPage.logoSecondaryTileId))
         {
             // First prepare the tile to be unpinned
             SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId);
             // Now make the delete request.
             bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(MainPage.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
             if (isUnpinned)
             {
                 rootPage.NotifyUser("Secondary tile successfully unpinned.", NotifyType.StatusMessage);
             }
             else
             {
                 rootPage.NotifyUser("Secondary tile not unpinned.", NotifyType.ErrorMessage);
             }
         }
         else
         {
             rootPage.NotifyUser(MainPage.logoSecondaryTileId + " is not currently pinned.", NotifyType.ErrorMessage);
         }
     }
 }
開發者ID:mbin,項目名稱:Win81App,代碼行數:31,代碼來源:UnpinTile.xaml.cs

示例13: Pin

		public async Task<bool> Pin(TileInfo tileInfo)
		{
			if (tileInfo == null)
			{
				throw new ArgumentNullException("tileInfo");
			}

			var isPinned = false;

			if (!SecondaryTile.Exists(tileInfo.TileId))
			{
				var secondaryTile = new SecondaryTile(
					tileInfo.TileId,
					tileInfo.ShortName,
					tileInfo.DisplayName,
					tileInfo.Arguments,
					tileInfo.TileOptions,
					tileInfo.LogoUri);

				if (tileInfo.WideLogoUri != null)
				{
					secondaryTile.WideLogo = tileInfo.WideLogoUri;
				}

				isPinned = await secondaryTile.RequestCreateForSelectionAsync(
						GetElementRect(tileInfo.AnchorElement), tileInfo.RequestPlacement);
			}

			return isPinned;
		}
開發者ID:slodge,項目名稱:Charmed,代碼行數:30,代碼來源:Win8SecondaryPinner.cs

示例14: PinAndUpdate_Click

        private async void PinAndUpdate_Click(object sender, RoutedEventArgs e)
        {
            // Create the original Square150x150 tile
            var tile = new SecondaryTile(SCENARIO1_TILEID, "Scenario 1", "/MainPage.xaml?scenario=Scenario1", new Uri("ms-appx:///Assets/originalTileImage.png"), TileSize.Default);
            tile.VisualElements.ShowNameOnSquare150x150Logo = true;
            await tile.RequestCreateAsync();

            // When a new tile is created, the app will be deactivated and the new tile will be displayed to the user on the start screen.
            // Any code after the call to RequestCreateAsync is not guaranteed to run. 
            // For example, a common scenario is to associate a push channel with the newly created tile,
            // which involves a call to WNS to get a channel using the CreatePushNotificationChannelForSecondaryTileAsync() asynchronous operation. 
            // Another example is updating the secondary tile with data from a web service. Both of these are examples of actions that may not
            // complete before the app is deactivated. To illustrate this, we'll create a delay and then attempt to update our secondary tile.

            
            // If the app is deactivated before reaching this point, the following code will never run.

            // Update the tile we created using a notification.
            var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);

            // The TileSquare150x150Image template only contains one image entry, so retrieve it.
            var imageElement = tileXml.GetElementsByTagName("image").Single();

            // Set the src propertry on the image entry.
            imageElement.Attributes.GetNamedItem("src").NodeValue = "ms-appx:///Assets/updatedTileImage.png";

            // Create a new tile notification.
            var notification = new Windows.UI.Notifications.TileNotification(tileXml);

            // Create a tile updater.
            var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(SCENARIO1_TILEID);

            // Send the update notification for the tile. 
            updater.Update(notification);
        }
開發者ID:SoftwareFactoryUPC,項目名稱:ProjectTemplates,代碼行數:35,代碼來源:Scenario1_Inline.xaml.cs

示例15: PinToStart

        public async Task PinToStart() {
            var logo = new Uri("ms-appx:///Assets/Logo.png");

            var secondaryTile = new SecondaryTile(Guid.NewGuid().ToString(), _list.Title, _list.Id.ToString(), logo, TileSize.Square150x150);
            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            await secondaryTile.RequestCreateAsync();
        }
開發者ID:skallab78,項目名稱:solid-navigation-dwx-2015,代碼行數:7,代碼來源:TasksPageViewModel.cs


注:本文中的Windows.UI.StartScreen.SecondaryTile類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。