예제 #1
0
        /// <inheritdoc />
        protected override void OnMouseDown(GeoMouseArgs e)
        {
            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                _mousePosition = e.Location;
                if (_dragging)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        _dragging = false;
                        Map.Invalidate();
                        Map.IsBusy = false;
                    }
                }
                else
                {
                    if (_selectedFeature != null)
                    {
                        Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);

                        Envelope env = Map.PixelToProj(mouseRect).ToEnvelope();

                        if (CheckForVertexDrag(e))
                        {
                            return;
                        }

                        // No vertex selection has occured.
                        if (!_selectedFeature.Geometry.Intersects(env.ToPolygon()))
                        {
                            // We are clicking down outside of the given polygon, so clear our selected feature
                            DeselectFeature();
                            return;
                        }
                    }

                    if (_activeFeature != null)
                    {
                        // Don't start dragging a vertices right away for polygons and lines.
                        // First you select the polygon, which displays the vertices, then they can be moved.
                        if (_featureSet.FeatureType == FeatureType.Polygon)
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            IPolygonCategory sc = _selectedCategory as IPolygonCategory;
                            if (sc == null)
                            {
                                _selectedCategory = new PolygonCategory(Color.FromArgb(55, 0, 255, 255), Color.Blue, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }

                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else if (_featureSet.FeatureType == FeatureType.Line)
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            ILineCategory sc = _selectedCategory as ILineCategory;
                            if (sc == null)
                            {
                                _selectedCategory = new LineCategory(Color.Cyan, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }
                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else
                        {
                            _dragging  = true;
                            Map.IsBusy = true;
                            _dragCoord = _activeFeature.Geometry.Coordinates[0];
                            MapPointLayer mpl = _layer as MapPointLayer;
                            if (mpl != null)
                            {
                                mpl.SetVisible(_activeFeature, false);
                            }
                            IPointCategory sc = _selectedCategory as IPointCategory;
                            if (sc == null)
                            {
                                IPointSymbolizer ps =
                                    _layer.GetCategory(_activeFeature).Symbolizer.Copy() as IPointSymbolizer;
                                if (ps != null)
                                {
                                    ps.SetFillColor(Color.Cyan);
                                    _selectedCategory = new PointCategory(ps);
                                }
                            }
                        }
                    }
                    Map.MapFrame.Initialize();
                    Map.Invalidate();
                }
            }
            base.OnMouseDown(e);
        }
예제 #2
0
        /// <inheritdoc />
        protected override void OnMouseDown(GeoMouseArgs e)
        {
            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                _mousePosition = e.Location;
                if (_dragging)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        _dragging = false;
                        Map.Invalidate();
                        Map.IsBusy = false;
                    }
                }
                else
                {
                    // ÆíÁýÇÒ µµÇüÀÌ ¼±ÅõǾî ÀÖÀ¸¸é, ÆíÁýÇÒ Á¤Á¡À» ¼±ÅÃÇÕ´Ï´Ù.
                    if (_selectedFeature != null)
                    {
                        // Á¤Á¡ ¼±ÅÃÀ» À§ÇÑ ¿µ¿ªÀ» ¼³Á¤ÇÕ´Ï´Ù.
                        Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
                        Envelope  env       = Map.PixelToProj(mouseRect).ToEnvelope();

                        // Á¤Á¡ÀÌ ¼±ÅõǾú½À´Ï´Ù.
                        if (CheckForVertexDrag(e))
                        {
                            return;
                        }

                        // Á¤Á¡ ¼±ÅÃÀÌ ¹ß»ýÇÏÁö ¾Ê¾Ò½À´Ï´Ù.
                        if (!_selectedFeature.Geometry.Intersects(env.ToPolygon()))
                        {
                            // ¼±ÅÃÀ» Ãë¼ÒÇÕ´Ï´Ù.
                            DeselectFeature();
                            return;
                        }
                    }

                    if (_activeFeature != null)
                    {
                        // ´Ù°¢Çü°ú ¼±ÀÇ Á¤Á¡À» ¹Ù·Î µå·¡±×ÇÏÁö ¸¶½Ê½Ã¿À. ¸ÕÀú Á¤Á¡À» Ç¥½ÃÇÏ´Â ´Ù°¢ÇüÀ» ¼±ÅÃÇÑ ´ÙÀ½ À̵¿ÇÒ ¼ö ÀÖ½À´Ï´Ù.
                        if (_featureSet.FeatureType == FeatureType.Polygon) // ¸é
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            if (!(_selectedCategory is IPolygonCategory sc))
                            {
                                _selectedCategory = new PolygonCategory(Color.FromArgb(55, 0, 255, 255), Color.Blue, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }

                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else if (_featureSet.FeatureType == FeatureType.Line) // ¼±
                        {
                            _selectedFeature = _activeFeature;
                            _activeFeature   = null;
                            if (!(_selectedCategory is ILineCategory sc))
                            {
                                _selectedCategory = new LineCategory(Color.Cyan, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }

                            _layer.SetCategory(_selectedFeature, _selectedCategory);
                        }
                        else // Á¡
                        {
                            _dragging  = true;
                            Map.IsBusy = true;
                            _dragCoord = _activeFeature.Geometry.Coordinates[0];
                            MapPointLayer mpl = _layer as MapPointLayer;
                            mpl?.SetVisible(_activeFeature, false);

                            if (!(_selectedCategory is IPointCategory sc))
                            {
                                if (_layer.GetCategory(_activeFeature).Symbolizer.Copy() is IPointSymbolizer ps)
                                {
                                    ps.SetFillColor(Color.Cyan);
                                    _selectedCategory = new PointCategory(ps);
                                }
                            }
                        }
                    }

                    Map.MapFrame.Initialize();
                    Map.Invalidate();
                }
            }

            base.OnMouseDown(e);
        }