コード例 #1
0
        /// <summary>
        /// Get extent near point.
        /// </summary>
        /// <param name="position">Dropping position.</param>
        /// <returns>Extent near point.</returns>
        private Envelope _GetExtentNearDroppedPoint(System.Windows.Point position)
        {
            Debug.Assert(_mapView != null);

            System.Windows.Point leftTopPoint     = new System.Windows.Point(position.X - ROUTE_WIDTH, position.Y + ROUTE_WIDTH);
            System.Windows.Point rightBottomPoint = new System.Windows.Point(position.X + ROUTE_WIDTH, position.Y - ROUTE_WIDTH);
            ESRI.ArcGIS.Client.Geometry.MapPoint leftTopMapPoint     = _mapView.mapCtrl.map.ScreenToMap(leftTopPoint);
            ESRI.ArcGIS.Client.Geometry.MapPoint rightBottomMapPoint = _mapView.mapCtrl.map.ScreenToMap(rightBottomPoint);

            ESRI.ArcLogistics.Geometry.Point leftTopPointOnMap = new ESRI.ArcLogistics.Geometry.Point(
                leftTopMapPoint.X, leftTopMapPoint.Y);
            ESRI.ArcLogistics.Geometry.Point rightBottomPointOnMap = new ESRI.ArcLogistics.Geometry.Point(
                rightBottomMapPoint.X, rightBottomMapPoint.Y);

            // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
            if (_mapView.mapCtrl.Map.SpatialReferenceID.HasValue)
            {
                leftTopPointOnMap = WebMercatorUtil.ProjectPointFromWebMercator(leftTopPointOnMap,
                                                                                _mapView.mapCtrl.Map.SpatialReferenceID.Value);
                rightBottomPointOnMap = WebMercatorUtil.ProjectPointFromWebMercator(rightBottomPointOnMap,
                                                                                    _mapView.mapCtrl.Map.SpatialReferenceID.Value);
            }

            Envelope extent = new Envelope(leftTopPointOnMap.X, leftTopPointOnMap.Y,
                                           rightBottomPointOnMap.X, rightBottomPointOnMap.Y);

            return(extent);
        }
コード例 #2
0
        /// <summary>
        /// React on mouse down.
        /// </summary>
        /// <param name="pressedButton">Pressed mouse button.</param>
        /// <param name="modifierKeys">Modifier keys state.</param>
        /// <param name="x">X coord.</param>
        /// <param name="y">Y coord.</param>
        public void OnMouseDown(MouseButton pressedButton,
                                ModifierKeys modifierKeys, double x, double y)
        {
            Debug.Assert(_mapControl != null);

            if (_mapControl.PointedGraphic != null)
            {
                Point point = new Point(x, y);

                // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
                if (_mapControl.Map.SpatialReferenceID.HasValue)
                {
                    point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapControl.Map.SpatialReferenceID.Value);
                }

                // Save current position.
                _previousX = point.X;
                _previousY = point.Y;

                // Start dragging.
                DataGraphicObject pointedGraphicObject = _mapControl.PointedGraphic as DataGraphicObject;
                if (pointedGraphicObject != null &&
                    (pointedGraphicObject.Data == EditingObject || pointedGraphicObject is EditMarkerGraphicObject))
                {
                    _editingInProcess = true;
                    _editedGraphic    = pointedGraphicObject;
                    _StartPan();
                }
            }
            else
            {
                _editingInProcess = false;
            }
        }
コード例 #3
0
        /// <summary>
        /// React on polygon tool complete.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _PolygonToolOnComplete(object sender, EventArgs e)
        {
            if (_dataGridControl.SelectedItems.Count == 1 || _currentItem != null)
            {
                Debug.Assert(_polygonTool.Geometry.Rings.Count == 1);
                ESRI.ArcGIS.Client.Geometry.PointCollection pointsCollection = _polygonTool.Geometry.Rings[0];

                ESRI.ArcLogistics.Geometry.Point[] points = new Point[pointsCollection.Count];

                for (int index = 0; index < pointsCollection.Count; index++)
                {
                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = pointsCollection[index];
                    Point point = new Point(mapPoint.X, mapPoint.Y);

                    // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
                    if (_mapCtrl.Map.SpatialReferenceID.HasValue)
                    {
                        point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapCtrl.Map.SpatialReferenceID.Value);
                    }

                    points[index] = point;
                }

                if (_isInEditedMode)
                {
                    _mapCtrl.ClearEditMarkers();
                }

                ESRI.ArcLogistics.Geometry.Polygon polygon = new Polygon(points);

                if (_type == typeof(Zone))
                {
                    Zone zone = (Zone)_currentItem;
                    zone.Geometry = polygon;
                }
                else
                {
                    Barrier barrier = (Barrier)_currentItem;
                    barrier.Geometry = polygon;

                    _ShowBarrierEditor(barrier, polygon.GetPoint(polygon.TotalPointCount - 1));
                }

                App.Current.Project.Save();

                if (_isInEditedMode)
                {
                    _mapCtrl.FillEditMarkers(_currentItem);
                }

                _mapCtrl.map.UpdateLayout();
            }
        }
コード例 #4
0
        public void OnMouseMove(MouseButtonState left, MouseButtonState right,
                                MouseButtonState middle, ModifierKeys modifierKeys, double x, double y)
        {
            Point point = new Point(x, y);

            // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
            if (_mapControl.Map.SpatialReferenceID.HasValue)
            {
                point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapControl.Map.SpatialReferenceID.Value);
            }

            _popupAddress.OnMouseMove(point.X, point.Y);
        }
コード例 #5
0
        /// <summary>
        /// React on polyline tool complete.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _PolylineToolOnComplete(object sender, EventArgs e)
        {
            if (_dataGridControl.SelectedItems.Count == 1 || _currentItem != null)
            {
                Debug.Assert(_polylineTool.Geometry.Paths.Count == 1);
                ESRI.ArcGIS.Client.Geometry.PointCollection pointsCollection = _polylineTool.Geometry.Paths[0];

                ESRI.ArcLogistics.Geometry.Point[] points = new Point[pointsCollection.Count];

                for (int index = 0; index < pointsCollection.Count; index++)
                {
                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = pointsCollection[index];
                    Point point = new Point(mapPoint.X, mapPoint.Y);

                    // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
                    if (_mapCtrl.Map.SpatialReferenceID.HasValue)
                    {
                        point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapCtrl.Map.SpatialReferenceID.Value);
                    }

                    points[index] = point;
                }

                if (_isInEditedMode)
                {
                    _mapCtrl.ClearEditMarkers();
                }

                ESRI.ArcLogistics.Geometry.Polyline polyline = new Polyline(points);

                Barrier barrier = (Barrier)_currentItem;
                barrier.Geometry = polyline;
                barrier.BarrierEffect.BlockTravel = true;

                // Save this polyline as initial geometry.
                _initialGeometry = polyline;

                App.Current.Project.Save();

                if (_isInEditedMode)
                {
                    _mapCtrl.FillEditMarkers(_currentItem);
                }

                _mapCtrl.map.UpdateLayout();
            }
        }
コード例 #6
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Get rect from extent envelope
        /// </summary>
        /// <param name="envelope">Extent envelope in map spatial reference</param>
        /// <param name="spatialReferenceID">Map spatial reference ID</param>
        /// <returns>Extent envelope in WGS84</returns>
        public static ESRI.ArcLogistics.Geometry.Envelope CreateRect(ESRI.ArcGIS.Client.Geometry.Envelope env,
                                                                     int?spatialReferenceID)
        {
            // Project extent to map spatial reference
            ESRI.ArcLogistics.Geometry.Point leftTop     = new ESRI.ArcLogistics.Geometry.Point(env.XMin, env.YMax);
            ESRI.ArcLogistics.Geometry.Point rightBottom = new ESRI.ArcLogistics.Geometry.Point(env.XMax, env.YMin);

            // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator
            if (spatialReferenceID.HasValue)
            {
                leftTop     = WebMercatorUtil.ProjectPointFromWebMercator(leftTop, spatialReferenceID.Value);
                rightBottom = WebMercatorUtil.ProjectPointFromWebMercator(rightBottom, spatialReferenceID.Value);
            }

            ESRI.ArcLogistics.Geometry.Envelope rect = new ESRI.ArcLogistics.Geometry.Envelope(
                leftTop.X, leftTop.Y, rightBottom.X, rightBottom.Y);

            return(rect);
        }
コード例 #7
0
        /// <summary>
        /// React on point tool complete.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _PointToolOnComplete(object sender, EventArgs e)
        {
            if (_dataGridControl.SelectedItems.Count == 1 || _currentItem != null)
            {
                if (_isInEditedMode)
                {
                    _mapCtrl.ClearEditMarkers();
                }

                Point point = new Point(_pointTool.X.Value, _pointTool.Y.Value);

                // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
                if (_mapCtrl.Map.SpatialReferenceID.HasValue)
                {
                    point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapCtrl.Map.SpatialReferenceID.Value);
                }

                if (_type == typeof(Zone))
                {
                    Zone zone = (Zone)_currentItem;
                    zone.Geometry = point;
                }
                else
                {
                    Barrier barrier = (Barrier)_currentItem;
                    barrier.Geometry = point;

                    _ShowBarrierEditor(barrier, point);
                }

                App.Current.Project.Save();
                _mapCtrl.map.UpdateLayout();

                if (_isInEditedMode)
                {
                    _mapCtrl.FillEditMarkers(_currentItem);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// React on mouse move.
        /// </summary>
        /// <param name="left">Left button state.</param>
        /// <param name="right">Right button state.</param>
        /// <param name="middle">Middle button state.</param>
        /// <param name="modifierKeys">Modifier keys state.</param>
        /// <param name="x">X coord.</param>
        /// <param name="y">Y coord.</param>
        public void OnMouseMove(MouseButtonState left, MouseButtonState right, MouseButtonState middle,
                                ModifierKeys modifierKeys, double x, double y)
        {
            Debug.Assert(_mapControl != null);

            if (_editingInProcess && left == MouseButtonState.Pressed)
            {
                Debug.Assert(_editedGraphic != null);

                Point point = new Point(x, y);

                // Project point from Web Mercator to WGS84 if spatial reference of map is Web Mercator.
                if (_mapControl.Map.SpatialReferenceID.HasValue)
                {
                    point = WebMercatorUtil.ProjectPointFromWebMercator(point, _mapControl.Map.SpatialReferenceID.Value);
                }

                double dx = point.X - _previousX;
                double dy = point.Y - _previousY;

                // Save current position.
                _previousX = point.X;
                _previousY = point.Y;

                // Do pan object.
                object obj = _editedGraphic.Data;
                if (obj is EditingMarker || obj is IGeocodable || obj is Zone || obj is Barrier)
                {
                    _PanObject(EditingObject, dx, dy);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            else
            {
                // If can start drag - change cursor.
                Cursor            newCursor            = null;
                DataGraphicObject pointedGraphicObject = _mapControl.PointedGraphic as DataGraphicObject;
                if (pointedGraphicObject != null)
                {
                    if (pointedGraphicObject.Data == EditingObject || pointedGraphicObject is EditMarkerGraphicObject)
                    {
                        bool multiple = false;
                        if (pointedGraphicObject is EditMarkerGraphicObject)
                        {
                            EditMarkerGraphicObject editMarkerGraphicObject = (EditMarkerGraphicObject)pointedGraphicObject;
                            multiple = editMarkerGraphicObject.EditingMarker.MultipleIndex > -1;
                        }
                        if (multiple)
                        {
                            newCursor = _moveVertexCursor;
                        }
                        else
                        {
                            newCursor = _moveShapeCursor;
                        }
                    }
                }
                _ChangeCursor(newCursor);
            }

            _popupAddress.OnMouseMove(_previousX, _previousY);
        }