private void cmdQuery_Click(object sender, System.EventArgs e)
        {
            //Determine whether permission to search layers
            if (m_queryFeatures == false)
            {
                System.Windows.Forms.MessageBox.Show("You do not have permission to search for features!");
                return;
            }

            //Get IARQueryDef interface
            ArcReaderSearchDefClass searchDef = new ArcReaderSearchDefClass();

            //Set the spatial searching to intersects
            searchDef.SpatialRelationship = esriARSpatialRelationship.esriARSpatialRelationshipIntersects;

            //Get the coordinates of the current extent
            double dXmax = 0; double dXmin = 0; double dYmin = 0; double dYmax = 0;

            axArcReaderControl1.ARPageLayout.FocusARMap.GetExtent(ref dXmin, ref dYmin, ref dXmax, ref dYmax);
            //Set the envelope coordinates as the search shape
            searchDef.SetEnvelopeShape(dXmin, dYmin, dXmax, dYmax, 0);

            //Get IARFeatureSet interface
            m_featureSet = axArcReaderControl1.ARPageLayout.FocusARMap.QueryARFeatures(searchDef);
            //Reset the featureset
            m_featureSet.Reset();
            //Get the IARFeature interface
            m_feature = m_featureSet.Next();
            //Display attribute values
            m_record = 0;
            UpdateValueDisplay();
        }
Пример #2
0
        private void PopulateFields(bool bIsStringField)
        {
            try
            {
                // Clear all items in fields combo
                cboFields.Items.Clear();
                ARLayer            arLayer         = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];
                ArcReaderSearchDef arSearchDef     = new ArcReaderSearchDefClass();
                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;
                while (i < arFeature.FieldCount)
                {
                    if (bIsStringField == true)
                    {
                        if (arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeString)
                        {
                            cboFields.Items.Add(arFeature.get_FieldName(i));
                        }
                    }
                    else
                    {
                        if ((arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeDouble) || (arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeInteger) || (arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeSingle) || (arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeSmallInteger) || (arFeature.get_FieldType(i) == esriARFieldType.esriARFieldTypeOID))
                        {
                            cboFields.Items.Add(arFeature.get_FieldName(i));
                        }
                    }

                    i = i + 1;

                    if (cboFields.Items.Count != 0)
                    {
                        cboFields.SelectedIndex = 0;
                    }
                }
                ;
            }
            catch
            {
                MessageBox.Show("An error occurred populating the Field ComboBox.");
            }
        }
		private void cmdQuery_Click(object sender, System.EventArgs e)
		{
			//Determine whether permission to search layers
			if (m_queryFeatures == false)
			{
				System.Windows.Forms.MessageBox.Show("You do not have permission to search for features!");
				return;
			}

			//Get IARQueryDef interface
			ArcReaderSearchDefClass searchDef = new ArcReaderSearchDefClass();
			//Set the spatial searching to intersects
			searchDef.SpatialRelationship = esriARSpatialRelationship.esriARSpatialRelationshipIntersects;

			//Get the coordinates of the current extent
			double dXmax=0; double dXmin=0; double dYmin=0; double dYmax=0;
			axArcReaderControl1.ARPageLayout.FocusARMap.GetExtent(ref dXmin, ref dYmin, ref dXmax, ref dYmax);
			//Set the envelope coordinates as the search shape
			searchDef.SetEnvelopeShape(dXmin, dYmin, dXmax, dYmax,0);

			//Get IARFeatureSet interface
			m_featureSet = axArcReaderControl1.ARPageLayout.FocusARMap.QueryARFeatures(searchDef);
			//Reset the featureset
			m_featureSet.Reset();
			//Get the IARFeature interface
			m_feature = m_featureSet.Next();
			//Display attribute values
			m_record = 0;
			UpdateValueDisplay();
		}
		private void cmdQuery_Click(object sender, System.EventArgs e)
		{
			//Set mouse cursor as this can take some time with large datasets
			Cursor.Current = Cursors.WaitCursor;

			//Check value has been entered in field combo
			if (cboFields.Text == "")
			{
				System.Windows.Forms.MessageBox.Show("You have not selected a field.");
				Cursor.Current = Cursors.Default;
				return;
			}

			//Check value has been entered in operator combo
			if (cboOperator.Text == "")
			{
				System.Windows.Forms.MessageBox.Show("You have not selected an operator.");
				Cursor.Current = Cursors.Default;
				return;
			}

			//Check value has been entered in value textbox
			if (txtValue.Text == "")
			{
				System.Windows.Forms.MessageBox.Show("You have not entered a query value.");
				txtValue.Focus();
				Cursor.Current = Cursors.Default;
				return;
			}

			//Get layer to query
			ARMap arMap = axArcReaderControl1.ARPageLayout.FocusARMap;

			ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];
	
			//Build the ARSearchDef
			ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass();

			//Build WhereClause that meets search criteria
			string sWhereClause;

			//Remove quotes from WhereClause if search is numeric
			if (optNumber.Checked == true)
			{
				sWhereClause = cboFields.Text + " " + cboOperator.Text + " " + txtValue.Text;
			}
			else
			{
				sWhereClause = cboFields.Text + " " + cboOperator.Text + " '" + txtValue.Text + "'";
			}

			arSearchDef.WhereClause = sWhereClause;

			//Get ARFeatureSet that meets the search criteria
			m_arFeatureSetMeets = arLayer.QueryARFeatures(arSearchDef);

			//Build WhereClause that fails search criteria
			//Remove quotes from WhereClause if search is numeric
			if (optNumber.Checked == true)
			{
				sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " " + txtValue.Text;
			}
			else
			{
				sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " '" + txtValue.Text + "'";
			}

			arSearchDef.WhereClause = sWhereClause;

			//Get ARFeatureSet that fails search criteria
			m_arFeatureSetFails = arLayer.QueryARFeatures(arSearchDef);

			//Reset mouse cursor
			Cursor.Current = Cursors.Default;

			//Populate the DataGrid Controls with the ARFeatureSets
			PopulateFlexGrids(dataGridView1, m_arFeatureSetMeets);
			PopulateFlexGrids(dataGridView2, m_arFeatureSetFails);
		

			//Give the user some feedback regarding the number of features that meet criteria
			if (m_arFeatureSetMeets.ARFeatureCount > 0)
			{ 
				EnableMeetHighlightTools(true);
				lblMeets.Text = "Features MEETING the search criteria: " + m_arFeatureSetMeets.ARFeatureCount.ToString();
			}
			else
			{
				EnableMeetHighlightTools(false);
				dataGridView1.Rows.Clear();
				lblMeets.Text = "Features MEETING the search criteria: 0";
			}

			if (m_arFeatureSetFails.ARFeatureCount > 0)
			{
				EnableFailHighlightTools(true);
				lblFails.Text = "Features FAILING the search criteria: " + m_arFeatureSetFails.ARFeatureCount.ToString();
			}
			else
			{
				EnableFailHighlightTools(false);
                dataGridView2.Rows.Clear();
				lblMeets.Text = "Features FAILING the search criteria: 0";
			}

		}
		private void PopulateFields(bool bIsStringField)
		{
			try 
			{
				// Clear all items in fields combo
				cboFields.Items.Clear();
				ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];
				ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass();
				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;
				while (i <  arFeature.FieldCount)
				{
					if (bIsStringField ==  true)
					{
						if (arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeString)
						{
							cboFields.Items.Add(arFeature.get_FieldName(i));
						}
					}
					else
					{
						if ((arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeDouble) ||  (arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeInteger) ||  (arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeSingle) ||  (arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeSmallInteger) ||  (arFeature.get_FieldType(i) ==  esriARFieldType.esriARFieldTypeOID))
						{
							cboFields.Items.Add(arFeature.get_FieldName(i));
						}
					}
				
					i = i+ 1;

					if(cboFields.Items.Count != 0)
					{
						cboFields.SelectedIndex=0;
					}
				};
			}
			catch 
			{
				MessageBox.Show("An error occurred populating the Field ComboBox.");
			}
		}
Пример #6
0
        private void cmdQuery_Click(object sender, System.EventArgs e)
        {
            //Set mouse cursor as this can take some time with large datasets
            Cursor.Current = Cursors.WaitCursor;

            //Check value has been entered in field combo
            if (cboFields.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("You have not selected a field.");
                Cursor.Current = Cursors.Default;
                return;
            }

            //Check value has been entered in operator combo
            if (cboOperator.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("You have not selected an operator.");
                Cursor.Current = Cursors.Default;
                return;
            }

            //Check value has been entered in value textbox
            if (txtValue.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("You have not entered a query value.");
                txtValue.Focus();
                Cursor.Current = Cursors.Default;
                return;
            }

            //Get layer to query
            ARMap arMap = axArcReaderControl1.ARPageLayout.FocusARMap;

            ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];

            //Build the ARSearchDef
            ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass();

            //Build WhereClause that meets search criteria
            string sWhereClause;

            //Remove quotes from WhereClause if search is numeric
            if (optNumber.Checked == true)
            {
                sWhereClause = cboFields.Text + " " + cboOperator.Text + " " + txtValue.Text;
            }
            else
            {
                sWhereClause = cboFields.Text + " " + cboOperator.Text + " '" + txtValue.Text + "'";
            }

            arSearchDef.WhereClause = sWhereClause;

            //Get ARFeatureSet that meets the search criteria
            m_arFeatureSetMeets = arLayer.QueryARFeatures(arSearchDef);

            //Build WhereClause that fails search criteria
            //Remove quotes from WhereClause if search is numeric
            if (optNumber.Checked == true)
            {
                sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " " + txtValue.Text;
            }
            else
            {
                sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " '" + txtValue.Text + "'";
            }

            arSearchDef.WhereClause = sWhereClause;

            //Get ARFeatureSet that fails search criteria
            m_arFeatureSetFails = arLayer.QueryARFeatures(arSearchDef);

            //Reset mouse cursor
            Cursor.Current = Cursors.Default;

            //Populate the DataGrid Controls with the ARFeatureSets
            PopulateFlexGrids(dataGridView1, m_arFeatureSetMeets);
            PopulateFlexGrids(dataGridView2, m_arFeatureSetFails);


            //Give the user some feedback regarding the number of features that meet criteria
            if (m_arFeatureSetMeets.ARFeatureCount > 0)
            {
                EnableMeetHighlightTools(true);
                lblMeets.Text = "Features MEETING the search criteria: " + m_arFeatureSetMeets.ARFeatureCount.ToString();
            }
            else
            {
                EnableMeetHighlightTools(false);
                dataGridView1.Rows.Clear();
                lblMeets.Text = "Features MEETING the search criteria: 0";
            }

            if (m_arFeatureSetFails.ARFeatureCount > 0)
            {
                EnableFailHighlightTools(true);
                lblFails.Text = "Features FAILING the search criteria: " + m_arFeatureSetFails.ARFeatureCount.ToString();
            }
            else
            {
                EnableFailHighlightTools(false);
                dataGridView2.Rows.Clear();
                lblMeets.Text = "Features FAILING the search criteria: 0";
            }
        }