Beispiel #1
0
        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 = axArcReaderControl1.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 cmdMapProperties_Click(object sender, System.EventArgs e)
        {
            if (axArcReaderControl1.CurrentViewType == esriARViewType.esriARViewTypeNone)
            {
                System.Windows.Forms.MessageBox.Show("You must load a map document first!");
                return;
            }
            string sProps = "Map and Layer Properties" + "\xA" + "\xA";

            // Loop through each map in the document
            // Get the IARMap interface
            for (int i = 0; i <= axArcReaderControl1.ARPageLayout.ARMapCount - 1; i++)
            {
                ARMap map = axArcReaderControl1.ARPageLayout.get_ARMap(i);
                // Get map properties
                sProps = sProps + map.Name.ToUpper() + "\xA" + "Description:" + map.Description + "\xA" + "Spatial Reference:" + "\x9" + map.SpatialReferenceName + "\xA" + "Units:" + "\x9" + "\x9" + axArcReaderControl1.ARUnitConverter.EsriUnitsAsString(map.DistanceUnits, esriARCaseAppearance.esriARCaseAppearanceUnchanged, true) + "\xA";
                // Get map extent type
                esriARExtentType extent = axArcReaderControl1.ARPageLayout.get_MapExtentType(map);
                if (extent == esriARExtentType.esriARExtentTypeFixedExtent)
                {
                    sProps = sProps + "Extent Type:" + "\x9" + "Fixed Extent" + "\xA";
                }
                else if (extent == esriARExtentType.esriARExtentTypeFixedScale)
                {
                    sProps = sProps + "Extent Type:" + "\x9" + "Fixed Scale" + "\xA";
                }
                else
                {
                    sProps = sProps + "Extent Type:" + "\x9" + "Automatic" + "\xA";
                }
                sProps = sProps + "\xA";
                // Loop through each layer in the map
                // Get the IARLayer interface
                for (int j = 0; j <= map.ARLayerCount - 1; j++)
                {
                    IARLayer layer = map.get_ARLayer(j);
                    // Get the layer properties
                    sProps = sProps + layer.Name + "\xA" + "Description:" + "\x9" + layer.Description + "\xA" + "Minimum Scale:" + "\x9" + layer.MinimumScale + "\xA" + "Maximum Scale:" + "\x9" + layer.MaximumScale + "\xA" + "\xA";
                }
                sProps = sProps + "\xA";
            }
            RichTextBox1.Text = sProps;
        }
Beispiel #3
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";
            }
        }