示例#1
0
        //Start a new sketch
        void Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (sketch != null)
            {
                return;
            }

            //Mark the event arg as handled so the map won't treat the action as a pan action
            e.Handled = true;

            //Get the map point (first point of the sketch)
            client.Map map = sender as client.Map;
            client.Geometry.MapPoint mapPoint = map.ScreenToMap(e.GetPosition(map));

            //Create the geometry (polyline) of the sketch and add the first point to it
            client.Geometry.Polyline pl = new client.Geometry.Polyline();
            pl.SpatialReference = mapPoint.SpatialReference;
            pl.Paths.Add(new client.Geometry.PointCollection());
            pl.Paths[0].Add(mapPoint);

            //Create the sketch graphic with the geometry and the symbol
            sketch        = new client.Graphic();
            sketch.Symbol = new SimpleLineSymbol()
            {
                Color = new SolidColorBrush(SelectedColor),
                Width = selectedWidth
            };
            sketch.Geometry = pl;
            sketch.Geometry.SpatialReference = _mapWidget.Map.SpatialReference;

            //Add the sketch graphic to the layer
            sketchLayer.Graphics.Add(sketch);
        }
示例#2
0
        //Add a temporary graphic to trace user's mouse movement
        void map_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //Do nothing if user hasn't added the first point
            if (sketchGeometry.Paths[0].Count == 0)
            {
                return;
            }

            //Update the second point of the feedback layer with the current map point
            client.Map map = MapWidget.Map;
            (feedBackLyr.Graphics.First().Geometry as Polyline).Paths[0][1] = map.ScreenToMap(e.GetPosition(map));
        }
示例#3
0
        //For each move, get the map point and add it as a vertex of the polyline
        void Map_MouseMove(object sender, MouseEventArgs e)
        {
            if (sketch == null)
            {
                return;
            }

            //Get the map point
            client.Map map = sender as client.Map;
            client.Geometry.MapPoint mapPoint = map.ScreenToMap(e.GetPosition(map));

            //Add the map point to the sketch
            client.Geometry.Polyline polyline = sketch.Geometry as client.Geometry.Polyline;
            polyline.Paths[0].Add(mapPoint);
        }