コード例 #1
0
        private void FavAdd_Click(object sender, EventArgs e)
        {
            MessageBoxResult m = MessageBox.Show("add favourite?", "Favourites", MessageBoxButton.OKCancel);

                if (m == MessageBoxResult.OK)
                {
                    StopsC favC = new StopsC();

                    favC.StopsName = Stopname;
                    favC.AddName = add;
                    favC.Direction = direction;
                    favC.RouteNum = routeNum;
                    favC.Dir = dir;
                    favC.RouteName = routeFullName;

                    //Save stuff
                    var settings = IsolatedStorageSettings.ApplicationSettings;

                    //Saving Favourite
                    if (settings.Contains("Fav"))
                    {
                        var favs = IsolatedStorageSettings.ApplicationSettings["Fav"] as ObservableCollection<StopsC>;
                        favs.Add(favC);
                        settings["Fav"] = favs;
                    }
                    else
                    {
                        FavsList.Add(favC);
                        settings.Add("Fav", FavsList);
                    }

                    (this.ApplicationBar.Buttons[2] as ApplicationBarIconButton).IsEnabled = false;

            }
        }
コード例 #2
0
ファイル: Stops.cs プロジェクト: narwhaldisco/LTC_WebWatch
        void DownloadCompleted(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument doc = e.Document;
                if (doc != null)
                {

                    StopsC newC;

                    ObservableCollection<StopsC> newStopsList =
                    new ObservableCollection<StopsC>();

                    if (doc.DocumentNode.SelectNodes("//*[@class=\"ada\"]") == null)
                    {
                        Clickable = false;
                        newC = new StopsC();
                        newC.StopsName = "No stops with upcoming crossings times found.";
                        newStopsList.Add(newC);
                    }
                    else
                    {

                        foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//*[@class=\"ada\"]"))
                        {
                            try
                            {
                                string c;
                                //link.SelectSingleNode("/table");
                                newC = new StopsC();
                                c = link.Attributes["title"].Value;
                                newC.AddName = link.Attributes["href"].Value;
                                newC.StopsName = c;
                                newStopsList.Add(newC);
                            }
                            catch (FormatException)
                            {

                            }
                        }
                    }

                    // copy the data over
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {

                        Vis = Visibility.Collapsed;

                        StopsList.Clear();

                        //Saving stuff
                        var settings = IsolatedStorageSettings.ApplicationSettings;

                        //Saving Direction List
                        if (settings.Contains(stopsfile))
                        {
                            settings[stopsfile] = newStopsList;
                        }
                        else
                        {
                            settings.Add(stopsfile, newStopsList);
                        }

                        //Saving Date
                        if (settings.Contains("Date"))
                        {
                            settings["Date"] = DateTime.Today.ToString();
                        }
                        else
                        {
                            settings.Add("Date", DateTime.Today.ToString());
                        }

                        settings.Save();

                        // copy the list of forecast time periods over
                        foreach (StopsC stopsC in newStopsList)
                        {
                            StopsList.Add(stopsC);
                        }

                    });

                }
            }
        }