Inheritance: ITileNotification
コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: Hitchhikrr/Jukebox
        private async void ProcessPlaylist(Object sender, object e)
        {
            Debug.WriteLine("Timer");
            PlaylistListBox.Items.Clear();
            playList = await cloudtools.GetPlayList();
            List<Playlist> OrderplayList = playList.OrderBy(o => o.State).ToList();
           
            foreach (Playlist pl in OrderplayList)
            {
                String str = pl.SongName + "\n " + pl.ArtistName + "\n " + pl.AlbumName;
                PlaylistListBox.Items.Add(str);
            }
            if(PlaylistListBox.Items.Count > 0)
            {
                PlaylistListBox.SelectedIndex = 3;
            }
            
            
            
            TileTemplateType tileTemplate = TileTemplateType.TileSquare150x150Text03;
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(tileTemplate);
            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = "Current Song: \n" + PlaylistListBox.Items[3];

            Int16 dueTimeInSeconds = 10;
            DateTime dueTime = DateTime.Now.AddSeconds(dueTimeInSeconds);
            ScheduledTileNotification scheduledTile = new ScheduledTileNotification(tileXml, dueTime);
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile);
            TileNotification tileNot = new TileNotification(tileXml);
            //tileNot.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(5);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNot);
        }
コード例 #2
0
ファイル: Register.cs プロジェクト: DXChinaTE/BankApp
        public async void registerBackgroundTask()
        {
            try
            {
                var result = await BackgroundExecutionManager.RequestAccessAsync();
                if (result == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity ||
                    result == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
                {
                    foreach (var task in BackgroundTaskRegistration.AllTasks)
                    {
                        if (task.Value.Name == TASK_NAME)
                            task.Value.Unregister(true);
                    }

                    BackgroundTaskBuilder builder = new BackgroundTaskBuilder();
                    builder.Name = TASK_NAME;
                    builder.TaskEntryPoint = TASK_ENTRY;
                    builder.SetTrigger(new TimeTrigger(15, false));
                    var registration = builder.Register();
                }
                for (int i = 0; i < 5; i++)
                {
                    Uri u = new Uri("ms-appx:///tile/TileTemplate" + new Random().Next(1, 3).ToString() + ".xml");
                    StorageFile xmlFile = await StorageFile.GetFileFromApplicationUriAsync(u);
                    XmlDocument doc = await XmlDocument.LoadFromFileAsync(xmlFile);
                    TileNotification notifi = new TileNotification(doc);
                    TileUpdater udt = TileUpdateManager.CreateTileUpdaterForApplication();
                    udt.Update(notifi);
                }
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
コード例 #3
0
        private void tileUpdateButton_Click(object sender, RoutedEventArgs e)
        {
            // タイルのテンプレート選択
            // http://msdn.microsoft.com/ja-jp/library/windows/apps/hh761491.aspx#TileSquareText03
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);

            // キューに複数のタイル通知を設定可能にする
            //TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = this.tileText.Text;

            XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/wideTile.png");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "wideTile.png");

            XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
            XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
            squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(this.tileText.Text));
            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            TileNotification tileNotification = new TileNotification(tileXml);
            tileNotification.Tag = this.tileText.Text;

            //tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
コード例 #4
0
        private static void UpdateTile()
        {
            var updateManager = TileUpdateManager.CreateTileUpdaterForApplication();
            updateManager.Clear();
            updateManager.EnableNotificationQueue(true);

            //prepare collection
            List<HolidayItem> eventCollection = _manager.GetHolidayList(DateTime.Now);

            if (eventCollection.Count < 5)
            {
                DateTime dt = DateTime.Now.AddMonths(1);
                List<HolidayItem> s = _manager.GetHolidayList(dt);
                eventCollection.AddRange(s);
            }

            //finalize collection
            eventCollection = (eventCollection.Count <= 5) ? eventCollection : eventCollection.Take(5).ToList();
            
            if (eventCollection.Count > 0)
                foreach (var currEvent in eventCollection)
                {
                    //date to show
                    DateTime date = new DateTime((int)currEvent.Year, (int)currEvent.Month, currEvent.Day);

                    var xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(String.Format(DataBakgroundManager.XML_TEMPLATE, date.ToString("d"), currEvent.HolidayName));

                    var notification = new TileNotification(xmlDocument);
                    updateManager.Update(notification);
                }
        }
コード例 #5
0
ファイル: LiveTileBuilder.cs プロジェクト: Romaxaqaz/Onliner
            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);

        }
コード例 #6
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            date.Text = DateTime.Today.ToString("d.M.yyyy");
            System.Net.Http.HttpClient hc = new System.Net.Http.HttpClient();
            System.Net.Http.HttpResponseMessage response = await hc.GetAsync("http://api.teknolog.fi/taffa/sv/today/");
            response.EnsureSuccessStatusCode();
            menu.Text = await response.Content.ReadAsStringAsync();


            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text05);

            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = menu.Text;


            XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text03);
            XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
            squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(menu.Text));
            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            TileNotification tileNotification = new TileNotification(tileXml);

            tileNotification.ExpirationTime = DateTime.Now.Date.AddDays(1);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);



        }
コード例 #7
0
ファイル: Background.cs プロジェクト: radu-ungureanu/QOTD
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

            DataService ds = new DataService();
            var quote = await ds.GetQuoteOfTheDayAsync();

            //Create the Large Tile
            var largeTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText09);
            largeTile.GetElementsByTagName("text")[0].InnerText = quote.Author;
            largeTile.GetElementsByTagName("text")[1].InnerText = quote.Content;

            //Create a Small Tile
            var smallTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
            smallTile.GetElementsByTagName("text")[0].InnerText = quote.Content;

            //Merge the two updates into one <visual> XML node
            var newNode = largeTile.ImportNode(smallTile.GetElementsByTagName("binding").Item(0), true);
            largeTile.GetElementsByTagName("visual").Item(0).AppendChild(newNode);

            TileNotification notification = new TileNotification(largeTile);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);

            deferral.Complete();
        }
コード例 #8
0
        public void OnUpdateTileClicked(object sender, RoutedEventArgs e)
        {
            string xml = @"<tile>
        <visual>
        <binding template=""TileMedium"">
            <group>
            <subgroup>
                <text hint-style=""subtitle"">John Doe</text>
                <text hint-style=""subtle"">Photos from our trip</text>
                <text hint-style=""subtle"">Thought you might like to see all of</text>
            </subgroup>
            </group>
            <group>
            <subgroup>
                <text hint-style=""subtitle"">Jane Doe</text>
                <text hint-style=""subtle"">Questions about your blog</text>
                <text hint-style=""subtle\"">Have you ever considered writing a</text>
            </subgroup>
            </group>
        </binding>
        </visual>
    </tile>";



            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            TileNotification notification = new TileNotification(doc);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
コード例 #9
0
        private async void UpdateTilesAsync()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(tileUpdateURL);
                HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
                StreamReader reader = new StreamReader(response.GetResponseStream());

                string tileXml = reader.ReadToEnd();
                Debug.WriteLine(tileXml);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(tileXml);
                TileNotification tileNotification = new TileNotification(xmlDoc);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                UpdateTaskCompleted();
            }
        }
コード例 #10
0
        public static void UpdateBigTileWithMusicInfo()
        {
            const TileTemplateType template = TileTemplateType.TileWide310x150PeekImage05;
            var tileXml = TileUpdateManager.GetTemplateContent(template);

            var tileTextAttributes = tileXml.GetElementsByTagName("text");
#if WINDOWS_APP
            tileTextAttributes[0].InnerText = "Now playing";
#endif
            if (Locator.MusicPlayerVM.CurrentTrack != null)
            {
#if WINDOWS_APP
                tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.CurrentTrack.ArtistName;
#else
                tileTextAttributes[0].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name ?? "";
                tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.AlbumName;
                tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.ArtistName;
#endif
                var tileImgAttribues = tileXml.GetElementsByTagName("image");
#if WINDOWS_APP
                if (Locator.MusicPlayerVM.CurrentArtist != null)
                    tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentArtist.Picture;
                
                if (Locator.MusicPlayerVM.CurrentAlbum != null)
                    tileImgAttribues[1].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverFullUri;
#else
                if (Locator.MusicPlayerVM.CurrentAlbum != null)
                    tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverFullUri;
#endif
            }

            var tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
コード例 #11
0
        public static bool Tile(string line1, string line2, string line3)
        {
            try
            {
                Toast.TileClear();
                TileContent content = GetTileContent(line1, line2, line3);


                // Create the tile notification
                var notification = new TileNotification(content.GetXml());

                notification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);

                // And send the notification
                TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);

                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
            
        }
コード例 #12
0
 private void UpdatePrimaryTile(object sender, RoutedEventArgs e)
 {
     var xmlDoc = TileService.CreateTiles(new Models.PrimaryTile());
     var updater = TileUpdateManager.CreateTileUpdaterForApplication();
     TileNotification notification = new TileNotification(xmlDoc);
     updater.Update(notification);
 }
コード例 #13
0
ファイル: FeedManager.cs プロジェクト: kiewic/Questions
        // For more about tile templates:
        // http://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx
        public static void CreateTileUpdate(string text)
        {
            try
            {
                string tileXmlString = "<tile>"
                                     + "<visual>"
                                     + "<binding template='TileWideText04'>"
                                     + "<text id='1'>" + text + "</text>"
                                     + "</binding>"
                                     + "</visual>"
                                     + "</tile>";

                XmlDocument tileDOM = new XmlDocument();
                tileDOM.LoadXml(tileXmlString);
                TileNotification tile = new TileNotification(tileDOM);

                // Enable notification cycling.
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #14
0
        private void Send_Notif(object sender, RoutedEventArgs e)
        {
            //Updates Live Tile and Lock Screen if pinned
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);

            TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);

            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = input.Text;

            XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/wideLogo_up.png");

            /*
            XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);
            XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");

            squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode(input.Text));
            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
             * */

            TileNotification tileNotification = new TileNotification(tileXml);

            //Sets when the notification should expire
            //tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            //Update feedback
            feedback.Text = "Lock Screen and Tile updated";
        }
コード例 #15
0
        public override TileNotification GetNotificacion()
        {
            tile = new XmlDocument();            
            tile.LoadXml(stile);

            //System.Diagnostics.Debug.Write(tile.GetXml());

            var nodevisual = tile.GetElementsByTagName("binding");
            if (Title != null && Title != "")
            {
                ((XmlElement)nodevisual[1]).SetAttribute("displayName", this.Title);
            }

            var nodeImage = tile.GetElementsByTagName("image");
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[0]).SetAttribute("src", BackgroundImage.OriginalString);
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[1]).SetAttribute("src", BackgroundImage.OriginalString);
            //((Windows.Data.Xml.Dom.XmlElement)nodeImage[2]).SetAttribute("src", BackgroundImage.OriginalString);

            var nodeText = tile.GetElementsByTagName("text");
            nodeText[0].InnerText = BackTitle.ToString();
            nodeText[1].InnerText = BackContent.ToString();
            //nodeText[2].InnerText = BackContent.ToString();

            //System.Diagnostics.Debug.Write(this.tile.GetXml());
            var tileNotc = new TileNotification(this.tile);           
            return tileNotc;
        }
コード例 #16
0
ファイル: LiveTileManager.cs プロジェクト: pglazkov/Linqua
        private async Task<List<TileNotification>> CreateDataTilesAsync()
        {
            var result = new List<TileNotification>();

            var randomEntries = await backendServiceClient.GetRandomEntries(5);

            foreach (var randomEntry in randomEntries)
            {
                var tileHeading = randomEntry.Text;
                var tileText = randomEntry.Definition;

                var wideTile = TileContentFactory.CreateTileWide310x150Text01();
                wideTile.TextHeading.Text = tileHeading;
                wideTile.TextBody1.Text = tileText;

                var squareTile = TileContentFactory.CreateTileSquare150x150Text01();
                squareTile.TextHeading.Text = tileHeading;
                squareTile.TextBody1.Text = tileText;

                wideTile.Square150x150Content = squareTile;

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(wideTile.ToString());

                var notification = new TileNotification(xmlDocument);

                result.Add(notification);
            }

            return result;
        }
コード例 #17
0
        /// <summary>
        /// Delegate to update the secondary tile. This is called from the OnSuspending event handler in App.xaml.cs
        /// </summary>
        private void UpdateTile()
        {
            // Simulate a long-running task. For illustration purposes only.
            if (Debugger.IsAttached)
            {
                // Set a larger delay to give you time to select "Suspend" from the "LifetimeEvents" dropdown in Visual Studio in
                // order to simulate the app being suspended when the new tile is created.
                Task.Delay(5000).Wait();
            }
            else
            {
                // When the app is not attached to the debugger, the app will be suspended so we can use a
                // more realistic delay.
                Task.Delay(2000).Wait();
            }

            // 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. The image in this sample is a lime green image with the word "Updated" in white text
            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(SCENARIO2_TILEID);

            // Send the update notification for the tile.
            updater.Update(notification);
        }
コード例 #18
0
        /// <summary>
        /// Set the application's tile to display a local image file.
        /// After clicking, go back to the start screen to watch your application's tile update.
        /// </summary>
        private void SetTileImageButtonClick(object sender, RoutedEventArgs e)
        {
            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var tileXml = new XmlDocument();
            var title = tileXml.CreateElement("title");
            var visual = tileXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a TileSquareImage. This tells the tile update manager what to expect next.
            var binding = tileXml.CreateElement("binding");
            binding.SetAttribute("template", "TileSquareImage");
            // An image element is then created under the TileSquareImage XML node. The path to the image is specified
            var image = tileXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", @"ms-appx:///Assets/DemoImage.png");

            // All the XML elements are chained up together.
            title.AppendChild(visual);
            visual.AppendChild(binding);
            binding.AppendChild(image);
            tileXml.AppendChild(title);

            // The XML is used to create a new TileNotification which is then sent to the TileUpdateManager
            var tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
ファイル: Sender.cs プロジェクト: aurora-lzzp/Aurora-Weather
        public static void CreateSubTileNotification(List<TileContent> list, string tileName)
        {
            if (SecondaryTile.Exists(tileName))
            {
                var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileName);
                updater.EnableNotificationQueue(true);
                int i = 0;
                foreach (var item in list)
                {
                    try
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        TileNotification n = new TileNotification(item.GetXml());
                        n.Tag = i.ToString();
                        updater.Update(n);
                        i++;
                    }
                    catch (Exception)
                    {
                        continue;
                    }

                }
            }
        }
コード例 #21
0
ファイル: BG.cs プロジェクト: FutureUnleashed/HOL
        public void Run(IBackgroundTaskInstance taskInstance)
        {


            // Checking for the last time access when the network was available and displaying it on the live tile.

            var tileContent = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);

            var tileLines = tileContent.SelectNodes("tile/visual/binding/text");

            var networkStatus = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

            tileLines[0].InnerText = (networkStatus == null) ?
                "No network" :
                networkStatus.GetNetworkConnectivityLevel().ToString();

            tileLines[1].InnerText = DateTime.Now.ToString("MM/dd/yyyy");
            tileLines[2].InnerText = DateTime.Now.ToString("HH:mm:ss");
            tileLines[3].InnerText = "Update from my App";

            var notification = new TileNotification(tileContent);

            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);

        }
コード例 #22
0
        internal TileNotification Build()
        {
            var tileNotification = new TileNotification(_Tile);
            tileNotification.ExpireIn(_ExpirationTime);

            return tileNotification;
        }
コード例 #23
0
        // Initialize the app's tiles on the Start page. There are three different sizes of tiles users can
        // choose from.
        private void InitializeTiles()
        {
            tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var mediumSquareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);
            var largeSquareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndText02);
            var wideTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02);

            tileUpdater.EnableNotificationQueue(true);

            mediumSquareTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe";
            largeSquareTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe";
            wideTile.GetElementsByTagName("text")[0].InnerText = "TicTacToe";

            var node1 = wideTile.ImportNode(mediumSquareTile.GetElementsByTagName("binding")[0], true);
            wideTile.GetElementsByTagName("visual")[0].AppendChild(node1);

            var node2 = wideTile.ImportNode(largeSquareTile.GetElementsByTagName("binding")[0], true);
            wideTile.GetElementsByTagName("visual")[0].AppendChild(node2);

            var testNotification = new TileNotification(wideTile);
            testNotification.Tag = "Test";
            tileUpdater.Update(testNotification);

            badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

        }
コード例 #24
0
        private void UpdateTileWithTextWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            // Create a string with the tile template xml.
            // Note that the version is set to "3" and that fallbacks are provided for the Square150x150 and Wide310x150 tile sizes.
            // This is so that the notification can be understood by Windows 8 and Windows 8.1 machines as well.
            string tileXmlString =
                "<tile>"
                + "<visual version='3'>"
                + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "<binding template='TileSquare310x310Text09'>"
                + "<text id='1'>Hello World! My very own tile notification</text>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            // Create a DOM.
            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();

            // Load the xml string into the DOM.
            tileDOM.LoadXml(tileXmlString);

            // Create a tile notification.
            TileNotification tile = new TileNotification(tileDOM);

            // Send the notification to the application? tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);

            OutputTextBlock.Text = MainPage.PrettyPrint(tileDOM.GetXml());
            rootPage.NotifyUser("Tile notification with text sent", NotifyType.StatusMessage);
        }
コード例 #25
0
        public void UpdateTile(bool Transparent)
        {
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Image);

            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            //tileTextAttributes[0].InnerText = "Hello World! My very own tile notification";

            XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", (Transparent ? "ms-appx:///Assets/Wide310x150LogoTrans.png" : "ms-appx:///Assets/Wide310x150Logo.png"));
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "");

            XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
            XmlNodeList tileImageAttributesSquare = squareTileXml.GetElementsByTagName("image");
            ((XmlElement)tileImageAttributesSquare[0]).SetAttribute("src", (Transparent ? "ms-appx:///Assets/Square150x150LogoTrans.png" : "ms-appx:///Assets/Square150x150Logo.png"));

            XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
            //squareTileTextAttributes[0].AppendChild(squareTileXml.CreateTextNode("Hello World! My very own tile notification"));


            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);
            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            TileNotification tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

        }
コード例 #26
0
ファイル: TileUtils.cs プロジェクト: uvbs/MyProjects
        public static void CreateLogoNotifications()
        {
            TileUpdater notifier = TileUpdateManager.CreateTileUpdaterForApplication();
            if (notifier.Setting == NotificationSetting.Enabled)
            {
                notifier.EnableNotificationQueue(true);

                var MainSquareTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareImage);
                MainSquareTemplate.GetElementsByTagName("image")[0].Attributes[1].NodeValue = "ms-appx:///Assets/Logo.png";
                var squareNode = MainSquareTemplate.CreateAttribute("branding");
                squareNode.Value = "name";  //none|logo|name
                MainSquareTemplate.GetElementsByTagName("binding")[0].Attributes.SetNamedItem(squareNode);

                var MainWideTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImage);
                MainWideTemplate.GetElementsByTagName("image")[0].Attributes[1].NodeValue = "ms-appx:///Assets/WideLogo.png";
                var wideNode = MainWideTemplate.CreateAttribute("branding");
                wideNode.Value = "none";
                MainWideTemplate.GetElementsByTagName("binding")[0].Attributes.SetNamedItem(wideNode);

                var Mainnode = MainWideTemplate.ImportNode(MainSquareTemplate.GetElementsByTagName("binding").Item(0), true);
                MainWideTemplate.GetElementsByTagName("visual").Item(0).AppendChild(Mainnode);
                var MaintileNotification = new TileNotification(MainWideTemplate);
                notifier.Update(MaintileNotification);
            }
        }
コード例 #27
0
        private async void ButtonPinTile_Click(object sender, RoutedEventArgs e)
        {
            base.IsEnabled = false;

            string ImageUrl = _imagePath.ToString();

            SecondaryTile tile = TilesHelper.GenerateSecondaryTile("App Package Image");
            await tile.RequestCreateAsync();

            string tileXmlString =
                "<tile>"
                + "<visual>"
                + "<binding template='TileSmall'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileMedium'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileWide'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileLarge'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(tileXmlString);
            TileNotification notifyTile = new TileNotification(xmlDoc);
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notifyTile);

            base.IsEnabled = true;
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        private void UpdateTile()
        {
            var now = DateTime.Now.ToString("HH:mm:ss");
            var xml =
                "<tile>" +
                "  <visual>" +
                "    <binding template='TileSmall'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileMedium'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileWide'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileLarge'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "  </visual>" +
                "</tile>";

            var tileDom = new XmlDocument();
            tileDom.LoadXml(xml);
            var tile = new TileNotification(tileDom);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
        }
コード例 #30
0
        private static void CreateTile()
        {
            var TileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            TileUpdater.Clear();
            TileUpdater.EnableNotificationQueue(true);

            XmlDocument squareXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText04);
            var tileImageElements = squareXml.GetElementsByTagName("image");
            ((XmlElement)tileImageElements[0]).SetAttribute("src", "ms-appx:///Assets/Logo.scale-100.png");

            XmlDocument wideXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageAndText01);
            tileImageElements = wideXml.GetElementsByTagName("image");
            ((XmlElement)tileImageElements[0]).SetAttribute("src", "ms-appx:///Assets/WideLogo.scale-100.png");

            var squareTextAttributes = squareXml.GetElementsByTagName("text");
            var wideTextAttributes = wideXml.GetElementsByTagName("text");

            ((XmlElement)squareXml.GetElementsByTagName("binding")[0]).SetAttribute("branding", "none");
            ((XmlElement)wideXml.GetElementsByTagName("binding")[0]).SetAttribute("branding", "none");

            IXmlNode node = wideXml.ImportNode(squareXml.GetElementsByTagName("binding").Item(0), true);
            wideXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            foreach (string msg in Messages)
            {
                squareTextAttributes[0].InnerText = msg;
                wideTextAttributes[0].InnerText = msg;
                TileNotification notification = new TileNotification(wideXml);
                TileUpdater.Update(notification);
            }
        }
コード例 #31
0
 public TileNotification CreateNotification()
 {
     var xml = XmlBuilder.Build(this).ToString();
     var xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(xml);
     var notification = new TileNotification(xmlDocument);
     return notification;
 }
コード例 #32
0
        private void UpdateTile()
        {
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            xdoc.LoadXml(System.IO.File.ReadAllText("tile.xml"));
            var notification = new Windows.UI.Notifications.TileNotification(xdoc);
            var updator      = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();

            updator.Update(notification);
        }
コード例 #33
0
        private async void PinAndUpdate_Click(object sender, RoutedEventArgs e)
        {
            // Create the secondary 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 is suspended and the new tile is 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.

            // Simulate a long-running task
            if (Debugger.IsAttached)
            {
                // Set a larger delay to give you time to select "Suspend" from the "LifetimeEvents" dropdown in Visual Studio in
                // order to simulate the app being suspended when the new tile is created.
                await Task.Delay(8000);
            }
            else
            {
                // When the app is not attached to the debugger, the app will be suspended so we can use a
                // more realistic delay.
                await Task.Delay(2000);
            }

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

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

            // retrieve the single image element from the TileSquare150x150Image template. .
            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);
        }
コード例 #34
0
        private void UpdateTile()
        {
            // 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(SCENARIO2_TILEID);

            // Send the update notification for the tile.
            updater.Update(notification);
        }
コード例 #35
0
        private async void UpdeteTile(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "UpdateTime")
            {
                return;
            }
            await Task.Run(() =>
            {
                var text    = WebConnect.Current.WebTrafficExact.ToString();
                var manager = TileUpdateManager.CreateTileUpdaterForApplication();
                manager.Clear();
                manager.EnableNotificationQueue(true);

                var squareTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                var longTile   = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text01);
                var node       = squareTile.ImportNode(longTile.GetElementsByTagName("binding").Item(0), true);
                squareTile.GetElementsByTagName("visual").Item(0).AppendChild(node);
                var bindings = squareTile.GetElementsByTagName("binding");
                ((XmlElement)bindings[0]).SetAttribute("branding", "name");
                ((XmlElement)bindings[1]).SetAttribute("branding", "name");
                var tileTexts          = squareTile.GetElementsByTagName("text");
                tileTexts[0].InnerText = text;
                tileTexts[4].InnerText = string.Format("已用流量:{0}", text);
                var devices            = new WebDevice[5];
                WebConnect.Current.DeviceList.CopyTo(devices, 0);
                foreach (var item in devices)
                {
                    if (item == null)
                    {
                        break;
                    }
                    tileTexts[1].InnerText          = tileTexts[5].InnerText = item.Name;
                    tileTexts[2].InnerText          = tileTexts[6].InnerText = item.IPAddress.ToString();
                    tileTexts[3].InnerText          = tileTexts[7].InnerText = item.LogOnDateTime.ToString();
                    var tileNotification            = new Windows.UI.Notifications.TileNotification(squareTile);
                    tileNotification.ExpirationTime = new DateTimeOffset(DateTime.Now.AddDays(1));
                    manager.Update(tileNotification);
                }
            });
        }
コード例 #36
0
        private async void ResetMyMainTile()
        {
            IReadOnlyList <SecondaryTile> tileToFind = await SecondaryTile.FindAllAsync();

            if (tileToFind != null)
            {
                if (tileToFind.Count > 0)
                {
                    var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileToFind.First().TileId);

                    updater.EnableNotificationQueue(true);
                    updater.Clear();

                    var LiveTile = @"<tile> 
                                <visual version=""1""> 
                                 <binding template=""TileWideImageAndText01"">
                                    <image id=""1"" src=""Background.png"" alt=""alt text""/>
                                    <text id=""1"">Push Woosh</text>
                                 </binding> 
                                 <binding template=""TileSquarePeekImageAndText02"">
                                    <image id=""1"" src=""Background.png"" alt=""alt text""/>
                                    <text id=""1"">Push Woosh</text>
                                    <text id=""2"">Push Woosh Tile Test</text>
                                  </binding> 
                                </visual> 
                              </tile>";

                    XmlDocument tileXml = new XmlDocument();
                    tileXml.LoadXml(LiveTile);

                    var tileNotification = new Windows.UI.Notifications.TileNotification(tileXml);

                    TileNotification tileData = new TileNotification(tileXml);
                    TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileToFind.First().TileId).Update(tileData);
                }
            }
        }