Пример #1
0
        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);
        }
Пример #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);
        }
        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);
        }
Пример #4
0
        private void CreateBatchFile()
        {
            string path             = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }

            if (!Directory.Exists(path))
            {
                Utilities_MessageBox.ErrorBox("Path Does Not Exist", MB_TITLE);
                return;
            }

            int    versionCount = 1; // This is used to make mutiple files so the batch file don't overwrite on another.
            string filePath     = path + string.Format(@"\{0}_{1}_{2}.bat", cbo_TileIndex.Text, "CopyFiles", versionCount);

            while (File.Exists(filePath))
            {
                versionCount++;
                filePath = path + string.Format(@"\{0}_{1}_{2}.bat", cbo_TileIndex.Text, "CopyFiles", versionCount);
            }



            bool itWorked = false;



            int                    cloneCount            = 1; // labeling the processor bar
            ITrackCancel           trackcancel           = new CancelTracker();
            IProgressDialogFactory progressdialogfactory = new ProgressDialogFactoryClass();
            IStepProgressor        stepprogressor        = progressdialogfactory.Create(trackcancel, _application.hWnd);

            stepprogressor.MinRange  = 0;
            stepprogressor.MaxRange  = _fileList.Count;
            stepprogressor.StepValue = 1;
            stepprogressor.Message   = "Generating...";
            IProgressDialog2 progressdialog = (IProgressDialog2)stepprogressor; // Creates and displays

            progressdialog.CancelEnabled = false;
            progressdialog.Description   = "Prepping {_fileList.Count} files...";
            progressdialog.Title         = MB_TITLE;
            progressdialog.Animation     = esriProgressAnimationTypes.esriProgressSpiral;


            foreach (KeyValuePair <String, Boolean> file in _fileList)
            {
                if (file.Value)
                {
                    progressdialog.Description = string.Format("Adding File {0} of {1}...", cloneCount, _fileList.Count);
                    if (!itWorked)
                    {
                        SaveFileTypeList(GetExtension());
                    }
                    itWorked = true;

                    try
                    {
                        var sourceFile      = txb_FileWorkspaceSrc.Text + @"\" + Utilities_General.AddPrefixAndSuffixToFileName(file.Key, txb_Prefix.Text, txb_Suffix.Text) + GetExtension();
                        var destinationFile = txb_FileWorkspaceDst.Text + @"\" + Utilities_General.AddPrefixAndSuffixToFileName(file.Key, txb_Prefix.Text, txb_Suffix.Text) + GetExtension();

                        using (System.IO.StreamWriter sw = File.AppendText(filePath))
                        {
                            sw.WriteLine(String.Format("copy {0} {1}", sourceFile, destinationFile));
                        }
                    }
                    catch (Exception yourBest) // but you don't succeed
                    {
                        yourBest.ToString();
                        // Just So We Get No Crashes ;)
                    }
                    stepprogressor.Step();
                    cloneCount++;
                }
            }
            trackcancel    = null;
            stepprogressor = null;
            progressdialog.HideDialog();
            progressdialog = null;
            //_activeView.Refresh();
        }