Exemplo n.º 1
0
        private static void UpdateTile(string condition, string celsius, string fahrenheit)
        {
            var tile = TileUpdateManager.CreateTileUpdaterForApplication();

            if (tile.Setting != NotificationSetting.Enabled)
            {
                return;
            }

            var locationName = GetSetting("locationName");

            ITileWideText01 tileContent = TileContentFactory.CreateTileWideText01();

            tileContent.TextHeading.Text = locationName;
            tileContent.TextBody1.Text   = condition;
            tileContent.TextBody2.Text   = "Celsius: " + celsius;
            tileContent.TextBody3.Text   = "Fahrenheit: " + fahrenheit;

            ITileSquareBlock squareTileContent = TileContentFactory.CreateTileSquareBlock();

            squareTileContent.TextBlock.Text    = celsius;
            squareTileContent.TextSubBlock.Text = locationName;
            tileContent.SquareContent           = squareTileContent;

            tileContent.Branding = TileBranding.Logo;

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

            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
        //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.º 3
0
        // 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);
        }