Ejemplo n.º 1
0
        /// <summary>
        /// DrawPolyline_MouseClick
        ///     draw polyline as a series of click nodes
        ///     drawn as two polylines
        ///         base buffer thickness
        ///         top polyline
        /// </summary>
        private void DrawPolyline_MouseClick(object sender, MouseButtonEventArgs e)
        {
            if (draw)
            {
                Location loc = _map.ViewportPointToLocation(e.GetPosition(_map));
                if (startdraw)
                {
                    //first click
                    _layerDraw.Children.Clear();
                    //add a profile drawline of zero length
                    _layerDraw.CaptureMouse();
                    _map.MouseMove        += new MouseEventHandler(DrawPolyline_MouseMove);
                    _map.MouseDoubleClick += new EventHandler <MapMouseEventArgs>(DrawPolyline_MouseDoubleClick);

                    drawbuffer                    = new MapPolyline();
                    drawbuffer.Name               = "Buffer";
                    drawbuffer.StrokeEndLineCap   = PenLineCap.Round;
                    drawbuffer.StrokeStartLineCap = PenLineCap.Round;
                    drawbuffer.StrokeLineJoin     = PenLineJoin.Round;
                    drawbuffer.StrokeMiterLimit   = 0;
                    drawbuffer.Stroke             = (SolidColorBrush)this.Resources["DrawToolFillBrush"];

                    drawbuffer.Locations = new LocationCollection();
                    drawbuffer.Locations.Add(loc);
                    drawbuffer.Locations.Add(loc);
                    _layerDraw.Children.Add(drawbuffer);

                    drawline                  = new MapPolyline();
                    drawline.Stroke           = (SolidColorBrush)this.Resources["DrawToolStrokeBrush"];
                    drawline.StrokeThickness  = 2;
                    drawline.StrokeEndLineCap = PenLineCap.Flat;
                    drawline.StrokeLineJoin   = PenLineJoin.Bevel;
                    drawline.StrokeMiterLimit = 0;
                    drawline.Locations        = new LocationCollection();
                    drawline.Locations.Add(loc);
                    drawline.Locations.Add(loc);
                    _layerDraw.Children.Add(drawline);
                    startdraw = false;
                }
                else
                {
                    //subsequent clicks
                    drawline.Locations.Add(loc);
                    drawbuffer.Locations.Add(loc);
                    if (drawbuffer.Locations.Count < 4)
                    {
                        drawbuffer.StrokeThickness = BufferSlider.Value * 2000 / GetMapResolution(loc.Latitude, _map.ZoomLevel);
                    }
                }
            }
        }