コード例 #1
0
        internal static string LocateCBfile()
        {
            IGxDialog GxD = new GxDialog();

            GxD.AllowMultiSelect = false;
            GxD.ButtonCaption    = "Add";
            GxD.Title            = "Select the Colorbrewer File";
            GxD.RememberLocation = true;

            IGxObjectFilter textFileFilter = new GxFilterTextFiles();

            GxD.ObjectFilter = textFileFilter;

            IEnumGxObject enumObj;

            if (GxD.DoModalOpen(ArcMap.Application.hWnd, out enumObj) == false)
            {
                System.Windows.Forms.MessageBox.Show("Operation Failed");
                return("Operation Failed: Please Try Again");
            }
            IGxObject gxObj = enumObj.Next();

            filepath = gxObj.FullName;
            System.Windows.Forms.MessageBox.Show("File Path: " + filepath);
            return(filepath);
        }
コード例 #2
0
        public string GetOutputFileName(string aFileType, string anInitialDirectory = @"C:\")
        {
            // This would be done better with a custom type but this will do for the momment.
            IGxDialog myDialog = new GxDialogClass();
            myDialog.set_StartingLocation(anInitialDirectory);
            IGxObjectFilter myFilter;


            switch (aFileType)
            {
                case "Geodatabase FC":
                    myFilter = new GxFilterFGDBFeatureClasses();
                    break;
                case "Geodatabase Table":
                    myFilter = new GxFilterFGDBTables();
                    break;
                case "Shapefile":
                    myFilter = new GxFilterShapefiles();
                    break;
                case "DBASE file":
                    myFilter = new GxFilterdBASEFiles();
                    break;
                case "Text file":
                    myFilter = new GxFilterTextFiles();
                    break;
                default:
                    myFilter = new GxFilterDatasets();
                    break;
            }

            myDialog.ObjectFilter = myFilter;
            myDialog.Title = "Save Output As...";
            myDialog.ButtonCaption = "OK";

            string strOutFile = "None";
            if (myDialog.DoModalSave(thisApplication.hWnd))
            {
                strOutFile = myDialog.FinalLocation.FullName + @"\" + myDialog.Name;
                
            }
            myDialog = null;
            return strOutFile; // "None" if user pressed exit
            
        }