예제 #1
0
    public void SetLayer(int layer)
    {
        ARLayer aRlayer = (ARLayer)layer;

        for (int i = 0; i < layers.Length; i++)
        {
            layers[i].SetActive(false);
        }

        switch (aRlayer)
        {
        case ARLayer.none:
            break;

        case ARLayer.goldilocks:
            goldilocksLayer.SetActive(true);
            break;

        case ARLayer.belts:
            beltsLayer.SetActive(true);
            break;

        default:
            break;
        }
    }
예제 #2
0
        private void cboLayers_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];

            //Check if layer can be searched
            if (arLayer.Searchable)
            {
                EnableSearchTools(true);
                PopulateFields(optString.Checked);
                PopulateOperators(optString.Checked);
            }
            else
            {
                MessageBox.Show("The Layer you have selected is not Searchable.");
                EnableSearchTools(false);
            }

            //Clear Grids, Labels and disable display tools
            dataGridView1.Rows.Clear();
            dataGridView2.Rows.Clear();
            lblMeets.Text = "";
            lblFails.Text = "";
            EnableMeetHighlightTools(false);
            EnableFailHighlightTools(false);
        }
예제 #3
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.");
            }
        }
예제 #4
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";
            }
        }
예제 #5
0
        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 (axArcReaderControl1.CheckDocument(sFilePath) == true)
            {
                axArcReaderControl1.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 = axArcReaderControl1.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryFeatures);
            bool bqueryValues   = axArcReaderControl1.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);
        }