private void GetStandardPlayers()
 {
     _application     = ArcMap.Application;
     _mxdocument      = (IMxDocument)_application.Document;
     _map             = _mxdocument.FocusMap;
     _utilitiesArcMap = new Utilities_ArcMap(_map);
     _editor          = _utilitiesArcMap.GetEditorFromArcMap((IMxApplication)_application);
 }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
        }
Example #4
0
        private bool CheckRequirements()
        {
            _editor = _utilities.GetEditorFromArcMap(_application as IMxApplication);

            if (_editor == null)
            {
                MessageBox.Show("Editor verion of ArcMap Required", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }

            if (_editor.EditState != esriEditState.esriStateEditing)
            {
                MessageBox.Show("Start an edit session first", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }

            if (String.IsNullOrEmpty(cboFeatureLayer.Text))
            {
                MessageBox.Show("Initialize Tool Settings", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            if (String.IsNullOrEmpty(cboField.Text))
            {
                MessageBox.Show("Choose Field", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return(false);
            }

            IFeatureLayer featureLayer = _utilities.FeatureLayer((cboFeatureLayer.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);
            }

            if (!(_utilities.FindField(featureClass, cboField.Text) > -1))
            {
                MessageBox.Show("Can't Find Fields", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            IFeatureSelection featureSelection = featureLayer as IFeatureSelection;

            if (featureSelection.SelectionSet.Count <= 0)
            {
                MessageBox.Show("Select at least one feature", MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }



            return(true);
        }