コード例 #1
0
ファイル: XMLFileHandler.cs プロジェクト: PCVinnie/Happyhour
        public List<PubRoute> readRouteXMLFile(List<LocationData> pubList)
        {
            if (pubList.Count != 0)
            {
                XElement element;
                List<PubRoute> routes = new List<PubRoute>();
                PubRoute route = null;
                LocationData pubdata = new LocationData();

                using (XmlReader reader = XmlReader.Create("Assets/XML/PubRoutes.xml"))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            switch (reader.Name.ToString().ToUpper())
                            {
                                case "ROUTE":
                                    route = new PubRoute();
                                    break;
                                case "NAME":
                                    element = XElement.ReadFrom(reader) as XElement;
                                    route.name = element.Value.ToString();
                                    break;
                                case "PUB":
                                    pubdata = new LocationData();
                                    break;
                                case "ID":
                                    element = XElement.ReadFrom(reader) as XElement;
                                    int id = -1;
                                    int.TryParse(element.Value.ToString(), out id);
                                    foreach (LocationData data in pubList)
                                    {
                                        if (data.id == id)
                                        {
                                            pubdata = data;
                                            break;
                                        }
                                    }
                                    route.addPubToList(pubdata);
                                    break;
                            }
                        }
                        else if (reader.NodeType == XmlNodeType.EndElement && reader.Name.ToString().ToUpper() == "ROUTE")
                            routes.Add(route);
                    }
                }
                return routes;
            }
            else
                return null;
        }
コード例 #2
0
ファイル: Map.xaml.cs プロジェクト: PCVinnie/Happyhour
        private void RoutesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (currentLocation != null)
            {
                InputMap.MapElements.Clear();
                InputMap.Routes.Clear();
                GeofenceMonitor.Current.Geofences.Clear();

                visitedPubs = 0;
                selectedRoute = (PubRoute)RoutesListView.SelectedItem;
                Debug.WriteLine(selectedRoute.name);
                Summary.Text = "Route is aan het inladen....";

                for(int index = 0; index < selectedRoute.pubs.Count; index++)
                {
                    AddMapIcon(selectedRoute.pubs[index]);
                    if (index > 0)
                        getRouteWithPubs(selectedRoute.pubs[index - 1], selectedRoute.pubs[index]);
                }

            
                AddMapIcon(currentLocation, "U bent hier");
                getRouteWithCurrentLocation(currentLocation.Point, selectedRoute.pubs[0]);
            }
            else
            {
                Summary.Text = "";
                Hyperlink link = new Hyperlink();
                link.Inlines.Add(new Run()
                {
                    Text = "settings voor Happyhour",
                    Foreground = new SolidColorBrush(Colors.White)
                });
                link.NavigateUri = new Uri("ms-settings:privacy-location");

                Summary.Inlines.Add(new Run()
                {
                    Text = "Huidige locatie niet bekend"
                });
                Summary.Inlines.Add(new LineBreak());
                Summary.Inlines.Add(new Run()
                {
                    Text = "Check de locatie "
                });
                Summary.Inlines.Add(link);

                RoutesListView.SelectedIndex = -1;
                getCurrentLocation();
            }
        }
コード例 #3
0
ファイル: NewRoute.xaml.cs プロジェクト: PCVinnie/Happyhour
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if(string.IsNullOrEmpty(Name_TextBox.Text))
                ErrorMessage_TextBlock.Text = "Er is geen naam opgegeven";
               else if(pubList.Count < 2)
                ErrorMessage_TextBlock.Text = "Er zijn te weinig pubs opgegeven voor een route";
               else
            {
                PubRoute route = new PubRoute(Name_TextBox.Text, pubList.ToList());
                LocationHandler.Instance.addRoute(route);

                Frame.Navigate(typeof(View.Map));
            }
        }
コード例 #4
0
ファイル: LocationHandler.cs プロジェクト: PCVinnie/Happyhour
 public void addRoute(PubRoute route)
 {
     routeList.Add(route);
     xmlFileHandler.writeRouteXMLFile(routeList);
 }