コード例 #1
0
        /// <summary>
        /// 磁贴更新
        /// </summary>
        /// <param name="i"></param>
        static public void TileUpdate(int i)
        {
            XmlDocument document = new XmlDocument();

            document.LoadXml(System.IO.File.ReadAllText("Tile.xml"));
            XmlNodeList textElements = document.GetElementsByTagName("text");
            XmlNodeList image        = document.GetElementsByTagName("image");
            int         count        = (Application.Current as App).ViewModel.getoshi.Count;

            if (count == 0)
            {
                return;
            }
            textElements[0].InnerText = (Application.Current as App).ViewModel.getoshi[i].name;
            textElements[1].InnerText = (Application.Current as App).ViewModel.getoshi[i].eng;
            textElements[2].InnerText = (Application.Current as App).ViewModel.getoshi[i].name;
            textElements[3].InnerText = (Application.Current as App).ViewModel.getoshi[i].eng;
            textElements[4].InnerText = (Application.Current as App).ViewModel.getoshi[i].name;
            textElements[5].InnerText = (Application.Current as App).ViewModel.getoshi[i].eng;
            ((XmlElement)image[0]).SetAttribute("src", (Application.Current as App).ViewModel.getoshi[i].image);
            ((XmlElement)image[1]).SetAttribute("src", (Application.Current as App).ViewModel.getoshi[i].image);
            ((XmlElement)image[2]).SetAttribute("src", (Application.Current as App).ViewModel.getoshi[i].image);
            var tileNotification = new TileNotification(document);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
        }
コード例 #2
0
        private void UpdateTile(IEnumerable <ArtistTileData> artists)
        {
            // Create a tile update manager for the specified syndication feed.
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

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

            // Keep track of the number feed items that get tile notifications.
            var itemCount = 0;

            // Create a tile notification for each feed item.
            foreach (var item in artists)
            {
                var tileXml = GetTileTemplate(item);

                // Create a new tile notification.
                var tileNotification = new TileNotification(tileXml)
                {
                    ExpirationTime = DateTime.Now.AddHours(2)
                };

                updater.Update(tileNotification);

                // Don't create more than 5 notifications.
                if (itemCount++ > 5)
                {
                    break;
                }
            }
        }
コード例 #3
0
        public static void UpdateMainTileForPlayback(DbMediaFile item, string imageUrl)
        {
            lock (_lock)
            {
                // Not supported on IoT and Holographic platform.
                if (PlatformInfo.CurrentPlatform != Platform.WindowsMobile &&
                    PlatformInfo.CurrentPlatform != Platform.WindowsDesktop)
                {
                    return;
                }

                // Large tile
                var largeTileXml =
                    TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310ImageAndTextOverlay02);
                var largeTileTextAttributes = largeTileXml.GetElementsByTagName("text");
                largeTileTextAttributes[0].InnerText = item.Title;
                largeTileTextAttributes[1].InnerText = $"{item.Album} by {item.Artist}";
                var largeTileImageAttributes = largeTileXml.GetElementsByTagName("image");
                ((XmlElement)largeTileImageAttributes[0]).SetAttribute("src", string.IsNullOrEmpty(imageUrl) ?
                                                                       CommonSharedStrings.DefaultAlbumImagePath : imageUrl);
                ((XmlElement)largeTileImageAttributes[0]).SetAttribute("alt", item.Album);

                // Wide tile
                var tileXml            = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText02);
                var tileTextAttributes = tileXml.GetElementsByTagName("text");
                tileTextAttributes[0].InnerText = item.Title;
                tileTextAttributes[1].InnerText = item.Album;
                tileTextAttributes[2].InnerText = item.Artist;
                tileTextAttributes[3].InnerText = CommonSharedStrings.LiveTileLine3;
                var tileImageAttributes = tileXml.GetElementsByTagName("image");
                ((XmlElement)largeTileImageAttributes[0]).SetAttribute("src", string.IsNullOrEmpty(imageUrl) ?
                                                                       CommonSharedStrings.DefaultAlbumImagePath : imageUrl);
                ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", item.Album);

                // Square tile
                var sqTileXml            = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText02);
                var sqTileTextAttributes = sqTileXml.GetElementsByTagName("text");
                sqTileTextAttributes[0].InnerText = item.Title;
                sqTileTextAttributes[1].InnerText = $"{item.Album} by {item.Artist}";
                var sqTileImageAttributes = sqTileXml.GetElementsByTagName("image");
                ((XmlElement)largeTileImageAttributes[0]).SetAttribute("src", string.IsNullOrEmpty(imageUrl) ?
                                                                       CommonSharedStrings.DefaultAlbumImagePath : imageUrl);
                ((XmlElement)sqTileImageAttributes[0]).SetAttribute("alt", item.Album);

                // Merge
                var node = largeTileXml.ImportNode(tileXml.GetElementsByTagName("binding").Item(0), true);
                // ReSharper disable once PossibleNullReferenceException
                largeTileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);
                node = largeTileXml.ImportNode(sqTileXml.GetElementsByTagName("binding").Item(0), true);
                // ReSharper disable once PossibleNullReferenceException
                largeTileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

                var tileNotification = new TileNotification(largeTileXml)
                {
                    ExpirationTime = DateTimeOffset.UtcNow.AddHours(2.0)
                };

                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
        }
コード例 #4
0
        private async Task setLiveTile()   //开启磁贴
        {
            try
            {
                TimeSpan tn = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                long     allSeconds = 105695630 + ((long)tn.TotalSeconds - 1606379872) * 7;
                long     dd, mm, hh, ss; //用于存储最终数值
                dd = allSeconds / 60 / 60 / 24 % 9999999;
                hh = allSeconds / 60 / 60 % 24;
                mm = allSeconds / 60 % 60;
                ss = allSeconds % 60;

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

                var tileAttributes = tileXml.GetElementsByTagName("text");
                tileAttributes[0].AppendChild(tileXml.CreateTextNode("时间众筹总计"));
                tileAttributes[1].AppendChild(tileXml.CreateTextNode(dd + "天"));
                tileAttributes[2].AppendChild(tileXml.CreateTextNode(hh + "小时"));
                tileAttributes[3].AppendChild(tileXml.CreateTextNode(mm + "分钟"));
                var tileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
            catch { }

            var tileContent       = new Uri("https://add-one-second.papapoi.workers.dev/"); //自建网站
            var requestedInterval = PeriodicUpdateRecurrence.HalfHour;                      //半小时一次

            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.StartPeriodicUpdate(tileContent, requestedInterval);
        }
コード例 #5
0
ファイル: MainPage.xaml.cs プロジェクト: obrcnh/music_player
 //创建动态磁贴
 void updatetile()
 {
     if (list.SelectedItem == null)
     {
         var i = new MessageDialog("please select a song!");
         return;
     }
     try
     {
         var Items   = list.SelectedItem;
         var updater = TileUpdateManager.CreateTileUpdaterForApplication();
         updater.Clear();
         XmlDocument tile = new XmlDocument();
         tile.LoadXml(File.ReadAllText("Tile.xml"));
         XmlNodeList tileText  = tile.GetElementsByTagName("text");
         XmlNodeList tileImage = tile.GetElementsByTagName("image");
         for (int i = 0; i < tileText.Count;)
         {
             ((XmlElement)tileText[i]).InnerText = Items.Name;
             i++;
             ((XmlElement)tileText[i]).InnerText = Items.Artist;
             i++;
         }
         TileNotification notification = new TileNotification(tile);
         updater.Update(notification);
     }
     catch (Exception err)
     {
         throw err;
     }
 }
コード例 #6
0
ファイル: MainPage.xaml.cs プロジェクト: huangyt39/UWP
        public MainPage()
        {
            this.InitializeComponent();

            this.ViewModel = new ItemListViewModels();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(4);
            timer.Tick    += (x, y) =>
            {
                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                TileNotification notification;

                var item = ViewModel.AllItems.ElementAt(ItemIndex);

                var xmlDoc = TileService.CreateTiles(new PrimaryTile(item.title, item.detail, item.date));

                notification = new TileNotification(xmlDoc);
                updater.Update(notification);

                ItemIndex = (ItemIndex + 1) % ViewModel.AllItems.Count;
            };
            timer.Start();
        }
コード例 #7
0
        public MainPage()
        {
            this.InitializeComponent();
            DisplayProperties.OrientationChanged += Orientation;

            BQ = new BlueQueenCore(@"http://usafeapi.bluequeen.tk", "v1", "token");
            CultureInfo culture = new CultureInfo("en-US");

            WeatherData  = BQ.getWeatherData(fromDate: DateTime.Now.ToString("d", culture));
            PressureData = BQ.getPressureData(fromDate: DateTime.Now.ToString("d", culture));

            //var test = WeatherData;
            fillTextBlock();

            //tile
            var tileXml   = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);
            var tileImage = tileXml.GetElementsByTagName("image")[0] as XmlElement;

            tileImage.SetAttribute("src", "ms-appx:///Assets/Square71x71Logo.scale-100.png");

            var          tileText  = tileXml.GetElementsByTagName("text");
            WeatherInfo  lastTemp  = WeatherData.Last(x => x.ID > 0);
            PressureInfo lastPress = PressureData.Last(x => x.ID > 0);

            (tileText[0] as XmlElement).InnerText = "Wejherowo";
            (tileText[1] as XmlElement).InnerText = lastTemp.Date.ToString();
            (tileText[2] as XmlElement).InnerText = string.Format("{0}°C", lastTemp.Value.ToString());
            (tileText[3] as XmlElement).InnerText = string.Format("{0} hPa", lastPress.Pressure.ToString());
            var tileNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            // eoTile
        }
コード例 #8
0
        public async static Task SetQuoteNotifications()
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

            var tileXml   = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText04);
            var tileImage = tileXml.GetElementsByTagName("image")[0] as XmlElement;

            var quotes = LoadQuotes();
            var i      = 0;
            TileNotification tileNotification;

            foreach (var quote in quotes)
            {
                tileImage.SetAttribute("src", quote.ImageUrl);

                var tileText = tileXml.GetElementsByTagName("text");
                (tileText[0] as XmlElement).InnerText = quote.Quote;

                tileNotification     = new TileNotification(tileXml);
                tileNotification.Tag = i.ToString();
                i++;

                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
        }
コード例 #9
0
        public static void UpdateTile(XmlDocument tileXml)
        {
            TileNotification tile        = new TileNotification(tileXml);
            TileUpdater      tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Update(tile);
        }
コード例 #10
0
        public Task PublishAsync(Song song, IPlaylist currentPlaylist, Uri albumArtUri, CancellationToken cancellationToken)
        {
            this.TilesInitialization();

            return(Task.Factory.StartNew(() =>
            {
                XmlDocument wideTileTemplate = this.GenerateWideTile(song, albumArtUri);
                XmlDocument squareTileTemplate = this.GenerateSquareTile(song);

                IXmlNode squareBindingNode = squareTileTemplate.GetElementsByTagName("binding").Item(0);
                IXmlNode visualNode = wideTileTemplate.GetElementsByTagName("visual").Item(0);
                if (visualNode != null && squareBindingNode != null)
                {
                    visualNode.AppendChild(wideTileTemplate.ImportNode(squareBindingNode, true));
                }

                var tileNotification = new TileNotification(wideTileTemplate)
                {
                    ExpirationTime = DateTimeOffset.UtcNow.Add(song.Duration),
                    Tag = CurrentSongTileTag
                };

                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }, cancellationToken));
        }
コード例 #11
0
        public void UpdateRedditTile(string tileId, IList <GalleryItem> images)
        {
            TileContent      content          = GetTileContent(tileId, images);
            TileNotification tileNotification = new TileNotification(content.GetXml());

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileNotification);
        }
コード例 #12
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);
        }
コード例 #13
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool susppending = ((App)App.Current).issuspend;

            DataTransferManager.GetForCurrentView().DataRequested -= OnShareDataRequested;
            var updator = TileUpdateManager.CreateTileUpdaterForApplication();

            updator.Clear();
            for (int count = 0; count < View_Model.AllItems.Count; count++)
            {
                XmlDocument tile = new XmlDocument();
                tile.LoadXml(File.ReadAllText("Tile.xml"));
                XmlNodeList tileText = tile.GetElementsByTagName("text");
                for (int i = 0; i < tileText.Count; i++)
                {
                    ((XmlElement)tileText[i]).InnerText = View_Model.AllItems[count].title;
                    i++;
                    ((XmlElement)tileText[i]).InnerText = View_Model.AllItems[count].description;
                }
                TileNotification notification = new TileNotification(tile);
                updator.Update(notification);
            }
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            if (susppending)
            {
                ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();
                composite["title"]  = Title.Text;
                composite["detail"] = Detail.Text;
                //composite["imgae"] = (Icon.Source as BitmapImage).UriSource.OriginalString;
                composite["date"] = Date.Date;
                ApplicationData.Current.LocalSettings.Values["NewPage"] = composite;
            }
        }
コード例 #14
0
        public static void ValueTileUpdater(string value)
        {
            _tileContent = GenerateTileContent(value);
            var notification = new TileNotification(_tileContent.GetXml());

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
コード例 #15
0
        public static void ResumeTile()
        {
            var tile = new TileBinding()
            {
                DisplayName = Windows.ApplicationModel.Package.Current.DisplayName,
                Branding    = TileBranding.Name,
                Content     = new TileBindingContentAdaptive()
                {
                    BackgroundImage = new TileBackgroundImage()
                    {
                        Source = MusicImage.DefaultImagePath
                    },
                }
            };
            var tileContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = tile,
                    TileWide   = tile,
                    TileLarge  = tile
                }
            };

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

            // And send the notification to the primary tile
            tileUpdater.Update(tileNotification);
        }
コード例 #16
0
 internal void HandleTileNotification(TileNotification tileNotification)
 {
     if (tileUpdater != null)
     {
         tileUpdater.Update(tileNotification);
     }
 }
コード例 #17
0
        /// <summary>
        /// 通过Xml磁贴模版文件更新默认磁贴内容
        /// </summary>
        /// <param name="tileXml"></param>
        public static void UpdateSecondaryTileNotificationsByXml(string tileId, string tileXmlString)
        {
            /*
             * string tileXmlString = "<tile>"
             + "<visual version='3'>"
             + "<binding template='TileSquare71x71Image'>"
             + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
             + "</binding>"
             + "<binding template='TileSquare150x150Image' fallback='TileSquareImage'>"
             + "<image id='1' src='ms-appx:///images/graySquare150x150.png' alt='Gray image'/>"
             + "</binding>"
             + "<binding template='TileWide310x150ImageAndText01' fallback='TileWideImageAndText01'>"
             + "<image id='1' src='ms-appx:///images/redWide310x150.png' alt='Red image'/>"
             + "<text id='1'>This tile notification uses ms-appx images</text>"
             + "</binding>"
             + "<binding template='TileSquare310x310Image'>"
             + "<image id='1' src='ms-appx:///images/purpleSquare310x310.png' alt='Purple image'/>"
             + "</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’s tile.
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tile);
        }
コード例 #18
0
ファイル: TileManger.cs プロジェクト: GostBop/WeChatUwp
        public static void Tile(String FromNickName, String ToNickName)
        {
            Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument();
            xdoc.LoadXml(File.ReadAllText("tile.xml"));
            Windows.Data.Xml.Dom.XmlNodeList TileList = xdoc.GetElementsByTagName("text");
            TileList[0].InnerText  = FromNickName;
            TileList[1].InnerText  = "To";
            TileList[2].InnerText  = ToNickName;
            TileList[3].InnerText  = FromNickName;
            TileList[4].InnerText  = "To";
            TileList[5].InnerText  = ToNickName;
            TileList[6].InnerText  = FromNickName;
            TileList[7].InnerText  = "To";
            TileList[8].InnerText  = ToNickName;
            TileList[9].InnerText  = FromNickName;
            TileList[10].InnerText = "To";
            TileList[11].InnerText = ToNickName;

            TileNotification notification = new TileNotification(xdoc);

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
コード例 #19
0
        private async void updateInfor()
        {
            string msg    = "";
            string status = "";
            var    local  = ApplicationData.Current.LocalFolder;

            var file = await local.GetFileAsync(@"\Data\data.txt");

            IList <string> lines = await FileIO.ReadLinesAsync(file);

            foreach (var item in lines)
            {
                string[] d = item.Split(' ', '\n');
                status = d[0];
            }


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


            // msg = (networkInfor == null) ? "No Internet Access" : "Internet Access";
            msg = (networkInfor == null) ? "No Internet Access" : status;


            XmlDocument xdoc = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text03);

            xdoc.GetElementsByTagName("text")[0].InnerText = msg;
            TileNotification notification = new TileNotification(xdoc);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
コード例 #20
0
ファイル: TileService.cs プロジェクト: Liu-YT/MOSAD
        //磁贴
        static public void UpdateTileItem()
        {
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueue(true);
            updater.Clear();
            if (MatchesVM.GetMatchesVM().AllMatches.Count == 0)
            {
                return;
            }
            else
            {
                int count = 0;
                foreach (var match in MatchesVM.GetMatchesVM().AllMatches)
                {
                    ++count;
                    var xmlDoc = TileService.CreateFiles(match);
                    TileNotification notification = new TileNotification(xmlDoc);
                    updater.Update(notification);
                    if (count == 5)
                    {
                        break;
                    }
                }
            }
        }
コード例 #21
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);
        }
コード例 #22
0
        private void OnClick(object sender, RoutedEventArgs e)
        {
            XmlDocument tileXml = new XmlDocument();

            tileXml.LoadXml(File.ReadAllText("tiles.xml"));
            XmlNodeList arr = tileXml.GetElementsByTagName("text");

            for (int i = 0; i < arr.Count; i++)
            {
                if (ViewModel.SelectedItem != null)
                {
                    ((XmlElement)arr[i]).InnerText = ViewModel.SelectedItem.title;
                    i++;
                    ((XmlElement)arr[i]).InnerText = ViewModel.SelectedItem.description;
                    i++;
                    var str = ViewModel.SelectedItem.date.Year.ToString() + "/" + ViewModel.SelectedItem.date.Month.ToString() + "/" + ViewModel.SelectedItem.date.Day.ToString();
                    ((XmlElement)arr[i]).InnerText = str;
                }
                else
                {
                    ((XmlElement)arr[i]).InnerText = "未创建或更新item";
                }
            }
            TileNotification notifi = new TileNotification(tileXml);
            var updater             = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notifi);
        }
コード例 #23
0
        //磁贴
        static public void UpdateTileItem()
        {
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueue(true);
            updater.Clear();
            if (MainPage.allItem.AllItems.Count == 0)
            {
                return;
            }
            else
            {
                int count = 0;
                foreach (var item in MainPage.allItem.AllItems)
                {
                    ++count;
                    var xmlDoc = TileService.CreateFiles(item);
                    TileNotification notification = new TileNotification(xmlDoc);
                    updater.Update(notification);
                    if (count == 5)
                    {
                        break;
                    }
                }
            }
        }
コード例 #24
0
 public static void UpdateTile(Mediafile mediaFile)
 {
     if (!SharedLogic.Instance.SettingsVm.CoreSettingsVM.TileNotifcationsEnabled)
     {
         return;
     }
     try
     {
         string title    = WebUtility.HtmlEncode(mediaFile.Title);
         string artist   = WebUtility.HtmlEncode(mediaFile.LeadArtist);
         string album    = WebUtility.HtmlEncode(mediaFile.Album);
         string albumart = string.IsNullOrEmpty(mediaFile.AttachedPicture) ? "Assets/Square44x44Logo.scale-400.png" : mediaFile.AttachedPicture;
         string xml      = "<tile> <visual displayName=\"Now Playing\" branding=\"nameAndLogo\">" +
                           "<binding template=\"TileSmall\"> <image placement=\"background\" src=\"" + albumart + "\"/> </binding>" +
                           "<binding template=\"TileMedium\"> <image placement=\"background\" src=\"" + mediaFile.AttachedPicture + "\" hint-overlay=\"50\"/> <text hint-style=\"body\" hint-wrap=\"true\">{0}</text> <text hint-style=\"caption\">{1}</text> <text hint-style=\"captionSubtle\">{2}</text> </binding>" +
                           "<binding template=\"TileWide\" hint-textStacking=\"center\"> <image placement=\"background\" src=\"" + mediaFile.AttachedPicture + "\" hint-overlay=\"70\"/> <text hint-style=\"subtitle\" hint-align=\"center\">{0}</text> <text hint-style=\"body\" hint-align=\"center\">{1}</text> <text hint-style=\"caption\" hint-align=\"center\">{2}</text></binding>" +
                           "<binding template=\"TileLarge\"> <image placement=\"background\" src=\"" + mediaFile.AttachedPicture + "\" hint-overlay=\"80\"/> <group> <subgroup hint-weight=\"1\"/> <subgroup hint-weight=\"2\"> <image src=\"" + mediaFile.AttachedPicture + "\" hint-crop=\"circle\"/> </subgroup> <subgroup hint-weight=\"1\"/> </group> <text hint-style=\"subtitle\" hint-align=\"center\">{0}</text> <text hint-style=\"body\" hint-align=\"center\">{1}</text> <text hint-style=\"caption\" hint-align=\"center\">{2}</text> </binding> </visual> </tile>";
         var         formattedXml = string.Format(xml, title, artist, album);
         XmlDocument doc          = new XmlDocument();
         doc.LoadXml(formattedXml);
         var notification = new TileNotification(doc);
         TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
     }
     catch (Exception ex)
     {
         BLogger.E("Error occured while updating tile.", ex);
     }
 }
コード例 #25
0
ファイル: LiveTile.cs プロジェクト: Martineskerud/DOTNET2013
        //Code metrics: 59, commented in readme.
        /// <summary>
        /// Updates the live tile.
        /// </summary>
        private static void UpdateLiveTile()
        {
            TileUpdater tileUpdater = SetupUpdater();



            for (int i = 0; i < 5; i++)
            {
                try
                {
                    movie = movieArray[i];

                    movieTileText = xmlDocument.GetElementsByTagName("text");

                    movieTileText[0].InnerText = movie;

                    TileNotification tileNotification = new TileNotification(xmlDocument);

                    tileNotification.Tag = "tile" + i;

                    tileNotification.ExpirationTime = DateTime.Now.AddSeconds(10 * (i + 1));
                    tileUpdater.Update(tileNotification);
                }
                catch (ArgumentOutOfRangeException exception)
                {
                    movie = exception.Message;
                }
            }
        }
コード例 #26
0
        public static void ShowTileNotification(string message)
        {
            var nowTimeString = DateTime.Now.ToString(CultureInfo.CurrentCulture);

            var xml = $@"
                <tile version='3'>
                    <visual branding='nameAndLogo'>

                        <binding template='TileMedium'>
                            <text hint-wrap='true'>{message}</text>
                            <text hint-wrap='true' hint-style='captionSubtle'>{nowTimeString}</text>
                        </binding>

                        <binding template='TileWide'>
                            <text hint-wrap='true'>{message}</text>
                            <text hint-wrap='true' hint-style='captionSubtle'>{nowTimeString}</text>
                        </binding>

                        <binding template='TileLarge'>
                            <text hint-wrap='true'>{message}</text>
                            <text hint-wrap='true' hint-style='captionSubtle'>{nowTimeString}</text>
                        </binding>

                </visual>
            </tile>";

            var doc = new XmlDocument();

            doc.LoadXml(xml);

            var notification = new TileNotification(doc);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
コード例 #27
0
ファイル: TilesHelper.cs プロジェクト: AsteroidOS/WinSteroid
        public static void UpdateBatteryTile(int?percentage)
        {
            if (!SecondaryTile.Exists(BatteryTileId))
            {
                return;
            }

            var deviceId   = SettingsHelper.GetValue(Constants.LastSavedDeviceIdSettingKey, string.Empty);
            var deviceName = SettingsHelper.GetValue(Constants.LastSavedDeviceNameSettingKey, string.Empty);

            var tileVisual = new TileVisual
            {
                Branding   = TileBranding.NameAndLogo,
                TileMedium = CreateMediumTileBinding(percentage ?? 0, deviceName),
                TileWide   = CreateWideTileBinding(percentage ?? 0, deviceName),
                TileLarge  = CreateLargeTileBinding(percentage ?? 0, deviceName)
            };

            var tileContent = new TileContent
            {
                Visual = tileVisual
            };

            var tileNotification = new TileNotification(tileContent.GetXml());

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(BatteryTileId).Update(tileNotification);
        }
コード例 #28
0
        private void SendTileNotificationWithStringManipulation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                string tileXmlString = "<tile>"
                                       + "<visual>"
                                       + "<binding template='TileWideText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "<binding template='TileSquareText04'>"
                                       + "<text id='1'>Send to a secondary tile from strings</text>"
                                       + "</binding>"
                                       + "</visual>"
                                       + "</tile>";

                Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
                tileDOM.LoadXml(tileXmlString);
                TileNotification tile = new TileNotification(tileDOM);

                // Send the notification to the secondary tile by creating a secondary tile updater
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(tile);

                rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage);
            }
        }
コード例 #29
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();
        }
コード例 #30
0
        public static async Task TileUpdater()
        {
            try
            {
                var    localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                string value         = localSettings.Values["oneshot"].ToString();


                //var oneshot = true;
                var x = await DataUsage();

                if (x.errorList.Count == 0)
                {
                    _tileContent = GenerateTileContent(x.usageList[2]);
                    var notification = new TileNotification(_tileContent.GetXml());
                    TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
                    // x.usageList[2] = "9.5";
                    if (x.usageList[2].Contains("9.") && value == "true")
                    {
                        Pronto.PopToast("Your Monthly Data Usage have exceded 9 GB");
                        localSettings.Values["oneshot"] = "false";
                    }
                }
                else
                {
                    return;
                }
            }
            catch
            {
                return;
            }
        }
コード例 #31
0
 private void WriteTileOptions(JsonWriter writer, TileNotification option)
 {
     writer.StartObject();
     writer.WriteProperty("notificationtype", "tile");
     WriteTile(writer, "wp8", option.WP8Tile);
     WriteTile(writer, "wp75", option.WP75Tile);
     WriteTile(writer, "wp7", option.WP7Tile);
     writer.EndObject();
 }