Arcgis pro sdk : File/folder dialog

3188
2
04-21-2020 11:48 PM
by Anonymous User
Not applicable
3 2 3,188

Have noticed that there is arcgis pro sdk OpenItemDialog object which allow developers to use for consistent look and feel like arcgis pro.

 

Below is the ArcPro github guide.

ProGuide Custom Browse Dialog Filters · Esri/arcgis-pro-sdk Wiki · GitHub 

 

However if we run into the scenario to get the file types which are not natively support by the sdk.

Actually we can use two other libraries which are provided by microsoft.

 

For getting folder path - 

using (FolderBrowserDialog tmpDestination = new FolderBrowserDialog())
                {

                    if (tmpDestination.ShowDialog() == DialogResult.OK)
                    {
                        this.InputModel.SourceFolderPath = tmpDestination.SelectedPath;
                        
                                            
                    }
                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Help doco of that class : FolderBrowserDialog Class (System.Windows.Forms) | Microsoft Docs 

 

That will look like this.

 

 

For getting file for specific extension - like excel files. 

OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {              

                   //lets move on with 
string filePath = openFileDialog.FileName;
                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Help doco of that class :OpenFileDialog Class (System.Windows.Forms) | Microsoft Docs 

 

That will look like this.

 

All in all the point is that ArcGIS pro sdk is based on the wpf c#, so sometime if sdk don't have build in functionality, we can always go back to foundation to base libraries of wpf and sample out there may be in stackoverflow especially UI customization and, thread management. 

 

Feel free to comment, it is just my first blog because noticed that could give some ideas to the developer who does not know much about wpf development or .net framework area.

2 Comments