//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());
            }
        }
        protected override void CreateTile()
        {
            var applicationTile = TileContentFactory.CreateTileSquareText01();
            var tileUpdater     = TileUpdateManager.CreateTileUpdaterForApplication(CoreApplication.Id);

            tileUpdater.Clear();

            applicationTile.TextHeading.Text = this.Header;
            applicationTile.TextBody1.Text   = this.Line1;
            applicationTile.TextBody2.Text   = this.Line2;
            applicationTile.TextBody3.Text   = this.Line3;

            var tileNotification = applicationTile.CreateNotification();

            tileUpdater.Update(tileNotification);
        }
        // Update tile for today
        private void UpdateTile(SampleDataItem item, DateTime dueTime, DateTime expiryTime)
        {
            DateTime date  = dueTime;
            int      month = date.Month;
            int      day   = date.Day;
            String   festival;
            var      notifier = TileUpdateManager.CreateTileUpdaterForApplication();

            Debug.WriteLine("Update tile {0} {1}", dueTime, expiryTime);
            festival = item.GetFestival(month, day);
            PanchangData pdata = item.GetPanchangData(month, day);
            // create the wide template
            ITileWideText01 tileContent = TileContentFactory.CreateTileWideText01();

            tileContent.TextHeading.Text = date.ToString("d");
            tileContent.TextBody1.Text   = pdata._fieldValues[(int)FieldType.SanskritMonth];
            tileContent.TextBody2.Text   = pdata._fieldValues[(int)FieldType.TamilMonth];
            tileContent.TextBody3.Text   = festival;

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

            squareContent.TextHeading.Text = date.ToString("d");
            squareContent.TextBody1.Text   = pdata._fieldValues[(int)FieldType.SanskritMonth];
            squareContent.TextBody2.Text   = pdata._fieldValues[(int)FieldType.TamilMonth];
            squareContent.TextBody3.Text   = festival;
            tileContent.SquareContent      = squareContent;

            // send the notification
            ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);

            futureTile.ExpirationTime = expiryTime;
            notifier.AddToSchedule(futureTile);


            // 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];
            futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime);
            futureTile.ExpirationTime = expiryTime;
            notifier.AddToSchedule(futureTile);
            Debug.WriteLine("Count of scheduled notifications {0}", notifier.GetScheduledTileNotifications().Count);
        }
Beispiel #4
0
        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();
        }