Esempio n. 1
0
        public override void OnClick()
        {
            if (m_Hook == null)
            {
                return;
            }

            if (m_Hook.ArcGisMapControl.Map.LayerCount == 0)
            {
                MessageBox.Show("当前没有调阅数据!", "提示", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(Caption);
            }
            try
            {
                frmQuerySet fmQS = new frmQuerySet(m_Hook.ArcGisMapControl.Map, queryType.Within);
                if (fmQS.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                frmQuery            fmQuery = new frmQuery(m_Hook.MapControl, enumQueryMode.Visiable, false);
                SysCommon.CProgress pgss    = new SysCommon.CProgress("正在查询,请稍候...");
                pgss.EnableCancel    = false;
                pgss.ShowDescription = false;
                pgss.FakeProgress    = true;
                pgss.TopMost         = true;
                pgss.ShowProgress();
                Application.DoEvents();
                fmQuery.FillData(fmQS.lstQueryedLayer, fmQS.GeometryBag, queryType.Within);
                pgss.Close();
                Application.DoEvents();
                if (this.WriteLog)
                {
                    Plugin.LogTable.Writelog(Caption);
                }
                fmQuery.Show(m_frmhook.MainForm);
            }
            catch (Exception exError)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", exError.Message);
            }
        }
Esempio n. 2
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_pNewEnvelope == null)
            {
                return;
            }

            IEnvelope pEnvelope     = m_pNewEnvelope.Stop();
            int       iPiexl        = 3;
            double    iMapTolerance = ConvertPixelsToMapUnits(m_MapControl.ActiveView, iPiexl);

            IGeometry pGeometry = null;

            if (pEnvelope == null || pEnvelope.IsEmpty)
            {
                ITopologicalOperator pTopo = (ITopologicalOperator)m_pPoint;
                if (pTopo != null)
                {
                    pGeometry = pTopo.Buffer(iMapTolerance);
                }
            }
            else
            {
                pEnvelope.SpatialReference = m_MapControl.ActiveView.FocusMap.SpatialReference;
                pGeometry = pEnvelope;
            }
            m_pNewEnvelope = null;

            if (m_frmQuery == null)
            {
                m_frmQuery             = new frmQuery(m_MapControl, m_enumQueryMode);
                m_frmQuery.Owner       = m_mainFrm;
                m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
            }
            //ygc 2012-8-28 将查询结果数据在主窗体下方显示
            // _QuerBar.m_pMapControl = m_MapControl;
            // _QuerBar.EmergeQueryData(m_MapControl.ActiveView.FocusMap, pGeometry, esriSpatialRelEnum.esriSpatialRelIntersects);
            m_frmQuery.Show();
            ///ZQ 20111119  modify
            m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry, esriSpatialRelEnum.esriSpatialRelIntersects);
        }
Esempio n. 3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            if (_axmapcontrol != null)
            {
                try
                {
                    IEnvelope penvelope = new EnvelopeClass();
                    penvelope.XMin = Convert.ToDouble(textBoxWest.Text);
                    penvelope.XMax = Convert.ToDouble(textBoxEast.Text);
                    penvelope.YMax = Convert.ToDouble(textBoxNorth.Text);
                    penvelope.YMin = Convert.ToDouble(textBoxSouth.Text);
                    IPoint pmiddle = new PointClass();
                    pmiddle.PutCoords((penvelope.XMax + penvelope.XMin) / 2, (penvelope.YMax + penvelope.YMin) / 2);//中心点
                    /*********************************将Envelope转成Polygon*/
                    IPolygon         pon = new PolygonClass();
                    IPointCollection ptcoll = new PolygonClass();
                    IPoint           a = new PointClass(); IPoint b = new PointClass(); IPoint c = new PointClass(); IPoint d = new PointClass();
                    a.PutCoords(penvelope.XMin, penvelope.YMax);
                    b.PutCoords(penvelope.XMax, penvelope.YMax);
                    c.PutCoords(penvelope.XMax, penvelope.YMin);
                    d.PutCoords(penvelope.XMin, penvelope.YMin);
                    object missing = Type.Missing;
                    ptcoll.AddPoint(a, ref missing, ref missing);
                    ptcoll.AddPoint(b, ref missing, ref missing);
                    ptcoll.AddPoint(c, ref missing, ref missing);
                    ptcoll.AddPoint(d, ref missing, ref missing);
                    pon = ptcoll as IPolygon;
                    /*********************************/
                    IGeometry geo = new PolygonClass();

                    geo = pon as IGeometry;

                    /*-----xisheng 20110802------*/
                    ISpatialReference         earthref    = null;
                    ISpatialReference         flatref     = null;
                    ISpatialReferenceFactory2 pSpatRefFac = new SpatialReferenceEnvironmentClass();
                    earthref = pSpatRefFac.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                    if (this.WriteLog)
                    {
                        Plugin.LogTable.Writelog(this.Text);//xisheng 日志记录 0928;
                    }
                    if (_axmapcontrol.MapUnits == esriUnits.esriMeters)
                    {
                        flatref = _axmapcontrol.Map.SpatialReference;
                        geo.SpatialReference = flatref;//yjl20110812
                        //geo.Project(flatref);
                    }
                    /*-----xisheng 20110802------*/


                    //创建Topo对象,简化后统一空间参考
                    ITopologicalOperator pTopo = (ITopologicalOperator)geo;
                    pTopo.Simplify();
                    geo.Project(_axmapcontrol.Map.SpatialReference);


                    if (m_frmQuery == null)
                    {
                        m_frmQuery             = new frmQuery(_axmapcontrol, m_enumQueryMode);
                        m_frmQuery.Owner       = m_mainFrm;
                        m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
                    }

                    //清除上次的所有元素
                    (_axmapcontrol.Map as IGraphicsContainer).DeleteAllElements();
                    m_frmBufferSet             = new frmBufferSet(geo, _axmapcontrol.Map, m_frmQuery);
                    m_frmBufferSet.FormClosed += new FormClosedEventHandler(frmBufferSet_FormClosed);
                    _axmapcontrol.CenterAt(pmiddle);
                    IGeometry pGeometry = m_frmBufferSet.GetBufferGeometry();
                    if (pGeometry == null || m_frmBufferSet.Res == false)
                    {
                        return;
                    }

                    m_frmQuery.Show();
                    ///ZQ 20111119  modify
                    m_frmQuery.FillData(_axmapcontrol.ActiveView.FocusMap, pGeometry, m_frmBufferSet.pesriSpatialRelEnum);
                    this.Close();
                }
                catch (Exception ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "错误:" + ex.Message);
                }
            }
        }