/// <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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unexpand cluster
        /// </summary>
        private void _UnexpandCluster()
        {
            if (!_mapctrl.IsInEditedMode)
                _mapctrl.SetOpacityToLayers(MapControl.FullOpacity);

            Debug.Assert(ClusterExpanded);
            _expandedClusterGraphic.SetZIndex(ObjectLayer.BACKZINDEX);
            _expandedClusterGraphic = null;
            _clusterCenter = null;
            _clusteringLayerColl.Clear();
            _clusteringLayer.SelectedItems.Clear();
            _leaderLinesLayer.Graphics.Clear();
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        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>
        /// Create graphic object for order
        /// </summary>
        /// <param name="location">Source order</param>
        /// <returns>Graphic object for order</returns>
        public static ClusterGraphicObject Create(MapPoint mapPoint, IList<Graphic> cluster)
        {
            ClusterGraphicObject graphic = new ClusterGraphicObject(mapPoint, cluster);

            // ClusterGraphicObject contains static list of all clusters.
            // This list used for disposing after new clustering process is started.
            _graphics.Add(graphic);
            return graphic;
        }