Exemplo n.º 1
0
        public override void OnMouseUp(int x, int y)
        {
            if (m_selection != null)
            {
                List <Feature> SelectFeatures = new List <Feature>();
                screenSelRect = m_selection.ScreenRect();
                RgPoint     lowLeft = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(screenSelRect.Left, screenSelRect.Bottom));
                RgPoint     upRight = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(screenSelRect.Right, screenSelRect.Top));
                BoundingBox box     = new BoundingBox(lowLeft, upRight);
                //RectangleF selectionRect = m_selection.Selection(m_canvaswrapper);
                if (screenSelRect != Rectangle.Empty)
                {
                    // is any selection rectangle. use it for selection
                    for (int i = 0; i < mMap.Layers.Count; i++)
                    {
                        ILayer lyr = mMap.Layers[i];
                        if (lyr is FetureLayer)
                        {
                            Carto.FetureLayer featlyr = lyr as Carto.FetureLayer;
                            SelectFeatures = featlyr.GetHitObjects(box, m_selection.AnyPoint());
                            if (SelectFeatures != null)
                            {
                                for (int j = 0; j < SelectFeatures.Count; j++)
                                {
                                    SelectFeatures[j].IsSelected = true;
                                }
                                if (mMap.Selection == null)
                                {
                                    mMap.Selection = new MapSelection();
                                }

                                mMap.Selection.SelectedFeatures.AddRange(SelectFeatures);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < mMap.Layers.Count; i++)
                    {
                        ILayer lyr = mMap.Layers[i];
                        if (lyr is FetureLayer)
                        {
                            Carto.FetureLayer featlyr    = lyr as Carto.FetureLayer;
                            RgPoint           mousepoint = mScreenDisplay.DisplayTransformation.ToUnit(new PointF(x, y));
                            SelectFeatures = featlyr.GetHitObjects(mousepoint, 0.1);
                            if (SelectFeatures != null)
                            {
                                for (int j = 0; j < SelectFeatures.Count; j++)
                                {
                                    SelectFeatures[j].IsSelected = true;
                                }
                                if (mMap.Selection == null)
                                {
                                    mMap.Selection = new MapSelection();
                                }

                                mMap.Selection.SelectedFeatures.AddRange(SelectFeatures);
                            }
                        }
                    }
                }
                mMapCtrl.Refresh();
                m_selection = null;
            }
        }
Exemplo n.º 2
0
        public override void OnMouseDown(int x, int y, System.Windows.Forms.MouseEventArgs e)
        {
            PointF m_mousedownPoint = new PointF(x, y);

            m_selection = new SelectionRectangle(m_mousedownPoint);
        }