Beispiel #1
0
        /// <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);
                }
            }
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <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;
            }
        }