상속: ISecondaryTile
예제 #1
0
        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;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
            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);

        }
예제 #4
0
        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();
        }
예제 #5
0
		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;
		}
예제 #6
0
        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;
        }
예제 #7
0
        /*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;
            
        }
        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()));
            }
        }
        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);
        }
예제 #10
0
        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();
        }
예제 #11
0
        /// <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);
                }
            }
        }
예제 #12
0
 /// <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);
         }
     }
 }
예제 #13
0
		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;
		}
        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 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();
        }
        private async void CreateBadgeAndTextTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(TEXT_TILE_ID))
            {
                SecondaryTile secondTile = new SecondaryTile(
                    TEXT_TILE_ID,
                    "LockScreen CS - Badge and tile text",
                    "TEXT_ARGS",
                    new Uri("ms-appx:///images/squareTile-sdk.png"),
                    TileSize.Wide310x150
                );
                secondTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///images/tile-sdk.png");
                secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///images/badgelogo-sdk.png");
                secondTile.LockScreenDisplayBadgeAndTileText = true;

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Above);
                if (isPinned)
                {
                    ITileWide310x150Text03 tileContent = TileContentFactory.CreateTileWide310x150Text03();
                    tileContent.TextHeadingWrap.Text = "Text for the lock screen";
                    tileContent.RequireSquare150x150Content = false;
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(TEXT_TILE_ID).Update(tileContent.CreateNotification());
                    rootPage.NotifyUser("Secondary tile created and updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }

            }
            else
            {
                rootPage.NotifyUser("Badge and text secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
        private async void CreateBadgeTile_Click(object sender, RoutedEventArgs e)
        {
            if (!SecondaryTile.Exists(BADGE_TILE_ID)) {
                SecondaryTile secondTile = new SecondaryTile(
                    BADGE_TILE_ID,
                    "LockScreen CS - Badge only",
                    "BADGE_ARGS",
                    new Uri("ms-appx:///images/squareTile-sdk.png"),
                    TileSize.Square150x150
                );
                secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///images/badgelogo-sdk.png");

                bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Above);
                if (isPinned)
                {
                    BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2);
                    BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(BADGE_TILE_ID).Update(badgeContent.CreateNotification());
                    rootPage.NotifyUser("Secondary tile created and badge updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage);
                }
                else 
                {
                    rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage);
                }
                
            } else {
                rootPage.NotifyUser("Badge secondary tile already exists.", NotifyType.ErrorMessage);
            }
        }
        /// <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);

            }
        }
예제 #19
0
        /// <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();
        }
예제 #20
0
        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();
            }
        }
예제 #21
0
        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");
            }
        }
예제 #22
0
 public async Task<bool> UnpinAsync(string tileId)
 {
     System.Diagnostics.Contracts.Contract.Requires(tileId != null, "TileId");
     if (!SecondaryTile.Exists(tileId))
         return true;
     var tile = new SecondaryTile(tileId);
     return await tile.RequestDeleteAsync();
 }
예제 #23
0
 public async Task<bool> Unpin(TileInfo info)
 {
     System.Diagnostics.Contracts.Contract.Requires(info != null, "TileInfo");
     if (!SecondaryTile.Exists(info.TileId))
         return true;
     var tile = new SecondaryTile(info.TileId);
     var result = await tile.RequestDeleteForSelectionAsync(info.Rect(), info.RequestPlacement);
     return result;
 }
예제 #24
0
        private static async Task UpdateTileImagePrivate(Grid tileControl, SecondaryTile secondaryTile)
        {
            Action<string, string> assignText = (name, text) => ((TextBlock)tileControl.FindName(name)).Text = text;
            Action<string> hide = (name) => ((TextBlock)tileControl.FindName(name)).Visibility = Visibility.Collapsed;

            assignText("Timestamp", "Last update " + DateTime.Now.ToString("hh:mm:ss"));

            Timetable timetable = null;

            try
            {
                timetable = Timetable.ParseXml(await FileIO.ReadTextAsync(await
                    (await ApplicationData.Current.LocalFolder.GetFolderAsync("Timetables")).GetFileAsync(secondaryTile.Arguments)),
                    secondaryTile.Arguments, "");

                var day = timetable.GetListedLessons(DateTime.Now, DateTime.Now.AddDays(7), ConvertHelpers.IsOddWeek(DateTime.Now))
                    .First(p => p.Value.Any(q => q.Value.Subject != Subject.None));

                var lessonList = day.Value.Where(q => q.Value.Subject != Subject.None).Take(4).Select(p => new LessonData()
                {
                    LessonTime = string.Format(Strings.LessonTimeMultiLineFormat, p.Key.Start, p.Key.End),
                    Subject = p.Value.Subject.Name,
                    Room = p.Value.Room
                }).ToList();

                if (day.Key.Date != DateTime.Today)
                {
                    lessonList.Insert(0, new LessonData() { LessonTime = day.Key.Date.ToString("dddd") });
                    while (lessonList.Count > 4)
                        lessonList.RemoveAt(4);
                }

                ((ItemsControl)tileControl.FindName("LessonsControl")).ItemsSource = lessonList;

                var imageFileName = secondaryTile.Arguments + ".png";
                var wideImageFileName = secondaryTile.Arguments + ".wide.png";

                await RenderTile(tileControl, wideImageFileName, 310, 150);

                tileControl.Width = tileControl.Height;

                await RenderTile(tileControl, imageFileName, 150, 150);

                secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appdata:///local/" + imageFileName);
                secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appdata:///local/" + wideImageFileName);

                secondaryTile.DisplayName = timetable.Name;
            }
            catch
            {
                secondaryTile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/Logo.scale-240.png");
                secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.scale-240.png");

                return;
            }

        }
        public async Task<bool> UnpinTile(string tileId) {
            if (SecondaryTileExists(tileId)) {
                var secondaryTile = new SecondaryTile(tileId);
                bool isUnpinned = await secondaryTile.RequestDeleteAsync();
                return isUnpinned;
            }

            return true;
        }
예제 #26
0
        public async Task<bool> UnpinAsync(string tileId, Rect selection, Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above)
        {
            System.Diagnostics.Contracts.Contract.Requires(tileId != null, "TileId");

            if (!SecondaryTile.Exists(tileId))
                return true;
            var tile = new SecondaryTile(tileId);
            var result = await tile.RequestDeleteForSelectionAsync(selection, placement);
            return result;
        }
        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 static SecondaryTile GenerateSecondaryTile(string tileId, string displayName)
        {
            SecondaryTile tile = new SecondaryTile(tileId, displayName, "args", new Uri("ms-appx:///Assets/Logo.png"), TileSize.Default);
            tile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Small.png");
            tile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.png");
            tile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/LargeLogo.png");
            tile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/SmallLogo.png"); // Branding logo

            return tile;
        }
        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;
        }
예제 #30
0
 /// <summary>
 /// 移除辅助磁贴
 /// </summary>
 /// <param name="tileId">磁贴的唯一 ID</param>
 public async static Task DeleteSecondaryTileAsync(string tileId)
 {
     if (Windows.UI.StartScreen.SecondaryTile.Exists(tileId))
     {
         // First prepare the tile to be unpinned
         SecondaryTile secondaryTile = new SecondaryTile(tileId);
         // Now make the delete request.
         await secondaryTile.RequestDeleteAsync();
     }
 }