public static void Update()
        {
            try
            {
                // Application Tile is always the first Tile, even if it is not pinned to Start.
                ShellTile TileToFind = ShellTile.ActiveTiles.First();

                if (TileToFind != null)
                {
                    // Create the tile object and set some initial properties for the tile.
                    // The Count value of 12 will show the number 12 on the front of the Tile.
                    // Valid values are 1-99.
                    // A Count value of 0 will indicate that the Count should not be displayed.
                    int alarmCount = AlarmHelper.AlarmCount();
                    Alarm alarm = AlarmHelper.NearestAlarm();

                    StandardTileData NewTileData = new StandardTileData
                    {
                        BackgroundImage = new Uri("/Resources/Images/Tiles/BackgroundImage.png", UriKind.Relative),
                        Title = "Metro Calendar",
                        Count = alarmCount,
                        BackTitle = ((alarm == null) ? "Next alarm" : alarm.BeginTime.ToShortTimeString()),
                        BackContent = ((alarm == null) ? "No alarm" : alarm.Content),
                        BackBackgroundImage = new Uri("/Resources/Images/Tiles/BackBackgroundImage.png", UriKind.Relative)
                    };

                    TileToFind.Update(NewTileData);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Exemple #2
0
        public static void UpdateTile(ShellTile tile)
        {
            int id = Int32.Parse(tile.NavigationUri.OriginalString.Replace("/MainPage.xaml?tile=", ""));

            IRouteStopPair pair = App.UB.TileRegister.Get(id);

            if (pair == null)
            {
                return;
            }

            StopGroup stop  = pair.Stop;
            Route     route = pair.Route;

            DateTime now       = DateTime.Now;
            var      timeTable = App.Model.GetTimetable(route, stop, now);

            var control  = CreateTileBackgroundControl(stop, route, timeTable, now);
            Uri imageUri = GenerateTileImage(control, id + ".png");

            StandardTileData tileData = new StandardTileData
            {
                Title           = "",
                BackgroundImage = imageUri
            };

            tile.Update(tileData);

            //return true;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PinAppBtn_Click(object sender, EventArgs e)
        {
            var    dc       = (TransportsNantais.ViewModels.StopDetailsViewModel) this.DataContext;
            string tileName = "TanId=" + dc.TanId;

            // check if secondary tile is already made and pinned
            ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileName));

            if (Tile == null)
            {
                // create a new secondary tile
                StandardTileData data = new StandardTileData();
                // tile foreground data
                data.Title           = dc.StopName;
                data.BackgroundImage = new Uri("/Assets/info_trafic.png", UriKind.Relative);
                // create a new tile for this Second Page
                string tilePath = String.Format("/Views/StopDetailsView.xaml?TanId={0}&StopName={1}",
                                                dc.TanId,
                                                Uri.EscapeUriString(dc.StopName));

                ShellTile.Create(new Uri(tilePath, UriKind.Relative), data);
            }
            else
            {
                Tile.Delete();
            }

            this.ChangePinAppBtn();
        }
Exemple #4
0
        /// <summary>
        /// pin item to main screen.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void appbar_pin_Click(object sender, EventArgs e)
        {
            try
            {
                var       data = (this.DataContext as CityData);
                var       tileParameterData = apiUrl + " splitfromhere " + this.category + " splitfromhere " + data.CompositeKey;
                ShellTile tile = CheckIfTileExist(tileParameterData);
                if (tile == null)
                {
                    StandardTileData secondaryTile = new StandardTileData
                    {
                        Title           = data.Name,
                        BackgroundImage = new Uri(data.BackgroundImage, UriKind.Relative),
                        BackContent     = data.Name
                    };

                    string tileUri = string.Concat("/Views/CityCategoryDetail.xaml?tileParameter=", tileParameterData);
                    ShellTile.Create(new Uri(tileUri, UriKind.Relative), secondaryTile);
                }
                else
                {
                    ApplicationBarIconButton appButton = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
                    tile.Delete();
                    MessageBox.Show(AppResources.SecondaryTileDeletedMessage);
                    appButton.IconUri = new Uri("/Assets/Pin.png", UriKind.Relative);
                    appButton.Text    = AppResources.AppBarButtonPinText;
                }
            }
            catch (Exception)
            { }
        }
    private void PinToStart_Click(object sender, RoutedEventArgs e)
    {
        string    _url       = url.Text;
        ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("url=" + _url));

        // Create the Tile if we didn't find that it already exists.
        if (TileToFind == null)
        {
            StandardTileData NewTileData = new StandardTileData
            {
                BackgroundImage     = new Uri("Background.png", UriKind.Relative),
                Title               = string.Format("link - {0}", _url),
                Count               = 1,
                BackTitle           = "Quest",
                BackContent         = (string)_url,
                BackBackgroundImage = new Uri("", UriKind.Relative)
            };
            // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
            ShellTile.Create(new Uri("/MainPage.xaml?" + _key + "=" + _url, UriKind.Relative), NewTileData);
        }
        else
        {
            MessageBox.Show("Tile already exists");
        }
    }
Exemple #6
0
        //更新磁贴
        private void updateTile(string msg, int days)
        {
            ShellTile        NowTile  = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
            StandardTileData TileData = new StandardTileData
            {
                BackgroundImage = new Uri("background.jpg", UriKind.Relative),
                Title           = "live倒计时",
                Count           = days,
                BackTitle       = "提醒",
                BackContent     = msg,
                //BackBackgroundImage = new Uri("Blue.jpg", UriKind.Relative)
            };

            if (NowTile == null)
            {
                isFirstTime = true;
                ShellTile.Create(new Uri("/MainPage.xaml?TileID=2", UriKind.Relative), TileData);
            }
            else
            {
                isFirstTime = false;
                NowTile.Update(TileData);
            }
            //更新日期
            if (isoSetting.Contains("lastUpdate"))
            {
                isoSetting["lastUpdate"] = DateTime.Today;
            }
            else
            {
                isoSetting.Add("lastUpdate", DateTime.Today);
            }
            isoSetting.Save();
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        //protected override void OnInvoke(ScheduledTask task)
        //{
        //    //TODO: Add code to perform your task in background
        //    NotifyComplete();
        //}
        protected override void OnInvoke(ScheduledTask task)
        {
            // some random number
            Random random = new Random();
            // get application tile
            ShellTile tile = ShellTile.ActiveTiles.First();
            if (null != tile)
            {
                // creata a new data for tile
                StandardTileData data = new StandardTileData();
                // tile foreground data
                data.Title = "Title text here";
                data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
                data.Count = random.Next(99);
                // to make tile flip add data to background also
                data.BackTitle = "Secret text here";
                data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
                data.BackContent = "Back Content Text here...";
                // update tile
                tile.Update(data);
            }
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));
            System.Diagnostics.Debug.WriteLine("Periodic task is started again: " + task.Name);
            #endif

            NotifyComplete();
        }
        void CreateTile(Person person, Uri imageUri)
        {
            var uri = "/PersonPage.xaml?id=" + Uri.EscapeDataString(person.Id);

            // Make sure they are in our favorites list
            if (!ViewModel.IsFavorite)
            {
                ViewModel.ToggleFavorite();
            }

            // Delete any old tile
            var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(uri));

            if (foundTile != null)
            {
                foundTile.Delete();
            }

            // Create the new tile
            var tile = new StandardTileData {
                Title           = person.SafeDisplayName,
                BackContent     = person.TitleAndDepartment,
                BackTitle       = person.SafeDisplayName,
                BackgroundImage = (imageUri != null) ? imageUri : new Uri("/Background.png", UriKind.RelativeOrAbsolute),
            };

            ShellTile.Create(new Uri(uri, UriKind.Relative), tile);
        }
Exemple #9
0
        public override void SetNotifications(IEnumerable<TileNotification> notifications)
        {
            if (!notifications.Any())
                return;

            StandardTileData mainTile = new StandardTileData();
            string content = "";

            if (notifications.Count() == 1)
            {
                var not = notifications.First();
                if (not.Type == TweetType.Mention)
                    content = String.Format(Resources.NewMention, not.From);
                else
                    content = String.Format(Resources.NewMessage, not.From);
            }
            else
            {
                if (notifications.Any(x => x.Type == TweetType.Mention) && notifications.Any(x => x.Type == TweetType.Message))
                    content = String.Format(Resources.NewXMentionsMessages, notifications.Count());
                else if (notifications.Any(x => x.Type == TweetType.Mention))
                    content = String.Format(Resources.NewXMentions, notifications.Count());
                else if (notifications.Any(x => x.Type == TweetType.Message))
                    content = String.Format(Resources.NewXMessages, notifications.Count());
            }

            mainTile.BackTitle = String.Format(Resources.ForX, GetChainOfNames(notifications.Select(x => x.To).Distinct().ToList()));
            mainTile.BackContent = content;

            mainTile.Count = notifications.Count();
            ShellTile.ActiveTiles.FirstOrDefault().Update(mainTile);
        }
        private void HandlePinClick (object sender, EventArgs e)
        {
            var vm = (SpeakerDetailsViewModel)DataContext;

            var uri = "/SpeakerDetails.xaml?key=" + vm.Key;

            var imageUri = default (Uri);
            try {
                imageUri = SpeakerImage.SaveAsTile ("Speaker-" + vm.ID);
            }
            catch (Exception) {
            }            

            var foundTile = ShellTile.ActiveTiles.FirstOrDefault (x => x.NavigationUri.ToString ().Contains (uri));

            if (foundTile != null) {
                foundTile.Delete ();
            }

            var tile = new StandardTileData {
                Title = vm.Name,
                BackContent = string.Format ("{0} at {1}", vm.Title, vm.Company),
                BackTitle = vm.Name,
                BackgroundImage = (imageUri != null) ? imageUri : new Uri ("/Background.png", UriKind.RelativeOrAbsolute),
            };

            ShellTile.Create (new Uri (uri, UriKind.Relative), tile);
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            ShellTile applicationTile = ShellTile.ActiveTiles.First();
            //ApplicationTile永远是所有已经激活了的磁贴中的第一个对象。

            //判断应用程序磁贴时候已经被pin到开始页面
            if (applicationTile != null)
            {
                int newCount=0;//消息数目,数目为0时,数字0将不会被显示到磁贴中去
                if (textBoxCount.Text != "")
                    newCount = int.Parse(textBoxCount.Text);

                //利用StandardTileData类型的数据来更新ApplicationTile
                //将用户输入的内容分别赋值给StandardTileData对象
                StandardTileData updateData = new StandardTileData
                {
                    Title=textBoxTitle.Text,
                    Count=newCount,
                    BackgroundImage=new Uri(textBoxBackgroundImage.Text,UriKind.RelativeOrAbsolute),
                    BackTitle=textBoxBackTitle.Text,
                    BackContent=textBoxBackContent.Text,
                    BackBackgroundImage=new Uri(textBoxBackBackgroundImage.Text,UriKind.RelativeOrAbsolute)
                };
                //调用磁贴对象的函数,传入StandardTileData的对象来更新应用程序磁贴
                applicationTile.Update(updateData);
                MessageBox.Show("已经更新ApplicationTile");
            }
        }
Exemple #12
0
        public Task<bool> Pin(TileInfo tileInfo)
        {
            var result = false;
            if (IsPinned(tileInfo))
            {
                Unpin(tileInfo).Wait();
            }

            var tileData = new StandardTileData
            {
                Title = tileInfo.DisplayName,
                BackgroundImage = tileInfo.LogoUri,
                Count = tileInfo.Count,
                BackTitle = tileInfo.AppName,
                BackBackgroundImage = new Uri("", UriKind.Relative),
                BackContent = tileInfo.DisplayName
            };

            try
            {
                ShellTile.Create(new Uri(string.Format("/View/Shell.xaml?routeId={0}&routeName={1}", tileInfo.TileId, tileInfo.DisplayName), UriKind.Relative), tileData);
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return Task.FromResult<bool>(result);
        }
Exemple #13
0
 void nzRSS_DSC(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         var rssData = (from rss in XElement.Parse(e.Result).Descendants("item")
                        select new PostMessage
                        {
                            title = rss.Element("title").Value
                        }).ToArray().Reverse();
         foreach (var item in rssData)
         {
             String nameData = item.title;
             var tile = ShellTile.ActiveTiles.First();
             var apptile = new StandardTileData();
             apptile.Title = "Здесь в...";
             apptile.BackgroundImage = new Uri("/TilePic.png", UriKind.RelativeOrAbsolute);
             apptile.BackContent = nameData;
             tile.Update(apptile);
         }
     }
     catch
     {
     }
     finally
     {
         NotifyComplete();
     }
 }
Exemple #14
0
        private void PinToStartTapMenuOnClick(object sender, RoutedEventArgs e)
        {
            var item = sender as Microsoft.Phone.Controls.MenuItem;

            if (item != null)
            {
                var arg = (item.CommandParameter ?? string.Empty).ToString();

                int index;
                if (int.TryParse(arg, out index))
                {
                    var group = ApplicationData.GetConfiguration().Groups[index];
                    var icon  = ApplicationData.Settings.GetIcon(index);

                    string pageUrl = string.Format("/Pages/Group.xaml?index={0}&cache={1:N}", index, Guid.NewGuid());
                    string iconUrl = icon.GetTileIconPath();

                    var secTileData = new StandardTileData
                    {
                        Title           = group.Name,
                        BackgroundImage = new Uri(iconUrl, UriKind.RelativeOrAbsolute)
                    };

                    ShellTile.Create(new Uri(pageUrl, UriKind.RelativeOrAbsolute), secTileData);
                }
            }
        }
        void PodcastListDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            int j = 0;
           
            if (IsolatedStorageSettings.ApplicationSettings.Contains("LastShowPostedOn"))
                LastShow = (DateTime)IsolatedStorageSettings.ApplicationSettings["LastShowPostedOn"];  

            try
            {
                var doc = XDocument.Parse(e.Result);
                var xChannel = doc.Descendants("channel").First();

                foreach (var item in xChannel.Descendants("item"))
                {                
                    if (RssHelper.ParseRssDate(RssHelper.getElementValue(item, "pubDate")) > LastShow)
                    {
                        j++;
                    }
                }
               
            }
            catch (Exception)
            {
                // do nothing just let the MinValue be returned
            }
            
            var tile = ShellTile.ActiveTiles.First();

            StandardTileData update = new StandardTileData();
            update.Count = j;
            update.BackBackgroundImage = new Uri("/Images/Background.png", UriKind.Relative);
            tile.Update(update);

            NotifyComplete();
        }
Exemple #16
0
        public static void Update(AccountData[] accountData)
        {
            if (accountData == null)
            {
                return;
            }

            var netWorth = accountData.Sum(data => data.Balance);
            var balanceIssueCount = accountData.Count(data => data.AccountType == "bank" && data.Balance < 0);
            var loginIssueCount = accountData.Count(data => data.LoginStatus == AccountLoginStatus.Invalid);

            var tile = ShellTile.ActiveTiles.First();

            var tileData = new StandardTileData();

            tileData.Count = loginIssueCount + balanceIssueCount;
            tileData.BackTitle = "Net Worth";
            tileData.BackContent = String.Format("{0:c}", netWorth);
            if (balanceIssueCount > 0)
            {
                tileData.BackgroundImage = new Uri("/Assets/Tiles/TileMediumIconRed.png", UriKind.Relative);
                tileData.BackBackgroundImage = new Uri("/Assets/Tiles/TileMediumRed.png", UriKind.Relative);
            }
            else
            {
                tileData.BackgroundImage = new Uri("/Assets/Tiles/TileMediumIcon.png", UriKind.Relative);
                tileData.BackBackgroundImage = new Uri(String.Empty, UriKind.Relative);
            }

            tile.Update(tileData);
        }
        private void PinTrip()
        {
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/Views/TripDetails.xaml?tripId=" + PathResultsModel.SelectedPathOption.TripId.ToString()));

            if (tile == null)
            {
                IEnumerable<Path> paths = UnitOfWork.PathRepository.GetAllCached(UnitOfWork.PublicTransportOperatorRepository.GetAll());

                Path pinnedPath = paths.Where(x => x.TripId == PathResultsModel.SelectedPathOption.TripId).FirstOrDefault();

                if (pinnedPath == null)
                    return;

                pinnedPath.IsPinned = true;
                UnitOfWork.PathRepository.Insert(pinnedPath);
                UnitOfWork.Save();

                var newTile = new StandardTileData()
                {
                    Title = string.Format(AppResources.TripDetailsLiveTileText, PathResultsModel.Destination.ShortAddressText),
                    BackgroundImage = new Uri("/Images/Tiles/TileTrip7.png", UriKind.Relative),
                    BackContent = string.Format(AppResources.TripDetailsLiveTileBackText, PathResultsModel.SelectedPathOption.StartTime.Value.ToString("HH:mm"), PathResultsModel.Location.ShortAddressText, PathResultsModel.Destination.ShortAddressText)
                     
                };

                ShellTile.Create(new Uri("/Views/TripDetails.xaml?tripId=" + PathResultsModel.SelectedPathOption.TripId.ToString(), UriKind.Relative), newTile);
            }
            else
            {
                ShowPopup(CustomPopupMessageType.Error, AppResources.TileAlreadyPinnedErrorText, AppResources.CustomPopupGenericOkGotItMessage, null);
            }
        }
Exemple #18
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            // get application tile
            ShellTile tile = ShellTile.ActiveTiles.First();

            if (null != tile)
            {
                // creata a new data for tile
                StandardTileData data = new StandardTileData();
                // tile foreground data
                data.Title           = "";
                data.BackgroundImage = new Uri("/Images/logo.jpg", UriKind.Relative);


                //: new Uri("/Images/white.png", UriKind.Relative);

                AgentStarter.CheckTileTextUpdate(NotifyComplete);
                // take just TITLE from description
                // update tile
                //tile.Update(data);
            }
#if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));
            System.Diagnostics.Debug.WriteLine("Periodic task is started again: " + task.Name);
#endif

            //NotifyComplete();
        }
Exemple #19
0
        ////////////////////////////////////////////////////////////////////////////////////////////////



        public void CreateAdvies(PlannerSearch search, int index, ReisMogelijkheid mogelijkheid)
        {
            if (!Exists(string.Format("/Views/Reisadvies.xaml?id={0}&index={1}", search.Id, index)))
            {
                var filenameInput = string.Format("/Shared/ShellContent/{0}_{1}.jpg", search.Id, index);

                var filename          = GenerateAdviesTile(search, mogelijkheid, search.VanStation.Name, search.NaarStation.Name, mogelijkheid.GeplandeVertrekTijd.ToString("dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture), filenameInput);
                var isoStoreTileImage = string.Format("isostore:{0}", filename);

                // Create the Tile object and set some initial properties for the Tile.
                // The Count value of 12 shows the number 12 on the front of the Tile. Valid values are 1-99.
                // A Count value of 0 indicates that the Count should not be displayed.
                StandardTileData NewTileData = new StandardTileData
                {
                    BackgroundImage = new Uri(isoStoreTileImage, UriKind.Absolute),
                    //Title = name,
                    //Count = 12,
                    //BackTitle = "Back of Tile",
                    //BackContent = "Welcome to the back of the Tile",
                    //BackBackgroundImage = new Uri("Blue.jpg", UriKind.Relative)
                };

                // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                ShellTile.Create(new Uri(string.Format("/Views/Reisadvies.xaml?id={0}&index={1}", search.Id, index), UriKind.Relative), NewTileData);
            }
        }
        private void HandlePinClick(object sender, EventArgs e)
        {
            var vm = (SpeakerDetailsViewModel)DataContext;

            var uri = "/SpeakerDetails.xaml?key=" + vm.Key;

            var imageUri = default(Uri);

            try {
                imageUri = SpeakerImage.SaveAsTile("Speaker-" + vm.ID);
            }
            catch (Exception) {
            }

            var foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(uri));

            if (foundTile != null)
            {
                foundTile.Delete();
            }

            var tile = new StandardTileData {
                Title           = vm.Name,
                BackContent     = string.Format("{0} at {1}", vm.Title, vm.Company),
                BackTitle       = vm.Name,
                BackgroundImage = (imageUri != null) ? imageUri : new Uri("/Background.png", UriKind.RelativeOrAbsolute),
            };

            ShellTile.Create(new Uri(uri, UriKind.Relative), tile);
        }
        public bool ResetTileToDefault()
        {
            bool result = false;

            try
            {
                StandardTileData tileData = new StandardTileData()
                {
                    Title               = "Trivia Buff",
                    BackgroundImage     = new Uri("/icons/Application_Icon_336.png", UriKind.Relative),
                    BackBackgroundImage = new Uri("NONESUCH.png", UriKind.Relative),
                    BackTitle           = string.Empty,
                    BackContent         = string.Empty
                };

                ShellTile tile = ShellTile.ActiveTiles.First();
                tile.Update(tileData);
                result = true;
            }
            catch (Exception)
            {
                // ignore, best effort cleanup
            }

            return(result);
        }
Exemple #22
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            var tileToFind = ShellTile.ActiveTiles.FirstOrDefault();

            if(tileToFind != null)
            {
                var tileData = new StandardTileData
                                   {
                                       BackTitle = "Jeg lever!",
                                       BackBackgroundImage = new Uri(_pictureUrl, UriKind.Absolute)
                                   };

                tileToFind.Update(tileData);
            }

            /*

            var toast = new ShellToast
                            {
                                Title = "Toast!",
                                Content = "Backgrond agent says hello!",
                            };
            toast.Show();

            */

            NotifyComplete();
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {

            //TODO: Add code to perform your task in background

            /// If application uses both PeriodicTask and ResourceIntensiveTask
            if (task is PeriodicTask)
            {
                // Execute periodic task actions here.
                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
                if (TileToFind != null)
                {
                     StandardTileData NewTileData = new StandardTileData
                        {
                            Title= "updated by scheduled task",
                            Count = System.DateTime.Now.Minute
                        };
                     TileToFind.Update(NewTileData);
                }
            }
            else
            {
                // Execute resource-intensive task actions here.
            }

            NotifyComplete();
           
        }
        public static void Create(Uri uri, StandardTileData data)
        {
            var bgImage = data.BackgroundImage;
            var backBgImage = data.BackBackgroundImage;

            bool found = false;
            if (bgImage != null && bgImage.IsAbsoluteUri)
            {
                data.BackgroundImage = null;
                found = true;
            }

            if (backBgImage != null && backBgImage.IsAbsoluteUri)
            {
                data.BackBackgroundImage = null;
                found = true;
            }

            ShellTile.Create(uri, data);

            //if no distant uri, do nothing
            if (!found)
                return;

            //find my tile
            ShellTile mytile = ShellTile.ActiveTiles.FirstOrDefault(currentTile => currentTile.NavigationUri == uri);
            if (mytile == null)
                return;

            //update the tile
            mytile.Update(new StandardTileData() { BackgroundImage = bgImage, BackBackgroundImage = backBgImage });
        }
Exemple #25
0
        public static void Update()
        {
            try
            {
                // Application Tile is always the first Tile, even if it is not pinned to Start.
                ShellTile TileToFind = ShellTile.ActiveTiles.First();

                if (TileToFind != null)
                {
                    // Create the tile object and set some initial properties for the tile.
                    // The Count value of 12 will show the number 12 on the front of the Tile.
                    // Valid values are 1-99.
                    // A Count value of 0 will indicate that the Count should not be displayed.
                    int   alarmCount = AlarmHelper.AlarmCount();
                    Alarm alarm      = AlarmHelper.NearestAlarm();

                    StandardTileData NewTileData = new StandardTileData
                    {
                        BackgroundImage     = new Uri("/Resources/Images/Tiles/BackgroundImage.png", UriKind.Relative),
                        Title               = "Metro Calendar",
                        Count               = alarmCount,
                        BackTitle           = ((alarm == null) ? "Next alarm" : alarm.BeginTime.ToShortTimeString()),
                        BackContent         = ((alarm == null) ? "No alarm" : alarm.Content),
                        BackBackgroundImage = new Uri("/Resources/Images/Tiles/BackBackgroundImage.png", UriKind.Relative)
                    };

                    TileToFind.Update(NewTileData);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
        /// <summary>
        /// スケジュールされたタスクを実行するエージェント
        /// </summary>
        /// <param name="task">
        /// 呼び出されたタスク
        /// </param>
        /// <remarks>
        /// このメソッドは、定期的なタスクまたはリソースを集中的に使用するタスクの呼び出し時に呼び出されます
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            var setting   = IOManager.GetManager().LoadFromAgent();
            var manifests = IOManager.GetManager().LoadManifests(false);
            var message   = "";

            if (setting.ID.Equals(Guid.Empty))
            {
                var random = new Random();
                message = manifests[random.Next(2)].Title;
            }
            else
            {
                message = manifests.Where(m => m.ID.Equals(setting.ID)).FirstOrDefault().Title;
            }
            var tile    = ShellTile.ActiveTiles.FirstOrDefault();
            var newTile = new StandardTileData
            {
                // Title = "TEST",
                // BackBackgroundImage = new Uri(@"https://twimg0-a.akamaihd.net/profile_images/1339209451/dog_icon3_master.png"),
                Count       = 3,
                BackTitle   = "目標",
                BackContent = message,
            };

            tile.Update(newTile);

            // If debugging is enabled, launch the agent again in one minute.
#if DEBUG
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
#endif

            NotifyComplete();
        }
Exemple #27
0
        private void pinOption_Click(object sender, EventArgs e)
        {
            string    tileParameter = appapikey;
            ShellTile tile          = CheckIfTileExist(tileParameter);// Check if Tile's title has been used

            if (tile == null)
            {
                StandardTileData secondaryTile = new StandardTileData
                {
                    Title           = Util.shrinkString(appName),
                    BackgroundImage = new Uri("Background2.png", UriKind.Relative),
                    //Count = 0,
                    //BackContent = "Secondary Tile Test"
                };
                Uri targetUri = new Uri("/AppMetrics.xaml?appapikey=" + appapikey + "&apikey=" + apiKey + "&appName=" + appName + "&platform=" + platform, UriKind.Relative);
                if (Util.Is512Mb)
                {
                    this.Perform(() => LoadUpXMLAppMetricsForTile("ActiveUsers", targetUri, secondaryTile), 0);
                }
                else // put standard shelltile for 256devices
                {
                    ShellTile.Create(targetUri, secondaryTile); // Pass tileParameter as QueryString
                }
            }
            else
            {
                MessageBox.Show("Tile " + appName + " already exists on homescreen.");
            }
        }
        private void PinItem_Click(object sender, RoutedEventArgs e)
        {
            LocationInformation locationInformation =
             (sender as MenuItem).DataContext as LocationInformation;

            Uri tileUri = MakeTileUri(locationInformation);

            StandardTileData initialData = new StandardTileData()
            {
                BackgroundImage = new Uri("Images/Clear.png", UriKind.Relative),
                Title = locationInformation.Name
            };

            ((sender as MenuItem).Parent as ContextMenu).IsOpen = false;

            try
            {
                ShellTile.Create(tileUri, initialData);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error creating tile", MessageBoxButton.OK);
                return;
            }
        }
        private void SavaSettings_Click(object sender, EventArgs e)
        {
            Settings.UpdateTile          = ToggleSwitch_UpdateLiveTiles.IsChecked.Value;
            Settings.updateContLiveTiles = ToggleSwitch_UpdateContLiveTiles.IsChecked.Value;

            if (ToggleSwitch_UpdateLiveTiles.IsChecked == false)
            {
                ShellTile tile = ShellTile.ActiveTiles.First(); //Recupera a tile da aplicação

                StandardTileData std = new StandardTileData     //Cria uma tila standard
                {
                    Count       = 0,                            //Número que aparece junto a parte da frente da tile
                    BackContent = "",                           //Texto que aparece atrás da tile
                    BackTitle   = "",                           //Título da aplicação de que aparece atrás da tile
                    //BackBackgroundImage = new Uri("/Imagens/backImagemTile.png", UriKind.Relative), //Imagem de fundo da parte de trás da tile
                    //BackgroundImage = new Uri("/Imagens/imagemTile.png", UriKind.Relative),  //Imagem de fundo da parte da frente da tile
                    //Title = "Texto texto..." //Título da parte da frente da tile
                };
                tile.Update(std); //Faz o update da tile da aplicação
            }
            else if (ToggleSwitch_UpdateContLiveTiles.IsChecked == false)
            {
                Settings.ContLiveTile = 0;
                ShellTile        tile = ShellTile.ActiveTiles.First();
                StandardTileData std  = new StandardTileData
                {
                    Count = 0,
                };
                tile.Update(std);
            }

            NavigationService.Navigate(new Uri("/home.xaml", UriKind.RelativeOrAbsolute));
        }
Exemple #30
0
        private static void CreateOrUpdateTile(string title, Uri uri)
        {
            var tiledata = new StandardTileData()
            {
                BackgroundImage = new Uri("Background.png", UriKind.Relative),
                Title           = title
            };

            //-- If we already have a Shell Tile for this pageUri, we can just
            // update the tile.
            foreach (var st in ShellTile.ActiveTiles)
            {
                if (st.NavigationUri == uri)
                {
                    st.Update(tiledata);

                    //-- Notify the user the tile was created.
                    MessageBox.Show(string.Format("Successfully updated {0} tile.", title));
                    return;
                }
            }

            //-- If this is a new Shell Tile, then lets go create one!
            ShellTile.Create(uri, tiledata);
        }
Exemple #31
0
        private void cbHubTile_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var ischecked  = cbHubTile.IsChecked;
            var tiles      = ShellTile.ActiveTiles;
            var TileToFind = tiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileUriParam));

            if (ischecked == true)
            {
                if (TileToFind == null)
                {
                    StandardTileData NewTileData = new StandardTileData
                    {
                        BackgroundImage = new Uri("/Resource/Images/AddTweetTileBackground.png", UriKind.Relative),
                        Title           = "新微博",
                        BackTitle       = "腾讯微博",
                        BackContent     = "快速启动\r\n发布微博"
                    };
                    ShellTile.Create(new Uri("/Oauth.xaml?" + tileUriParam, UriKind.Relative), NewTileData);
                }
            }
            else
            {
                if (TileToFind != null)
                {
                    TileToFind.Delete();
                }
            }
        }
 private void toggleSetting_Clicked(object sender, RoutedEventArgs e)
 {
     StandardTileData tileData = new StandardTileData();
     tileData.BackContent = toggleSetting.IsChecked.ToString();
     tileData.Count = 10;
     ShellTile.ActiveTiles.First().Update(tileData);
 }
Exemple #33
0
        private void UpdateTile(int count)
        {
            ShellTile        apptile     = ShellTile.ActiveTiles.First();
            StandardTileData appTileData = new StandardTileData();

            appTileData.Count = count;

            if (count == 0)
            {
                appTileData.BackTitle   = null;
                appTileData.BackContent = null;
            }
            else
            {
                appTileData.BackTitle = "µTorrent Remote";
                string message =
                    count == 1
                        ? string.Format("{0} torrent was downloaded", count)
                        : string.Format("{0} torrents were downloaded", count);

                appTileData.BackContent = message;
            }

            apptile.Update(appTileData);
        }
Exemple #34
0
        public static bool CreateTile(StopGroup stop, Route route)
        {
            string tileName = "stoproute" + stop.ID + "-" + route.ID;

            int tileId = App.UB.TileRegister.Get(route, stop);

            if (tileId != -1)
            {
                return(false);
            }

            DateTime now       = DateTime.Now;
            var      timeTable = App.Model.GetTimetable(route, stop, now);

            var control  = Tiles.CreateTileBackgroundControl(stop, route, timeTable, now);
            Uri imageUri = Tiles.GenerateTileImage(control, tileName + ".png");

            StandardTileData tileData = new StandardTileData
            {
                Title           = "",
                BackgroundImage = imageUri
            };

            int id      = App.UB.TileRegister.Bind(route, stop);
            Uri tileUri = new Uri("/MainPage.xaml?tile=" + id, UriKind.Relative);

            ShellTile.Create(tileUri, tileData);

            return(true);
        }
Exemple #35
0
        //for mango
        public static void CreateApplicationTile()
        {
            var appTile = ShellTile.ActiveTiles.First();

            if (appTile != null)
            {
                string tileText = "";
                var    items    = IsolatedStorageOperations.GetHighScores().OrderByDescending(p => p.Score);
                if (items.Count() == 0)
                {
                    tileText += "-----";
                }
                else
                {
                    var item = items.FirstOrDefault();
                    tileText = item.Initials + " - " + item.Score.ToString();
                }
                var standardTile = new StandardTileData
                {
                    Title               = "Snap 21",
                    BackgroundImage     = new Uri("tilefront.png", UriKind.Relative),
                    Count               = null,// any number can go here, leaving this null shows NO number
                    BackTitle           = tileText,
                    BackBackgroundImage = new Uri("tileicon.png", UriKind.Relative),
                    BackContent         = "High Score"
                };

                appTile.Update(standardTile);
            }
        }
Exemple #36
0
        public void Execute(object parameter)
        {
            var filename = parameter.ToString();
            var number = Path.GetFileNameWithoutExtension(filename).Split('_')[2];

            if (ShellTile.ActiveTiles.Any(st => st.NavigationUri.ToString().Contains(number)))
            {
                new MessagePrompt() { Title = "SimInfo", Message = AppResources.TileAlreadyPinned }.Show();
                return;
            }

            var baseDir = Path.GetDirectoryName(filename);

            var smallpath = Path.Combine(baseDir, string.Format("{0}_{1}_{2}.jpg", 159, 159, number));
            var normalpath = Path.Combine(baseDir, string.Format("{0}_{1}_{2}.jpg", 336, 336, number));
            //var widepath = Path.Combine(baseDir, string.Format("{0}_{1}_{2}.jpg", 691, 336, number));

            StandardTileData tileData = new StandardTileData
            {
                Title = " ",
                //  WideBackgroundImage = new Uri("isostore:" + widepath, UriKind.Absolute),
                BackgroundImage = new Uri("isostore:" + normalpath, UriKind.Absolute),
                //SmallBackgroundImage = new Uri("isostore:" + smallpath, UriKind.Absolute),
                BackBackgroundImage = new Uri("isostore:" + normalpath, UriKind.Absolute),
                // WideBackBackgroundImage = new Uri("isostore:" + widepath, UriKind.Absolute),
            };

            string tileUri = string.Concat("/DataPage.xaml?number=", HttpUtility.UrlEncode(number));
            ShellTile.Create(new Uri(tileUri, UriKind.Relative), tileData, false);
        }
Exemple #37
0
        /// <summary>
        /// Manage the Tile. Change its count, backTitle and backContent.
        /// </summary>
        /// <param name="count">The tile count</param>
        /// <param name="backTitle">The tile backTitle</param>
        /// <param name="backContent">The tile backContent</param>
        public void changeBackTile(double imc, double currentHeight, double currentWeight, string backContent)
        {
            IMCCalculatorManager imcManager = new IMCCalculatorManager();
            string backTitle = backTitleForIMC(imc, currentHeight, currentWeight);
            string backBackgroundImageName = imageFileNameForIMC(imc);

            // Application Tile is always the first Tile, even if it is not pinned to Start.
            ShellTile TileToFind = ShellTile.ActiveTiles.First();

            // Application should always be found
            if (TileToFind != null)
            {
                createImageForBackTile(backBackgroundImageName);

                // Set the properties to update for the Application Tile.
                // Empty strings for the text values and URIs will result in the property being cleared.
                StandardTileData NewTileData = new StandardTileData
                {
                    // Title = "Mon title",
                    // BackgroundImage = new Uri(textBoxBackgroundImage.Text, UriKind.Relative),
                    Count = Convert.ToInt32(imc),
                    BackTitle = backTitle,
                    BackBackgroundImage = new Uri("isostore:/Shared/ShellContent/tile.png", UriKind.Absolute),
                    BackContent = backContent
                };

                // Update the Application Tile
                TileToFind.Update(NewTileData);
            }
        }
Exemple #38
0
        public EntryPage()
        {
            InitializeComponent();
            StandardTileData sd = new StandardTileData
            {
                Title = "Property Viewer",
                BackgroundImage = new Uri("Background.png", UriKind.Relative),
                Count = 0
            };

            ShellTile st = ShellTile.ActiveTiles.ElementAt(0);
            st.Update(sd);
            client = new ImageServiceClient();

            string channelName = "ChannelName";
            httpChannel = HttpNotificationChannel.Find(channelName);
            if (httpChannel != null)
            {
                channelUri = httpChannel.ChannelUri;
                client.SetUrlAsync(channelUri);
            }
            else
            {
                httpChannel = new HttpNotificationChannel(channelName);
                httpChannel.ErrorOccurred += OnErrorOccurred;
                httpChannel.Open();
                channelUri = httpChannel.ChannelUri;

            }
            httpChannel.ChannelUriUpdated += OnChannelUriUpdated;
            client.resetCompleted += OnResetCompleted;
        }
Exemple #39
0
        public static void AddLiveTile(Category cat)
        {
            // Look to see whether the Tile already exists; if so, don't try to create it again.
            ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/Category/" +
                cat.CategoryID.ToString()));

            // Create the Tile if we didn't find that it already exists.
            if (tileToFind == null)
            {
                // Create an image for the category if there isnt one.
                if (cat.ImageURL == null || cat.ImageURL == String.Empty)
                {
                    cat.ImageURL = ImageGrabber.GetDefaultImage();
                }

                // Create the Tile object and set some initial properties for the Tile.
                StandardTileData newTileData = new StandardTileData
                {
                    BackgroundImage = new Uri(cat.ImageURL, UriKind.RelativeOrAbsolute),
                    Title = cat.CategoryTitle,
                    Count = 0,
                    BackTitle = cat.CategoryTitle,
                    BackContent = "Read the latest in " + cat.CategoryTitle + "!",
                };

                // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                ShellTile.Create(new Uri("/Category/" + cat.CategoryID, UriKind.Relative), newTileData);
                // note: Tile URI could have listed the full path to the Category page. For example --> /Views/CategoryPage.xaml?id=

                cat.IsPinned = true;
                App.DataBaseUtility.SaveChangesToDB();
            }
        }
Exemple #40
0
        /// <summary>
        /// Create a secondary tile linking to an existing feed.
        /// </summary>
        /// <param name="feed">The feed to be linked to on the tile</param>
        public static void AddLiveTile(Feed feed)
        {
            // Look to see whether the Tile already exists; if so, don't try to create it again.
            ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/Feed/" +
                feed.FeedID.ToString()));

            // Create the Tile if we didn't find that it already exists.
            if (tileToFind == null)
            {
                // Create the Tile object and set some initial properties for the Tile.
                StandardTileData newTileData = new StandardTileData
                {
                    BackgroundImage = new Uri(feed.ImageURL, UriKind.RelativeOrAbsolute),
                    Title = feed.FeedTitle,
                    Count = 0,
                    BackTitle = feed.FeedTitle,
                    BackContent = "Read the latest in " + feed.FeedTitle + "!",
                };

                // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                ShellTile.Create(new Uri("/Feed/" + feed.FeedID, UriKind.Relative), newTileData);
                // note: Tile URI could also have listed the full path to the feed page. For example --> /Views/FeedPage.xaml?id=

                feed.IsPinned = true;
                App.DataBaseUtility.SaveChangesToDB();
            }
        }
Exemple #41
0
        private void PinTrip()
        {
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/Views/TripDetails.xaml?tripId=" + PathResultsModel.SelectedPathOption.TripId.ToString()));

            if (tile == null)
            {
                IEnumerable <Path> paths = UnitOfWork.PathRepository.GetAllCached(UnitOfWork.PublicTransportOperatorRepository.GetAll());

                Path pinnedPath = paths.Where(x => x.TripId == PathResultsModel.SelectedPathOption.TripId).FirstOrDefault();

                if (pinnedPath == null)
                {
                    return;
                }

                pinnedPath.IsPinned = true;
                UnitOfWork.PathRepository.Insert(pinnedPath);
                UnitOfWork.Save();

                var newTile = new StandardTileData()
                {
                    Title           = string.Format(AppResources.TripDetailsLiveTileText, PathResultsModel.Destination.ShortAddressText),
                    BackgroundImage = new Uri("/Images/Tiles/TileTrip7.png", UriKind.Relative),
                    BackContent     = string.Format(AppResources.TripDetailsLiveTileBackText, PathResultsModel.SelectedPathOption.StartTime.Value.ToString("HH:mm"), PathResultsModel.Location.ShortAddressText, PathResultsModel.Destination.ShortAddressText)
                };

                ShellTile.Create(new Uri("/Views/TripDetails.xaml?tripId=" + PathResultsModel.SelectedPathOption.TripId.ToString(), UriKind.Relative), newTile);
            }
            else
            {
                ShowPopup(CustomPopupMessageType.Error, AppResources.TileAlreadyPinnedErrorText, AppResources.CustomPopupGenericOkGotItMessage, null);
            }
        }
Exemple #42
0
        private void ImageAdd_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (MessageBox.Show(AppResources.createSecTileAsk, AppResources.createSecTileTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                //Nesse metodo é verificado se o usuário deseja criar um Tile secundario para o usuario cadastrado
                var mySelectedItem = listaUsuarios.SelectedItem as Usuario;

                Uri       uri    = new Uri("/view/UsuarioProjetos.xaml?nome=" + mySelectedItem.Nome, UriKind.Relative);
                ShellTile existe = ShellTile.ActiveTiles.FirstOrDefault(
                    x => x.NavigationUri.Equals(uri));

                if (existe == null)
                {
                    StandardTileData dados = new StandardTileData();
                    dados.Title           = mySelectedItem.Nome;
                    dados.BackTitle       = mySelectedItem.Nome;
                    dados.BackgroundImage = new Uri("Assets/Tiles/download.jpg", UriKind.Relative);
                    ShellTile.Create(uri, dados);
                }
                else
                {
                    MessageBox.Show(AppResources.existedTile);
                }
            }
        }
Exemple #43
0
        /// <summary>
        /// Cerates tile data
        /// </summary>
        private StandardTileData CreateTileData(LiveTilesOptions liveTileOptions)
        {
            StandardTileData standardTile = new StandardTileData();

            if (!string.IsNullOrEmpty(liveTileOptions.Title))
            {
                standardTile.Title = liveTileOptions.Title;
            }
            if (!string.IsNullOrEmpty(liveTileOptions.Image))
            {
                standardTile.BackgroundImage = new Uri(liveTileOptions.Image, UriKind.RelativeOrAbsolute);
            }
            if (liveTileOptions.Count > 0)
            {
                standardTile.Count = liveTileOptions.Count;
            }
            if (!string.IsNullOrEmpty(liveTileOptions.BackTitle))
            {
                standardTile.BackTitle = liveTileOptions.BackTitle;
            }
            if (!string.IsNullOrEmpty(liveTileOptions.BackContent))
            {
                standardTile.BackContent = liveTileOptions.BackContent;
            }
            if (!string.IsNullOrEmpty(liveTileOptions.BackImage))
            {
                standardTile.BackBackgroundImage = new Uri(liveTileOptions.BackImage, UriKind.RelativeOrAbsolute);
            }
            return(standardTile);
        }
Exemple #44
0
        private void appBarBtnSaveTileClicked(object sender, EventArgs e)
        {
            SearchResultsViewModel vm = this.DataContext as SearchResultsViewModel;

            foreach (var item in ShellTile.ActiveTiles)
            {

                if (item.NavigationUri.ToString().Contains(vm.SearchTerm))
                {
                    MessageBox.Show("You have already saved this search term as a tile", "Already saved", MessageBoxButton.OK);
                }
            }

            string term = vm.SearchTerm;
            if (!term.StartsWith("#"))
                term = "#" + term;

            StandardTileData tile = new StandardTileData()
            {
                Title = term,
                BackContent = vm.Items[0].Message,
                BackTitle = term,
            };

            if (vm.Items.Count > 0)
            {
                tile.BackgroundImage = new Uri(vm.Items[0].ProfilePhotoURL, UriKind.Absolute);
                tile.Title = vm.Items[0].Username;
            }
            ShellTile.Create(new Uri("/Views/Search.xaml?searchTerm=" + vm.SearchTerm, UriKind.Relative), tile);
        }
        public static void CreateOrUpdateTileForProject(Project project, int count)
        {
            StandardTileData NewTileData = new StandardTileData
            {
                Title = project.name,
                BackgroundImage = null,
                Count = count,
                BackTitle = project.name,
                BackBackgroundImage = null,
                BackContent = "You have uncompleted tasks for today"
            };

            if (!Tiles.Keys.Select(key => key == project).FirstOrDefault())
            {
                ShellTile.Create(new Uri("/SecondaryTile.xaml?Project=", UriKind.Relative), NewTileData);
                string IdentifyFromString = String.Format("ProjectName={0}&ProjectId={1}", project.name, project.id);
                ShellTile TileOfProjectCreated =
                    ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(IdentifyFromString));
                Tiles.Add(project, TileOfProjectCreated);
            }
            else
            {
                Tiles[project].Update(NewTileData);
            }
        }
Exemple #46
0
 void nzRSS_DSC(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         var rssData = (from rss in XElement.Parse(e.Result).Descendants("item")
                        select new PostMessage
         {
             title = rss.Element("title").Value
         }).ToArray().Reverse();
         foreach (var item in rssData)
         {
             String nameData = item.title;
             var    tile     = ShellTile.ActiveTiles.First();
             var    apptile  = new StandardTileData();
             apptile.Title           = "Здесь в...";
             apptile.BackgroundImage = new Uri("/TilePic.png", UriKind.RelativeOrAbsolute);
             apptile.BackContent     = nameData;
             tile.Update(apptile);
         }
     }
     catch
     {
     }
     finally
     {
         NotifyComplete();
     }
 }
Exemple #47
0
        private void PinToStart(string siteID, string boardID, string displayName)
        {
            StandardTileData data = new StandardTileData();

            data.Title               = displayName;
            data.BackgroundImage     = new Uri("/Background.png", UriKind.Relative);
            data.BackContent         = string.Empty;
            data.BackBackgroundImage = new Uri("", UriKind.Relative);
            data.BackTitle           = string.Empty;

            Uri uri = new Uri(string.Format("/Views/ViewArticle.xaml?siteID={0}&boardID={1}&boardName={2}", siteID, boardID, displayName), UriKind.Relative);

            try
            {
                if (!ShellTile.ActiveTiles.Any(st => st.NavigationUri == uri))
                {
                    ShellTile.Create(uri, data);
                }
                else
                {
                    MessageBox.Show("이미 시작 화면에 고정되어 있습니다");
                }
            }
            catch
            {
            }
        }
        private void PinTileToStartMenu()
        {
            var thePerson = this.DataContext as Person;

            // Check the existence of the secondary tile
            var shellTile = ShellTile.ActiveTiles.FirstOrDefault(
                x => x.NavigationUri.ToString().Contains("FirstName=" + thePerson.FirstName));

            if (shellTile != null)
                return;

            // Create the tile data with some proeprties
            var tileData = new StandardTileData
            {
                Title = String.Format("{0} {1}", thePerson.FirstName, thePerson.LastName),
                Count = DateTime.Now.Year - thePerson.BirthDate.Year,
                BackTitle = "Back page",
                BackContent = "This is the back page for " + thePerson.FirstName,
                BackBackgroundImage = new Uri("back.jpg", UriKind.Relative)
            };

            // create the tile at the start screen
            Uri newUri = new Uri("/DetailsPage.xaml?FirstName=" + thePerson.FirstName, UriKind.Relative);
            ShellTile.Create(newUri, tileData);

            foreach (var item in ShellTile.ActiveTiles)
            {
                Debug.WriteLine(item.NavigationUri);
            }
        }
        private static StandardTileData SetupTileData(Happening item)
        {
            var backContent = String.Empty;

            if (item.ShowMonthsAndDaysOnLiveTile)
            {
                if (item.NumberOfDaysLeft.ToString().StartsWith("-"))
                {
                    backContent = AppResources.HappeningOver;
                }
                else if (!String.IsNullOrEmpty(item.MonthsAndDaysLeftText))
                {
                    backContent = String.Format("{0} {1}", item.MonthsAndDaysLeftText, AppResources.Left);
                }
                else
                {
                    backContent = String.Format("{0} {1}", AppResources.Occurs, AppResources.Today);
                }
            }

            var tile = new StandardTileData
            {
                BackgroundImage = !String.IsNullOrEmpty(item.ImagePath)
                                                                                                            ? new Uri("isostore:" + item.ImagePath, UriKind.Absolute)
                                                                                                            : new Uri(Globals.DefaultImage, UriKind.Relative),
                Title     = item.Name,
                Count     = item.NumberOfDaysLeft <= 99 ? item.NumberOfDaysLeft : 0,
                BackTitle = item.ShowMonthsAndDaysOnLiveTile
                                                                                                    ? item.Name
                                                                                                    : String.Empty,
                BackContent = backContent
            };

            return(tile);
        }
Exemple #50
0
        private void ButtonBase_OnClick_Flip(object sender, RoutedEventArgs e)
        {
            var tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("flip"));
            var flipTileData = new FlipTileData
            {
                Title = "Title",
                Count = 56,
                BackTitle = "BackTitle",
                BackContent = "BackContent",
                WideBackContent = "WideBackContent",
                SmallBackgroundImage = new Uri(@"Assets/Tiles/Flip/159x159.png", UriKind.Relative),
                BackgroundImage = new Uri(@"Assets/Tiles/Flip/336x336.png", UriKind.Relative),
                WideBackBackgroundImage = new Uri(@"Assets/Tiles/Flip/691x336.png", UriKind.Relative),
                BackBackgroundImage = new Uri(@"Assets/Tiles/Flip/A336.png", UriKind.Relative),
                WideBackgroundImage = new Uri(@"Assets/Tiles/Flip/A691.png", UriKind.Relative)
            };

            if (tile != null)
            {
                tile.Update(flipTileData);
            }
            else
            {
                var shellTileData = new StandardTileData
                {
                    Title = "Title",
                    Count = 56,
                    BackTitle = "BackTitle",
                    BackContent = "BackContent",
                    BackgroundImage = new Uri(@"Assets/Tiles/Flip/336x336.png", UriKind.Relative)
                };

                ShellTile.Create(new Uri("/Tiles.xaml?id=flip", UriKind.Relative), shellTileData);
            }
        }
        public bool ResetTileToDefault()
        {
            bool result = false;

            try
            {
                StandardTileData tileData = new StandardTileData()
                {
                    Title = "On This Day...",
                    BackgroundImage = new Uri("/icons/Application_Icon_336.png", UriKind.Relative),
                    BackBackgroundImage = new Uri("NONESUCH.png", UriKind.Relative),
                    BackTitle = string.Empty,
                    BackContent = string.Empty
                };

                ShellTile tile = ShellTile.ActiveTiles.First();
                tile.Update(tileData);
                result = true;
            }
            catch (Exception)
            {
                // ignore, best effort cleanup
            }

            return result;
        }
Exemple #52
0
        /// <summary>
        /// Fügt dem Live Tile eine Badge Nummer hinzu
        /// </summary>
        public void setBadge(string badgeNumber)
        {
            // Application Tile is always the first Tile, even if it is not pinned to Start.
            ShellTile TileToFind = ShellTile.ActiveTiles.First();

            // Application should always be found
            if (TileToFind != null)
            {
                string[] args  = JsonHelper.Deserialize <string[]>(badgeNumber);
                int      count = 0;

                try
                {
                    count = int.Parse(args[0]);
                }
                catch (FormatException) {};

                StandardTileData TileData = new StandardTileData
                {
                    Count = count
                };

                TileToFind.Update(TileData);

                DispatchCommandResult();
            }
        }
Exemple #53
0
        /// <summary>
        /// Updates application live tile
        /// </summary>
        public void updateAppTile(string options)
        {
            LiveTilesOptions liveTileOptions;

            try
            {
                liveTileOptions = JsonHelper.Deserialize <LiveTilesOptions[]>(options)[0];
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }

            try
            {
                ShellTile appTile = ShellTile.ActiveTiles.First();

                if (appTile != null)
                {
                    StandardTileData standardTile = CreateTileData(liveTileOptions);
                    appTile.Update(standardTile);
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Can't get application tile"));
                }
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error updating application tile"));
            }
        }
Exemple #54
0
        private void MainItemPin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MenuItem      menuitem = (MenuItem)sender;
                int           itemId   = (int)menuitem.CommandParameter;
                ItemViewModel item     = App.ViewModel.GetItem(itemId);

                if (item != null)
                {
                    string    tileparameter = string.Format("ItemId={0}", item.ItemId);
                    ShellTile tile          = CheckIfTileExist(tileparameter);
                    if (tile == null)
                    {
                        StandardTileData secondarytile = new StandardTileData

                        {
                            BackBackgroundImage = new Uri("/Images/CalorieCounter/CalorieCOunterStartTileLogo.png", UriKind.Relative),
                            Title           = item.mainitems,
                            BackgroundImage = new Uri(item.ItemImage, UriKind.Relative),
                            BackTitle       = "Calorie Counter",
                            BackContent     = item.mainitems
                        };

                        ShellTile.Create(new Uri("/Views/CalorieCounterItemsList.xaml?" + tileparameter, UriKind.Relative), secondarytile);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("an error occurred during processing. we apologize for inconvenience.", "error", MessageBoxButton.OK);
            }
        }
Exemple #55
0
        /// <summary>
        /// Update the default Live Tile and by extension the lock screen with the count of notifications remaining
        /// in the day, and the title of the next notification.
        /// </summary>
        public static void UpdateDefaultTile()
        {
            // the sample code uses static to enable calls from MainPage.xaml.xs. The code in the book does not use static.
            DateTime now = DateTime.Now;
            //now = new DateTime(now.Year, now.Month, now.Day+2, 0, 0, 0);
            DateTime endOfDay      = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
            var      notifications = ScheduledActionService.GetActions <ScheduledNotification>()
                                     .Where((item) => item.BeginTime > now && item.BeginTime < endOfDay)
                                     .OrderBy((item) => item.BeginTime);
            int count = notifications.Count();
            ScheduledNotification nextNotification = notifications.FirstOrDefault();

            string message = null;

            if (nextNotification != null)
            {
                message = string.Format("{0:t} {1}", nextNotification.BeginTime, nextNotification.Title);
            }

            ShellTile        defaultTile = ShellTile.ActiveTiles.First();
            StandardTileData tileData    = new StandardTileData
            {
                Count       = count,
                BackContent = message,
            };

            defaultTile.Update(tileData);
        }
        public static TileInformation CreateFromTileData(StandardTileData data)
        {
            var ti = new TileInformation();
            ti.Title = data.Title;
            ti.BackgroundImage = data.BackgroundImage;

            return ti;
        }
 public void UpdateTile(StandardTileData tileData)
 {
     ShellTile tile = GetTile();
     if (tile != null)
     {
         tile.Update(tileData);
     }
 }
Exemple #58
0
        private void PinToStart(object sender, EventArgs e){
            var newTile = new StandardTileData {
                Title = "Garage Doors",
                BackgroundImage = new Uri("/Assets/Tiles/garage_icon_173.png", UriKind.Relative),
            };

            ShellTile.Create(new Uri("/GarageDoors.xaml?state=From a Live Tile", UriKind.Relative), newTile);
        }
 public void UpdateCount(int newCount)
 {
     StandardTileData tileData = new StandardTileData
     {
         Count = newCount
     };
     UpdateTile(tileData);
 }
        public void UpdateSecondaryTile(String pagePath,StandardTileData stdTileData)
        {
            CheckSecondaryTile(pagePath);

            if (isSecTilePined)
            {
                secondaryTile.Update(stdTileData);
            }
        }