예제 #1
0
        private void button20_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text != "" && textBox1.Text != "")
                {
                    ILayer        Layer         = axMapControl1.ActiveView.FocusMap.get_Layer(comboBox1.SelectedIndex);
                    IFeatureLayer selectedLayer = Layer as IFeatureLayer;
                    IQueryFilter  pFilter       = new QueryFilterClass();
                    pFilter.WhereClause = textBox1.Text;
                    IFeatureSelection featSelect = selectedLayer as IFeatureSelection;
                    if (comboBox2.SelectedIndex == 0)
                    {
                        featSelect.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
                    }
                    if (comboBox2.SelectedIndex == 1)
                    {
                        featSelect.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
                    }
                    if (comboBox2.SelectedIndex == 2)
                    {
                        featSelect.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultSubtract, false);
                    }
                    axMapControl1.Refresh();
                }

                this.Close();
                f1.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("There was an error with the expression. \nGeneral function failure [" + comboBox1.Text.ToString() + "] \nSyntax error (missing operator) in query expression '" + textBox1.Text.ToString() + "'.");
            }
        }
예제 #2
0
 /// <summary>
 /// 设置地图初始化范围
 /// </summary>
 public void InitExtent()
 {
     Core.Generic.myXML xml = new Core.Generic.myXML(System.Windows.Forms.Application.StartupPath + "\\Setting.xml");
     try
     {
         float xmin, ymin, xmax, ymax;
         float.TryParse(xml.GetElement("InitExtent", "Xmin"), out xmin);
         float.TryParse(xml.GetElement("InitExtent", "Ymin"), out ymin);
         float.TryParse(xml.GetElement("InitExtent", "Xmax"), out xmax);
         float.TryParse(xml.GetElement("InitExtent", "Ymax"), out ymax);
         IEnvelope env = new Envelope() as IEnvelope;
         env.XMin          = xmin;
         env.YMin          = ymin;
         env.XMax          = xmax;
         env.YMax          = ymax;
         mapControl.Extent = env;
         mapControl.Refresh();
     }
     catch (Exception ex)
     {
         throw (ex);
     }
     finally
     {
         xml = null;
     }
 }
예제 #3
0
파일: BaseFuncs.cs 프로젝트: hehao1999/GIS
        public static void NewMapDoc(Control.ControlCollection controls, ESRI.ArcGIS.Controls.AxMapControl mainMapControl)
        {
            try
            {
                //实例化AxMapControl控件,并加入Form的Controls
                ESRI.ArcGIS.Controls.AxMapControl axMapControl = new ESRI.ArcGIS.Controls.AxMapControl();
                ((System.ComponentModel.ISupportInitialize)(axMapControl)).BeginInit();
                controls.Add(axMapControl);
                ((System.ComponentModel.ISupportInitialize)(axMapControl)).EndInit();

                //实例化SaveFileDialog控件
                SaveFileDialog pSaveFileDialog = new SaveFileDialog();
                pSaveFileDialog.Title            = "输入需要新建地图文档的名称";
                pSaveFileDialog.Filter           = "地图文件(*.mxd)|*.mxd";
                pSaveFileDialog.OverwritePrompt  = true;
                pSaveFileDialog.RestoreDirectory = true;

                if (pSaveFileDialog.ShowDialog() == DialogResult.OK)
                {//保存地图文档
                    string       filename     = pSaveFileDialog.FileName;
                    IMapDocument pMapDocument = new MapDocumentClass();
                    pMapDocument.New(filename);
                    axMapControl.Map = pMapDocument.get_Map(0);
                    axMapControl.DocumentFilename = pMapDocument.DocumentFilename;
                    pMapDocument.Close();
                    mainMapControl.LoadMxFile(filename);
                    mainMapControl.Refresh();
                    MessageBox.Show("新建地图文档成功!", "信息提示", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    return;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("新建地图文档失败!" + exc.Message, "信息提示", MessageBoxButtons.OK);
                return;
            }
        }
예제 #4
0
파일: Form5.cs 프로젝트: abanoubamin/ArcMap
        private void button20_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text != "")
                {
                    ILayer                  sheyakhaLayer  = axMapControl1.ActiveView.FocusMap.get_Layer(layerIndex);
                    IFeatureLayer           fsheyakhalayer = sheyakhaLayer as FeatureLayer;
                    IFeatureLayerDefinition dlayer         = fsheyakhalayer as IFeatureLayerDefinition;
                    dlayer.DefinitionExpression = textBox1.Text;
                    axMapControl1.Refresh();
                }

                this.Close();
                f1.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("There was an error with the expression. \nGeneral function failure [" + Layer + "] \nSyntax error (missing operator) in query expression '" + textBox1.Text.ToString() + "'.");
            }
        }