/// <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> /// 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> /// Get elements in frame. /// </summary> /// <param name="objectLayer">Layer to find elements.</param> /// <param name="frame">Frame.</param> /// <returns>Elements in frame.</returns> private List <object> _GetElementsInSelectionFrame(ObjectLayer objectLayer, ESRI.ArcGIS.Client.Geometry.Envelope frame) { Debug.Assert(SelectedItems != null); Debug.Assert(_selectionFrame != null); Debug.Assert(_clustering != null); List <object> elementsInFrame = new List <object>(); foreach (DataGraphicObject graphic in objectLayer.MapLayer.Graphics) { // Null extent in case of empty polyline. if (graphic.Geometry != null && graphic.Geometry.Extent != null && graphic.Data.GetType() == objectLayer.LayerType) { // If graphic in frame, data type is equals to objectLayer data type and data contains in objectayercollection. if (MapHelpers.IsIntersects(frame, graphic.Geometry) && graphic.Data.GetType() == objectLayer.LayerType && MapHelpers.CollectionContainsData(objectLayer.Collection, graphic.Data)) { elementsInFrame.Add(graphic.Data); } } } _clustering.AddElementsFromClusterAndNotInFrame(objectLayer, frame, elementsInFrame); return(elementsInFrame); }
/// <summary> /// Get items in frame and select them. /// </summary> private void _SelectInFrame() { Debug.Assert(SelectedItems != null); Debug.Assert(_selectionFrame != null); Debug.Assert(_clustering != null); ESRI.ArcGIS.Client.Geometry.Envelope frame = _selectionFrame.Geometry.Extent; if (Keyboard.Modifiers != ModifierKeys.Shift && Keyboard.Modifiers != ModifierKeys.Control) { SelectedItems.Clear(); } for (int index = _objectLayers.Count - 1; index >= 0; index--) { ObjectLayer objectLayer = _objectLayers[index]; if (objectLayer == _clustering.ClusteringLayer) { continue; } if (objectLayer.Selectable && !objectLayer.SingleSelection) { //Get elements in selection frame List <object> elementsInFrame = _GetElementsInSelectionFrame(objectLayer, frame); _ProcessSelectionChanges(elementsInFrame, objectLayer); } } }
/// <summary> /// Add item to selection. /// </summary> /// <param name="item">Item to select.</param> private void _AddToSelection(object item) { Debug.Assert(item != null); Debug.Assert(_objectLayers != null); Debug.Assert(SelectedItems != null); // Candidates selects not in common map selected items, but diretly in object layer. if (item is AddressCandidate) { ObjectLayer candidatesLayer = null; foreach (ObjectLayer layer in _objectLayers) { if (layer.LayerType == typeof(AddressCandidate)) { candidatesLayer = layer; break; } } Debug.Assert(candidatesLayer != null); candidatesLayer.SelectedItems.Clear(); candidatesLayer.SelectedItems.Add(item); } else { SelectionChangedFromMap = true; SelectedItems.Add(item); SelectionChangedFromMap = false; } }
/// <summary> /// Process cluster graphic mouse events. /// </summary> /// <param name="clusterGraphic">Cluster graphic.</param> /// <param name="clickedGraphic">Last clicked item.</param> private void _ProcessClusterGraphicMouseEvents(ClusterGraphicObject clusterGraphic, Graphic clickedGraphic) { Debug.Assert(clusterGraphic != null); Debug.Assert(clickedGraphic != null); Debug.Assert(_clustering != null); Debug.Assert(_objectLayers != null); if (!_clustering.ClusterExpanded) { _clustering.ExpandIfNeeded(clusterGraphic); } else { IList <object> clusteredData = _clustering.GetClusteredData(clusterGraphic); ObjectLayer layer = MapHelpers.GetLayerWithData(clusteredData[0], _objectLayers); if (clickedGraphic == clusterGraphic && layer.Selectable) { if (Keyboard.Modifiers != ModifierKeys.Shift && Keyboard.Modifiers != ModifierKeys.Control) { _mapControl.SelectedItems.Clear(); } _ProcessSelectionChanges(clusteredData, layer); } } }
/// <summary> /// Init maptip for layer if maptip enabled. /// </summary> /// <param name="layer">Parent layer for maptip.</param> /// <param name="mapTip">Inited maptip.</param> internal void CreateMapTipIfNeeded(ObjectLayer layer, FrameworkElement mapTip) { if (layer.MapTipEnabled) { layer.MapLayer.MapTip = mapTip; ContentControl contentControl = (ContentControl)layer.MapLayer.MapTip; contentControl.IsVisibleChanged += new DependencyPropertyChangedEventHandler(_MapTipVisibilityChanged); } }
/// <summary> /// Check graphics count /// </summary> /// <param name="clusterGraphic">Cluster graphic to expand</param> /// <returns>True if exceeded</returns> private bool _MaxGraphicsToExpandExceeded(ClusterGraphicObject clusterGraphic) { IList <object> clusterData = GetClusteredData(clusterGraphic); ObjectLayer objectLayer = MapHelpers.GetLayerWithData(clusterData[0], _mapctrl.ObjectLayers); FlareClusterer clusterer = (FlareClusterer)objectLayer.MapLayer.Clusterer; int objectsInCluster = (int)clusterGraphic.Attributes[ALClusterer.COUNT_PROPERTY_NAME]; bool exceeded = objectsInCluster > clusterer.MaximumFlareCount; return(exceeded); }
/// <summary> /// Do initialisation /// </summary> private void _Init() { _clusteringLayerColl = new ObservableCollection <object>(); _clusteringLayer = new ObjectLayer(_clusteringLayerColl, typeof(object), false); _clusteringLayer.EnableToolTip(); _clusteringLayer.Selectable = true; _clusteringLayer.ConstantOpacity = true; _leaderLinesLayer = new GraphicsLayer(); }
/// <summary> /// Process selection changes according to already selected items and keyboard status. /// </summary> /// <param name="elements">Elements to process.</param> /// <param name="objectLayer">Layer to change selection.</param> private void _ProcessSelectionChanges(IList <object> elements, ObjectLayer objectLayer) { Debug.Assert(elements != null); Debug.Assert(objectLayer != null); Debug.Assert(_mapControl != null); if (Keyboard.Modifiers == ModifierKeys.Shift) { // Foreach element check possibility to being selected and select if not selected yet. foreach (object data in elements) { if (_mapControl.CanSelectCallback(data) && !objectLayer.SelectedItems.Contains(data)) { _AddToSelection(data); } } } else if (Keyboard.Modifiers == ModifierKeys.Control) { // Foreach element check possibility to being selected and invert selection. foreach (object data in elements) { if (_mapControl.CanSelectCallback(data)) { if (objectLayer.SelectedItems.Contains(data)) { _RemoveFromSelection(data); } else { _AddToSelection(data); } } } } else { // Clear previous selection... objectLayer.SelectedItems.Clear(); // ... and select elements, if possibility exists. if (_mapControl.Map.IsInitialized() && App.Current.InternalGeocoder.IsInitialized()) { foreach (object data in elements) { if (_mapControl.CanSelectCallback(data)) { _AddToSelection(data); } } } } }
/// <summary> /// Find layer which contains data. /// </summary> /// <param name="data">Object to find.</param> /// <param name="objectLayers">Object layers for searching in.</param> /// <returns>Layer, that contains graphic, associated to object.</returns> public static ObjectLayer GetLayerWithData(object data, IList <ObjectLayer> objectLayers) { ObjectLayer layerWithData = null; foreach (ObjectLayer objectLayer in objectLayers) { if (objectLayer.Collection != null) { bool isContains = CollectionContainsData(objectLayer.Collection, data); if (isContains) { layerWithData = objectLayer; break; } } } return(layerWithData); }
/// <summary> /// Add editing tool to tools list. /// </summary> /// <param name="tool">Editing tool.</param> private void _AddEditingTool(EditingTool tool) { Debug.Assert(_editingTool == null); _editedCollection = new ObservableCollection <object>(); _editedObjectLayer = new ObjectLayer(_editedCollection, typeof(object), false); _editedObjectLayer.ConstantOpacity = true; _mapctrl.AddLayer(_editedObjectLayer); _editMarkers = new ObservableCollection <EditingMarker>(); _editMarkersLayer = new ObjectLayer(_editMarkers, typeof(EditingMarker), false); _editMarkersLayer.ConstantOpacity = true; _mapctrl.AddLayer(_editMarkersLayer); _editingTool = (EditingTool)tool; _editingTool.Initialize(_mapctrl); _editingTool.SetLayer(_editMarkersLayer); _editingTool.CursorChanged += new EventHandler(_EditingToolCursorChanged); }
/// <summary> /// Add elements from cluster and not in frame /// </summary> /// <param name="objectLayer">Object layer to find cluster</param> /// <param name="frame">Selection fram envelope</param> /// <param name="elementsInFrame">Already selected elements list</param> public void AddElementsFromClusterAndNotInFrame(ObjectLayer objectLayer, Envelope frame, IList <object> elementsInFrame) { foreach (ClusterGraphicObject clusterGraphic in ClusterGraphicObject.Graphics) { if (MapHelpers.IsIntersects(frame, clusterGraphic.Geometry)) { IList <object> clusterDataList = GetClusteredData(clusterGraphic); foreach (object data in clusterDataList) { // if graphic not in frame yet, data type is equals to objectLayer data type and data contains in objectayercollection if (data.GetType() == objectLayer.LayerType && !elementsInFrame.Contains(data) && MapHelpers.CollectionContainsData(objectLayer.Collection, data)) { elementsInFrame.Add(data); } } } } }
/// <summary> /// Create layer for showing project zones /// </summary> private void _CreateZonesLayer() { IEnumerable zonesColl = (IEnumerable)App.Current.Project.Zones; _zonesLayer = new ObjectLayer(zonesColl, typeof(Zone), false); _zonesLayer.EnableToolTip(); _zonesLayer.MapLayer.Visible = App.Current.MapDisplay.ShowZones; _zonesLayer.ConstantOpacity = true; _zonesLayer.Name = App.Current.FindString("ZonesLayerName"); _zonesLayer.IsBackgroundLayer = true; mapCtrl.AddLayer(_zonesLayer); }
/// <summary> /// Create RegionsPage. /// </summary> /// <param name="mapCtrl">Map from parent page.</param> /// <param name="dataGridControl">Grid from parent page.</param> /// <param name="parentLayer">Layer, that contains regions.</param> /// <param name="type">Semantic type of regions. Barrier or Zone.</param> /// <param name="layoutRoot">Parent page layout root.</param> /// <param name="mapBorder">Container element for map.</param> public RegionsPage(MapControl mapCtrl, DataGridControlEx dataGridControl, ObjectLayer parentLayer, Type type, Grid layoutRoot, Border mapBorder) { _mapCtrl = mapCtrl; _mapCtrl.CanSelectCallback = _CanSelect; _mapCtrl.StartEditRegionCallback = _EditStarted; _mapCtrl.EndEditRegionCallback = _EditEnded; _dataGridControl = dataGridControl; _parentLayer = parentLayer; _type = type; if (_type == typeof(Zone)) { _polygonTool = new ZonePolygonTool(); _polygonTool.OnComplete += new EventHandler(_PolygonToolOnComplete); _mapCtrl.AddTool(_polygonTool, _CanActivateZonePolygonTool); } else if (_type == typeof(Barrier)) { _CreateBarrierTools(); } else Debug.Assert(false); _gridAutoFitHelper = new GridAutoFitHelper(dataGridControl, layoutRoot, mapBorder); }
/// <summary> /// Create layer for showing ungeocoded orders. /// </summary> private void _CreateOrdersLayer() { _ordersLayer = new ObjectLayer(new List<Order>(), typeof(Order), false); _ordersLayer.EnableToolTip(); _ordersLayer.Selectable = false; mapCtrl.AddLayer(_ordersLayer); }
/// <summary> /// React on selected items changed. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Collection changed args.</param> private void _SelectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Debug.Assert(_objectLayers != null); Debug.Assert(_clustering != null); _StoreSelectionIfNeeded(e); switch (e.Action) { case NotifyCollectionChangedAction.Add: { foreach (object data in e.NewItems) { // Select item in object layer. ObjectLayer objectLayer = MapHelpers.GetLayerWithData(data, _objectLayers); if (objectLayer != null) { objectLayer.SelectedItems.Add(data); } // Select in clustering layer also. if (_clustering != null) { _clustering.AddToSelection(data); } } break; } case NotifyCollectionChangedAction.Remove: { foreach (object data in e.OldItems) { // Deselect item in object layer. ObjectLayer objectLayer = MapHelpers.GetLayerWithData(data, _objectLayers); if (objectLayer != null) { objectLayer.SelectedItems.Remove(data); } // Remove from selection in clustering layer also. if (_clustering != null) { _clustering.RemoveFromSelection(data); } } break; } case NotifyCollectionChangedAction.Reset: { foreach (ObjectLayer objectLayer in _objectLayers) { objectLayer.SelectedItems.Clear(); } break; } default: Debug.Assert(false); break; } }
/// <summary> /// Create layer to show barriers on map. /// </summary> private void _CreateBarriersLayer() { var coll = (IEnumerable) _collectionSource.Source; _barriersLayer = new ObjectLayer(coll, typeof(Barrier), false); _barriersLayer.EnableToolTip(); mapCtrl.AddLayer(_barriersLayer); _barriersLayer.Selectable = true; _barriersLayer.LayerContext = App.Current.CurrentDate; _CreateMultiCollectionBinding(); }
/// <summary> /// Create layer for showing project locations /// </summary> private void _CreateLocationsLayer() { IEnumerable coll = (IEnumerable)App.Current.Project.Locations; _locationsLayer = new ObjectLayer(coll, typeof(Location), false); _locationsLayer.EnableToolTip(); mapCtrl.AddLayer(_locationsLayer); _locationsLayer.Selectable = true; }
/// <summary> /// Add layer. /// </summary> /// <param name="layer">ObjectLayer for add.</param> public void AddLayer(ObjectLayer layer) { _objectLayers.Add(layer); FrameworkElement mapTip = (FrameworkElement)LayoutRoot.FindResource("MapTip"); _mapTips.CreateMapTipIfNeeded(layer, mapTip); }
/// <summary> /// Create layer for showing project zones /// </summary> private void _CreateZonesLayer() { _zonesLayer = new ObjectLayer(null, typeof(Zone), false); _zonesLayer.EnableToolTip(); _zonesLayer.MapLayer.Visible = App.Current.MapDisplay.ShowZones; _zonesLayer.ConstantOpacity = true; _zonesLayer.Name = (string)App.Current.FindResource("ZonesLayerName"); _zonesLayer.IsBackgroundLayer = true; mapCtrl.AddLayer(_zonesLayer); }
/// <summary> /// Get elements in frame. /// </summary> /// <param name="objectLayer">Layer to find elements.</param> /// <param name="frame">Frame.</param> /// <returns>Elements in frame.</returns> private List<object> _GetElementsInSelectionFrame(ObjectLayer objectLayer, ESRI.ArcGIS.Client.Geometry.Envelope frame) { Debug.Assert(SelectedItems != null); Debug.Assert(_selectionFrame != null); Debug.Assert(_clustering != null); List<object> elementsInFrame = new List<object>(); foreach (DataGraphicObject graphic in objectLayer.MapLayer.Graphics) { // Null extent in case of empty polyline. if (graphic.Geometry != null && graphic.Geometry.Extent != null && graphic.Data.GetType() == objectLayer.LayerType) { // If graphic in frame, data type is equals to objectLayer data type and data contains in objectayercollection. if (MapHelpers.IsIntersects(frame, graphic.Geometry) && graphic.Data.GetType() == objectLayer.LayerType && MapHelpers.CollectionContainsData(objectLayer.Collection, graphic.Data)) elementsInFrame.Add(graphic.Data); } } _clustering.AddElementsFromClusterAndNotInFrame(objectLayer, frame, elementsInFrame); return elementsInFrame; }
/// <summary> /// Create layer for showing stops associated with orders of current schedule. /// </summary> private void _CreateStopOrdersLayer() { _stopOrdersLayer = new ObjectLayer(_stopOrders, typeof(Stop), true); _stopOrdersLayer.EnableToolTip(); _stopOrdersLayer.Selectable = true; mapCtrl.AddLayer(_stopOrdersLayer); }
/// <summary> /// Create layer for showing routes of current schedule. /// </summary> private void _CreateRoutesLayer() { _routesLayer = new ObjectLayer(_routesColl, typeof(Route), false); _routesLayer.EnableToolTip(); mapCtrl.AddLayer(_routesLayer); _routesLayer.Selectable = true; }
/// <summary> /// Set markers layer. /// </summary> /// <param name="markersLayer">Parent map control markers layer.</param> public void SetLayer(ObjectLayer markersLayer) { Debug.Assert(_markersLayer == null); Debug.Assert(markersLayer != null); _markersLayer = markersLayer; }
/// <summary> /// Create GeocodablePage. /// </summary> /// <param name="geocodableType">Geocodable type.</param> /// <param name="mapCtrl">Map from parent page.</param> /// <param name="candidateSelect">Control for selecting candidates.</param> /// <param name="controlsGrid">Grid, that contains map and candidateselect control.</param> /// <param name="geocodableGrid">Grid with geocodable items from parent page.</param> /// <param name="splitter">Splitter between map and candidateSelectControl.</param> /// <param name="parentLayer">Layer, that contains regions.</param> public GeocodablePage(Type geocodableType, MapControl mapCtrl, CandidateSelectControl candidateSelect, Grid controlsGrid, DataGridControlEx geocodableGrid, GridSplitter splitter, ObjectLayer parentLayer) { Debug.Assert(mapCtrl != null); Debug.Assert(candidateSelect != null); Debug.Assert(controlsGrid != null); Debug.Assert(geocodableGrid != null); Debug.Assert(splitter != null); Debug.Assert(parentLayer != null); _mapCtrl = mapCtrl; _candidateSelect = candidateSelect; _candidateSelect.Initialize(geocodableType); _controlsGrid = controlsGrid; _geocodableGrid = geocodableGrid; _splitter = splitter; _parentLayer = parentLayer; _geocodableType = geocodableType; _collapsed = new GridLength(0, GridUnitType.Star); _expanded = controlsGrid.ColumnDefinitions[SELECTORGRIDINDEX].Width; _collapsedMinWidth = 0; _expandedMinWidth = controlsGrid.ColumnDefinitions[SELECTORGRIDINDEX].MinWidth; _CollapseCandidateSelect(); // Subscribe to grid loaded event. _geocodableGrid.Loaded += new RoutedEventHandler(_GeocodableGridLoaded); }
/// <summary> /// Create candidates layer. /// </summary> private void _CreateCandidatesLayer() { Debug.Assert(_mapCtrl != null); List<AddressCandidate> coll = new List<AddressCandidate>(); _candidatesLayer = new ObjectLayer(coll, typeof(AddressCandidate), false); _mapCtrl.AddLayer(_candidatesLayer); _candidatesLayer.Selectable = true; _candidatesLayer.SelectedItems.CollectionChanged += new NotifyCollectionChangedEventHandler(_SelectedItemsCollectionChanged); _candidatesLayer.SingleSelection = true; _candidatesLayer.ConstantOpacity = true; }
/// <summary> /// Create layer for showing project barriers for current date /// </summary> private void _CreateBarriersLayer() { _barriersLayer = new ObjectLayer(null, typeof(Barrier), false); _barriersLayer.EnableToolTip(); // REV: can we expose EnableToolTip as a property rather than a method _barriersLayer.MapLayer.Visible = App.Current.MapDisplay.ShowBarriers; _barriersLayer.ConstantOpacity = true; _barriersLayer.Name = (string)App.Current.FindResource("BarriersLayerName"); _barriersLayer.IsBackgroundLayer = true; mapCtrl.AddLayer(_barriersLayer); }
/// <summary> /// Create layer for showing newly created location. /// </summary> private void _CreateEditedLayer() { _editedCollection = new ObservableCollection<object>(); _editedObjectLayer = new ObjectLayer(_editedCollection, typeof(Location), false); _editedObjectLayer.ConstantOpacity = true; _editedObjectLayer.Selectable = false; mapCtrl.AddLayer(_editedObjectLayer); }
/// <summary> /// Create layer for showing stops associated with locations of current schedule. /// </summary> private void _CreateStopLocationsLayer() { _stopLocationsLayer = new ObjectLayer(_stopLocations, typeof(Stop), false); _stopLocationsLayer.EnableToolTip(); _stopLocationsLayer.Selectable = true; mapCtrl.AddLayer(_stopLocationsLayer); }
/// <summary> /// Create layer for showing project locations. /// </summary> private void _CreateLocationsLayer() { _locationsLayer = new ObjectLayer(_locations, typeof(Location), false); _locationsLayer.EnableToolTip(); _locationsLayer.Selectable = false; mapCtrl.AddLayer(_locationsLayer); }
/// <summary> /// Create layer for showing unassigned orders of current schedule. /// </summary> private void _CreateUnassignedLayer() { _unassignedLayer = new ObjectLayer(_unassignedOrdersColl, typeof(Order), true, _stopOrdersLayer.MapLayer); _unassignedLayer.EnableToolTip(); mapCtrl.AddLayer(_unassignedLayer); _unassignedLayer.Selectable = true; }
/// <summary> /// Add elements from cluster and not in frame /// </summary> /// <param name="objectLayer">Object layer to find cluster</param> /// <param name="frame">Selection fram envelope</param> /// <param name="elementsInFrame">Already selected elements list</param> public void AddElementsFromClusterAndNotInFrame(ObjectLayer objectLayer, Envelope frame, IList<object> elementsInFrame) { foreach (ClusterGraphicObject clusterGraphic in ClusterGraphicObject.Graphics) { if (MapHelpers.IsIntersects(frame, clusterGraphic.Geometry)) { IList<object> clusterDataList = GetClusteredData(clusterGraphic); foreach (object data in clusterDataList) { // if graphic not in frame yet, data type is equals to objectLayer data type and data contains in objectayercollection if (data.GetType() == objectLayer.LayerType && !elementsInFrame.Contains(data) && MapHelpers.CollectionContainsData(objectLayer.Collection, data)) { elementsInFrame.Add(data); } } } } }
/// <summary> /// Create layer to show zones on map. /// </summary> private void _CreateZonesLayer() { IEnumerable coll = (IEnumerable)App.Current.Project.Zones; _zonesLayer = new ObjectLayer(coll, typeof(Zone), false); _zonesLayer.EnableToolTip(); mapCtrl.AddLayer(_zonesLayer); _zonesLayer.Selectable = true; _CreateMultiCollectionBinding(); }
/// <summary> /// Do initialisation /// </summary> private void _Init() { _clusteringLayerColl = new ObservableCollection<object>(); _clusteringLayer = new ObjectLayer(_clusteringLayerColl, typeof(object), false); _clusteringLayer.EnableToolTip(); _clusteringLayer.Selectable = true; _clusteringLayer.ConstantOpacity = true; _leaderLinesLayer = new GraphicsLayer(); }
/// <summary> /// Process selection changes according to already selected items and keyboard status. /// </summary> /// <param name="elements">Elements to process.</param> /// <param name="objectLayer">Layer to change selection.</param> private void _ProcessSelectionChanges(IList<object> elements, ObjectLayer objectLayer) { Debug.Assert(elements != null); Debug.Assert(objectLayer != null); Debug.Assert(_mapControl != null); if (Keyboard.Modifiers == ModifierKeys.Shift) { // Foreach element check possibility to being selected and select if not selected yet. foreach (object data in elements) { if (_mapControl.CanSelectCallback(data) && !objectLayer.SelectedItems.Contains(data)) { _AddToSelection(data); } } } else if (Keyboard.Modifiers == ModifierKeys.Control) { // Foreach element check possibility to being selected and invert selection. foreach (object data in elements) { if (_mapControl.CanSelectCallback(data)) { if (objectLayer.SelectedItems.Contains(data)) { _RemoveFromSelection(data); } else { _AddToSelection(data); } } } } else { // Clear previous selection... objectLayer.SelectedItems.Clear(); // ... and select elements, if possibility exists. if (_mapControl.Map.IsInitialized() && App.Current.InternalGeocoder.IsInitialized()) { foreach (object data in elements) { if (_mapControl.CanSelectCallback(data)) { _AddToSelection(data); } } } } }
/// <summary> /// Create layer for showing project barriers for all dates /// </summary> private void _CreateBarriersLayer() { IEnumerable barriersColl = (IDataObjectCollection<Barrier>)App.Current.Project.Barriers.SearchAll(true); _barriersLayer = new ObjectLayer(barriersColl, typeof(Barrier), false); _barriersLayer.EnableToolTip(); _barriersLayer.MapLayer.Visible = App.Current.MapDisplay.ShowBarriers; _barriersLayer.ConstantOpacity = true; _barriersLayer.Name = (string)App.Current.FindResource("BarriersLayerName"); _barriersLayer.IsBackgroundLayer = true; mapCtrl.AddLayer(_barriersLayer); }