/// <summary> /// Create graphic object for data element. /// </summary> /// <param name="data">Data object to show on map.</param> /// <param name="typeOfData">Type of data.</param> /// <param name="graphicObjectType">Graphic, associated with data object.</param> /// <param name="layerContext">Layer context.</param> /// <returns>Created graphic object.</returns> public Graphic CreateGraphic(object data, Type typeOfData, Type graphicObjectType, object layerContext) { Graphic graphic = null; Type type = data.GetType(); if (type == typeof(Location)) { graphic = LocationGraphicObject.Create((Location)data); } else if (type == typeof(Order)) { graphic = OrderGraphicObject.Create((Order)data); } else if (type == typeof(EditingMarker)) { graphic = EditMarkerGraphicObject.Create((EditingMarker)data); } else if (type == typeof(AddressCandidate)) { graphic = CandidateGraphicObject.Create((AddressCandidate)data); } else if (type == typeof(Route)) { graphic = RouteGraphicObject.Create((Route)data); } else if (type == typeof(Stop)) { graphic = StopGraphicObject.Create((Stop)data); } else if (type == typeof(Zone)) { graphic = ZoneGraphicObject.Create((Zone)data); } else if (type == typeof(Barrier)) { graphic = BarrierGraphicObject.Create((Barrier)data); } else { Debug.Assert(false); } DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null) { dataGraphicObject.ParentLayer = this; _graphicDictionary.Add(data, dataGraphicObject); } return(graphic); }
/// <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); }