예제 #1
0
        public static void UpdateTile()
        {
            TileTemplateType tileTemplate        = TileTemplateType.TileWideImageAndText01;
            XmlDocument      tileXml             = TileUpdateManager.GetTemplateContent(tileTemplate);
            XmlNodeList      tileImageAttributes = tileXml.GetElementsByTagName("image");

            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/breakfast400.jpg");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "Breakfast");

            var textElements = tileXml.GetElementsByTagName("text");

            ((XmlElement)textElements[0]).InnerText = "MENU card";

            TileNotification notification = new TileNotification(tileXml);

            notification.ExpirationTime = DateTimeOffset.Now.AddMinutes(60);

            TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Update(notification);
        }
예제 #2
0
        public static async Task CreateLiveTile(string tileFileName)
        {
            if (tileFileName != null)
            {
                try
                {
                    var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                    tileUpdater.EnableNotificationQueue(true);
                    tileUpdater.Clear();

                    StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                    StorageFile   file   = await folder.GetFileAsync(tileFileName);

                    tileUpdater.Update(new TileNotification(await XmlDocument.LoadFromFileAsync(file)));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
예제 #3
0
        private void EnsureDefaultTile()
        {
            var wideTile   = TileContentFactory.CreateTileWide310x150Image();
            var squareTile = TileContentFactory.CreateTileSquare150x150Image();

            wideTile.Square150x150Content = squareTile;

            squareTile.Branding  = TileBranding.Name;
            squareTile.Image.Src = "ms-appx:///resources/images/square150.png";

            wideTile.Branding  = TileBranding.Name;
            wideTile.Image.Src = "ms-appx:///resources/images/wide.png";

            var notification = wideTile.CreateNotification();

            notification.Tag = "default";

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Update(notification);
        }
예제 #4
0
        private void ImageCollection_Toggled(object sender, RoutedEventArgs e)
        {
            if (ImageCollection.IsOn)
            {
                tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150ImageCollection);

                tileList = tileXml.GetElementsByTagName("image");
                (tileList[0] as XmlElement).SetAttribute("src", "ms-appx:///Assets/blue.310x150.png");
                (tileList[1] as XmlElement).SetAttribute("src", "ms-appx:///Assets/red.310x150.png");
                (tileList[2] as XmlElement).SetAttribute("src", "ms-appx:///Assets/green.310x150.png");
                (tileList[3] as XmlElement).SetAttribute("src", "ms-appx:///Assets/yellow.310x150.png");
                (tileList[4] as XmlElement).SetAttribute("src", "ms-appx:///Assets/orange.310x150.png");

                notif = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(notif);
            }
            else
            {
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            }
        }
예제 #5
0
        public static void UpdateBigTileWithMusicInfo()
        {
            const TileTemplateType template = TileTemplateType.TileWidePeekImage05;
            var tileXml = TileUpdateManager.GetTemplateContent(template);

            var tileTextAttributes = tileXml.GetElementsByTagName("text");

            tileTextAttributes[0].InnerText = "Now playing";
            if (Locator.MusicPlayerVM.Artist != null)
            {
                tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.Artist.CurrentAlbumItem.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.Artist.CurrentAlbumItem.Artist;

                var tileImgAttribues = tileXml.GetElementsByTagName("image");
                tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.Artist.Picture;
                tileImgAttribues[1].Attributes[1].NodeValue = Locator.MusicPlayerVM.Artist.CurrentAlbumItem.Picture;
            }

            var tileNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
예제 #6
0
        public MainPage()
        {
            this.InitializeComponent();

            var resLoader = ResourceLoader.GetForCurrentView();

            this.navView.Loaded      += NavView_Loaded;
            this.navView.ItemInvoked += NavView_ItemInvoked;
            this.navView.PaneOpening += NavView_PaneOpening;

            if (StoreServicesFeedbackLauncher.IsSupported())
            {
                this.navItemFeedback.Visibility = Visibility.Visible;
            }

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

            var tileNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
예제 #7
0
        public static void UpdateTile(HomeSensorData data)
        {
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

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

            var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText04);

            tile.GetElementsByTagName("text")[0].InnerText = string.Format("Temp {2}{1}DewPoint {3}{0}Humidity {4}{1}Light {5}{0}Smoke {6}{1}CO {7}{0}{8}",
                                                                           Environment.NewLine,
                                                                           "\t",
                                                                           Math.Round(data.Temperature, 2),
                                                                           Math.Round(data.DewPoint, 3),
                                                                           data.Humidity,
                                                                           data.Light,
                                                                           data.Smoke,
                                                                           data.CarbonMonoxide,
                                                                           DateTime.Now.ToString("h:mm tt"));
            updater.Update(new TileNotification(tile));
        }
예제 #8
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var defferal = taskInstance.GetDeferral();

            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.EnableNotificationQueue(true);

            updater.Clear();

            for (int i = 1; i < 6; i++)
            {
                var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
                tile.GetElementsByTagName("text")[0].InnerText = "Tile " + i;
                tile.GetElementsByTagName("text")[1].InnerText = DateTime.Now.ToString("hh-mm");

                updater.Update(new TileNotification(tile));
            }

            defferal.Complete();
        }
예제 #9
0
        private void setLiveTile(string imgPath, string text, int second)
        {
            //Chọn tile template
            var tile         = TileTemplateType.TileSquare150x150PeekImageAndText04;
            var tileTemplate = TileUpdateManager.GetTemplateContent(tile);
            //Tạo notification
            var notifi = new TileNotification(tileTemplate);

            notifi.ExpirationTime = DateTime.Now + TimeSpan.FromSeconds(second);
            //Tạo xml để đưa icon và Text lên Tile
            XmlNodeList node = tileTemplate.GetElementsByTagName("image");

            node[0].Attributes[1].NodeValue = "ms-appx:///Assets/" + imgPath;
            tileTemplate.GetElementsByTagName("text");
            node[0].InnerText = text;

            //Cập nhật tile
            var tud = TileUpdateManager.CreateTileUpdaterForApplication();

            tud.Update(notifi);
        }
예제 #10
0
        void UpdateTileWithWebImage_Click(object sender, RoutedEventArgs e)
        {
            // Note: This sample contains an additional project, NotificationsExtensions.
            // NotificationsExtensions exposes an object model for creating notifications, but you can also
            // modify the strings directly. See UpdateTileWithWebImageWithStringManipulation_Click for an example

            // Create notification content based on a visual template.
            ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();

            tileContent.TextCaptionWrap.Text = "This tile notification uses web images.";

            // !Important!
            // The Internet (Client) capability must be checked in the manifest in the Capabilities tab
            // to display web images in tiles (either the http:// or https:// protocols)

            tileContent.Image.Src = ImageUrl.Text;
            tileContent.Image.Alt = "Web image";

            // Users can resize tiles to square or wide.
            // Apps can choose to include only square assets (meaning the app's tile can never be wide), or
            // include both wide and square assets (the user can resize the tile to square or wide).
            // Apps cannot include only wide assets.

            // Apps that support being wide should include square tile notifications since users
            // determine the size of the tile.

            // Create square notification content based on a visual template.
            ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();

            squareContent.Image.Src = ImageUrl.Text;
            squareContent.Image.Alt = "Web image";

            // include the square template.
            tileContent.SquareContent = squareContent;

            // send the notification to the app's application tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());

            OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent());
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        //更新磁贴
        private void updateTile()
        {
            //使用TileUpdateManager来创建磁贴更新队列
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            foreach (var todo in viewmodel.AllItem)
            {
                XmlDocument xml = new XmlDocument();
                //读取Tile.xml中的内容
                xml.LoadXml(File.ReadAllText("Tile.xml"));
                //通过标签来定位,text 标签有title 与discrption两种
                XmlNodeList text  = xml.GetElementsByTagName("text");
                XmlNodeList image = xml.GetElementsByTagName("image");

                //修改所有的text标签内容
                for (int i = 0; i < text.Count; i++)
                {
                    ((XmlElement)text[i]).InnerText = todo.title;
                    i++;
                    ((XmlElement)text[i]).InnerText = todo.description;
                }
                foreach (var element in image)
                {
                    BitmapImage bitmapimage = (BitmapImage)todo.image;
                    //只能加载本地的图片
                    if (todo.image != null)
                    {
                        ((XmlElement)element).SetAttribute("src", bitmapimage.UriSource.ToString());
                    }
                    else
                    {
                        ((XmlElement)element).SetAttribute("src", "Assets/bar.jpg");
                    }
                }


                var notification = new TileNotification(xml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
            }
        }
예제 #13
0
        public async Task <int> updateLiveTile()
        {
            // create the instance of Tile Updater, which enables you to change the appearance of the calling app's tile
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            // enables the tile to queue up to five notifications
            updater.EnableNotificationQueue(true);
            updater.Clear();
            ISquare310x310TileNotificationContent largeContent;
            LiveTileSty lts;

            if ((bool)localSettings.Values["TileClearSty"])
            {
                lts = new LiveTileSty(clearLiveTiles);
            }
            else
            {
                lts = new LiveTileSty(detailedLiveTiles);
            }
            largeContent = await lts(subscrSiteList[0]);

            // Create a new tile notification.
            updater.Update(new TileNotification(largeContent.GetXml()));

            foreach (var siteName in subscrSiteList.GetRange(1, subscrSiteList.Count - 1))
            {
                if (!SecondaryTile.Exists(siteName))
                {
                    continue;
                }
                var updater2 = TileUpdateManager.CreateTileUpdaterForSecondaryTile(siteName);
                updater2.EnableNotificationQueue(true);
                updater2.Clear();
                largeContent = await lts(siteName);

                updater2.Update(new TileNotification(largeContent.GetXml()));
            }

            return(0);
        }
        private void WriteOnTile(string p)
        {
            // create a string with the tile template xml
            string tileXmlString = "<tile>"
                                   + "<visual version='2'>"
                                   + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileWide310x150Text03' fallback='TileWideText03'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileSquare310x310Text05'>"
                                   + "<text id='1'>" + p + "</text>"
                                   + "</binding>"
                                   + "<binding template='TileWide310x150BlockAndText01'>"
                                   + "<text id='1'>" + p + "</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, catching any invalid xml characters
            tileDOM.LoadXml(tileXmlString);

            try
            {
                // create a tile notification
                TileNotification tile = new TileNotification(tileDOM);

                // Enter expiry time
                tile.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);

                // send the notification to the app's application tile
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
            }
            catch (System.Exception ex)
            {
            }
        }
예제 #15
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);
                }
            });
        }
예제 #16
0
        public static void UpdateTileWithWideTextImageImages(List <NotificationTile> notificationTileList)
        {
            if (notificationTileList != null && notificationTileList.Count > 0)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
                for (int i = 0; i < notificationTileList.Count; i++)
                {
                    if (i < 5)
                    {
                        var photoTileSmall = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquarePeekImageAndText02);
                        var photoTileWide  = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText01);

                        //Add several tile templates to an IEnumerable<> list for merging
                        string TextBodyWrap = string.Empty;
                        if (notificationTileList[i].TextBodyWrap.Length > 80)
                        {
                            TextBodyWrap = notificationTileList[i].TextBodyWrap.Substring(0, 80);
                        }
                        else
                        {
                            TextBodyWrap = notificationTileList[i].TextBodyWrap;
                        }
                        var liveTilesIn = new List <XmlDocument>
                        {
                            photoTileSmall.AddImages(new[] { notificationTileList[i].ImageUri }, new[] { notificationTileList[i].ImageAltName }).AddText(new[] { TextBodyWrap }),
                            photoTileWide.AddImages(new[] { notificationTileList[i].ImageUri }, new[] { notificationTileList[i].ImageAltName }).AddText(new[] { TextBodyWrap })
                        };

                        //Use the Tag property to uniquely identify this tile
                        TileNotification tileNotification = new TileNotification(liveTilesIn.MergeTiles());
                        if (!string.IsNullOrEmpty(notificationTileList[i].NotificationTileTag) || !string.IsNullOrWhiteSpace(notificationTileList[i].NotificationTileTag))
                        {
                            tileNotification.Tag = notificationTileList[i].NotificationTileTag;
                        }
                        TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
                    }
                }
            }
        }
        private void open(object sender, RoutedEventArgs e)
        {
            Storyboard1.Begin();
            string xml  = @"
<tile>
  <visual>
    <binding template='TileSquarePeekImageAndText01'>
      <image id='1' src='Assets/medium_tile.jpg' alt='alt text'/>
      <text id='1'>Global News(larger text)</text>
      <text id='2'>National News</text>
      <text id='3'>Facts</text>
      <text id='4'>All News</text>
    </binding>  
  </visual>
</tile>
";
            var    docc = new XmlDocument();

            docc.LoadXml(xml);
            var notif = new TileNotification(docc);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(notif);


            string xm  = @"
<tile>
  <visual>
    <binding template='TileWideImageAndText01'>
      <image id='1' src='Assets/wide_tiles.jpg' alt='alt text'/>
      <text id='1'>News Stand</text>
    </binding>  
  </visual>
</tile>";
            var    doc = new XmlDocument();

            doc.LoadXml(xm);
            var not = new TileNotification(doc);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(not);
        }
예제 #18
0
        private async Task UpdateTile(TrackInfo args)
        {
            if (args == null)
            {
                TileUpdateManager.CreateTileUpdaterForApplication("App").Clear();
            }
            else
            {
                string artPath = string.Empty;
                if (!string.IsNullOrEmpty(args.ArtPath))
                {
                    IStorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(args.ArtPath);

                    artPath = file.Path;
                }

                XmlDocument tileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);

                XmlNodeList textAttributes = tileTemplate.GetElementsByTagName("text");

                textAttributes[0].AppendChild(tileTemplate.CreateTextNode(args.Title));
                textAttributes[1].AppendChild(tileTemplate.CreateTextNode(args.Artist));
                textAttributes[2].AppendChild(tileTemplate.CreateTextNode(args.Album));

                XmlNodeList imageAttribute = tileTemplate.GetElementsByTagName("image");
                XmlElement  imageElement   = (XmlElement)imageAttribute[0];
                imageElement.SetAttribute("src", artPath);

                // Create the notification from the XML.
                var tileNotification = new TileNotification(tileTemplate);

                try
                {
                    TileUpdateManager.CreateTileUpdaterForApplication("App").Update(tileNotification);
                }
                catch (Exception)
                {
                }
            }
        }
예제 #19
0
        private async Task AppSuspendingAsync(object sender, SuspendingEventArgs e)
        {
            var def = e.SuspendingOperation.GetDeferral();

            try
            {
                // Clear live tile
                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.Clear();

                var playbackService = SimpleIoc.Default.GetInstance <IPlaybackService>();
                if (playbackService != null)
                {
                    // Save current position
                    var currentPosition = playbackService.GetMediaPlayer()?.PlaybackSession?.Position;
                    await RoamingService.StopActivityAsync(currentPosition);

                    // Update the resume files
                    var roamingFolder = ApplicationData.Current.RoamingFolder;

                    var track    = new BaseSoundByteItem(playbackService.GetCurrentTrack());
                    var playlist = playbackService.GetMediaPlaybackList().Items.Select(x => new BaseSoundByteItem(x.Source.AsBaseTrack()));
                    var token    = playbackService.GetPlaylistToken();
                    var source   = playbackService.GetPlaylistSource();

                    var playbackFile = await roamingFolder.CreateFileAsync("currentPlayback.txt", CreationCollisionOption.OpenIfExists);

                    await FileIO.WriteTextAsync(playbackFile,
                                                ProtocolHelper.EncodeTrackProtocolItem(new ProtocolHelper.TrackProtocolItem(source, track, playlist, token, SimpleIoc.Default.GetInstance <IPlaybackService>().GetTrackPosition(), SimpleIoc.Default.GetInstance <IPlaybackService>().IsPlaylistShuffled()), false) + "\n" + SettingsService.Instance.SessionId);
                }
            }
            catch (Exception ex)
            {
                SimpleIoc.Default.GetInstance <ITelemetryService>().TrackException(ex);
            }
            finally
            {
                def.Complete();
            }
        }
예제 #20
0
        void RefreshListView()
        {
            IReadOnlyList <ScheduledToastNotification> scheduledToasts = ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications();
            IReadOnlyList <ScheduledTileNotification>  scheduledTiles  = TileUpdateManager.CreateTileUpdaterForApplication().GetScheduledTileNotifications();

            int toastLength = scheduledToasts.Count;
            int tileLength  = scheduledTiles.Count;

            List <NotificationData> bindingList = new List <NotificationData>(toastLength + tileLength);

            for (int i = 0; i < toastLength; i++)
            {
                ScheduledToastNotification toast = scheduledToasts[i];

                bindingList.Add(new NotificationData()
                {
                    ItemType    = "Toast",
                    ItemId      = toast.Id,
                    DueTime     = toast.DeliveryTime.ToLocalTime().ToString(),
                    InputString = toast.Content.GetElementsByTagName("text")[0].InnerText,
                    IsTile      = false
                });
            }

            for (int i = 0; i < tileLength; i++)
            {
                ScheduledTileNotification tile = scheduledTiles[i];

                bindingList.Add(new NotificationData()
                {
                    ItemType    = "Tile",
                    ItemId      = tile.Id,
                    DueTime     = tile.DeliveryTime.ToLocalTime().ToString(),
                    InputString = tile.Content.GetElementsByTagName("text")[0].InnerText,
                    IsTile      = true
                });
            }

            ItemGridView.ItemsSource = bindingList;
        }
예제 #21
0
        private async Task Getdate()
        {
            loading.IsIndeterminate = true;
            try
            {
                location = await getlocation.Location();

                RootObject myweather = await getweather.GetWeather(location.Coordinate.Point.Position.Latitude, location.Coordinate.Point.Position.Longitude);

                city.Text = myweather.HeWeather5[0].basic.city;
                temp.Text = myweather.HeWeather5[0].daily_forecast[0].tmp.min + "°C~" + myweather.HeWeather5[0].daily_forecast[0].tmp.max + "°C";
                string icon = String.Format("ms-appx:///Assets/icon/{0}.png", myweather.HeWeather5[0].daily_forecast[0].cond.code_d);
                icond.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
                icon         = String.Format("ms-appx:///Assets/icon/{0}.png", myweather.HeWeather5[0].daily_forecast[0].cond.code_n);
                iconn.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
                zhuan.Text   = "~";
                if (myweather.HeWeather5[0].daily_forecast[0].cond.txt_d == myweather.HeWeather5[0].daily_forecast[0].cond.txt_n)
                {
                    weather.Text = myweather.HeWeather5[0].daily_forecast[0].cond.txt_d;
                }
                else
                {
                    weather.Text = myweather.HeWeather5[0].daily_forecast[0].cond.txt_d + "转" + myweather.HeWeather5[0].daily_forecast[0].cond.txt_n;
                }
                wind.Text = myweather.HeWeather5[0].daily_forecast[0].wind.sc;
                sug.Text  = myweather.HeWeather5[0].suggestion.air.txt + "\n\n" + myweather.HeWeather5[0].suggestion.comf.txt + "\n\n" + myweather.HeWeather5[0].suggestion.cw.txt + "\n\n" + myweather.HeWeather5[0].suggestion.drsg.txt + "\n\n" + myweather.HeWeather5[0].suggestion.flu.txt + "\n\n" + myweather.HeWeather5[0].suggestion.sport.txt;
                loading.IsIndeterminate = false;
                loading.Opacity         = 0;
                string text           = city.Text + "\n\n " + temp.Text + "\n\n " + weather.Text;
                var    tilexml        = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                var    tileattributes = tilexml.GetElementsByTagName("text");
                tileattributes[0].AppendChild(tilexml.CreateTextNode(text));
                var tilenotification = new TileNotification(tilexml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tilenotification);
            }
            catch (System.UnauthorizedAccessException)
            {
                await new MessageDialog("请打开定位且在设置中允许定位").ShowAsync();
            }
        }
예제 #22
0
        // 更新 application tile 的数据
        private void btnUpdateTile_Click(object sender, RoutedEventArgs e)
        {
            // 用于描述 tile 通知的 xml 字符串
            string tileXml = $@"
                <tile>
                    <visual>
                        <binding template='TileSmall'>
                            <text>Small(小){DateTime.Now.ToString("HH:mm:ss")}</text>
                        </binding>
                        <binding template='TileMedium'>
                            <text>Medium(中){DateTime.Now.ToString("HH:mm:ss")}</text>
                        </binding>
                        <binding template='TileWide'>
                            <text>Wide(宽){DateTime.Now.ToString("HH:mm:ss")}</text>
                        </binding>
                        <binding template='TileLarge'>
                            <text>Large(大){DateTime.Now.ToString("HH:mm:ss")}</text>
                        </binding>
                    </visual>
                </tile>";

            // 将 xml 字符串转换为 Windows.Data.Xml.Dom.XmlDocument 对象
            XmlDocument tileDoc = new XmlDocument();

            tileDoc.LoadXml(tileXml);
            // 获取此 tile 的 xml
            // lblMsg.Text = tileDoc.GetXml();

            // 实例化 TileNotification 对象
            TileNotification tileNotification = new TileNotification(tileDoc);
            DateTimeOffset   expirationTime   = DateTimeOffset.UtcNow.AddSeconds(30);

            tileNotification.ExpirationTime = expirationTime; // 30 秒后清除这个 tile

            // 将指定的 TileNotification 对象更新到 application tile
            TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.EnableNotificationQueue(true); // 启用 tile 的队列功能(最多可容纳 5 个 tile)
            tileUpdater.Update(tileNotification);
        }
예제 #23
0
        public void SetLiveTile(string text1, string text2)
        {
            var tileXml2 = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage02);
            var tileXml3 = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01);

            var notification2 = new ScheduledTileNotification(tileXml2, DateTime.Now + TimeSpan.FromSeconds(2));
            var notification3 = new ScheduledTileNotification(tileXml3, DateTime.Now + TimeSpan.FromSeconds(4));

            notification2.ExpirationTime = DateTime.Now + TimeSpan.FromDays(14);
            notification3.ExpirationTime = DateTime.Now + TimeSpan.FromDays(14);

            //weit
            XmlNodeList nodes2 = tileXml2.GetElementsByTagName("image");

            nodes2[0].Attributes[1].NodeValue = "ms-appx:///Assets/" + "wide-live.png";
            nodes2 = tileXml2.GetElementsByTagName("text");
            nodes2[0].InnerText = "Stand";
            nodes2[1].InnerText = text1;
            nodes2[2].InnerText = text2;

            //normal
            XmlNodeList nodes3 = tileXml3.GetElementsByTagName("image");

            nodes3[0].Attributes[1].NodeValue = "ms-appx:///Assets/" + "small-live.png";
            nodes3 = tileXml3.GetElementsByTagName("text");
            nodes3[0].InnerText = "Stand";
            nodes3[1].InnerText = text1;
            nodes3[2].InnerText = text2;

            if (gesamtAnzahlNoten != 0)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(notification2);
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(notification3);
            }
            else
            {
                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            }
        }
예제 #24
0
        public static void CreateCycleTile(Dictionary <string, string> images)
        {
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.EnableNotificationQueue(true);
            tileUpdater.Clear();

            foreach (var image in images)
            {
                var squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Image);
                SetTileImages(squareTileXml, image.Value);
                var wideTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Image);
                SetTileImages(wideTileXml, image.Value);

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

                var notif = new TileNotification(wideTileXml);
                notif.Tag = image.Key;
                tileUpdater.Update(notif);
            }
        }
예제 #25
0
        public static void SetLiveTile(string title, string body, int seconds)
        {
            // Get tile template.
            var tileTemplate = TileTemplateType.TileSquareBlock;
            var tileXml      = TileUpdateManager.GetTemplateContent(tileTemplate);

            // Create notification.
            var notification = new TileNotification(tileXml);

            notification.ExpirationTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

            // Set notification text.
            XmlNodeList nodes = tileXml.GetElementsByTagName("text");

            nodes[0].InnerText = title;
            nodes[1].InnerText = body;

            // Update Live Tile.
            var upd = TileUpdateManager.CreateTileUpdaterForApplication();

            upd.Update(notification);
        }
예제 #26
0
        private void SendTileNotification(SignalMessage message)
        {
            TileBindingContentAdaptive tileBindingContent = new TileBindingContentAdaptive()
            {
                PeekImage = new TilePeekImage()
                {
                    Source = "ms-appx:///Assets/gambino.png"
                }
            };
            var notificationText = GetNotificationText(message);

            foreach (var item in notificationText)
            {
                tileBindingContent.Children.Add(item);
            }

            TileBinding tileBinding = new TileBinding()
            {
                Content = tileBindingContent
            };

            TileContent tileContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = tileBinding,
                    TileWide   = tileBinding,
                    TileLarge  = tileBinding
                }
            };

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

            if (message.Author.ExpiresInSeconds > 0)
            {
                tileNotification.ExpirationTime = DateTime.Now.Add(TimeSpan.FromSeconds(message.Author.ExpiresInSeconds));
            }
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
예제 #27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Centennial!");
            Console.WriteLine("Pin this app to Start");
            Console.WriteLine("Enter the text for your Live Tile:");
            string liveTileText = Console.ReadLine();

            // Update the apps live tile
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);

            XmlNodeList textNodes = tileXml.GetElementsByTagName("text");

            textNodes[0].InnerText = liveTileText;
            textNodes[1].InnerText = DateTime.Now.ToString("HH:mm:ss");

            TileNotification tileNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            Console.WriteLine("See how it has received the live update");
            Console.ReadLine();
        }
예제 #28
0
        //翻转磁贴
        public static void ShowTilePeek()
        {
            XmlDocument xml;

            if (hoto.Length > 36)
            {
                xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage04);
            }
            else
            {
                xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage03);
            }
            XmlNodeList list  = xml.GetElementsByTagName("text");
            XmlNodeList list1 = xml.GetElementsByTagName("image");

            list[0].AppendChild(xml.CreateTextNode(hoto));
            if (source == "龙虎斗" || source == "黑执事" || source == "魔法禁书目录" || source == "魔法少女小圆" || source == "魔卡少女樱" || source == "鬼泣" || source == "食灵" || source == "青之驱魔师" || source == "问题儿童来自异世界" || source == "银魂" ||
                source == "钢之炼金术师" || source == "进击的巨人" || source == "通灵王" || source == "这是僵尸吗" || source == "言叶之庭" || source == "美少女战士" || source == "缘之空" || source == "笨蛋测试召唤兽" || source == "穿越时空的少女" || source == "空之境界" ||
                source == "秒速五厘米" || source == "火影忍者" || source == "狼与香辛料" || source == "物语" || source == "灼眼的夏娜" || source == "灌篮高手" || source == "潜行吧奈亚子" || source == "海贼王" || source == "死神" || source == "海猫鸣泣之时" ||
                source == "某科学的超电磁炮" || source == "柯南" || source == "未闻花名" || source == "无头骑士异闻录" || source == "夏目友人帐" || source == "反叛的鲁鲁修" || source == "EVA" || source == "CLANNAD" || source == "Angel Beats!" || source == "高达" ||
                source == "我的青春恋爱物语果然有问题" || source == "我的朋友很少" || source == "幸运星" || source == "寒蝉鸣泣之时" || source == "文学少女")
            {
                ((XmlElement)list1[0]).SetAttribute("src", "ms-appx:///Assets/St/" + source + ".png");
            }
            else
            {
                if (com.Values["Peek1"].ToString() == "1" && (com.Values["moban"].ToString() == "1" || com.Values["moban"].ToString() == "3"))
                {
                    ((XmlElement)list1[0]).SetAttribute("src", "ms-appdata:///Local/PeekName1/" + com.Values["PeekName1"].ToString() + ".png");
                }
                else
                {
                    ((XmlElement)list1[0]).SetAttribute("src", "ms-appx:///Assets/WideLogo.scale-240.png");
                }
            }
            TileNotification tn = new TileNotification(xml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tn);
        }
예제 #29
0
        private void viewModel_ActivityUpdated(SleepActivityViewModel sender, string args)
        {
            var settings = SettingsViewModel.Current;

            if (sender.EndTime.HasValue || string.IsNullOrWhiteSpace(args))
            {
                settings.InProgressSleepActivityId = null;
            }

            settings.LastActivityScheduleGeneratedAt = DateTimeOffset.MinValue;
            settings.LastDataTrendsGeneratedAt       = DateTimeOffset.MinValue;

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.UpdateBabysActivityStatusTile(activityName,
                                                      new BabyActivityStatus
            {
                ActivityName      = activityName,
                BabyGivenName     = DefaultViewModel.Baby.GivenName,
                ActivityIsRunning = false
            });
        }
예제 #30
0
        public static void ShowliveTile(bool IsLiveTile1, string name)
        {
            string wideTilesrc  = "ms-appx:///Assets/BigLiveTile1.jpg";
            string smallTilesrc = "ms-appx:///Assets/SmallLiveTile1.jpg";

            if (!IsLiveTile1)
            {
                wideTilesrc  = "ms-appx:///Assets/BigLiveTile2.jpg";
                smallTilesrc = "ms-appx:///Assets/SmallLiveTile2.jpg";
            }
            // Note: This sample contains an additional project, NotificationsExtensions.
            // NotificationsExtensions exposes an object model for creating notifications, but you can also
            // modify the strings directly. See UpdateTileWithImageWithStringManipulation_Click for an example

            // Create notification content based on a visual template.
            ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01();

            tileContent.TextCaptionWrap.Text = name;
            tileContent.Image.Src            = wideTilesrc;
            tileContent.Image.Alt            = "Live tile";

            // Users can resize tiles to square or wide.
            // Apps can choose to include only square assets (meaning the app's tile can never be wide), or
            // include both wide and square assets (the user can resize the tile to square or wide).
            // Apps should not include only wide assets.

            // Apps that support being wide should include square tile notifications since users
            // determine the size of the tile.

            // create the square template and attach it to the wide template
            ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage();

            squareContent.Image.Src   = smallTilesrc;
            squareContent.Image.Alt   = "Live tile";
            tileContent.SquareContent = squareContent;

            // Send the notification to the app's application tile.
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
        }