private bool CheckRequirments() { if (String.IsNullOrEmpty(cboTileIndex.Text) || String.IsNullOrEmpty(cboNameField.Text) || String.IsNullOrEmpty(txbFileWorkspace.Text)) { Utilities_MessageBox.ErrorBox("Initialize Tool Settings", MB_TITLE); this.Visible = true; return(false); } if (String.IsNullOrEmpty(txbCustomExtension.Text)) { Utilities_MessageBox.ErrorBox("Enter A Custom Extension (eg. '.tif' or 'las')", MB_TITLE); this.Visible = true; return(false); } try { IFeatureLayer tile_index1 = _utilitiesArcMap.FeatureLayer(cboTileIndex.Text); if (tile_index1 == null) { return(false); } IFeatureClass tile_index2 = tile_index1.FeatureClass; if (tile_index2 == null) { return(false); } IFields fields = tile_index2.Fields; if (!(fields.FindField(cboNameField.Text) > -1)) { return(false); } if (!Directory.Exists(txbFileWorkspace.Text)) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(false); }
/// <summary> /// Checks to see if the correct settings are setup for the tool to run /// </summary> /// <returns></returns> private bool CheckRequirements() { if (string.IsNullOrEmpty(cbo_featureclass.Text)) { Utilities_MessageBox.ErrorBox("Initialize Tool Settings", MB_TITLE); this.Visible = true; return(false); } try { _editor = _utilitiesArcMap.GetEditorFromArcMap(_application as IMxApplication); if (_editor == null) { Utilities_MessageBox.ErrorBox("Editor version of ArcMap required.", MB_TITLE); return(false); } if (_editor.EditState != esriEditState.esriStateEditing) { MessageBox.Show("Start an edit session first.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } IFields fields = _utilitiesArcMap.FeatureLayer(cbo_featureclass.Text)?.FeatureClass?.Fields; if (fields == null) { Utilities_MessageBox.ErrorBox("Error...Not a feature class", MB_TITLE); return(false); } return(true); } catch (Exception ex) { Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE); } try { IFeatureLayer feature_layer = _utilitiesArcMap.FeatureLayer(cbo_featureclass.Text); IFeatureClass feature_calss = feature_layer.FeatureClass; return(true); } catch (Exception ex) { RS_Tools.Utilities.Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE); } return(false); }
private void ApplyDomainNull() { if (CheckRequirements()) { try { IFeatureLayer featureLayer = _utilities.FeatureLayer(cboFeatureLayer.Text); IFeatureClass featureClass = featureLayer.FeatureClass; IFeatureSelection featureSelection = featureLayer as IFeatureSelection; IEnumIDs enumIDs = featureSelection.SelectionSet.IDs; int fieldIndex = _utilities.FindField(featureClass, cboField.Text); enumIDs.Reset(); _editor.StartOperation(); int intOID = enumIDs.Next(); while (intOID != -1) { IFeature feature = featureClass.GetFeature(intOID); if (feature != null) { feature.set_Value(fieldIndex, System.DBNull.Value); feature.Store(); } intOID = enumIDs.Next(); } _activeView.Refresh(); _editor.StopOperation("Update Class Type"); } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception ex) #pragma warning restore CS0168 // Variable is declared but never used { MessageBox.Show("Shapefiles Don't Accept Null"); } } }
private bool CheckRequirements() { if (!groupCorner.Controls.OfType <RadioButton>().Any(x => x.Checked)) { MessageBox.Show("Select A Corner", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } if (!groupDirection.Controls.OfType <RadioButton>().Any(x => x.Checked)) { MessageBox.Show("Select A Direction", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } try { if (_utilitiesArcMap == null) { _mxdocument = (IMxDocument)_application.Document; _map = _mxdocument.FocusMap; _activeView = _mxdocument.ActiveView; if (_utilitiesArcMap == null) { _utilitiesArcMap = new Utilities_ArcMap(_map); } } if (this.cbo_FeatureLayers.Items.Count == 0) { MessageBox.Show("Add a layer to inspect to the table of contents", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } IFeatureLayer featureLayer = _utilitiesArcMap.FeatureLayer((cbo_FeatureLayers.Text)); if (featureLayer == null) { MessageBox.Show("Feature Layer Failed To Load", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass == null) { MessageBox.Show("Feature Class Failed To Load", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } ILayer layer = _utilitiesArcMap.Layer(this.cbo_FeatureLayers.Text); int inspectionfieldindex = _utilitiesArcMap.FindField(layer, "rsi_index"); if (inspectionfieldindex < 0) { MessageBox.Show("Add 'rsi_index' field, short integer!", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } _editor = _utilitiesArcMap.GetEditorFromArcMap(_application as IMxApplication); if (_editor == null) { MessageBox.Show("Editor version of ArcMap required.", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } if (_editor.EditState != esriEditState.esriStateEditing) { MessageBox.Show("Start an edit session first.", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private void btnOKNext_Click(object sender, EventArgs e) { if (!CheckRequirements()) { return; } IFeatureLayer buildingslayer = _utilitiesArcMap.FeatureLayer(this.cboBuildingLayer.Text); try { if (buildingslayer != null) { int indexField = _utilitiesArcMap.FindField(buildingslayer, "rsi_index"); int inspectionfieldindex = _utilitiesArcMap.FindField(buildingslayer, "rsi"); IFeatureClass buildingsfeatureclass = buildingslayer.FeatureClass; IFeatureSelection buildingsfeatureselection = buildingslayer as IFeatureSelection; if (buildingsfeatureselection.SelectionSet.Count > 0) { Update(1, buildingslayer); } IFeatureCursor featurecursor = null; IQueryFilter queryfilter = new QueryFilterClass(); queryfilter.WhereClause = "\"rsi\" IS NULL"; if (indexField > -1) { queryfilter.SubFields = "rsi_index"; IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)queryfilter; queryFilterDef.PostfixClause = "ORDER BY rsi_index"; } featurecursor = buildingsfeatureclass.Search(queryfilter, false); IFeature feature = null; while ((feature = featurecursor.NextFeature()) != null) { IPolygon polygon = feature.Shape as IPolygon; IPolyline polyline = feature.Shape as IPolyline; if ((polygon != null) || (polyline != null)) { buildingsfeatureselection.Clear(); buildingsfeatureselection.Add(feature); buildingsfeatureselection.SelectionChanged(); IEnumGeometry enumgeometry = new EnumFeatureGeometryClass(); IEnumGeometryBind enumgeometrybind = enumgeometry as IEnumGeometryBind; enumgeometrybind.BindGeometrySource(null, buildingsfeatureselection.SelectionSet); IGeometryFactory geometryfactory = new GeometryEnvironmentClass(); IGeometry geometry = geometryfactory.CreateGeometryFromEnumerator(enumgeometry); IEnvelope envelope = geometry.Envelope; double scale = tb_scale.Value / 100.0; envelope.Expand(scale, scale, true); _activeView.Extent = envelope; _activeView.Refresh(); GetStatus(); return; } IPoint point = feature.Shape as IPoint; if (point != null) { buildingsfeatureselection.Clear(); buildingsfeatureselection.Add(feature); buildingsfeatureselection.SelectionChanged(); IEnvelope envelope = _activeView.Extent; envelope.CenterAt(point); _activeView.Extent = envelope; double scale = tb_scale.Value; _map.MapScale = scale; _activeView.Refresh(); GetStatus(); return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { //_restartreport = false; } }
private bool CheckRequirments() { if (String.IsNullOrEmpty(cbo_TileIndex.Text)) { Utilities_MessageBox.ErrorBox("Initialize Tool Settings", MB_TITLE); return(false); } if (String.IsNullOrEmpty(cbo_FieldName.Text)) { Utilities_MessageBox.ErrorBox("Select Field", MB_TITLE); return(false); } if (String.IsNullOrEmpty(txb_FileWorkspace.Text)) { Utilities_MessageBox.ErrorBox("Select File Workspace", MB_TITLE); return(false); } try { IFeatureLayer featureLayer = _utilitiesArcMap.FeatureLayer(cbo_TileIndex.Text); if (featureLayer == null) { return(false); } IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass == null) { return(false); } IFields fields = featureClass.Fields; if (!(_utilitiesArcMap.FindField(featureClass, cbo_FieldName.Text) > -1)) { return(false); } if (rb_selected.Checked == false && rb_all.Checked == false) { Utilities_MessageBox.ErrorBox("Select A File Loading Method", MB_TITLE); return(false); } // If selected file loading method check if anything is selected if (rb_selected.Checked) { IFeatureSelection featureSelection = featureLayer as IFeatureSelection; if (featureSelection.SelectionSet.Count == 0) { Utilities_MessageBox.ErrorBox("Select At Least One Feature", MB_TITLE); return(false); } } if (!Directory.Exists(txb_FileWorkspace.Text)) { Utilities_MessageBox.ErrorBox("File Workspace Is Invalid", MB_TITLE); return(false); } return(true); } catch (Exception ex) { Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE); } return(false); }