示例#1
0
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            if (e.Button != MouseButtons.Left) return;

            var rtol = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            var rstr = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            var tolerant = e.Map.PixelToProj(rtol);
            var strict = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null || _frmFeatureIdentifier.IsDisposed)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }
            _frmFeatureIdentifier.treFeatures.BeginUpdate();
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();

            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);

            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();
           
            SetSelectToSelectedNode(e.Map);
            _frmFeatureIdentifier.treFeatures.EndUpdate();

            if (!_frmFeatureIdentifier.Visible)
            {
                _frmFeatureIdentifier.Show(Map.MapFrame != null ? Map.MapFrame.Parent : null);
            }

            base.OnMouseUp(e);
        }
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            if (e.Button != MouseButtons.Left) return;
            Rectangle rtol = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            Rectangle rstr = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            Extent tolerant = e.Map.PixelToProj(rtol);
            Extent strict = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();
            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);
            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();
            _frmFeatureIdentifier.Show(Map.MapFrame != null? Map.MapFrame.Parent : null);
            base.OnMouseUp(e);
        }
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            Rectangle rtol     = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            Rectangle rstr     = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            Extent    tolerant = e.Map.PixelToProj(rtol);
            Extent    strict   = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();
            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);
            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();
            _frmFeatureIdentifier.Show();
            base.OnMouseUp(e);
        }
示例#4
0
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            var rtol     = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            var rstr     = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            var tolerant = e.Map.PixelToProj(rtol);
            var strict   = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null || _frmFeatureIdentifier.IsDisposed)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }

            _frmFeatureIdentifier.treFeatures.BeginUpdate();
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();

            Identify(e.Map.MapFrame.GetLayers().Reverse(), strict, tolerant);

            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();

            SetSelectToSelectedNode(e.Map);
            _frmFeatureIdentifier.treFeatures.EndUpdate();

            if (!_frmFeatureIdentifier.Visible)
            {
                _frmFeatureIdentifier.Show(Map.MapFrame?.Parent);
            }

            base.OnMouseUp(e);
        }
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            
            if (e.Button != MouseButtons.Left) return;
            Rectangle rtol = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            Rectangle rstr = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            Extent tolerant = e.Map.PixelToProj(rtol);
            Extent strict = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }

            _frmFeatureIdentifier.treFeatures.BeginUpdate();
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();

            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);
 
            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();

             if (_frmFeatureIdentifier.Visible == false)
             {
                 _frmFeatureIdentifier.Show(Map.MapFrame != null ? Map.MapFrame.Parent : null);
             }
             base.OnMouseUp(e);

                //Code for making the Identify Tool actually highlight what is being clicked.  
                //However, it needs more adjusting to work properly and will be shelved for now
            try
            {
                
                feature = _frmFeatureIdentifier.treFeatures.SelectedNode.Tag as IFeature;
                layer = _frmFeatureIdentifier.treFeatures.SelectedNode.Parent.Tag as IFeatureLayer;

                /* This logic is used to clear all selections on the entire map and only select a single feature when using the identify tool
                 To get it exactly as desired, I had to get the top layer, which is the mapframe, and perform a ClearSelection from there and then return
                 to the original layer selected in the legend. */
                var layers = e.Map.MapFrame.GetAllLayers();
                ILayer tempLayer = null;
                foreach (var mapLayer in layers)
                {
                    if (mapLayer.IsSelected)
                    {
                        tempLayer = mapLayer;
                        mapLayer.IsSelected = false;
                    }
                }
                if (tempLayer == null)
                {
                    tempLayer = e.Map.MapFrame;
                }
                e.Map.MapFrame.IsSelected = true;
                IEnvelope env = new Envelope();
                e.Map.MapFrame.ClearSelection(out env);
                e.Map.MapFrame.IsSelected = false;
                tempLayer.IsSelected = true;
              

                if (feature != null && layer != null && layer.IsVisible == true)
                {
                    layer.Select(feature);
                }
            }
            catch (NullReferenceException)
            {
                Debug.WriteLine("Clicked area has a null reference");
            }
            finally
            {
                _frmFeatureIdentifier.treFeatures.EndUpdate();
            }
        }
示例#6
0
        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            Rectangle rtol     = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            Rectangle rstr     = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            Extent    tolerant = e.Map.PixelToProj(rtol);
            Extent    strict   = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }

            _frmFeatureIdentifier.treFeatures.BeginUpdate();
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();

            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);

            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();

            if (_frmFeatureIdentifier.Visible == false)
            {
                _frmFeatureIdentifier.Show(Map.MapFrame != null ? Map.MapFrame.Parent : null);
            }
            base.OnMouseUp(e);

            //Code for making the Identify Tool actually highlight what is being clicked.
            //However, it needs more adjusting to work properly and will be shelved for now
            try
            {
                feature = _frmFeatureIdentifier.treFeatures.SelectedNode.Tag as IFeature;
                layer   = _frmFeatureIdentifier.treFeatures.SelectedNode.Parent.Tag as IFeatureLayer;

                /* This logic is used to clear all selections on the entire map and only select a single feature when using the identify tool
                 * To get it exactly as desired, I had to get the top layer, which is the mapframe, and perform a ClearSelection from there and then return
                 * to the original layer selected in the legend. */
                var    layers    = e.Map.MapFrame.GetAllLayers();
                ILayer tempLayer = null;
                foreach (var mapLayer in layers)
                {
                    if (mapLayer.IsSelected)
                    {
                        tempLayer           = mapLayer;
                        mapLayer.IsSelected = false;
                    }
                }
                if (tempLayer == null)
                {
                    tempLayer = e.Map.MapFrame;
                }
                e.Map.MapFrame.IsSelected = true;
                IEnvelope env = new Envelope();
                e.Map.MapFrame.ClearSelection(out env);
                e.Map.MapFrame.IsSelected = false;
                tempLayer.IsSelected      = true;


                if (feature != null && layer != null && layer.IsVisible == true)
                {
                    layer.Select(feature);
                }
            }
            catch (NullReferenceException)
            {
                Debug.WriteLine("Clicked area has a null reference");
            }
            finally
            {
                _frmFeatureIdentifier.treFeatures.EndUpdate();
            }
        }