예제 #1
0
        private void btExtractDirectionInfo_Click(object sender, EventArgs e)
        {
            HtmlElement DirectionsSteps = webBrowser1.Document.GetElementById("tDirections");

            if (DirectionsSteps == null)
            {
                MessageBox.Show("oops direction is not populated yet!!");
                return;
            }
            label2.Text = "Loading... will take a while..";
            Application.DoEvents();
            SerializableList <DirectionStep> Steps = new SerializableList <DirectionStep>();
            string description   = "";
            double lat           = 0;
            double lng           = 0;
            int    PolyLineIndex = 0;

            foreach (HtmlElement InnerElement in DirectionsSteps.All)
            {
                if (InnerElement.GetAttribute("className") == "dStepDesc")
                {
                    description = InnerElement.InnerText;
                }
                if (InnerElement.GetAttribute("className") == "dLat")
                {
                    lat = double.Parse(InnerElement.InnerText);
                }
                if (InnerElement.GetAttribute("className") == "dLag")
                {
                    lng = double.Parse(InnerElement.InnerText);
                }
                if (InnerElement.GetAttribute("className") == "dPolyLineIndex")
                {
                    PolyLineIndex = int.Parse(InnerElement.InnerText);
                    DirectionStep ds = new DirectionStep(new LatLng(lat, lng), description, PolyLineIndex);
                    Steps.Add(ds);
                }
            }
            SerializableList <LatLng> Points = new SerializableList <LatLng>();
            HtmlElement PathPoints           = webBrowser1.Document.GetElementById("Points");

            if (PathPoints == null)
            {
                MessageBox.Show("oops direction is not populated yet!!");
                return;
            }

            foreach (HtmlElement InnerElement in PathPoints.All)
            {
                if (InnerElement.GetAttribute("className") == "pLat")
                {
                    lat = double.Parse(InnerElement.InnerText);
                }
                if (InnerElement.GetAttribute("className") == "pLng")
                {
                    lng = double.Parse(InnerElement.InnerText);

                    Points.Add(new LatLng(lat, lng));
                }
            }
            m_DirectionInfo = new DirectionInfo(key, Points, Steps);
            //m_DirectionInfo.
            label2.Text = "direction info loaded...";
        }