Example #1
0
        public detail()
        {
            InitializeComponent();
            List <Stand> tab   = (List <Stand>)PhoneApplicationService.Current.State["stands"];
            int          index = (int)PhoneApplicationService.Current.State["index"];

            //MessageBox.Show(index.ToString());
            Stand item = tab[index];

            station_id.Text = "Station n°" + item.Id;
            add.Text        = item.Add.ToString();
            ab.Text         = "Places : " + item.Ab.ToString();
            ap.Text         = "Velos : " + item.Ap.ToString();
            ac.Text         = "Capacité disponible : " + item.Ac.ToString();
            tc.Text         = "Capacité totale: : " + item.Tc.ToString();

            GeoCoordinate loc = new GeoCoordinate();

            //Location loc = new Location();
            loc.Longitude = item.Lng;
            loc.Latitude  = item.Lat;

            Map Carte = new Map();

            Carte.Center    = loc;
            Carte.ZoomLevel = 17.0;

            Pushpin pin = new Pushpin();

            pin.GeoCoordinate = loc;
            //pin.Location = loc;
            ContentMap.Children.Add(Carte);

            ImageBrush imgBrush = new ImageBrush();

            imgBrush.Stretch     = System.Windows.Media.Stretch.UniformToFill;
            imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

            Grid MyGrid = new Grid();

            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.Background = new SolidColorBrush(Colors.Transparent);

            Rectangle MyRectangle = new Rectangle();

            MyRectangle.Fill   = imgBrush;
            MyRectangle.Height = 52;
            MyRectangle.Width  = 85;
            MyRectangle.SetValue(Grid.RowProperty, 0);
            MyRectangle.SetValue(Grid.ColumnProperty, 0);

            MyGrid.Children.Add(MyRectangle);

            MapLayer   layer   = new MapLayer();
            MapOverlay overlay = new MapOverlay();

            overlay.GeoCoordinate = pin.GeoCoordinate;
            overlay.Content       = MyGrid;
            layer.Add(overlay);



            //Carte.Children.Add(pin);
            Carte.Layers.Add(layer);
        }
Example #2
0
        //Location loc;
        public list()
        {
            InitializeComponent();
            String    xmlStr = (String)PhoneApplicationService.Current.State["stations"];
            XDocument xmlDoc = XDocument.Parse(xmlStr);

            Carte           = new Map();
            Carte.ZoomLevel = 10.0;
            ContentMap.Children.Add(Carte);
            int             inc          = 0;
            List <XElement> listOfStands = xmlDoc.Descendants("stand").ToList();

            foreach (XElement item in listOfStands)
            {
                if (int.Parse(item.Element("disp").Value) == 1)
                {
                    Stand std = new Stand();

                    if (item.HasAttributes)
                    {
                        std.Nom = item.Attribute("name").Value;
                        std.Id  = int.Parse(item.Attribute("id").Value);
                    }

                    //Descendants
                    if (item.HasElements)
                    {
                        //MessageBox.Show(item.Element("lng").Value);
                        //Double test = Double.Parse(item.Element("lng").Value);
                        if (item.Element("wcom") != null)
                        {
                            std.Add = item.Element("wcom").Value;
                        }
                        if (item.Element("lng") != null)
                        {
                            std.Lng = Convert.ToDouble(item.Element("lng").Value.Replace(".", ","));
                        }
                        if (item.Element("lat") != null)
                        {
                            std.Lat = Convert.ToDouble(item.Element("lat").Value.Replace(".", ","));
                        }
                        if (item.Element("ab") != null)
                        {
                            std.Ab = int.Parse(item.Element("ab").Value);
                        }
                        if (item.Element("ac") != null)
                        {
                            std.Ac = int.Parse(item.Element("ac").Value);
                        }
                        if (item.Element("ap") != null)
                        {
                            std.Ap = int.Parse(item.Element("ap").Value);
                        }
                        if (item.Element("tc") != null)
                        {
                            std.Tc = int.Parse(item.Element("tc").Value);
                        }

                        if (std.Add != null)
                        {
                            std.Add = std.Add.Replace("+", " ");
                            std.Add = std.Add.Replace("%c2", "°");
                        }
                        loc           = new GeoCoordinate();
                        loc.Longitude = std.Lng;
                        loc.Latitude  = std.Lat;
                        Pushpin pin = new Pushpin();

                        ToolTipService.SetToolTip(pin, "station n°" + std.Id + "\n" + std.Ap + " places disponible" + "\n" + std.Ab + " vélos disponible");

                        pin.TabIndex = inc;

                        pin.GeoCoordinate = loc;
                        pin.Name          = inc.ToString();

                        Carte.Center = loc;
                        pin.Tap     += pin_event;

                        ImageBrush imgBrush = new ImageBrush();
                        imgBrush.Stretch     = System.Windows.Media.Stretch.UniformToFill;
                        imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

                        Grid MyGrid = new Grid();
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.Background = new SolidColorBrush(Colors.Transparent);

                        Rectangle MyRectangle = new Rectangle();
                        MyRectangle.Fill   = imgBrush;
                        MyRectangle.Height = 52;
                        MyRectangle.Width  = 85;
                        MyRectangle.Name   = inc.ToString();
                        MyRectangle.SetValue(Grid.RowProperty, 0);
                        MyRectangle.SetValue(Grid.ColumnProperty, 0);
                        MyRectangle.Tap += pin_event;
                        MyGrid.Children.Add(MyRectangle);

                        MapLayer   layer   = new MapLayer();
                        MapOverlay overlay = new MapOverlay();
                        overlay.Content       = MyGrid;
                        overlay.GeoCoordinate = pin.GeoCoordinate;
                        layer.Add(overlay);

                        Carte.Layers.Add(layer);
                        inc++;
                    }
                    stands.Add(std);
                }
            }
            // standList.DataContext = stands;
        }
        //Location loc;
        public list()
        {
            InitializeComponent();
            String xmlStr = (String)PhoneApplicationService.Current.State["stations"];
            XDocument xmlDoc = XDocument.Parse(xmlStr);

            Carte = new Map();
            Carte.ZoomLevel = 10.0;
            ContentMap.Children.Add(Carte);
            int inc = 0;
            List<XElement> listOfStands = xmlDoc.Descendants("stand").ToList();
            foreach (XElement item in listOfStands)
            {

                if (int.Parse(item.Element("disp").Value) == 1)
                {
                    Stand std = new Stand();

                    if (item.HasAttributes)
                    {

                        std.Nom = item.Attribute("name").Value;
                        std.Id = int.Parse(item.Attribute("id").Value);
                    }

                    //Descendants
                    if (item.HasElements)
                    {
                        //MessageBox.Show(item.Element("lng").Value);
                        //Double test = Double.Parse(item.Element("lng").Value);
                        if (item.Element("wcom") != null) std.Add = item.Element("wcom").Value;
                        if (item.Element("lng") != null) std.Lng = Convert.ToDouble(item.Element("lng").Value.Replace(".",","));
                        if (item.Element("lat") != null) std.Lat = Convert.ToDouble(item.Element("lat").Value.Replace(".",","));
                        if (item.Element("ab") != null) std.Ab = int.Parse(item.Element("ab").Value);
                        if (item.Element("ac") != null) std.Ac = int.Parse(item.Element("ac").Value);
                        if (item.Element("ap") != null) std.Ap = int.Parse(item.Element("ap").Value);
                        if (item.Element("tc") != null) std.Tc = int.Parse(item.Element("tc").Value);

                        if (std.Add != null)
                        {
                            std.Add = std.Add.Replace("+", " ");
                            std.Add = std.Add.Replace("%c2", "°");
                        }
                        loc = new GeoCoordinate();
                        loc.Longitude = std.Lng;
                        loc.Latitude = std.Lat;
                        Pushpin pin = new Pushpin();

                        ToolTipService.SetToolTip(pin, "station n°" + std.Id + "\n" + std.Ap + " places disponible" + "\n" + std.Ab + " vélos disponible");

                        pin.TabIndex = inc;

                        pin.GeoCoordinate = loc;
                        pin.Name = inc.ToString();

                        Carte.Center = loc;
                        pin.Tap += pin_event;

                        ImageBrush imgBrush = new ImageBrush();
                        imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
                        imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

                        Grid MyGrid = new Grid();
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.Background = new SolidColorBrush(Colors.Transparent);

                        Rectangle MyRectangle = new Rectangle();
                        MyRectangle.Fill = imgBrush;
                        MyRectangle.Height = 52;
                        MyRectangle.Width = 85;
                        MyRectangle.Name = inc.ToString();
                        MyRectangle.SetValue(Grid.RowProperty, 0);
                        MyRectangle.SetValue(Grid.ColumnProperty, 0);
                        MyRectangle.Tap += pin_event;
                        MyGrid.Children.Add(MyRectangle);

                        MapLayer layer = new MapLayer();
                        MapOverlay overlay = new MapOverlay();
                        overlay.Content = MyGrid;
                        overlay.GeoCoordinate = pin.GeoCoordinate;
                        layer.Add(overlay);

                        Carte.Layers.Add(layer);
                        inc++;
                    }
                    stands.Add(std);
                }

            }
            // standList.DataContext = stands;
        }