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(); }
async void HomePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { //secondary tile var secondaryTileId = "AdminPage"; if (!SecondaryTile.Exists(secondaryTileId)) { Uri square150x150Logo = new Uri("ms-appx:///Assets/150winAdmin.png"); Uri square30x30Logo = new Uri("ms-appx:///Assets/30winAdmin.png"); string tileActivationArguments = secondaryTileId + " was pinned at = " + DateTime.Now.ToLocalTime().ToString(); string displayName = "IndiaRose.Admin"; TileSize newTileDesiredSize = TileSize.Square150x150; SecondaryTile secondaryTile = new SecondaryTile(secondaryTileId, displayName, tileActivationArguments, square150x150Logo, newTileDesiredSize); secondaryTile.VisualElements.Square30x30Logo = square30x30Logo; secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark; secondaryTile.BackgroundColor = Colors.CornflowerBlue; await secondaryTile.RequestCreateAsync(); } }
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(); }
public async Task<bool> PinDocumentTile(Document document) { string tileId = document.ID.ToString(); string arguements = tileId + "/" + "Document"; string displayName = document.DocumentName; 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; }
/// <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; }
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); }
public async static void CreateNormalTiles(TilePropertyModel tileProperty) { Uri uri = new Uri("ms-appx:///Assets/bird.png", UriKind.RelativeOrAbsolute); var tile = new SecondaryTile(); tile.Arguments = tileProperty.Arguments; tile.DisplayName = tileProperty.DisplayName; tile.PhoneticName = tileProperty.PhoneticName; tile.TileId = tileProperty.TileId; tile.VisualElements.BackgroundColor = Color.FromArgb(255, 34, 32, 222); tile.VisualElements.ForegroundText = ForegroundText.Light; tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; tile.VisualElements.Square150x150Logo = uri; tile.VisualElements.Square30x30Logo = uri; tile.VisualElements.Square310x310Logo = uri; //tile.VisualElements.Square70x70Logo = uri; tile.VisualElements.Square71x71Logo = uri; tile.VisualElements.Wide310x150Logo = uri; if (await tile.RequestCreateAsync()) { System.Diagnostics.Debug.WriteLine("a tile has been created"); } }
/// <summary> /// Creates a secondary tile given a subreddit. /// </summary> /// <param name="subreddit"></param> /// <returns></returns> public async Task<bool> CreateSubredditTile(Subreddit subreddit) { // If it already exists get out of here. if (IsSubredditPinned(subreddit.DisplayName)) { return true; } // Try to make the tile SecondaryTile tile = new SecondaryTile(); tile.DisplayName = subreddit.DisplayName; tile.TileId = c_subredditTitleId + subreddit.DisplayName; tile.Arguments = c_subredditOpenArgument + subreddit.DisplayName; // Set the visuals tile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/AppAssets/Square150x150/Square150.png", UriKind.Absolute); tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/AppAssets/Square310x310/Square210.png", UriKind.Absolute); tile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/AppAssets/Square44x44/Square44.png", UriKind.Absolute); tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/AppAssets/Square71x71/Square71.png", UriKind.Absolute); tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/AppAssets/Wide310x310/Wide310.png", UriKind.Absolute); tile.VisualElements.ShowNameOnSquare150x150Logo = true; tile.VisualElements.ShowNameOnSquare310x310Logo = true; tile.VisualElements.ShowNameOnWide310x150Logo = true; tile.RoamingEnabled = true; // Request the create. return await tile.RequestCreateAsync(); }
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); }
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(); }
/// <summary> /// Create the secondary tile /// </summary> /// <param name="element">Element to pin</param> public async Task PinAsync(PinnableObject element) { SecondaryTile tile = new SecondaryTile { TileId = element.Id, ShortName = element.Title, DisplayName = element.Title, Arguments = element.Id, TileOptions = TileOptions.ShowNameOnLogo, Logo = new Uri("ms-appx:///Assets/Logo.png") }; if (await tile.RequestCreateAsync()) { // Tile template definition ITileSquarePeekImageAndText04 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText04(); squareContent.TextBodyWrap.Text = element.Content; squareContent.Image.Src = element.ImageUrl; squareContent.Image.Alt = element.Content; // Tile creation TileNotification tileNotification = squareContent.CreateNotification(); // Send the notification TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(element.Id); tileUpdater.Update(tileNotification); } }
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())); } }
static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName) { // Construct the tile content as a string string content = $@" <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); }
public async Task PinToStart() { var logo = new Uri("ms-appx:///Assets/Logo.png"); var target = new TaskListTarget(_list.Id); var url = Router.Current.CreateUrl(target); var secondaryTile = new SecondaryTile(Guid.NewGuid().ToString(), _list.Title, url, logo, TileSize.Square150x150); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; await secondaryTile.RequestCreateAsync(); }
public async Task<bool> PinWideSecondaryTile(string tileId, string shortName, string displayName, string arguments) { if (!SecondaryTileExists(tileId)) { var secondaryTile = new SecondaryTile(tileId, shortName, displayName, arguments, TileOptions.ShowNameOnWideLogo, _squareLogoUri, _wideLogoUri); bool isPinned = await secondaryTile.RequestCreateAsync(); return isPinned; } return true; }
private async void ButtonPinTile_Click(object sender, RoutedEventArgs e) { base.IsEnabled = false; string tileId = DateTime.Now.Ticks.ToString(); SecondaryTile tile = new SecondaryTile(tileId, "Logo App Data", "args", _imagePath, TileSize.Default); await tile.RequestCreateAsync(); base.IsEnabled = true; }
private async void ButtonPinTile_Click(object sender, RoutedEventArgs e) { base.IsEnabled = false; string tileId = DateTime.Now.Ticks.ToString(); SecondaryTile tile = new SecondaryTile(tileId, "Logo App Package", "args", new Uri("ms-appx:///Assets/Photos/1.jpg"), TileSize.Default); await tile.RequestCreateAsync(); base.IsEnabled = true; }
/// <summary> /// 创建辅助磁贴 /// </summary> /// <param name="tileId">磁贴的唯一 ID</param> /// <param name="displayName">显示名称</param> /// <param name="tileActivationArguments">激活辅助磁贴时传递到父应用程序的参数字符串</param> public async static Task CreateSecondaryTileAsync(string tileId, string displayName, string tileActivationArguments) { SecondaryTile secondaryTile = new SecondaryTile(tileId, displayName, tileActivationArguments, square150x150Logo, TileSize.Square150x150); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; await secondaryTile.RequestCreateAsync(); }
public async Task CreateSecondaryTileAsync(string id, string imageUri, string title, string args, string wideLogo = null) { SecondaryTile tile = new SecondaryTile(id, title, args, new Uri(imageUri), TileSize.Square150x150); tile.VisualElements.BackgroundColor = Colors.Transparent; if (wideLogo != null) tile.VisualElements.Wide310x150Logo = new Uri(wideLogo); tile.RoamingEnabled = true; await tile.RequestCreateAsync(); }
public async Task<bool> PinSquareSecondaryTile(string tileId, string shortName, string displayName, string arguments) { if (!SecondaryTileExists(tileId)) { var secondaryTile = new SecondaryTile(tileId, shortName, displayName, arguments, TileOptions.ShowNameOnLogo, _assetsService.GetSquareLogoUri(), null); bool isPinned = await secondaryTile.RequestCreateAsync(); return isPinned; } return true; }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var secondaryTile = new SecondaryTile( "tilePage", "shortname", "displayname", new Uri("ms-appx:///Assets/StoreLogo.png", UriKind.Absolute), TileSize.Default); var success = await secondaryTile.RequestCreateAsync(); if (success) { var tileBindingContentAdaptive = new TileBindingContentAdaptive { Children = { new TileText { Text = "uwp tiles", Style = TileTextStyle.Header }, new TileText { Text = "secondary", Style = TileTextStyle.Body } } }; var tileBinding = new TileBinding { Branding = TileBranding.Name, Content = tileBindingContentAdaptive, DisplayName = "my tile" }; var tileContent = new TileContent { Visual = new TileVisual { TileMedium = tileBinding, TileWide = tileBinding, TileLarge = tileBinding } }; var xmlDoc = tileContent.GetXml(); TileNotification tileNotification = new TileNotification(xmlDoc); var tileUpdaterForSecondaryTile = TileUpdateManager.CreateTileUpdaterForSecondaryTile("tilePage"); tileUpdaterForSecondaryTile.Update(tileNotification); } }
private async void PinAndUpdate_Click(object sender, RoutedEventArgs e) { // Before creating and pinning the new tile, we'll set an action // to be called during the Suspending event to update the tile. // This action is called from OnSuspending in App.xaml.cs App.OnNewTilePinned = UpdateTile; // Create the original Square150x150 tile. The image to display on the tile has a purple background and the word "Original" in white text. var tile = new SecondaryTile(SCENARIO2_TILEID, "Scenario 2", "/MainPage.xaml?scenario=Scenario2", new Uri("ms-appx:///Assets/originalTileImage.png"), TileSize.Default); tile.VisualElements.ShowNameOnSquare150x150Logo = true; await tile.RequestCreateAsync(); }
public async Task<bool> PinSquareSecondaryTile(string tileId, string displayName, string arguments) { if (!SecondaryTileExists(tileId)) { var secondaryTile = new SecondaryTile(tileId, displayName, arguments, _squareLogoUri, TileSize.Square150x150); bool isPinned = await secondaryTile.RequestCreateAsync(); return isPinned; } return true; }
async private void pinToStartScreen(object sender, RoutedEventArgs e) { SecondaryTile secondaryTile = new SecondaryTile( "tileId", "SecondTile", "Secondary Tile", "target=SecondaryTilePage", TileOptions.ShowNameOnWideLogo, new Uri("ms-appx:///Assets/secondaryTile.png"), new Uri("ms-appx:///Assets/secondaryTileWide.png")); await secondaryTile.RequestCreateAsync(); }
public async Task<bool> PinWideSecondaryTile(string tileId, string displayName, string arguments) { if (!SecondaryTileExists(tileId)) { var secondaryTile = new SecondaryTile(tileId, displayName, arguments, _squareLogoUri, TileSize.Wide310x150); secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; secondaryTile.VisualElements.Wide310x150Logo = _wideLogoUri; bool isPinned = await secondaryTile.RequestCreateAsync(); return isPinned; } return true; }
public async void CreateTile(TyleType type) { var informations = GetTileInformation(type); var secondaryTile = new SecondaryTile( informations.Item1, informations.Item2, informations.Item1, informations.Item3, TileSize.Default); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; await secondaryTile.RequestCreateAsync(); }
public async Task<bool> Pin(string shortName, string description, string tileId, string tileActivationArgs, string tileLogoPath, string smallTileLogoPath) { var logo = new Uri(string.Format("ms-appx:///{0}", tileLogoPath)); var smallLogo = new Uri(string.Format("ms-appx:///{0}", smallTileLogoPath)); var tile = new SecondaryTile(tileId, shortName, description, tileActivationArgs, TileOptions.ShowNameOnLogo, logo); tile.ForegroundText = ForegroundText.Light; tile.SmallLogo = smallLogo; var result = await tile.RequestCreateAsync(); return result; }
// BeginCutPaste private async void Button_Tapped(object sender, TappedRoutedEventArgs e) { Uri square150x150Logo = new Uri("ms-appx:///Assets/Logo.png"); Uri square30x30Logo = new Uri("ms-appx:///Assets/SmallLogo.png"); SecondaryTile secondaryTile = new SecondaryTile("MyTileId", this.tileName.Text, "LaunchedFromMyTile", square150x150Logo, TileSize.Square150x150); secondaryTile.VisualElements.Square30x30Logo = square30x30Logo; secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark; await secondaryTile.RequestCreateAsync(); }
private async void OnPinRecipeButtonClicked(object sender, RoutedEventArgs e) { var item = (RecipeDataItem)this.flipView.SelectedItem; var uri = new Uri(item.TileImagePath.AbsoluteUri); var tile = new SecondaryTile( item.UniqueId, // Tile ID item.ShortTitle, // Tile short name item.Title, // Tile display name item.UniqueId, // Activation argument TileOptions.ShowNameOnLogo, // Tile options uri // Tile logo URI ); await tile.RequestCreateAsync(); }
private async void PinAndUpdate_Click(object sender, RoutedEventArgs e) { App.OnNewTilePinned = UpdateTile; // Create the original Square150x150 tile. The image to display on the tile has a purple background and the word "Original" in white text. var tile = new SecondaryTile(SCENARIO2_TILEID, "Scenario 2", "/MainPage.xaml?scenario=Scenario2", 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 suspended 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 suspended. To illustrate this, we'll create a delay and then attempt to update our secondary tile. }