/// <summary> /// React on main window mouse move. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="args">Mouse move event args.</param> private void _MainWindowMouseMove(object sender, MouseEventArgs args) { // Clear clickedgraphic in case of mouse button released. if (args.LeftButton == MouseButtonState.Released && _clickedGraphic != null) { _clickedGraphic = null; } // Clicked graphic is not DataGraphicObject in case of moving from cluster layer. DataGraphicObject clickedDataGraphic = _clickedGraphic as DataGraphicObject; if (clickedDataGraphic != null) { bool isNewlyCreated = _mapControl.SelectedItems.Count == 0 && clickedDataGraphic.Selected; // If selection can be changed by mouse move. if (!isNewlyCreated && !_mapControl.IsInEditedMode) { if (!(Keyboard.Modifiers != ModifierKeys.Control && _mapControl.SelectedItems.Contains(clickedDataGraphic.Data)) && !(clickedDataGraphic is EditMarkerGraphicObject)) { _mapSelectionManager.ProcessGraphicMouseEvents(_clickedGraphic, _clickedGraphic); } } } _clickedGraphic = null; }
/// <summary> /// Set map positions to graphics in clustering layer by circle /// </summary> private void _SetCircledPositionsToExpandedClusterGraphics() { int count = _clusteringLayer.MapLayer.Graphics.Count; // do visual expand double sinus = Math.Sin(Math.PI / count); double radius = DIST_BETWEEN_EXPANDED_SYMBOLS / (2 * sinus); if (radius < MINIMAL_EXPANDED_CLUSTER_RADIUS) { radius = MINIMAL_EXPANDED_CLUSTER_RADIUS; } _expandedAreaRadius = radius + ADDITIONAL_EXPANDED_AREA; for (int index = 0; index < count; index++) { double angle = (2 * Math.PI / count) * index; double dx = radius * Math.Cos(angle); double dy = radius * Math.Sin(angle); DataGraphicObject graphic = (DataGraphicObject)_clusteringLayer.MapLayer.Graphics[index]; MarkerSymbol symbol = (MarkerSymbol)graphic.Symbol; System.Windows.Point symbolPoint = _mapctrl.map.MapToScreen((MapPoint)graphic.Geometry); symbol.OffsetX = dx - _clusterCenter.Value.X + symbolPoint.X; symbol.OffsetY = dy - _clusterCenter.Value.Y + symbolPoint.Y; graphic.SetZIndex(ObjectLayer.FRONTZINDEX); } }
public static Control CreateCustomOrderSymbol(object orderOrStop) { DataGraphicObject graphicObject = null; // Create data graphic object that depends on object type. if (orderOrStop is Stop) { graphicObject = StopGraphicObject.Create(orderOrStop as Stop); } else if (orderOrStop is Order) { graphicObject = OrderGraphicObject.Create(orderOrStop as Order); } else { Debug.Assert(false); // Not supported. } // Init graphics object by order symbology manager. SymbologyManager.InitGraphic(graphicObject); // Create symbol control var control = new ESRI.ArcLogistics.App.DragAndDrop.Adornments.Controls.SymbolControl (graphicObject.Symbol.ControlTemplate); // Copy attributes from graphics object to symbol control. control.SymbologyContextDictionary = graphicObject.Attributes; // Offset symbol so it is not rendered shifted. control.RenderTransform = new TranslateTransform(-control.OffsetX, -control.OffsetY); return(control); }
/// <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; } }
private static Symbol _InitGraphicByCategory(object value, DataGraphicObject graphicObject) { SymbologyRecord record = null; foreach (OrderCategory orderCategory in OrderCategories) { if (!orderCategory.DefaultValue && value != null && orderCategory.Value == value.ToString()) { record = orderCategory; break; } } if (record == null) { foreach (OrderCategory orderCategory in OrderCategories) { if (orderCategory.DefaultValue) { record = orderCategory; } } } return(_InitGraphicByRecord(record, graphicObject)); }
/// <summary> /// Set map positions to graphics in clustering layer by spiral /// </summary> /// <param name="count"></param> private void _SetSpiraledPositionsToExpandedClusterGraphics() { int count = _clusteringLayer.MapLayer.Graphics.Count; double radius = MINIMAL_EXPANDED_CLUSTER_RADIUS; double dRadius = START_DELTA_RADIUS; double angle = START_ANGLE; double dAngle = START_DELTA_ANGLE; for (int index = 0; index < count; index++) { double dx = radius * Math.Cos(angle); double dy = radius * Math.Sin(angle); DataGraphicObject graphic = (DataGraphicObject)_clusteringLayer.MapLayer.Graphics[index]; MarkerSymbol symbol = (MarkerSymbol)graphic.Symbol; System.Windows.Point symbolPoint = _mapctrl.map.MapToScreen((MapPoint)graphic.Geometry); symbol.OffsetX = -(dx + _clusterCenter.Value.X - symbolPoint.X); symbol.OffsetY = -(dy + _clusterCenter.Value.Y - symbolPoint.Y); graphic.SetZIndex(ObjectLayer.FRONTZINDEX); radius += dRadius; dRadius *= DELTA_RADIUS_MULTIPLIER; angle += dAngle; dAngle *= DELTA_ANGLE_MULTIPLIER; } _expandedAreaRadius = radius + ADDITIONAL_EXPANDED_AREA; }
/// <summary> /// Find object layer, which contains graphic. /// </summary> /// <param name="graphic">Graphic to find.</param> /// <returns>Object layer, if it contains graphic. Null otherwise.</returns> private ObjectLayer _FindObjectLayer(Graphic graphic) { Debug.Assert(graphic != null); Debug.Assert(_objectLayers != null); Debug.Assert(_clustering != null); ObjectLayer layer = null; for (int index = 0; index < _objectLayers.Count; index++) { if (_objectLayers[index].MapLayer.Graphics.Contains(graphic)) { DataGraphicObject dataGraphic = graphic as DataGraphicObject; if (dataGraphic != null && dataGraphic.Data.GetType() != _objectLayers[index].LayerType && _objectLayers[index] != _clustering.ClusteringLayer) { continue; } layer = _objectLayers[index]; break; } } return(layer); }
/// <summary> /// Fill textBlock with order\stop names, that contains in this cluster /// </summary> /// <param name="textBlock">TextBlock to fill</param> /// <param name="dic">Cluster attributes</param> internal static void FillClusterToolText(TextBlock textBlock, IDictionary <string, object> dic) { textBlock.Inlines.Clear(); int count = (int)dic[ALClusterer.COUNT_PROPERTY_NAME]; for (int index = 0; index < count; index++) { string attributeName = ALClusterer.GRAPHIC_PROPERTY_NAME + index.ToString(); DataGraphicObject dataGraphic = (DataGraphicObject)dic[attributeName]; object item = dataGraphic.Data; Inline inline = null; Stop stop = item as Stop; Order order = item as Order; if (stop != null) { inline = new Run(stop.Name); } else if (order != null) { inline = new Run(order.Name); } else { Debug.Assert(false); } textBlock.Inlines.Add(inline); if (index != count - 1) { textBlock.Inlines.Add(new LineBreak()); } } }
/// <summary> /// Process data graphic mouse events. /// </summary> /// <param name="dataGraphic">Data graphic.</param> /// <param name="clickedGraphic">Last clicked item.</param> private void _ProcessDataGraphicMouseEvents(DataGraphicObject dataGraphic, Graphic clickedGraphic) { Debug.Assert(dataGraphic != null); Debug.Assert(_mapControl != null); ObjectLayer layer = _FindObjectLayer(dataGraphic); // Candidates selects not in common map selected items, but diretly in object layer. if (dataGraphic is CandidateGraphicObject) { _AddToSelection(dataGraphic.Data); } else if (layer != null && layer.Selectable && !_mapControl.IsInEditedMode) { // Check down and up points equals. if (clickedGraphic == dataGraphic && layer.Selectable) { // Do not need to clear selection and return the same element. if (!(SelectedItems.Count == 1 && SelectedItems[0] == dataGraphic.Data)) { if (Keyboard.Modifiers != ModifierKeys.Shift && Keyboard.Modifiers != ModifierKeys.Control && SelectedItems.Count > 0) { SelectedItems.Clear(); } SelectionWasMade = true; List <object> elementList = new List <object>(); elementList.Add(dataGraphic.Data); _ProcessSelectionChanges(elementList, layer); } } } }
/// <summary> /// Find graphic object by associated data object. /// </summary> /// <param name="data">Key data.</param> /// <returns>Graphic object, which represents data on map.</returns> public DataGraphicObject FindGraphicByData(object data) { DataGraphicObject graphicResult = null; if (_graphicDictionary.ContainsKey(data)) { graphicResult = _graphicDictionary[data]; } return(graphicResult); }
/// <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); }
public IList <object> GetClusteredData(ClusterGraphicObject clusterGraphic) { List <object> clusteredData = new List <object>(); int count = (int)clusterGraphic.Attributes[ALClusterer.COUNT_PROPERTY_NAME]; for (int index = 0; index < count; index++) { string attributeName = ALClusterer.GRAPHIC_PROPERTY_NAME + index.ToString(); DataGraphicObject dataGraphic = (DataGraphicObject)clusterGraphic.Attributes[attributeName]; clusteredData.Add(dataGraphic.Data); } return(clusteredData); }
/// <summary> /// Init Graphic. Set it's attributes and symbol /// </summary> /// <param name="graphicObject">Graphic to init</param> public static void InitGraphic(DataGraphicObject graphicObject) { if (!_inited) { _InitProjectSymbology(); } if (FieldName.Length == 0) { System.Windows.Media.Color mediaColor; Stop stop = graphicObject.Data as Stop; if (stop == null) { mediaColor = System.Windows.Media.Color.FromRgb(0, 0, 0); } else { System.Drawing.Color color = stop.Route.Color; mediaColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); } graphicObject.Attributes[SymbologyContext.FILL_ATTRIBUTE_NAME] = new SolidColorBrush(mediaColor); graphicObject.Symbol = new CustomOrderSymbol(); } else { Order order = graphicObject.Data as Order; if (order == null) { Stop stop = (Stop)graphicObject.Data; order = (Order)stop.AssociatedObject; } object value = Order.GetPropertyValue(order, FieldName); Symbol orderSymbol; if (SymbologyType == SymbologyType.CategorySymbology) { orderSymbol = _InitGraphicByCategory(value, graphicObject); } else { orderSymbol = _InitGraphicByQuantity(value, graphicObject); } graphicObject.Symbol = orderSymbol; } }
private static Symbol _InitGraphicByQuantity(object value, DataGraphicObject graphicObject) { SymbologyRecord record = null; if (value != null) { double?numValue = null; if (value is string) { double result; if (double.TryParse((string)value, out result)) { numValue = result; } } else { numValue = (double)value; } if (numValue.HasValue) { foreach (OrderQuantity orderQuantity in OrderQuantities) { if (!orderQuantity.DefaultValue && value != null && (orderQuantity.MinValue == numValue || orderQuantity.MinValue < numValue && orderQuantity.MaxValue > numValue)) { record = orderQuantity; } } } } if (record == null) { foreach (OrderQuantity orderQuantity in OrderQuantities) { if (orderQuantity.DefaultValue) { record = orderQuantity; } } } return(_InitGraphicByRecord(record, graphicObject)); }
/// <summary> /// Process graphic mouse events: expand or select. /// </summary> /// <param name="graphic">Graphic to process events.</param> /// <param name="clickedGraphic">Last clicked graphic.</param> public void ProcessGraphicMouseEvents(Graphic graphic, Graphic clickedGraphic) { Debug.Assert(graphic != null); DataGraphicObject dataGraphic = graphic as DataGraphicObject; ClusterGraphicObject clusterGraphic = graphic as ClusterGraphicObject; if (clusterGraphic != null) { _ProcessClusterGraphicMouseEvents(clusterGraphic, clickedGraphic); } else if (dataGraphic != null) { _ProcessDataGraphicMouseEvents(dataGraphic, clickedGraphic); } }
/// <summary> /// Expand cluster from cluster graphic /// </summary> /// <param name="clusterGraphic">Cluster graphic to expand</param> private void _ExpandCluster(ClusterGraphicObject clusterGraphic) { if (_mapctrl.IsInEditedMode || _MaxGraphicsToExpandExceeded(clusterGraphic)) { return; } if (!_mapctrl.IsInEditedMode) { _mapctrl.SetOpacityToLayers(MapControl.HalfOpacity); } _expandedClusterGraphic = clusterGraphic; _clusteringLayer.Visible = true; int count = (int)clusterGraphic.Attributes[ALClusterer.COUNT_PROPERTY_NAME]; Debug.Assert(count > 0); for (int index = 0; index < count; index++) { string attrKey = ALClusterer.GRAPHIC_PROPERTY_NAME + index.ToString(); DataGraphicObject grObj = (DataGraphicObject)clusterGraphic.Attributes[attrKey]; _clusteringLayerColl.Add(grObj.Data); // support already selected items if (_mapctrl.SelectedItems.Contains(grObj.Data)) { _clusteringLayer.SelectedItems.Add(grObj.Data); } } _clusterCenter = _mapctrl.map.MapToScreen((MapPoint)clusterGraphic.Geometry); if (_clusteringLayer.MapLayer.Graphics.Count > MAXIMUM_GRAPHICS_IN_CIRCLE_EXPANDED) { _SetSpiraledPositionsToExpandedClusterGraphics(); } else { _SetCircledPositionsToExpandedClusterGraphics(); } _CreateLeaderLines(); _expandedClusterGraphic.SetZIndex(ObjectLayer.FRONTZINDEX); }
/// <summary> /// Delete graphic object from layer. /// </summary> /// <param name="data">Data object to delete.</param> /// <param name="layer">Graphics layer from which to delete.</param> public static void DeleteObject(object data, GraphicsLayer layer) { for (int index = layer.Graphics.Count - 1; index >= 0; index--) { DataGraphicObject graphic = (DataGraphicObject)layer.Graphics[index]; if (graphic.Data == data) { layer.Graphics.Remove(graphic); DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null) { dataGraphicObject.UnsubscribeOnChange(); } break; } } }
/// <summary> /// Start edit. /// </summary> /// <param name="item">Editing object.</param> public void StartEdit(object item) { if (IsInEditedMode) { return; } EditedObject = item; if (item is Route || item is Stop) { return; } Debug.Assert(item is IGeocodable || item is Zone || item is Barrier); if (_clustering != null) { _clustering.ClusteringLayer.Selectable = false; // Workaround: clusters dont unexpands in case of only one cluster on view. _clustering.UnexpandIfExpanded(); } // Find graphic, which represents edited item. DataGraphicObject graphic = null; foreach (ObjectLayer layer in _objectLayers) { graphic = layer.FindGraphicByData(item); if (graphic != null) { break; } } SetOpacityToLayers(HALF_OPACITY); _tools.StartEdit(item); // Hide graphic which represents edited item. graphic.IsVisible = false; }
/// <summary> /// Get pointed item on map control by original source. /// </summary> /// <param name="e">Mouse event args.</param> /// <returns>Pointed item.</returns> private object _GetPointedItemByMouseArgs(MouseEventArgs e) { Debug.Assert(_mapView != null); FrameworkElement element = e.OriginalSource as FrameworkElement; if (element == null) { return(null); } DataBinding dataBinding = element.DataContext as DataBinding; if (dataBinding == null) { return(null); } if (!dataBinding.Attributes.ContainsKey(DataGraphicObject.DataKeyName)) { // Check this is cluster. if (dataBinding.Attributes.ContainsKey(ALClusterer.COUNT_PROPERTY_NAME)) { int count = (int)dataBinding.Attributes[ALClusterer.COUNT_PROPERTY_NAME]; for (int index = 0; index < count; index++) { string attributeName = ALClusterer.GRAPHIC_PROPERTY_NAME + index.ToString(); DataGraphicObject dataGraphic = (DataGraphicObject)dataBinding.Attributes[attributeName]; if (_mapView.SelectedItems.Contains(dataGraphic.Data)) { return(dataGraphic.Data); } } } return(null); } object item = dataBinding.Attributes[DataGraphicObject.DataKeyName]; return(item); }
/// <summary> /// React on mouse double click. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Mouse button event args.</param> private void _MapMouseDoubleClick(object sender, MouseButtonEventArgs e) { System.Windows.Point position = e.GetPosition(_mapControl.map); bool isGraphicEdited = !(_clickedGraphic is EditMarkerGraphicObject) && !(_clickedGraphic is CandidateGraphicObject); // Workaround: // due notundersandable map messages(1 graphic mouse up on 3 graphic mouse down) in case of // mouse down on graphic, pan, mouse up, doubleclick, // need to check selection. if selected element differ from doubleclicked - deny editing DataGraphicObject dataGraphic = _clickedGraphic as DataGraphicObject; bool isSelected = true; if (dataGraphic != null && !_mapSelectionManager.SelectedItems.Contains(dataGraphic.Data)) { isSelected = false; } if (_clickedGraphic != null && isGraphicEdited && !_mapControl.IsInEditedMode && position.Equals(ClickedCoords) && isSelected) { if (dataGraphic != null && dataGraphic.Data != _mapControl.EditedObject) { if (dataGraphic.Data is IGeocodable) { _mapSelectionManager.SelectionChangedFromMap = true; _mapControl.StartEditGeocodableCallback(dataGraphic.Data); _mapSelectionManager.SelectionChangedFromMap = false; } else if (dataGraphic.Data is Zone || dataGraphic.Data is Barrier) { _mapSelectionManager.SelectionChangedFromMap = true; _mapControl.StartEditRegionCallback(dataGraphic.Data); _mapSelectionManager.SelectionChangedFromMap = false; } _mapSelectionManager.SelectionWasMade = true; e.Handled = true; } } }
/// <summary> /// React on creating new item. /// </summary> /// <param name="e">Creating item event args.</param> public void OnCreatingNewItem(DataGridCreatingNewItemEventArgs e) { _mapCtrl.CurrentTool = null; _currentItem = (object)e.NewItem; // Graphic, which created to show not yet committed new item. Graphic graphic = _parentLayer.CreateGraphic(_currentItem); DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null && _parentLayer.LayerContext != null) { dataGraphicObject.ObjectContext = _parentLayer.LayerContext; } _parentLayer.MapLayer.Graphics.Add(graphic); _EditStarted(_currentItem); _SetToolsEnabled(true); }
/// <summary> /// Add collection elements to map. /// </summary> private void _InitializeGraphics() { if (_collection != null) { foreach (object dataObject in _collection) { Debug.Assert(_dataType == dataObject.GetType()); Graphic graphic = CreateGraphic(dataObject, _dataType, _graphicObjectType, LayerContext); DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null && _layerContext != null) { dataGraphicObject.ObjectContext = _layerContext; } if (graphic != null) { _layer.Graphics.Add(graphic); } } } }
private static Symbol _InitGraphicByRecord(SymbologyRecord record, DataGraphicObject graphicObject) { Symbol symbol = new MarkerSymbol(); symbol.ControlTemplate = GetTemplateByFileName(record.SymbolFilename); graphicObject.Attributes[SymbologyContext.SIZE_ATTRIBUTE_NAME] = record.Size; graphicObject.Attributes[SymbologyContext.OFFSETX_ATTRIBUTE_NAME] = -record.Size / 2 - SymbologyManager.DEFAULT_INDENT / 2; graphicObject.Attributes[SymbologyContext.OFFSETY_ATTRIBUTE_NAME] = -record.Size / 2 - SymbologyManager.DEFAULT_INDENT / 2; graphicObject.Attributes[SymbologyContext.FULLSIZE_ATTRIBUTE_NAME] = record.Size + SymbologyManager.DEFAULT_INDENT; if (!record.UseRouteColor) { System.Drawing.Color color = (System.Drawing.Color)record.Color; System.Windows.Media.Color mediaColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); graphicObject.Attributes[SymbologyContext.FILL_ATTRIBUTE_NAME] = new SolidColorBrush(mediaColor); } else { System.Windows.Media.Color mediaColor; Stop stop = graphicObject.Data as Stop; if (stop == null) { mediaColor = System.Windows.Media.Color.FromRgb(0, 0, 0); } else { System.Drawing.Color color = stop.Route.Color; mediaColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); } graphicObject.Attributes[SymbologyContext.FILL_ATTRIBUTE_NAME] = new SolidColorBrush(mediaColor); } return(symbol); }
/// <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); }
/// <summary> /// React on collection changed. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Event args.</param> private void _CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: { System.Diagnostics.Debug.Assert(e.NewItems.Count > 0); foreach (object data in e.NewItems) { // If graphic for this item was already created (to show not yet committed item) // - do not create it again. if (FindGraphicByData(data) == null) { Graphic graphic = CreateGraphic(data, _dataType, _graphicObjectType, LayerContext); if (graphic != null) { DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null && _layerContext != null) { dataGraphicObject.ObjectContext = _layerContext; } _layer.Graphics.Add(graphic); } } } break; } case NotifyCollectionChangedAction.Remove: { System.Diagnostics.Debug.Assert(e.OldItems.Count > 0); foreach (object data in e.OldItems) { DeleteObject(data, _layer); _graphicDictionary.Remove(data); } break; } case NotifyCollectionChangedAction.Reset: { foreach (Graphic graphic in _layer.Graphics) { DataGraphicObject dataGraphicObject = graphic as DataGraphicObject; if (dataGraphicObject != null) { dataGraphicObject.UnsubscribeOnChange(); } } _graphicDictionary.Clear(); _layer.Graphics.Clear(); break; } default: throw new NotSupportedException(); } }