⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributequery.cs

📁 利用CSharp二次开发的地理属性查询
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.lblFieldType.TabIndex = 28;
			this.lblFieldType.Text = "Field Type:";
			// 
			// lblLayerToQuery
			// 
			this.lblLayerToQuery.Location = new System.Drawing.Point(8, 24);
			this.lblLayerToQuery.Name = "lblLayerToQuery";
			this.lblLayerToQuery.Size = new System.Drawing.Size(120, 16);
			this.lblLayerToQuery.TabIndex = 27;
			this.lblLayerToQuery.Text = "Layer to Query:";
			// 
			// cmdQuery
			// 
			this.cmdQuery.Location = new System.Drawing.Point(24, 272);
			this.cmdQuery.Name = "cmdQuery";
			this.cmdQuery.Size = new System.Drawing.Size(104, 32);
			this.cmdQuery.TabIndex = 26;
			this.cmdQuery.Text = "Query";
			this.cmdQuery.Click += new System.EventHandler(this.cmdQuery_Click);
			// 
			// txtValue
			// 
			this.txtValue.Location = new System.Drawing.Point(8, 240);
			this.txtValue.Name = "txtValue";
			this.txtValue.Size = new System.Drawing.Size(120, 20);
			this.txtValue.TabIndex = 25;
			this.txtValue.Text = "";
			this.txtValue.TextChanged += new System.EventHandler(this.txtValue_TextChanged);
			// 
			// cboLayers
			// 
			this.cboLayers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboLayers.Location = new System.Drawing.Point(8, 40);
			this.cboLayers.Name = "cboLayers";
			this.cboLayers.Size = new System.Drawing.Size(120, 21);
			this.cboLayers.TabIndex = 24;
			this.cboLayers.SelectedIndexChanged += new System.EventHandler(this.cboLayers_SelectedIndexChanged);
			// 
			// optString
			// 
			this.optString.Location = new System.Drawing.Point(80, 96);
			this.optString.Name = "optString";
			this.optString.Size = new System.Drawing.Size(56, 16);
			this.optString.TabIndex = 23;
			this.optString.Text = "String";
			this.optString.Click += new System.EventHandler(this.DataType_Click);
			// 
			// optNumber
			// 
			this.optNumber.Location = new System.Drawing.Point(8, 96);
			this.optNumber.Name = "optNumber";
			this.optNumber.Size = new System.Drawing.Size(64, 16);
			this.optNumber.TabIndex = 22;
			this.optNumber.Text = "Number";
			this.optNumber.Click += new System.EventHandler(this.DataType_Click);
			// 
			// cboOperator
			// 
			this.cboOperator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboOperator.Location = new System.Drawing.Point(8, 192);
			this.cboOperator.Name = "cboOperator";
			this.cboOperator.Size = new System.Drawing.Size(120, 21);
			this.cboOperator.TabIndex = 21;
			// 
			// cboFields
			// 
			this.cboFields.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboFields.Location = new System.Drawing.Point(8, 144);
			this.cboFields.Name = "cboFields";
			this.cboFields.Size = new System.Drawing.Size(120, 21);
			this.cboFields.TabIndex = 20;
			// 
			// lblMeets
			// 
			this.lblMeets.Location = new System.Drawing.Point(8, 360);
			this.lblMeets.Name = "lblMeets";
			this.lblMeets.Size = new System.Drawing.Size(344, 24);
			this.lblMeets.TabIndex = 21;
			// 
			// lblFails
			// 
			this.lblFails.Location = new System.Drawing.Point(368, 360);
			this.lblFails.Name = "lblFails";
			this.lblFails.Size = new System.Drawing.Size(336, 24);
			this.lblFails.TabIndex = 22;
			// 
			// axLicenseControl1
			// 
			this.axLicenseControl1.Enabled = true;
			this.axLicenseControl1.Location = new System.Drawing.Point(320, 64);
			this.axLicenseControl1.Name = "axLicenseControl1";
			this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
			this.axLicenseControl1.Size = new System.Drawing.Size(200, 50);
			this.axLicenseControl1.TabIndex = 23;
			// 
			// AttributeQuery
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(712, 517);
			this.Controls.Add(this.axLicenseControl1);
			this.Controls.Add(this.lblFails);
			this.Controls.Add(this.lblMeets);
			this.Controls.Add(this.grpBox);
			this.Controls.Add(this.cmdFullExtent);
			this.Controls.Add(this.optPan);
			this.Controls.Add(this.optZoomOut);
			this.Controls.Add(this.optZoomIn);
			this.Controls.Add(this.cmdOpen);
			this.Controls.Add(this.cmdFailFlash);
			this.Controls.Add(this.cmdFailCenterAt);
			this.Controls.Add(this.cmdFailZoomTo);
			this.Controls.Add(this.cmdMeetFlash);
			this.Controls.Add(this.cmdMeetCenterAt);
			this.Controls.Add(this.cmdMeetZoomTo);
			this.Controls.Add(this.axReaderControl1);
			this.Controls.Add(this.axMSFlexGrid2);
			this.Controls.Add(this.axMSFlexGrid1);
			this.Name = "AttributeQuery";
			this.Text = "AttributeQuery (LesserThan / GreaterThan) ";
			this.Load += new System.EventHandler(this.AttributeQuery_Load);
			((System.ComponentModel.ISupportInitialize)(this.axMSFlexGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.axMSFlexGrid2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.axReaderControl1)).EndInit();
			this.grpBox.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		[STAThread]
		static void Main() 
		{
			Application.Run(new AttributeQuery());
		}

		private void AttributeQuery_Load(object sender, System.EventArgs e)
		{
			//Disable Search Tools
			EnableSearchTools(false);
			EnableMapTools(false);
			EnableMeetHighlightTools(false);
			EnableFailHighlightTools(false);

			//Populate Inverse Operators array
			PopulateInverseOperators();

			optNumber.Checked=true;
		}	
		private void AttributeQuery_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//Release COM objects 
			ESRI.ArcGIS.Utility.COMSupport.AOUninitialize.Shutdown();
		}
		private void MixedControls_Click(object sender, System.EventArgs e)
		{
			//Added handler in InitializeComponent() for OptionButtons

			RadioButton b = (RadioButton) sender;
			//Set current tool
			switch (b.Name)
			{
				case "optZoomIn":
					axReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomIn;
					break;
				case "optZoomOut":
					axReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomOut;
					break;
				case "optPan":
					axReaderControl1.CurrentARTool = esriARTool.esriARToolMapPan;
					break;
			}
		}
		private void MixedDisplayResults_Click(object sender, System.EventArgs e)
		{
			//Added handler in InitializeComponent() for OptionButtons

			Button b = (Button) sender;
			//Set current tool
			switch (b.Name)
			{
				case "cmdMeetZoomTo":
					m_arFeatureSetMeets.ZoomTo();
					break;
				case "cmdMeetCenterAt":
					m_arFeatureSetMeets.CenterAt();
					break;
				case "cmdMeetFlash":
					m_arFeatureSetMeets.Flash();
					break;
				case "cmdFailZoomTo":
					m_arFeatureSetFails.ZoomTo();
					break;
				case "cmdFailCenterAt":
					m_arFeatureSetFails.CenterAt();
					break;
				case "cmdFailFlash":
					m_arFeatureSetFails.Flash();
					break;
			}
		}
		private void DataType_Click(object sender, System.EventArgs e)
		{
			//Added handler in InitializeComponent() for OptionButtons
				
			RadioButton b = (RadioButton) sender;
			//Set current tool
			switch (b.Name)
			{
				case "optNumber":
					PopulateFields(false);
					PopulateOperators(false);
					break;
				case "optString":
					PopulateFields(true);
					PopulateOperators(true);
					break;
			}
		}
		private void cmdFullExtent_Click(object sender, System.EventArgs e)
		{
			axReaderControl1.ARPageLayout.FocusARMap.ZoomToFullExtent();
		}
		private void cmdOpen_Click(object sender, System.EventArgs e)
		{
			//Open a file dialog for selecting map documents
			openFileDialog1.Title = "Select Published Map Document";
			openFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf";
			openFileDialog1.ShowDialog();

			//Exit if no map document is selected
			string sFilePath = openFileDialog1.FileName;
			if (sFilePath == "") return;

			//Load the specified pmf
			if (axReaderControl1.CheckDocument(sFilePath) == true)
			{
				axReaderControl1.LoadDocument(sFilePath,"");
			}
			else
			{
				System.Windows.Forms.MessageBox.Show("This document cannot be loaded!");
				return;
			}

			 //Disable search  & map tools
			cboLayers.Items.Clear();
			cboFields.Items.Clear();
			EnableSearchTools (false);
			EnableMeetHighlightTools (false);
			EnableFailHighlightTools (false);
			
			//Determine whether permission to search layers and query field values
			bool bqueryFeatures = axReaderControl1.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryFeatures);
			bool bqueryValues = axReaderControl1.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryValues);

			if (bqueryFeatures==false || bqueryValues==false)
			{
				System.Windows.Forms.MessageBox.Show("The selected Document does not have Query Permissions.");
				return;
			}

			//Add map layers to combo and store in HashTable with combo index
			m_LayersIndex = new Hashtable();
			ARPopulateComboWithMapLayers(cboLayers, m_LayersIndex);

			//Select first searchable layer
			for(int i=0;  i <= cboLayers.Items.Count-1; i++)
			{
				ARLayer arLayer = (ARLayer)m_LayersIndex[i];
				if (arLayer.Searchable==true)
				{
					cboLayers.SelectedIndex=i;
					break;
				}
			}

			//Enable Search & Map Tools
			EnableSearchTools(true);
			EnableMapTools(true);
		}
		private void ARPopulateComboWithMapLayers(ComboBox Layers, System.Collections.Hashtable LayersIndex)
		{
			//In case cboLayers is already populated
			Layers.Items.Clear();
			LayersIndex.Clear();

			ARLayer arLayer;
			ARLayer arGroupLayer;
			
			// Get the focus map
			ARMap arMap = axReaderControl1.ARPageLayout.FocusARMap;

			// Loop through each layer in the focus map
			for (int i=0; i <= arMap.ARLayerCount-1; i++)
			{
				// Get the layer name and add to combo
				arLayer = arMap.get_ARLayer(i);
				if (arLayer.IsGroupLayer == true)
				{
					//If a GroupLayer add the ARChildLayers to the combo and HashTable
					for (int g=0; g <= arLayer.ARLayerCount-1; g++)
					{
						arGroupLayer = arMap.get_ARLayer(i).get_ChildARLayer(g);
						Layers.Items.Add(arGroupLayer.Name);
						LayersIndex.Add(Layers.Items.Count-1,arGroupLayer);
					}
				}
				else if (arLayer.Searchable==true)
				{
					Layers.Items.Add(arLayer.Name);
					LayersIndex.Add(Layers.Items.Count-1,arLayer);
				}
			}
		}
		private void PopulateFields(bool bIsStringField)
		{
			try 
			{
				// Clear all items in fields combo
				cboFields.Items.Clear();
				ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];
				ARSearchDef arSearchDef = new ARSearchDefClass();
				ARFeatureCursor arFeatureCursor = arLayer.SearchARFeatures(arSearchDef);
			
				// Get the first feature in order to access the field names
				ARFeature arFeature = arFeatureCursor.NextARFeature();
        
				// Loop through fields and add field names to combo
				int i;
				i = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -