SuperMap.WindowsPhone.Samples.MeasureDistance.Tap C# (CSharp) Method

Tap() public method

public Tap ( GestureEventArgs e ) : void
e GestureEventArgs
return void
        public override void Tap(GestureEventArgs e)
        {
            base.Tap(e);
            Point2D point = _map.ScreenToMap(e.GetPosition(_map));
            if (!_isInited)
            {
                Init(point);
            }
            else
            {
                TextBlock text = new TextBlock();
                text.FontWeight = FontWeights.ExtraBlack;
                text.Foreground = new SolidColorBrush(Colors.Black);
                text.Opacity = 1;
                Border borderText = new Border();
                borderText.BorderBrush = new SolidColorBrush(Colors.LightGray);
                borderText.Background = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
                borderText.Child = text;
                _eLayer.AddChild(borderText, point);
                Point2D lastPoint = _points[_points.Count - 1];
                double nowDistance = Math.Sqrt((point.X - lastPoint.X) * (point.X - lastPoint.X) + (point.Y - lastPoint.Y) * (point.Y - lastPoint.Y));
                double lastDistance = _distances[_distances.Count - 1];
                double distance = nowDistance / 1000 + lastDistance;
                text.Text = string.Format("{0}公里", distance.ToString("0.0"));
                _distances.Add(distance);
                _distanceList.Add(borderText);
                _points.Add(point);
            }
        }