예제 #1
0
        public async static void AddTileNotification(Memo memo)
        {
            // load xml template
            var installLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var assetsFolder    = await installLocation.GetFolderAsync("Assets");

            var tileXmlFile = await assetsFolder.GetFileAsync(tileXmlFileName);

            var xmlText = await FileIO.ReadTextAsync(tileXmlFile);

            // set title and caption
            var tileXml = new XmlDocument();

            tileXml.LoadXml(string.Format(xmlText, memo.Title, Time2String.Time2Str(memo.Time) + "\n" + memo.Content));

            var tileNotification = new TileNotification(tileXml);

            tileNotification.Tag = memo.MemoID.Substring(6, 10);

            // set expiration time
            tileNotification.ExpirationTime = memo.Time.AddMinutes(1);

            // set TileUpdater
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Update(tileNotification);
        }
예제 #2
0
        public MemoView(Memo memo)
        {
            this.InitializeComponent();
            this.Memo    = memo;
            this.Tapped += ClickToModify;

            // presentation
            this.titleTB.Text   = memo.Title;
            this.contentTB.Text = memo.Content;

            this.timeTB.Text = Time2String.Time2Str(memo.Time);
        }
예제 #3
0
        public async static void RefreshTiles(IList <Memo> allMemos)
        {
            // load xml template
            var installLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var assetsFolder    = await installLocation.GetFolderAsync("Assets");

            var tileXmlFile = await assetsFolder.GetFileAsync(tileXmlFileName);

            var xmlText = await FileIO.ReadTextAsync(tileXmlFile);

            // set TileUpdater
            var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.EnableNotificationQueue(true);

            // start time
            var startTime = DateTime.Now.AddSeconds(10);

            // temp list to add tiles, then reverse it according to the emgergency
            tileUpdater.Clear();
            var         now      = DateTime.Now;
            List <Memo> tempList = new List <Memo>();

            for (int i = 0, addCount = 0; i < allMemos.Count && addCount < 5; ++i)
            {
                Memo memo = allMemos[i];

                if (now.CompareTo(memo.Time) <= 0)
                {
                    ++addCount;
                    tempList.Add(memo);
                }
            }

            // reverse and add to schedule
            for (int i = 0; i < tempList.Count; ++i)
            {
                Memo memo = tempList[tempList.Count - 1 - i];

                // set title and caption
                var tileXml = new XmlDocument();
                tileXml.LoadXml(string.Format(xmlText, memo.Title, Time2String.Time2Str(memo.Time) + "\n" + memo.Content));

                var tileNotification = new ScheduledTileNotification(tileXml, startTime.AddSeconds(i * 10));
                tileNotification.Tag = memo.MemoID.Substring(6, 10);

                // set expiration time
                tileNotification.ExpirationTime = memo.Time.AddMinutes(1);

                tileUpdater.AddToSchedule(tileNotification);
            }
        }