Inheritance: IScheduledTileNotification
Exemplo n.º 1
0
 public static void CreateScheduledTileNotification(TileContent content, DateTime dueTime, string id)
 {
     ScheduledTileNotification scheduledTile = new ScheduledTileNotification(content.GetXml(), dueTime);
     scheduledTile.Id = id;
     RemoveSpecScheduledTileNotification(id);
     TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile);
 }
Exemplo n.º 2
0
        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);
        }
        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);

            Int16 dueTimeInSeconds = 15;
            DateTime dueTime = DateTime.Now.AddSeconds(dueTimeInSeconds);

            ScheduledTileNotification tileNotification = new ScheduledTileNotification(tileXml,dueTime);
            tileNotification.Tag = this.tileText.Text;

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

            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(tileNotification);
        }
        private void FutureLiveTile()
        {
            var applicationTile = TileContentFactory.CreateTileWidePeekImage02();
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(CoreApplication.Id);

            // clear the existing tile info
            //tileUpdater.Clear();

            applicationTile.TextHeading.Text = "Future Top Scores";
            applicationTile.TextBody1.Text = "Future Player 1 - 100";
            applicationTile.TextBody2.Text = "Future Player 1 - 92";
            applicationTile.TextBody3.Text = "Future Player 1 - 90";
            applicationTile.TextBody4.Text = "Future Player 1 - 85";
            
            applicationTile.RequireSquareContent = false;
            applicationTile.Image.Src = "/Images/AltLiveTileImage_310x150.png";

            var futureTile = new ScheduledTileNotification(applicationTile.GetXml(), DateTime.Now.AddSeconds(10));
            
            if ( ExpireContent )
            {
                futureTile.ExpirationTime = DateTime.Now.AddSeconds(600);
            }
            
            tileUpdater.AddToSchedule(futureTile);
            
        }
Exemplo n.º 5
0
        private static void _updatePrimaryTile(string text, string imgSrc, string imgAlt, TileTemplateType templateType) {

            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);

            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(templateType);  //TileWide310x150ImageAndText01

            //version
            XmlNodeList tileVersionAttributes = tileXml.GetElementsByTagName("visual");
            ((XmlElement)tileVersionAttributes[0]).SetAttribute("version", "2");
            //tileXml.FirstChild.FirstChild.Attributes[0].NodeValue = "2";

            ////branding
            //XmlNodeList tileBindingAttributes = tileXml.GetElementsByTagName("binding");
            //((XmlElement)tileBindingAttributes[0]).SetAttribute("branding", "logo");


            //text
            XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
            if(tileTextAttributes.Count > 0) tileTextAttributes[0].InnerText = text;
            //tileTextAttributes[1].InnerText = "xxxxx";

            //image
            XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image");

            ////image from apps package
            //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/redWide.png");
            //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");

            ////image from apps local storage
            //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appdata:///local/redWide.png");
            //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");
            ((XmlElement)tileImageAttributes[0]).SetAttribute("src", imgSrc);
            ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", imgAlt);

            ////image from the web
            //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "http://www.contoso.com/redWide.png");
            //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic");

            //create notifcation
            //TileNotification tileNotification = new TileNotification(tileXml);
            ScheduledTileNotification stn = new ScheduledTileNotification(tileXml, DateTimeOffset.Now.AddSeconds(8));

            //notification expires in 
            //tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);

            //forced clear notification for app
            //Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear();

            //send notification to app tile
            //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stn);

        }
Exemplo n.º 6
0
        public static void CreateSchedule()
        {
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

            string language = GlobalizationPreferences.Languages.First();
            CultureInfo cultureInfo = new CultureInfo(language);

            DateTime now = DateTime.Now;
            DateTime planTill = now.AddHours(4);

            DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
            if (plannedUpdated.Count > 0)
                updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max();

            const string xml = @"<tile><visual>
                                        <binding template=""TileSquareText02""><text id=""1"">{0}</text><text id=""2"">{1}</text></binding>
                                        <binding template=""TileWideText01""><text id=""1"">{0}</text><text id=""2"">{1}</text><text id=""3""></text><text id=""4""></text><text id=""5""></text></binding>
                                   </visual></tile>";

            var tileXmlNow = string.Format(xml, now.ToString(cultureInfo.DateTimeFormat.ShortTimePattern), now.ToString(cultureInfo.DateTimeFormat.LongDatePattern));
            XmlDocument documentNow = new XmlDocument();
            documentNow.LoadXml(tileXmlNow);

            tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });

            for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
            {
                Debug.WriteLine(startPlanning);
                Debug.WriteLine(planTill);

                try
                {
                    var tileXml = string.Format(xml, startPlanning.ToString(cultureInfo.DateTimeFormat.ShortTimePattern), startPlanning.ToString(cultureInfo.DateTimeFormat.LongDatePattern));
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(tileXml);

                    ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
                    tileUpdater.AddToSchedule(scheduledNotification);

                    Debug.WriteLine("schedule for: " + startPlanning);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("exception: " + e.Message);
                }
            }
        }
        public async static Task UpdateTile()
        {
            LatestStories l = await FileHelper.Current.ReadObjectAsync<LatestStories>("latest_stories.json");
            if (l != null)
            {
                List<string> list = l.Top_Stories.ToList().Select(s => s.Title).ToList();
                List<string> list_image = l.Top_Stories.ToList().Select(s => s.Image).ToList();
                var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                var plannedNotifications = tileUpdater.GetScheduledTileNotifications();

                DateTime now = DateTime.Now;
                DateTime updateTime = now;
                DateTime planTill = now.AddMinutes(16);

                //tile更新计划还未完全执行完毕
                if (plannedNotifications.Count > 0)
                {
                    updateTime = plannedNotifications.Select(n => n.DeliveryTime.DateTime).Max();
                }

                int index = 0;

                //制定tile更新的计划
                for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddSeconds(15))
                {
                    try
                    {
                        var tilexml = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();
                        tilexml.Image.Src = list_image[index % 5];
                        tilexml.TextHeading.Text = "知乎日报UWP";
                        tilexml.TextBodyWrap.Text = list[index % 5];
                        index++;

                        ScheduledTileNotification stn = new ScheduledTileNotification(tilexml.GetXml(), startPlanning);
                        stn.ExpirationTime = startPlanning.AddSeconds(12);

                        tileUpdater.AddToSchedule(stn);
                    }
                    catch
                    {

                    }
                }
            }
        }
        /// <summary>
        /// Schedule a local toast notification.  Notification will also appear in the Notification Center on Windows Phone 8.1.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        /// <param name="id">Id of the notification</param>
        /// <param name="notifyTime">Time to show notification</param>
        public void Show(string title, string body, int id, DateTime notifyTime)
        {
            var xmlData = string.Format(_TOAST_TEXT02_TEMPLATE, title, body);

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlData);

            var correctedTime = notifyTime <= DateTime.Now
              ? DateTime.Now.AddMilliseconds(100)
              : notifyTime;

            var scheduledTileNotification = new ScheduledTileNotification(xmlDoc, correctedTime)
            {
                Id = id.ToString()
            };

            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTileNotification);
        }
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            ITileWide310x150Text09 instance_any_name = TileContentFactory.CreateTileWide310x150Text09();

            instance_any_name.TextHeading.Text = "Hello WideTile";
            instance_any_name.TextBodyWrap.Text = "Contenttext";

            ITileSquare150x150Text04 instance_name = TileContentFactory.CreateTileSquare150x150Text04();
            instance_name.TextBodyWrap.Text = "Content inthe 150X150 tile";
            instance_any_name.Square150x150Content = instance_name;

            ScheduledTileNotification GiveitTime = new ScheduledTileNotification(instance_any_name.GetXml(), DateTime.Now.AddSeconds(15));
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(GiveitTime);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 更新头条文章的磁贴tile
        /// </summary>
        /// <param name="t"></param>
        private static void UpdateTile(LatestStories t)
        {
            //头5条 循环更新到tile中
            List<string> list = t.Top_Stories.ToList().Select(s => s.Title).ToList();
            List<string> list_image = t.Top_Stories.ToList().Select(s => s.Image).ToList();

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedNotifications = tileUpdater.GetScheduledTileNotifications();

            DateTime now = DateTime.Now;
            DateTime updateTime = now;
            DateTime planTill = now.AddMinutes(60);  //每次制定1小时的tile更新计划

            //删除还未执行的计划
            if (plannedNotifications.Count > 0)
            {
                plannedNotifications.ToList().ForEach(s => tileUpdater.RemoveFromSchedule(s));
            }

            int index = 0;
            int count = list.Count;

            //制定tile更新的计划
            for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddSeconds(10))
            {
                try
                {
                    var tilexml = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();
                    tilexml.Image.Src = list_image[index % count];
                    tilexml.TextHeading.Text = "知乎日报UWP";
                    tilexml.TextBodyWrap.Text = list[index % count];
                    index++;

                    ScheduledTileNotification stn = new ScheduledTileNotification(tilexml.GetXml(), startPlanning);
                    stn.ExpirationTime = startPlanning.AddSeconds(8);

                    tileUpdater.AddToSchedule(stn);
                }
                catch
                {

                }
            }
        }
      /// <summary>
      /// Notifies the specified notification.
      /// </summary>
      /// <param name="notification">The notification.</param>
      public void Notify(LocalNotification notification)
      {
          var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02);

          var tileTitle = tileXml.GetElementsByTagName("text");
          ((XmlElement)tileTitle[0]).InnerText = notification.Title;
          ((XmlElement)tileTitle[1]).InnerText = notification.Text;

          var correctedTime = notification.NotifyTime <= DateTime.Now
              ? DateTime.Now.AddMilliseconds(100)
              : notification.NotifyTime;

          var scheduledTileNotification = new ScheduledTileNotification(tileXml, correctedTime)
          {
              Id = notification.Id.ToString()
          };

          TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTileNotification);
      }
    public void Add(ref ListBox display, string value, TimeSpan occurs)
    {
        DateTime when = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
            occurs.Hours, occurs.Minutes, occurs.Seconds);
        if (when > DateTime.Now)
        {
            StringBuilder template = new StringBuilder();
            template.Append("<tile><visual version=\"4\">");
            template.Append("<binding template=\"TileSquare150x150Text03\">");
            template.AppendFormat("<text id=\"1\">{0}</text>", value);
            template.AppendFormat("<text id=\"2\">{0}</text>", when.ToLocalTime().ToString("HH:mm"));
            template.Append("</binding></visual></tile>");
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(template.ToString());

            ScheduledTileNotification tile = new ScheduledTileNotification(xml, when);
            tile.Id = random.Next(1, 100000000).ToString();
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(tile);
            display.Items.Add(new Item { Id = tile.Id, Content = value, Time = when.ToString() });
        }
    }
Exemplo n.º 13
0
        /// <summary>
        /// Appends a wide tile with a big block of text. Used to display up-coming buses.
        /// </summary>
        public void AppendTileWithBlockTextAndLines(DateTimeOffset scheduledTime, string blockText, string subBlockText, string text1 = null, string text2 = null, string text3 = null, string text4 = null)
        {
            //<tile>
            //  <visual>
            //    <binding template="TileWideBlockAndText01">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //      <text id="3">Text Field 3</text>
            //      <text id="4">Text Field 4</text>
            //      <text id="5">T5</text>
            //      <text id="6">Text Field 6</text>
            //    </binding>  
            //  </visual>
            //</tile>
            var document = new XmlDocument();
            var rootElement = document.CreateElement("tile");
            document.AppendChild(rootElement);

            XmlElement visualElement = document.CreateElement("visual");
            rootElement.AppendChild(visualElement);

            XmlElement wideBindingElement = document.CreateElement("binding");
            wideBindingElement.SetAttribute("template", "TileWideBlockAndText01");
            visualElement.AppendChild(wideBindingElement);

            string[] wideTexts = new string[]
            {
                text1,
                text2,
                text3,
                text4,
                blockText,
                subBlockText,
            };

            for (int i = 0; i < wideTexts.Length; i++)
            {
                string text = wideTexts[i];
                if (!string.IsNullOrEmpty(text))
                {
                    XmlElement textElement = document.CreateElement("text");
                    textElement.SetAttribute("id", (i + 1).ToString());
                    textElement.InnerText = text;
                    wideBindingElement.AppendChild(textElement);
                }
            }

            // Unfortunately, there is only one small tile template that supports block text.
            //<tile>
            //  <visual>
            //    <binding template="TileSquareBlock">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //    </binding>  
            //  </visual>
            //</tile>
            XmlElement smallBindingElement = document.CreateElement("binding");
            smallBindingElement.SetAttribute("template", "TileSquareBlock");
            visualElement.AppendChild(smallBindingElement);

            XmlElement smallBlockTextElement = document.CreateElement("text");
            smallBlockTextElement.SetAttribute("id", "1");
            smallBlockTextElement.InnerText = blockText;
            smallBindingElement.AppendChild(smallBlockTextElement);

            XmlElement smallSubTextElement = document.CreateElement("text");
            smallSubTextElement.SetAttribute("id", "2");
            smallSubTextElement.InnerText = text1;
            smallBindingElement.AppendChild(smallSubTextElement);

            if ((scheduledTime - DateTime.Now).TotalMinutes < 1)
            {
                var notification = new TileNotification(document);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (text1 + text2 + text3 + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.Update(notification);
            }
            else
            {
                var notification = new ScheduledTileNotification(document, scheduledTime);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (text1 + text2 + text3 + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.AddToSchedule(notification);
            }
        }
        public static void CreateSchedule()
        {
            appSettings = ApplicationData.Current.LocalSettings.Values;

            #region Show the date PopUp if there isn't a saved date
            if (!appSettings.ContainsKey(dateKey))
            {
                // No date is registered 
                //graduation_date = new DateTime(DateTime.Now.Year + 1, DateTime.Now.Month, DateTime.Now.Day); 
            }
            else
            {
                
                string date = appSettings[dateKey].ToString();
                var tempArray = date.Split(' ');    // Results in  tempArray[0] = xx/xx/xx
                var dateArray = tempArray[0].Split('/');
                int month = Convert.ToInt32(dateArray[0]);
                int day = Convert.ToInt32(dateArray[1]);
                int year = Convert.ToInt32(dateArray[2]);
                graduation_date = new DateTime(year, month, day);
                //Clock.WinRT.ClockTileScheduler.SetGraduationDate(year, month, day); 
            }
            #endregion 
            int CurrentYear = DateTime.Now.Year;                // Current year
            DateTime NewYear = new DateTime(DateTime.Now.Year + 1, 1, 1);       // January 1st of the next year

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

            string language = GlobalizationPreferences.Languages.First();
            CultureInfo cultureInfo = new CultureInfo(language);

            DateTime now = DateTime.Now;
            DateTime planTill = now.AddHours(4);



            DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
            if (plannedUpdated.Count > 0)
                updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new[] { updateTime }).Max();

            // Here is where I define a number of different live tiles 
            // This is the special tile that will display on Christmas day 
            const string Christmas_xml = @"<tile><visual>
                                        <binding template=""TileSquareText04""><text id=""1"">Merry Christmas!</text></binding>
                                        <binding template=""TileWideText03""><text id=""1"">Merry Christmas!</text></binding>
                                </visual></tile>";

            // Tile 1: XX days until Christmas!
            const string xml = @"<tile><visual>
                                        <binding template=""TileSquareText01""><text id=""1"">{0}</text><text id=""2"">until graduation!</text></binding>
                                        <binding template=""TileWideText01""><text id=""1"">{0}</text><text id=""2"">until graduation!</text></binding>
                                </visual></tile>";


            // Tile 2: XX days, YY hours until Christmas! 
            const string xml_2 = @"<tile><visual>
                                        <binding template=""TileSquareText01"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                        </binding>
                                        <binding template=""TileWideText05"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                        </binding>
                                </visual></tile>";

            // Tile 3: XX days, YY hours, ZZ minutes until Christmas!
            const string xml_3 = @"<tile><visual>
                                        <binding template=""TileSquareText01"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                            <text id=""4"">until Christmas!</text>
                                        </binding>
                                        <binding template=""TileWideText05"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                            <text id=""4"">until Christmas!</text>
                                        </binding>
                                </visual></tile>";

          
            var timeLeft = graduation_date - DateTime.Now;
            var tileXmlCountdown = "";
            if (Live_Tile_Style == 1)
            {
                tileXmlCountdown = string.Format(xml, timeLeft.Days.ToString() + " days");
            }
            else if (Live_Tile_Style == 2)
            {
                tileXmlCountdown = string.Format(xml_2, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour" : timeLeft.Hours.ToString() + " hours", "until Christmas!");
            }
            else if (Live_Tile_Style == 3)
            {
                tileXmlCountdown = string.Format(xml_3, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour," : timeLeft.Hours.ToString() + " hours,", timeLeft.Minutes == 1 ? timeLeft.Minutes.ToString() + " minute" : timeLeft.Minutes.ToString() + " minutes");
            }
            else    // default to style 1 
            {
                tileXmlCountdown = string.Format(xml, timeLeft.Days.ToString() + " days");
            }

            if (timeLeft.Days < 0)
                tileXmlCountdown = "No graduation date set."; 


            XmlDocument documentNow = new XmlDocument();
            documentNow.LoadXml(tileXmlCountdown);

            tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });

            for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
            {
                Debug.WriteLine(startPlanning);
                Debug.WriteLine(planTill);

                try
                {

                    var tileXml = "";
                    if (Live_Tile_Style == 1)
                    {
                        tileXml = string.Format(xml, timeLeft.Days.ToString() + " days");
                    }
                    else if (Live_Tile_Style == 2)
                    {
                        tileXml = string.Format(xml_2, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour" : timeLeft.Hours.ToString() + " hours", "until Christmas!");
                    }
                    else if (Live_Tile_Style == 3)
                    {
                        tileXml = string.Format(xml_3, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour," : timeLeft.Hours.ToString() + " hours,", timeLeft.Minutes == 1 ? timeLeft.Minutes.ToString() + " minute" : timeLeft.Minutes.ToString() + " minutes");
                    }

                    if (timeLeft.Days < 0)
                        tileXml = "No graduation date set."; 
                    
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(tileXml);

                    ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
                    tileUpdater.AddToSchedule(scheduledNotification);

                    Debug.WriteLine("schedule for: " + startPlanning);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("exception: " + e.Message);
                }
            }
        }
Exemplo n.º 15
0
        public static void CreateSchedule()
        {
            if (TileModels == null)
            {
                TileModels = new Dictionary<string, string>(ServiceManager.TileModels);
            }


            //foreach (SiteModel siteModel in ServiceManager.Sites)
            //{
            //    foreach (PageModel pageModel in siteModel.Pages)
            //    {
            //        foreach (var itemModel in pageModel.Items)
            //        {
            //            if (!string.IsNullOrEmpty(itemModel.ImagePath))
            //            {
            //                TileModels.AddSafe(itemModel.Title, itemModel.ImagePath);
            //            }
            //        }
            //    }
            //}

            try
            {

                var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

                string language = GlobalizationPreferences.Languages.First();
                CultureInfo cultureInfo = new CultureInfo(language);

                DateTime now = DateTime.Now;
                DateTime planTill = now.AddHours(4);

                DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
                if (plannedUpdated.Count > 0)
                    updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new[] {updateTime}).Max();


                const string xml = @"<tile><visual version=""2"" addImageQuery=""true"">
                                        <binding template=""TileSquare150x150Image"" fallback=""TileSquareImage"">
                                          <image id=""1"" src=""{0}"" alt=""{1}"" />
                                        </binding>
                                        <binding template=""TileWide310x150ImageAndText01"" fallback=""TileWideImageAndText01"">
                                          <image id=""1"" src=""{0}"" alt=""{1}"" />
                                          <text id=""1"">{1}</text>
                                        </binding>
                                        <binding template=""TileSquare310x310Image"">
                                          <image id=""1"" src=""{0}"" alt=""{1}"" />
                                        </binding>
                                   </visual></tile>";
                foreach (var tileModel in TileModels)
                {
                    var tileXmlNow = string.Format(xml, tileModel.Value, tileModel.Key);
                    XmlDocument documentNow = new XmlDocument();
                    documentNow.LoadXml(tileXmlNow);

                    tileUpdater.Update(new TileNotification(documentNow)
                    {
                        ExpirationTime = now.AddMinutes(1)
                    });

                    for (var startPlanning = updateTime;
                        startPlanning < planTill;
                        startPlanning = startPlanning.AddMinutes(1))
                    {
                        Debug.WriteLine(startPlanning);
                        Debug.WriteLine(planTill);

                        try
                        {
                            var tileXml = string.Format(xml, tileModel.Value, tileModel.Key);
                            XmlDocument document = new XmlDocument();
                            document.LoadXml(tileXml);

                            ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document,
                                new DateTimeOffset(startPlanning))
                            {
                                ExpirationTime = startPlanning.AddMinutes(1)
                            };
                            tileUpdater.AddToSchedule(scheduledNotification);

                            Debug.WriteLine("schedule for: " + startPlanning);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("exception: " + e.Message);
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 16
0
        // Tile
        public void showTile()
        {
            XmlDocument smallTileData = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText02);
            XmlNodeList smallTextData = smallTileData.GetElementsByTagName("text");
            XmlNodeList smallImageData = smallTileData.GetElementsByTagName("image");

            smallTextData[0].InnerText = postsList.ElementAt(0).brief;
            smallTextData[1].InnerText = postsList.ElementAt(0).date; 
            ((XmlElement)smallImageData[0]).SetAttribute("src", "ms-appx:///"+postsList.ElementAt(0).imageUrl);
//            ((XmlElement)smallImageData[0]).SetAttribute("src", "ms-appx:///Assets/Logo.jpg");
            ((XmlElement)smallImageData[0]).SetAttribute("alt", "red graphic");

            //宽版
//            XmlDocument wideTileData = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150BlockAndText01);
//            XmlNodeList wideTextData = smallTileData.GetElementsByTagName("text");
//            XmlNodeList wideImageData = smallTileData.GetElementsByTagName("image"); 
//            wideTextData[0].InnerText = postsList.ElementAt(0).brief;
//            wideTextData[1].InnerText = postsList.ElementAt(0).date;
//            ((XmlElement)wideImageData[0]).SetAttribute("src", "ms-appx:///" + postsList.ElementAt(0).imageUrl);
////            ((XmlElement)wideImageData[0]).SetAttribute("src", "ms-appx:///Assets/Wide310x150Logo.scale-100.jpg");
//            ((XmlElement)wideImageData[0]).SetAttribute("alt", "red graphic");
//            IXmlNode newNode = wideTileData.ImportNode(smallTileData.GetElementsByTagName("binding").Item(0), true);
            
            // 计划通知
            Int16 dueTimeInSeconds = 3;
            DateTime dueTime = DateTime.Now.AddSeconds(dueTimeInSeconds);
            ScheduledTileNotification scheduledTile = new ScheduledTileNotification(smallTileData, dueTime);
            scheduledTile.Id = "Future_Tile";
            //TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile);


            TileNotification notification = new TileNotification(smallTileData);
            //TileNotification notification = new TileNotification(wideTileData);
            //notification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(10);
           // TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
            //定期通知
            string polledUrl = "http://appdev.sysu.edu.cn/~mad/Tools/Test/sample.xml";
            PeriodicUpdateRecurrence recurrence = PeriodicUpdateRecurrence.HalfHour;
            System.Uri url = new System.Uri(polledUrl);

           // TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdate(url, recurrence);
        }
Exemplo n.º 17
0
         //Update tile for today
        private void UpdateTile(CalendarDataReader reader, DateTime dueTime)
        {
            int month = dueTime.Month;
            int day = dueTime.Day;
            PanchangData pdata =   reader.GetPanchangData(month, day);
             //create the wide template
            ITileWideText01 tileContent = TileContentFactory.CreateTileWideText01();
            tileContent.TextHeading.Text = dueTime.ToString("d");
            // Uncomment the following line to enable debugging
            tileContent.TextBody1.Text = pdata._fieldValues[(int)FieldType.SanskritMonth];
            tileContent.TextBody2.Text = pdata._fieldValues[(int)FieldType.TamilMonth];
            tileContent.TextBody3.Text = pdata._fieldValues[(int)FieldType.Festival];

             //create the square template and attach it to the wide template
            ITileSquareText01 squareContent = TileContentFactory.CreateTileSquareText01();
            squareContent.TextHeading.Text = dueTime.ToString("d");
            squareContent.TextBody1.Text = pdata._fieldValues[(int)FieldType.SanskritMonth];
            squareContent.TextBody2.Text = pdata._fieldValues[(int)FieldType.TamilMonth];
            squareContent.TextBody3.Text = pdata._fieldValues[(int)FieldType.Festival];
            tileContent.SquareContent = squareContent;


            if (dueTime > DateTime.Now)
            {
                ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
            }
            else
            {
                //send the notification
                //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
            }

             //Send another notification. this gives a nice animation in mogo
            tileContent.TextBody1.Text = pdata._fieldValues[(int)FieldType.Paksha];
            tileContent.TextBody2.Text = pdata._fieldValues[(int)FieldType.Tithi];
            tileContent.TextBody3.Text = pdata._fieldValues[(int)FieldType.Nakshatra];

            if (dueTime > DateTime.Now)
            {
                ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
            }
            else
            {
                //send the notification
                //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Appends a wide tile with a big block of text. Used to display up-coming buses.
        /// </summary>
        public void AppendTileWithBlockTextAndLines(DateTimeOffset scheduledTime, string blockText, string statusText, string busName, string tripHeadsign, string stopName, string scheduledArrivalTime, string predictedArrivalTime)
        {
            //<tile>
            //  <visual>
            //    <binding template="TileWideBlockAndText01">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //      <text id="3">Text Field 3</text>
            //      <text id="4">Text Field 4</text>
            //      <text id="5">T5</text>
            //      <text id="6">Text Field 6</text>
            //    </binding>  
            //  </visual>
            //</tile>
            var document = new XmlDocument();
            var rootElement = document.CreateElement("tile");
            document.AppendChild(rootElement);

            XmlElement visualElement = document.CreateElement("visual");
            visualElement.SetAttribute("version", "2");
            rootElement.AppendChild(visualElement);

            // Support large tiles for Win 8.1 and higher:
            //<visual version="2">
            //  <binding template="TileSquare310x310BlockAndText01">
            //    <text id="1">Text Field 1 (large text)</text>
            //    <text id="2">Text Field 2</text>
            //    <text id="3">Text Field 3</text>
            //    <text id="4">Text Field 4</text>
            //    <text id="5">Text Field 5</text>
            //    <text id="6">Text Field 6</text>
            //    <text id="7">Text Field 7</text>
            //    <text id="8">Text Field 8 (block text)</text>
            //    <text id="9">Text Field 9</text>
            //  </binding>  
            //</visual>
            XmlElement largeBindingElement = document.CreateElement("binding");
            largeBindingElement.SetAttribute("template", "TileSquare310x310BlockAndText01");

            AddSubTextElements(largeBindingElement, new string[]
            {
                busName,
                tripHeadsign,
                stopName,
                "SCHED / ETA",
                string.Format("{0} / {1}", scheduledArrivalTime, predictedArrivalTime),
                string.Empty,
                string.Empty,
                blockText,
                statusText,
            });

            visualElement.AppendChild(largeBindingElement);


            XmlElement wideBindingElement = document.CreateElement("binding");            
            wideBindingElement.SetAttribute("template", "TileWide310x150BlockAndText01");
            wideBindingElement.SetAttribute("fallback", "TileWideBlockAndText01");
            visualElement.AppendChild(wideBindingElement);

            AddSubTextElements(wideBindingElement, new string[]
            {
                busName,
                tripHeadsign,
                stopName,
                string.Format("{0} / {1}", scheduledArrivalTime, predictedArrivalTime),
                blockText,
                statusText,
            });

            // Unfortunately, there is only one small tile template that supports block text.
            //<tile>
            //  <visual>
            //    <binding template="TileSquareBlock">
            //      <text id="1">Text Field 1</text>
            //      <text id="2">Text Field 2</text>
            //    </binding>  
            //  </visual>
            //</tile>
            XmlElement smallBindingElement = document.CreateElement("binding");
            smallBindingElement.SetAttribute("template", "TileSquare150x150Block");
            smallBindingElement.SetAttribute("fallback", "TileSquareBlock");
            visualElement.AppendChild(smallBindingElement);

            XmlElement smallBlockTextElement = document.CreateElement("text");
            smallBlockTextElement.SetAttribute("id", "1");
            smallBlockTextElement.InnerText = blockText;
            smallBindingElement.AppendChild(smallBlockTextElement);

            XmlElement smallSubTextElement = document.CreateElement("text");
            smallSubTextElement.SetAttribute("id", "2");
            smallSubTextElement.InnerText = busName;
            smallBindingElement.AppendChild(smallSubTextElement);

            if ((scheduledTime - DateTime.Now).TotalMinutes < 1)
            {
                var notification = new TileNotification(document);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (busName + tripHeadsign + stopName + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.Update(notification);
            }
            else
            {
                var notification = new ScheduledTileNotification(document, scheduledTime);
                notification.ExpirationTime = scheduledTime.AddMinutes(1);
                notification.Tag = (busName + tripHeadsign + stopName + scheduledTime.ToString("hh:mm")).GetHashCode().ToString("X");
                this.tileUpdater.AddToSchedule(notification);
            }
        }
        void SetupTiles(List<int> durationList)
        {
            try
            {
                if (durationList.Count > 0)
                {
                    DateTimeOffset time = DateTime.Now.AddMinutes(durationList[0]);

                    //Windows.UI.Notifications.ScheduledToastNotification stf = new ScheduledToastNotification(GetTile(durationList.Count.ToString()), time);
                    //time.Add(new TimeSpan(0, 0, 0, durationList[0], 0));
                    //TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stf);

                    Windows.UI.Notifications.ScheduledTileNotification stf = new ScheduledTileNotification(GetTile(durationList.Count.ToString()), time);
                    //time.Add(new TimeSpan(0, 0, 0, durationList[0], 0));
                    TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stf);
                }
            }
            catch (Exception ex)
            {
                //new MessageDialog(ex.Message).ShowAsync();
            }
        }
Exemplo n.º 20
0
        public static void CreateSchedule()
        {
            StaticBinaryTime bTime = new StaticBinaryTime(DateTime.Now);

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

            DateTime now = DateTime.Now;
            //更新时间上限
            //DateTime planTill = now.AddHours(4);
            DateTime planTill = now.AddMinutes(20);

            //第一次计划更新从下一分钟整点开始
            DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
            if (plannedUpdated.Count > 0)
            {
                updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new[] { updateTime }).Max();
            }

            //TILE样式选择
            const string xml = @"<tile><visual>
                                        <binding template=""TileSquareText01""><text id=""1"">{1}</text><text id=""2"">{2}</text><text id=""3""></text><text id=""4"">{3}</text></binding>
                                        <binding template=""TileWideText01""><text id=""1"">{4}</text><text id=""2"">{5}</text><text id=""3""></text><text id=""4"">{3}</text><text id=""5""></text></binding>
                                   </visual></tile>";

            //初次更新内容
            var tileXmlNow = string.Format(xml,
                bTime.Day, //DAY
                bTime.HourHigh + " " + bTime.HourLow, //小时
                bTime.MinuteHigh + " " + bTime.MinuteLow, //分钟
                "Binary Clock", //名称
                bTime.HourHigh + " " + bTime.HourLow + " : " + bTime.MinuteHigh + " " + bTime.MinuteLow, //小时:分钟
                bTime.Day + " / " + bTime.Month);//DAY/MONTH
            //生成XML文件
            XmlDocument documentNow = new XmlDocument();
            documentNow.LoadXml(tileXmlNow);

            //初次更新,1分钟后失效
            tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });

            //计划更新,间隔为1分钟
            for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
            {
                try
                {
                    //计划开始时间
                    bTime.Set(startPlanning);
                    //计划更新内容
                    var tileXml = string.Format(xml, bTime.Day, bTime.HourHigh + " " + bTime.HourLow, bTime.MinuteHigh + " " + bTime.MinuteLow, "Binary Clock", bTime.HourHigh + " " + bTime.HourLow + " : " + bTime.MinuteHigh + " " + bTime.MinuteLow, bTime.Day + "/" + bTime.Month);
                    //生成XML文件
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(tileXml);

                    //计划更新失效时间1分钟
                    ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
                    //加入计划更新列表
                    tileUpdater.AddToSchedule(scheduledNotification);
                }
                catch (Exception)
                {
                    //do nothing
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {

            //SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
            
            //TileUpdateManager.CreateTileUpdaterForApplication().
            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            var rootFrame = new Frame();
            SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

            if (rootFrame.Content == null)
            {
                var lang = GlobalizationPreferences.Languages[0];
                var week = new Week(lang);
                
                var t = TileUpdateManager.CreateTileUpdaterForApplication();

                var xmlString = string.Format(@"<tile><visual branding='logo'>
                <binding template='TileWideBlockAndText02'><text id='1'>{0}</text><text id='2'>{1}</text><text id='3'></text></binding>
                <binding template='TileSquareBlock'><text id='1'>{1}</text><text id='2'>{2}</text></binding></visual></tile>",
                              week.GetYearMonthAndDayFormatted(DateTime.Today),
                              week.GetWeekNumberFromDate(DateTime.Today).ToString(),
                              week.DayAndMonthStringFromDate(DateTime.Today));
                var xml = new XmlDocument();
                xml.LoadXml(xmlString);
                var scheduledTileWide = new ScheduledTileNotification(xml, DateTime.Now.AddSeconds(1));
                t.AddToSchedule(scheduledTileWide);

                t.StartPeriodicUpdate(new Uri("http://weeknumber.apphb.com/TileWideBlockAndText02.aspx?culture=" + lang), PeriodicUpdateRecurrence.HalfHour);


                    //var badgeXml = Notifications.BadgeUpdateManager.getTemplateContent(Notifications.BadgeTemplateType.badgeNumber);
                    //var badgeAttributes = badgeXml.getElementsByTagName("badge");
                    //badgeAttributes[0].setAttribute("value", "7");

                    //BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);
                    //var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
                    //badgeXml.DocumentElement.SetAttribute("value","3");
                    //badgeAttributes[0].NodeValue = 7;
                
                //LockScreenUpdateManager

                  //  BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeXml));

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(GroupedItemsPage)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
        private void ScheduleTileUpdate(DateTime baseTime, TimeSpan shift, TileUpdater tileUpdater, ClockFormat clockFormat)
        {
            var shiftedTime = baseTime.Add(shift);
            var interval = 60/_baseDateTimes.Count();
            var i = 0;
            var calculatedCitiesInfo = _baseDateTimes.Select(c => new CalculatedCityInfo { CityInfo = c.Key, DestinationTime = c.Value.Add(shift) }).ToList();
            foreach (var info in calculatedCitiesInfo)
            {
                var tileXmlNow = GetTileUpdateMessage(info, calculatedCitiesInfo, _baseDateTimes.Count(), clockFormat);
                var document = new XmlDocument();
                document.LoadXml(tileXmlNow);

                var deliveryTime = shiftedTime.AddSeconds(i * interval);
                if (deliveryTime <= DateTime.Now)
                {
                    tileUpdater.Update(new TileNotification(document) { ExpirationTime = shiftedTime.AddSeconds(interval) });
                }
                else
                {
                    var scheduledNotification = new ScheduledTileNotification(document, deliveryTime) { ExpirationTime = deliveryTime.AddSeconds(interval) };
                    tileUpdater.AddToSchedule(scheduledNotification);
                }
                i++;
            }
        }
        void ScheduleTile(String updateString, DateTime dueTime, int idNumber)
        {
            // Set up the wide tile text
            ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09();
            tileContent.TextHeading.Text = updateString;
            tileContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime();

            // Set up square tile text
            ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04();
            squareContent.TextBodyWrap.Text = updateString;

            tileContent.Square150x150Content = squareContent;

            // Create the notification object
            ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);
            futureTile.Id = "Tile" + idNumber;

            // Add to schedule
            // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId)
            // See "Tiles" sample for more details
            TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
            rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage);
        }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            TimeSpan ts = Christmas - DateTime.Now;
            int days = ts.Days;
            int hours = ts.Hours;
            int minutes = ts.Minutes; 

            // Setup live tile 
            // Check to see if tile updating is enabled
            var tile = TileUpdateManager.CreateTileUpdaterForApplication();
            if (tile.Setting != NotificationSetting.Enabled)
                return;

            App.Live_Tile_Style = 0; // Convert.ToInt32(appSettings["LiveTileStyle"]); 

            switch (App.Live_Tile_Style)
            {

                case 0:
                    var tilecontent = TileContentFactory.CreateTileWideText01();
                    tilecontent.TextHeading.Text = days.ToString() + " days";
                    tilecontent.TextBody1.Text = "until Christmas!"; 
                    ITileSquareText01 squarecontent = TileContentFactory.CreateTileSquareText01(); 
                    squarecontent.TextHeading.Text = days + " days";
                    squarecontent.TextBody1.Text = "until Christmas!";
                    tilecontent.SquareContent = squarecontent; 
                    ScheduledTileNotification scheduledTile = new ScheduledTileNotification(tilecontent.GetXml(), DateTime.Now.AddSeconds(10));
                    var tileupdater = TileUpdateManager.CreateTileUpdaterForApplication();
                    tileupdater.EnableNotificationQueue(true);
                    tileupdater.AddToSchedule(scheduledTile); 
                    break;
                case 1:
                    var tilecontent2 = TileContentFactory.CreateTileWideText05();
                    tilecontent2.TextBody1.Text = days.ToString() + " days";
                    tilecontent2.TextBody2.Text = hours.ToString() + " hours"; 
                    tilecontent2.TextBody3.Text = "until Christmas!";
                    ITileSquareText01 squarecontent2 = TileContentFactory.CreateTileSquareText01(); 
                    squarecontent2.TextHeading.Text = days.ToString() + " days";
                    squarecontent2.TextBody1.Text = hours.ToString() + " hours"; 
                    squarecontent2.TextBody2.Text = "until Christmas!";
                    
                    tilecontent2.SquareContent = squarecontent2; 
                    ScheduledTileNotification scheduledTile2 = new ScheduledTileNotification(tilecontent2.GetXml(), DateTime.Now.AddSeconds(10));
                    var tileupdater2 = TileUpdateManager.CreateTileUpdaterForApplication();
                    tileupdater2.EnableNotificationQueue(true);
                    tileupdater2.AddToSchedule(scheduledTile2); 
                    break;
                case 2:
                    var tilecontent3 = TileContentFactory.CreateTileWideText05();
                    tilecontent3.TextBody1.Text = days.ToString() + " days";
                    tilecontent3.TextBody2.Text = hours.ToString() + " hours";
                    tilecontent3.TextBody3.Text = minutes.ToString() + " minutes";
                    tilecontent3.TextBody4.Text = "until Christmas!";
                    ITileSquareText01 squarecontent3 = TileContentFactory.CreateTileSquareText01();
                    squarecontent3.TextHeading.Text = days.ToString() + " days";
                    squarecontent3.TextBody1.Text = hours.ToString() + " hours";
                    squarecontent3.TextBody2.Text = minutes.ToString() + " minutes";
                    squarecontent3.TextBody3.Text = "until Christmas!";

                    tilecontent3.SquareContent = squarecontent3; 
                    ScheduledTileNotification scheduledTile3 = new ScheduledTileNotification(tilecontent3.GetXml(), DateTime.Now.AddSeconds(10));
                    var tileupdater3 = TileUpdateManager.CreateTileUpdaterForApplication();
                    tileupdater3.EnableNotificationQueue(true);
                    tileupdater3.AddToSchedule(scheduledTile3); 
                    break;
                default:
                    var tilecontent1 = TileContentFactory.CreateTileWideText01();
                    tilecontent1.TextHeading.Text = days.ToString() + " days";
                    tilecontent1.TextBody1.Text = "until Christmas!"; 
                    ITileSquareText01 squarecontent1 = TileContentFactory.CreateTileSquareText01(); 
                    squarecontent1.TextHeading.Text = days + " days";
                    squarecontent1.TextBody1.Text = "until Christmas!";
                    tilecontent1.SquareContent = squarecontent1; 
                    ScheduledTileNotification scheduledTile1 = new ScheduledTileNotification(tilecontent1.GetXml(), DateTime.Now.AddSeconds(10));
                    var tileupdater1 = TileUpdateManager.CreateTileUpdaterForApplication();
                    tileupdater1.EnableNotificationQueue(true);
                    tileupdater1.AddToSchedule(scheduledTile1); 
                    break;
            }

            base.OnNavigatedFrom(e);

            CreateClockTask();
        }
        static int Live_Tile_Style = 1; // Used to change which live tile style is shown

        #endregion Fields

        #region Methods

        public static void CreateSchedule()
        {
            int CurrentYear = DateTime.Now.Year;                // Current year
            DateTime NewYear = new DateTime(DateTime.Now.Year + 1, 1, 1);       // January 1st of the next year

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

            string language = GlobalizationPreferences.Languages.First();
            CultureInfo cultureInfo = new CultureInfo(language);

            DateTime now = DateTime.Now;
            DateTime planTill = now.AddHours(4);

            DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
               if (plannedUpdated.Count > 0)
                updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max();

            // Here is where I define a number of different live tiles
            // This is the special tile that will display on Christmas day
            const string Christmas_xml = @"<tile><visual>
                                        <binding template=""TileSquareText04""><text id=""1"">Merry Christmas!</text></binding>
                                        <binding template=""TileWideText03""><text id=""1"">Merry Christmas!</text></binding>
                                </visual></tile>";

            // Tile 1: XX days until Christmas!
            const string xml = @"<tile><visual>
                                        <binding template=""TileSquareText01""><text id=""1"">{0} days</text><text id=""2"">until Christmas!</text></binding>
                                        <binding template=""TileWideText01""><text id=""1"">{0}</text><text id=""2"">days until Christmas!</text></binding>
                                </visual></tile>";

            // Tile 2: XX days, YY hours until Christmas!
            const string xml_2 = @"<tile><visual>
                                        <binding template=""TileSquareText01"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                        </binding>
                                        <binding template=""TileWideText05"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                        </binding>
                                </visual></tile>";

            // Tile 3: XX days, YY hours, ZZ minutes until Christmas!
            const string xml_3 = @"<tile><visual>
                                        <binding template=""TileSquareText01"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                            <text id=""4"">until Christmas!</text>
                                        </binding>
                                        <binding template=""TileWideText05"">
                                            <text id=""1"">{0}</text>
                                            <text id=""2"">{1}</text>
                                            <text id=""3"">{2}</text>
                                            <text id=""4"">until Christmas!</text>
                                        </binding>
                                </visual></tile>";

            DateTime christmas = new DateTime(DateTime.Today.Year, 12, 25);
            if (DateTime.Now.Date > christmas.Date && DateTime.Now.Date < NewYear.Date)
            {
                christmas = new DateTime(NewYear.Year, 12, 25);
            }
            var timeLeft = christmas - DateTime.Now;
            var tileXmlCountdown = "";
            if (DateTime.Now.Date == christmas.Date)
            {
                tileXmlCountdown = string.Format(Christmas_xml);
            }
            else if (Live_Tile_Style == 1)
            {
                tileXmlCountdown = string.Format(xml, timeLeft.Days.ToString());
            }
            else if (Live_Tile_Style == 2)
            {
                tileXmlCountdown = string.Format(xml_2, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour" : timeLeft.Hours.ToString() + " hours", "until Christmas!");
            }
            else if(Live_Tile_Style == 3)
            {
                tileXmlCountdown = string.Format(xml_3, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour," : timeLeft.Hours.ToString() + " hours,", timeLeft.Minutes == 1 ? timeLeft.Minutes.ToString() + " minute" : timeLeft.Minutes.ToString() + " minutes");
            }
            else    // default to style 1
            {
                tileXmlCountdown = string.Format(xml, timeLeft.Days.ToString());
            }

            XmlDocument documentNow = new XmlDocument();
            documentNow.LoadXml(tileXmlCountdown);

            tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });

            for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
            {
                Debug.WriteLine(startPlanning);
                Debug.WriteLine(planTill);

                try
                {

                    var tileXml = "";
                    if (DateTime.Now.Date == christmas.Date)
                    {
                        tileXml = string.Format(Christmas_xml);
                    }
                    else
                    {
                        if (Live_Tile_Style == 1)
                        {
                            tileXml = string.Format(xml, timeLeft.Days.ToString());
                        }
                        else if (Live_Tile_Style == 2)
                        {
                            tileXml = string.Format(xml_2, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour" : timeLeft.Hours.ToString() + " hours", "until Christmas!");
                        }
                        else if (Live_Tile_Style == 3)
                        {
                            tileXml = string.Format(xml_3, timeLeft.Days.ToString() + " days,", timeLeft.Hours == 1 ? timeLeft.Hours.ToString() + " hour," : timeLeft.Hours.ToString() + " hours,", timeLeft.Minutes == 1 ? timeLeft.Minutes.ToString() + " minute" : timeLeft.Minutes.ToString() + " minutes");
                        }
                        else    // Added this part to fix a bug, don't delete it.
                        {
                            tileXmlCountdown = string.Format(xml, timeLeft.Days.ToString());
                        }
                    }
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(tileXml);

                    ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
                    tileUpdater.AddToSchedule(scheduledNotification);

                    Debug.WriteLine("schedule for: " + startPlanning);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("exception: " + e.Message);
                }
            }
        }
        public static void CreateSchedule()
        {
            appSettings = ApplicationData.Current.LocalSettings.Values;

            if (appSettings.ContainsKey(nameKey))    // If a name is given
            {
                CountdownHasName = true;
                CountdownName = appSettings[nameKey].ToString();
            }
            else
                CountdownHasName = false;

            #region Get the date if there is one
            if (appSettings.ContainsKey(dateKey))
            {

                string date = appSettings[dateKey].ToString();
                var tempArray = date.Split(' ');    // Results in  tempArray[0] = xx/xx/xx
                var dateArray = tempArray[0].Split('/');
                int month = Convert.ToInt32(dateArray[0]);
                int day = Convert.ToInt32(dateArray[1]);
                int year = Convert.ToInt32(dateArray[2]);
                end_date = new DateTime(year, month, day);
            }
            else
            {
                // We don't have a date saved.
            }
            #endregion

            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
            var plannedUpdated = tileUpdater.GetScheduledTileNotifications();

            string language = GlobalizationPreferences.Languages.First();
            CultureInfo cultureInfo = new CultureInfo(language);

            DateTime now = DateTime.Now;
            DateTime planTill = now.AddHours(4);

            DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
            if (plannedUpdated.Count > 0)
                updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max();

            const string xml = @"<tile><visual>
                                        <binding template=""TileSquareText01""><text id=""1"">{0} days</text><text id=""2"">until {1}!</text></binding>
                                        <binding template=""TileWideText01""><text id=""1"">{0} days</text><text id=""2"">until {1}!</text><text id=""3""></text><text id=""4""></text><text id=""5""></text></binding>
                                   </visual></tile>";

            var timeLeft = end_date - DateTime.Now;
            if (timeLeft.Days > 0)
            {
                var tileXmlNow = string.Format(xml, timeLeft.Days.ToString(), CountdownName);
                XmlDocument documentNow = new XmlDocument();
                documentNow.LoadXml(tileXmlNow);

                tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });

                for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
                {
                    Debug.WriteLine(startPlanning);
                    Debug.WriteLine(planTill);

                    try
                    {
                        var tileXml = string.Format(xml, timeLeft.Days.ToString(), CountdownName);
                        XmlDocument document = new XmlDocument();
                        document.LoadXml(tileXml);

                        ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
                        tileUpdater.AddToSchedule(scheduledNotification);

                        Debug.WriteLine("schedule for: " + startPlanning);
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine("exception: " + e.Message);
                    }
                }
            }
        }
Exemplo n.º 27
0
        private async void PinMenuFlyout_Click(object sender, RoutedEventArgs e)
        {
            EventManage selectedEventManage = ((MenuFlyoutItem)sender).DataContext as EventManage;
            string EventFileTitle = selectedEventManage.EventFileTitle;
            string EventFileRemarks = selectedEventManage.EventFileRemarks;
            string EventFileDateRemain = selectedEventManage.EventFileDateRemain;
            if (Int32.Parse(EventFileDateRemain) < 0)
                EventFileDateRemain = (-Int32.Parse(EventFileDateRemain)).ToString(); ;
            string EventFileDate = selectedEventManage.EventFileDate;
            Debug.WriteLine(EventFileTitle);

            string tileId = EventFileTitle;

            if (SecondaryTile.Exists(tileId))
            {
                await new MessageDialog("已存在").ShowAsync();
            }
            else
            {
                try
                {
                    Uri square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.scale-240.png");
                    Uri square150x150Logo = new Uri("ms-appx:///Assets/Square71x71Logo.scale-240.png");
                    Uri wide310x150Logo = new Uri("ms-appx:///Assets/WideLogo.scale-240.png");
                    SecondaryTile msecondaryTile = new SecondaryTile(tileId,
                                                                    "倒数计事",
                                                                    tileId,
                                                                    square150x150Logo,
                                                                    TileSize.Wide310x150);
                    msecondaryTile.VisualElements.Wide310x150Logo = wide310x150Logo;
                    msecondaryTile.VisualElements.Square150x150Logo = square150x150Logo;
                    msecondaryTile.VisualElements.Square71x71Logo = square71x71Logo;
                    msecondaryTile.VisualElements.ShowNameOnSquare150x150Logo = false;

                    bool isPinned = await msecondaryTile.RequestCreateAsync();

                    XmlDocument wideTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150BlockAndText01);
                    XmlNodeList wideTileTextAttributes = wideTileXml.GetElementsByTagName("text");
                    wideTileTextAttributes[0].AppendChild(wideTileXml.CreateTextNode(EventFileDateRemain));
                    wideTileTextAttributes[2].AppendChild(wideTileXml.CreateTextNode(tileId));
                    if (DateTime.Now.Date < DateTime.Parse(EventFileDate))
                        wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode("剩余"));
                    else
                        wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode("已过"));
                    if (EventFileRemarks != "")
                        wideTileTextAttributes[3].AppendChild(wideTileXml.CreateTextNode(EventFileRemarks));
                    else
                        wideTileTextAttributes[3].AppendChild(wideTileXml.CreateTextNode("无备注"));



                    XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                    XmlNodeList squareTileXmlAttributes = squareTileXml.GetElementsByTagName("text");
                    squareTileXmlAttributes[0].AppendChild(squareTileXml.CreateTextNode(tileId));
                    squareTileXmlAttributes[1].AppendChild(squareTileXml.CreateTextNode(EventFileRemarks));
                    if (DateTime.Now.Date < DateTime.Parse(EventFileDate))
                        squareTileXmlAttributes[2].AppendChild(squareTileXml.CreateTextNode("剩余 " + EventFileDateRemain + " 天"));
                    else
                        squareTileXmlAttributes[2].AppendChild(squareTileXml.CreateTextNode("已过 " + EventFileDateRemain + " 天"));

                    var TileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(tileId);
                    ScheduledTileNotification wideSchedule = new ScheduledTileNotification(wideTileXml, DateTimeOffset.Now.AddSeconds(5));
                    ScheduledTileNotification squareSchedule = new ScheduledTileNotification(squareTileXml, DateTimeOffset.Now.AddSeconds(5));

                    TileUpdater.Clear();

                    TileUpdater.EnableNotificationQueue(true);
                    TileUpdater.AddToSchedule(squareSchedule);
                    TileUpdater.AddToSchedule(wideSchedule);
                }
                catch (ArgumentException) { }
            }
        }
        private void SetupTiles()
        {
            try
            {
                DateTimeOffset time = DateTime.Now.AddSeconds(30);

                for (int i = 0; i < 2; i++)
                {
                    Windows.UI.Notifications.ScheduledTileNotification stf = new ScheduledTileNotification(GetTile(i.ToString()), time);
                    time.Add(new TimeSpan(0, 0, 0, 30, 0));
                    TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stf);
                }
            }
            catch (Exception ex)
            {
                new MessageDialog(ex.Message).ShowAsync();
            }
        }
        void ScheduleTileWithStringManipulation(String updateString, DateTime dueTime, int idNumber)
        {
            string tileXmlString = "<tile>"
                         + "<visual version='2'>"
                         + "<binding template='TileWide310x150Text09' fallback='TileWideText09'>"
                         + "<text id='1'>" + updateString + "</text>"
                         + "<text id='2'>" + "Received: " + dueTime.ToLocalTime() + "</text>"
                         + "</binding>"
                         + "<binding template='TileSquare150x150Text04' fallback='TileSquareText04'>"
                         + "<text id='1'>" + updateString + "</text>"
                         + "</binding>"
                         + "</visual>"
                         + "</tile>";

            Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
            try
            {
                tileDOM.LoadXml(tileXmlString);

                // Create the notification object
                ScheduledTileNotification futureTile = new ScheduledTileNotification(tileDOM, dueTime);
                futureTile.Id = "Tile" + idNumber;

                // Add to schedule
                // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId)
                // See "Tiles" sample for more details
                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile);
                rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage);
            }
        }
Exemplo n.º 30
0
        private async void refreshTile()
        {
            IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
            var files = await applicationFolder.GetFilesAsync();
            int[] kk;
            foreach (StorageFile file in files)
            {
                tileId = file.Name.ToString();
                string text = "";
                IStorageFile storageFileRE = await applicationFolder.GetFileAsync(file.Name.ToString());
                IRandomAccessStream accessStream = await storageFileRE.OpenReadAsync();
                using (StreamReader streamReader = new StreamReader(accessStream.AsStreamForRead((int)accessStream.Size)))
                {
                    text = streamReader.ReadToEnd();
                }
                kk = DateTimeDiff.dateTimeDiff.toResult(text.Substring(text.IndexOf("!@#$%^&*") + 8), DateTime.Now.Date.ToString(), DateTimeDiff.diffResultFormat.dd);
                Debug.WriteLine(kk[0].ToString());
                string EventFileRemarks = text.Substring(0, text.IndexOf("!@#$%^&*"));
                string EventFileTitle = file.Name.ToString();
                string EventFileDateRemain = kk[0].ToString();
                string EventFileDate = text.Substring(text.IndexOf("!@#$%^&*") + 8);

                //更新磁贴
                try
                {
                    XmlDocument wideTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150BlockAndText01);
                    XmlNodeList wideTileTextAttributes = wideTileXml.GetElementsByTagName("text");
                    wideTileTextAttributes[0].AppendChild(wideTileXml.CreateTextNode(EventFileDateRemain));
                    wideTileTextAttributes[2].AppendChild(wideTileXml.CreateTextNode(tileId));
                    if (DateTime.Now.Date < DateTime.Parse(EventFileDate))
                        wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode("剩余"));
                    else
                        wideTileTextAttributes[1].AppendChild(wideTileXml.CreateTextNode("已过"));
                    if (EventFileRemarks != "")
                        wideTileTextAttributes[3].AppendChild(wideTileXml.CreateTextNode(EventFileRemarks));
                    else
                        wideTileTextAttributes[3].AppendChild(wideTileXml.CreateTextNode("无备注"));

                    XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text01);
                    XmlNodeList squareTileXmlAttributes = squareTileXml.GetElementsByTagName("text");
                    squareTileXmlAttributes[0].AppendChild(squareTileXml.CreateTextNode(tileId));
                    squareTileXmlAttributes[1].AppendChild(squareTileXml.CreateTextNode(EventFileRemarks));
                    if (DateTime.Now.Date < DateTime.Parse(EventFileDate))
                        squareTileXmlAttributes[2].AppendChild(squareTileXml.CreateTextNode("剩余 " + EventFileDateRemain + " 天"));
                    else
                        squareTileXmlAttributes[2].AppendChild(squareTileXml.CreateTextNode("已过 " + EventFileDateRemain + " 天"));


                    var TileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(tileId);
                    ScheduledTileNotification wideSchedule = new ScheduledTileNotification(wideTileXml, DateTimeOffset.Now.AddSeconds(5));
                    ScheduledTileNotification squareSchedule = new ScheduledTileNotification(squareTileXml, DateTimeOffset.Now.AddSeconds(5));
                    TileUpdater.Clear();

                    TileUpdater.EnableNotificationQueue(true);
                    TileUpdater.AddToSchedule(squareSchedule);
                    TileUpdater.AddToSchedule(wideSchedule);
                }
                catch (Exception) { }
            }
        }