protected override void OnClick()
        {
            var bf = new BrowseProjectFilter();

            //This allows us to view the .quake custom item (the "container")
            //This allows the .quake item to be browsable to access the events inside
            bf.AddCanBeTypeId("acme_quake_event");

            bf.Name = "Quake Event Item";

            var openItemDialog = new OpenItemDialog
            {
                Title           = "Add Quake Event to Map",
                InitialLocation = @"E:\Data\CustomItem\QuakeCustomItem",
                BrowseFilter    = bf,
                MultiSelect     = false
            };
            bool?ok = openItemDialog.ShowDialog();

            if (ok != null)
            {
                if (ok.Value)
                {
                    var quake_event = openItemDialog.Items.First() as QuakeEventCustomItem;
                    QueuedTask.Run(() =>
                    {
                        Module1.AddToGraphicsLayer(quake_event);
                    });
                }
            }
        }
Exemple #2
0
        protected async override void OnClick()
        {
            try
            {
                OpenItemDialog addToMap = new OpenItemDialog
                {
                    Title           = "Add Data",
                    InitialLocation = @"C:\",
                    MultiSelect     = true
                };


                bool?ok = addToMap.ShowDialog();

                if (ok == true)
                {
                    IEnumerable <Item> selectedItems = addToMap.Items;
                    foreach (Item selectedItem in selectedItems)
                    {
                        await QueuedTask.Run(() =>
                                             LayerFactory.Instance.CreateLayer(selectedItem, MapView.Active.Map, LayerPosition.AutoArrange));
                    }
                }
            }

            catch (Exception)
            {
                string caption = "Failed to add data";
                string message = "Process failed.\n\nSave and restart ArcGIS Pro and try process again.\n\n" +
                                 "If problem persist, contact your local GIS nerd.";

                //Using the ArcGIS Pro SDK MessageBox class
                MessageBox.Show(message, caption);
            }
        }
        // TODO algr: temporary tests
        protected override void OnClick()
        {
            var bf = new BrowseProjectFilter();

            bf.AddCanBeTypeId("ProSuiteItem_ProjectItem");             //TypeID for the ".wlist" custom project item

            // for subitem allow to browse inside and add as type
            //bf.AddDoBrowseIntoTypeId("ProSuiteItem_ProjectItemWorkListFile");
            //bf.AddCanBeTypeId("ProSuiteItem_WorkListItem"); //subitem
            bf.Name = "Work List";

            var openItemDialog = new OpenItemDialog
            {
                Title = "Add Work List",
                //InitialLocation = "",
                BrowseFilter = bf
            };
            bool?result = openItemDialog.ShowDialog();

            if (result != null && (result.Value == false || !openItemDialog.Items.Any()))
            {
                return;
            }

            var    item     = openItemDialog.Items.FirstOrDefault();
            string filePath = item?.Path;

            QueuedTask.Run(() =>
            {
                ProjectRepository.Current.AddProjectFileItems(ProjectItemType.WorkListDefinition, new List <string>()
                {
                    filePath
                });
            });
        }
Exemple #4
0
        public void DownloadPathExecute()
        {
            //Display the filter in an Open Item dialog
            BrowseProjectFilter bf = new BrowseProjectFilter();

            bf.Name = "Folders and Geodatabases";

            bf.AddFilter(BrowseProjectFilter.GetFilter(ItemFilters.geodatabases));
            bf.AddFilter(BrowseProjectFilter.GetFilter(ItemFilters.folders));

            bf.Includes.Add("FolderConnection");
            bf.Includes.Add("GDB");
            bf.Excludes.Add("esri_browsePlaces_Online");

            OpenItemDialog dlg = new OpenItemDialog
            {
                Title                    = "Open Folder Dialog",
                InitialLocation          = _downloadPath,
                AlwaysUseInitialLocation = true,
                MultiSelect              = false,
                BrowseFilter             = bf
            };

            bool?ok = dlg.ShowDialog();

            if (ok == true)
            {
                var item = dlg.Items.First();

                DownloadPath = item.Path;
            }
        }
Exemple #5
0
        public static void NewFilterPolygonFileGDB()
        {
            //Create and use a new filter to view Polygon feature classes in a file GDB.
            //The browse filter is used in an OpenItemDialog.

            BrowseProjectFilter bf = new BrowseProjectFilter
            {
                //Name the filter
                Name = "Polygon feature class in FGDB"
            };

            //Add typeID for Polygon feature class
            bf.AddCanBeTypeId("fgdb_fc_polygon");
            //Allow only File GDBs
            bf.AddDontBrowseIntoFlag(BrowseProjectFilter.FilterFlag.DontBrowseFiles);
            bf.AddDoBrowseIntoTypeId("database_fgdb");
            //Display only folders and GDB in the browse dialog
            bf.Includes.Add("FolderConnection");
            bf.Includes.Add("GDB");
            //Does not display Online places in the browse dialog
            bf.Excludes.Add("esri_browsePlaces_Online");

            //Display the filter in an Open Item dialog
            OpenItemDialog aNewFilter = new OpenItemDialog
            {
                Title           = "Open Polygon Feature classes",
                InitialLocation = @"C:\Data",
                MultiSelect     = false,
                BrowseFilter    = bf
            };
            bool?ok = aNewFilter.ShowDialog();
        }
Exemple #6
0
        public static void NewFilterForCustomItem()
        {
            //Create and use a dialog filter to view a Custom item
            //The browse filter is used in an OpenItemDialog.

            BrowseProjectFilter bf = new BrowseProjectFilter();

            //Name the filter
            bf.Name = "\"customItem\" files";
            //Add typeID for Filters_ProGPXItem custom item
            bf.AddCanBeTypeId("Filters_ProGPXItem");
            //Does not allow browsing into files
            bf.AddDontBrowseIntoFlag(BrowseProjectFilter.FilterFlag.DontBrowseFiles);
            //Display only folders and GDB in the browse dialog
            bf.Includes.Add("FolderConnection");
            //Does not display Online places in the browse dialog
            bf.Excludes.Add("esri_browsePlaces_Online");

            //Display the filter in an Open Item dialog
            OpenItemDialog aNewFilter = new OpenItemDialog
            {
                Title           = "Open \"customItem\"",
                InitialLocation = @"C:\Data",
                MultiSelect     = false,
                BrowseFilter    = bf
            };
            bool?ok = aNewFilter.ShowDialog();
        }
Exemple #7
0
        protected async override void OnClick()
        {
            try
            {
                OpenItemDialog selectAoiDialog = new OpenItemDialog()
                {
                    Title       = "Select AOI Folder",
                    MultiSelect = false,
                    Filter      = ItemFilters.folders
                };
                if (selectAoiDialog.ShowDialog() == true)
                {
                    Module1.DeactivateState("Aoi_Selected_State");
                    IEnumerable <Item> selectedItems = selectAoiDialog.Items;
                    var            e    = selectedItems.FirstOrDefault();
                    BA_Objects.Aoi oAoi = await GeneralTools.SetAoiAsync(e.Path);

                    if (oAoi != null)
                    {
                        Module1.Current.CboCurrentAoi.SetAoiName(oAoi.Name);
                        MessageBox.Show("AOI is set to " + oAoi.Name + "!", "BAGIS PRO");
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred while trying to set the AOI!! " + e.Message, "BAGIS PRO");
            }
        }
        private bool BrowseItem(string itemFilter, Action <string> setPath, string initialPath = "")
        {
            if (string.IsNullOrEmpty(initialPath))
            {
                var myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                initialPath = Path.Combine(System.IO.Path.Combine(myDocs, "ArcGIS"));
            }

            OpenItemDialog pathDialog = new OpenItemDialog()
            {
                Title           = "Select Folder",
                InitialLocation = initialPath,
                MultiSelect     = false,
                Filter          = itemFilter,
            };

            bool?ok = pathDialog.ShowDialog();

            if ((ok == true) && (pathDialog.Items.Count() > 0))
            {
                IEnumerable <Item> selectedItems = pathDialog.Items;
                setPath(selectedItems.First().Path);
                return(true);
            }

            return(false);
        }
 protected override void OnClick()
 {
     try
     {
         var bpf = new BrowseProjectFilter("esri_browseDialogFilters_json_file")
         {
             Name = "Select JSON file containing exported Geometries"
         };
         var openItemDialog = new OpenItemDialog {
             BrowseFilter = bpf
         };
         var result = openItemDialog.ShowDialog();
         if (result.Value == false || openItemDialog.Items.Count() == 0)
         {
             return;
         }
         var item        = openItemDialog.Items.ToArray()[0];
         var filePath    = item.Path;
         var json        = System.IO.File.ReadAllText(filePath);
         var geometryBag = GeometryBagBuilderEx.FromJson(json);
         Module1.Geometries    = geometryBag.Geometries.ToList();
         Module1.HasImportData = true;
         MessageBox.Show($@"Geometries loaded: {Module1.Geometries.Count()}");
     }
     catch (Exception ex)
     {
         MessageBox.Show($@"Import exception: {ex}");
     }
 }
        protected override void OnClick()
        {
            var bf = new BrowseProjectFilter("Add_QuakeItem_To_Project");

            //Display the filter in an Open Item dialog
            OpenItemDialog op = new OpenItemDialog
            {
                Title           = "Add Quake Items",
                InitialLocation = @"E:\Data\SDK\Test\3.0",
                MultiSelect     = false,
                BrowseFilter    = bf
            };

            bool?ok = op.ShowDialog();

            if (ok != null)
            {
                if (ok.Value)
                {
                    var item = op.Items[0] as QuakeProjectItem;
                    if (item != null)
                    {
                        QueuedTask.Run(() =>
                        {
                            Project.Current.AddItem(item);
                        });
                    }
                }
            }
        }
Exemple #11
0
        public void ADAPTFilePathExecute()
        {
            //Display the filter in an Open Item dialog
            BrowseProjectFilter bf = new BrowseProjectFilter("esri_browseDialogFilters_browseFiles");

            bf.Name              = "Zipped File";
            bf.FileExtension     = "*.zip";
            bf.BrowsingFilesMode = true;

            OpenItemDialog dlg = new OpenItemDialog
            {
                Title                    = "Open Zipped File",
                InitialLocation          = _ADAPTFilePath,
                AlwaysUseInitialLocation = true,
                MultiSelect              = false,
                BrowseFilter             = bf
            };

            bool?ok = dlg.ShowDialog();

            if (ok == true)
            {
                var item = dlg.Items.First();

                ADAPTFilePath = item.Path;
            }
        }
Exemple #12
0
 protected override void OnClick()
 {
     if (MapView.Active?.Map == null)
     {
         MessageBox.Show("There is no active map");
         return;
     }
     try
     {
         //The browse filter is used in an OpenItemDialog.
         BrowseProjectFilter bf = new BrowseProjectFilter
         {
             //Name the filter
             Name = "SQL Express Connection File"
         };
         //Display the filter in an Open Item dialog
         OpenItemDialog aNewFilter = new OpenItemDialog
         {
             Title           = "Open SQL Express Feature classes",
             InitialLocation = @"C:\Data\PluginData",
             MultiSelect     = false,
             BrowseFilter    = bf
         };
         bool?ok = aNewFilter.ShowDialog();
         if (!(ok.HasValue && ok.Value))
         {
             return;
         }
         _ = AddToCurrentMap.AddProDataSubItemsAsync(aNewFilter.Items.OfType <ProDataSubItem>(), MapView.Active.Map);
     }
     catch (Exception ex)
     {
         MessageBox.Show($@"Exception: {ex.ToString()}");
     }
 }
        //
        // Open file dialog and browse to a picture.
        //
        public static string GetPictureURL()
        {
            var pngFilter = BrowseProjectFilter.GetFilter("esri_browseDialogFilters_browseFiles");

            pngFilter.FileExtension     = "*.png;";
            pngFilter.BrowsingFilesMode = true;
            //Specify a name to show in the filter dropdown combo box - otherwise the name will show as "Default"
            pngFilter.Name = "Png files (*.png;)";
            var insertPictureDialog = new OpenItemDialog
            {
                Title        = "Insert Picture",
                BrowseFilter = pngFilter
            };
            var result = insertPictureDialog.ShowDialog();

            // Process open file dialog box results
            if (result == false)
            {
                return(string.Empty);
            }

            IEnumerable <Item> selectedItems = insertPictureDialog.Items;

            return(selectedItems.FirstOrDefault().Path);
        }
Exemple #14
0
        public async Task <IGPResult> Execute_ApplySymbologyFromFeatureLayer()
        {
            var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);

            var prj = Project.Current;
            var map = MapView.Active;

            var featLayers = map.Map.Layers.OfType <FeatureLayer>().Where(l => l.Name.StartsWith("Crimes", StringComparison.OrdinalIgnoreCase));

            if (featLayers.Count() < 1)
            {
                MessageBox.Show("Unable to find Crimes layer: the topmost Crime layer is the target layer for the symbology, the symbology source is a lyrx file");
                return(null);
            }

            // the first layer in TOC is without any symbology
            FeatureLayer targetLayer = featLayers.ElementAt(0);

            // the second layer has the symbology
            // symbology from the 2nd layer will be applied to the first layer
            //Create instance of BrowseProjectFilter using the id for Pro's Lyrx files filter
            BrowseProjectFilter bf = new BrowseProjectFilter("esri_browseDialogFilters_layers_lyrx");
            //Display the filter in an Open Item dialog
            OpenItemDialog lyrxOpenDlg = new OpenItemDialog
            {
                Title        = "Symbology Input Layer",
                MultiSelect  = false,
                BrowseFilter = bf
            };
            bool?ok = lyrxOpenDlg.ShowDialog();

            if (!ok.HasValue || !ok.Value)
            {
                return(null);
            }
            // Full path for the lyrx file
            var lryxItem = lyrxOpenDlg.Items.FirstOrDefault().Path;

            var    sourceField = "Major_Offense_Type";
            var    targetField = "Major_Offense_Type";
            var    fieldType   = "VALUE_FIELD";
            String fieldInfo   = String.Format("{0} {1} {2}", fieldType, sourceField, targetField);           // VALUE_FIELD NAME NAME")

            MessageBox.Show("Field Info for symbology: " + fieldInfo);

            var parameters = Geoprocessing.MakeValueArray(targetLayer, lryxItem, fieldInfo);             //, symbologyFields, updateSymbology);

            // Does not Add outputs to Map as GPExecuteToolFlags.AddOutputsToMap is not used
            GPExecuteToolFlags executeFlags = GPExecuteToolFlags.RefreshProjectItems | GPExecuteToolFlags.GPThread | GPExecuteToolFlags.AddToHistory;

            IGPResult result = await Geoprocessing.ExecuteToolAsync("ApplySymbologyFromLayer_management", parameters, null, null, null, executeFlags);

            return(result);
        }
        public void LoadNoteFile()
        {
            try
            {
                // Load the setting with the default path, if there is a setting.


                // Read a file and load the contents into the Note values combobox
                string startLocation;
                if (_dialogPath == false)
                {
                    startLocation = System.IO.Path.GetDirectoryName(Project.Current.URI);
                }
                else
                {
                    startLocation = AppSettings.Default.NoteFilePath;
                }

                OpenItemDialog openDialog = new OpenItemDialog()
                {
                    Title           = "Select a Note values file to load",
                    MultiSelect     = false,
                    Filter          = ItemFilters.textFiles,
                    InitialLocation = startLocation
                };
                string savePath;
                if (openDialog.ShowDialog() == true)
                {
                    IEnumerable <Item> selectedItem = openDialog.Items;
                    foreach (Item i in selectedItem)
                    {
                        System.IO.StreamReader file = new System.IO.StreamReader(i.Path);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            EditNoteComboBox.AddItem(new ComboBoxItem(line));
                        }
                        savePath = System.IO.Path.GetDirectoryName(i.Path);
                        AppSettings.Default.NoteFilePath = savePath;
                    }
                    EditNoteComboBox.SelectedItem = EditNoteComboBox.ItemCollection.FirstOrDefault();

                    AppSettings.Default.Save();
                    _dialogPath = true;                     // is now set
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error in LoadNoteFile:  " + ex.ToString(), "Error");
            }
        }
Exemple #16
0
 public static void DisplayOpenItemDialog(BrowseProjectFilter browseProjectFilter, string dialogName)
 {
     OpenItemDialog aNewFilter = new OpenItemDialog
     {
         Title           = dialogName,
         InitialLocation = @"C:\Data",
         MultiSelect     = false,
         //Use BrowseFilter property to specify the filter
         //you want the dialog to display
         BrowseFilter = browseProjectFilter
     };
     bool?ok = aNewFilter.ShowDialog();
 }
        protected override async void OnClick()
        {
            //Create and use a new filter to view Polygon feature classes in a file GDB.
            //The browse filter is used in an OpenItemDialog.
            BrowseProjectFilter bf = new BrowseProjectFilter
            {
                //Name the filter
                Name = "Polygon feature class in FGDB"
            };

            //Add typeID for Polygon feature class
            bf.AddCanBeTypeId("fgdb_fc_polygon");
            //Allow only File GDBs
            bf.AddDontBrowseIntoFlag(BrowseProjectFilter.FilterFlag.DontBrowseFiles);
            bf.AddDoBrowseIntoTypeId("database_fgdb");
            //Display only folders and GDB in the browse dialog
            bf.Includes.Add("FolderConnection");
            bf.Includes.Add("GDB");
            //Does not display Online places in the browse dialog
            bf.Excludes.Add("esri_browsePlaces_Online");

            //Display the filter in an Open Item dialog
            OpenItemDialog dlg = new OpenItemDialog
            {
                Title = "Open Polygon Feature classes",
                //InitialLocation = Path.GetDirectoryName(Project.Current.URI),
                AlwaysUseInitialLocation = false,
                MultiSelect  = true,
                BrowseFilter = bf
            };

            bool?ok = dlg.ShowDialog();

            if (ok == true)
            {
                var items = dlg.Items;

                if (MapView.Active != null)
                {
                    var _map = MapView.Active.Map;
                    await QueuedTask.Run(() =>
                    {
                        foreach (Item item in items)
                        {
                            LayerFactory.Instance.CreateLayer(item, _map);
                        }
                    });
                }
            }
        }
Exemple #18
0
        protected async override void OnClick()
        {
            try
            {
                /// Read a file for line-delimited directory paths, and attempt to add them to the Project's Folder Connections
                OpenItemDialog openDialog = new OpenItemDialog()
                {
                    Title       = "Select a Folder Connections file",
                    MultiSelect = false,
                    Filter      = ItemFilters.textFiles
                };

                /// If the user clicks OK in the dialog, load the listed directories from the file to the Project's Folder Connections
                if (openDialog.ShowDialog() == true)
                {
                    IEnumerable <Item> selectedItem = openDialog.Items;
                    foreach (Item i in selectedItem)
                    {
                        System.IO.StreamReader file = new System.IO.StreamReader(i.Path);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            /// Add all folder connections to the current Project's folder connections
                            string notFound = "";
                            if (Directory.Exists(line))
                            {
                                var folderToAdd = ItemFactory.Instance.Create(line);
                                await QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem));
                            }
                            else
                            {
                                notFound += Environment.NewLine + line;
                            }

                            /// Report any folder connections that could not be found
                            if (notFound != "")
                            {
                                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("The following directories were not found and could not be added to the Folder Connections: " + notFound);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error adding a folder to the project: " + ex.ToString());
            }
        }
        protected async override void OnClick()
        {
            var dlg = new OpenItemDialog()
            {
                Title = "Browse Content"
            };

            dlg.InitialLocation = @"D:\SampleData";
            //show the dialog and retrieve the selection if there was one
            if (!dlg.ShowDialog().Value)
            {
                return;
            }
            var item = dlg.Items.First();
        }
Exemple #20
0
        // TODO algr: this should be moved to file utils
        private string SelectFileItem(BrowseProjectFilter projectFilter)
        {
            var dlg = new OpenItemDialog()
            {
                BrowseFilter = projectFilter,
                Title        = "Browse file ..."
            };

            if (!dlg.ShowDialog().Value)
            {
                return("");
            }

            return(dlg.Items.First()?.Path);
        }
        private void OpenObstacle(object args)
        {
            OpenItemDialog oid = new OpenItemDialog()
            {
                MultiSelect = false,
                Title       = "选择碍航物要素",
                Filter      = ItemFilters.featureClasses_all
            };

            if (oid.ShowDialog() == true)
            {
                var item = oid.Items.FirstOrDefault();
                ObstaclePath = item.Path;
            }
        }
        private void OnSelectClipExtentClicked(object sender, RoutedEventArgs e)
        {
            //var dialog = new OpenFileDialog { DefaultExt = ".shp",  Filter = "Shape Files|*.shp" };
            var dialog = new OpenItemDialog()
            {
                BrowseFilter = _outputExtentBrowseFilter
            };

            if (dialog.ShowDialog() == true)
            {
                ClipExtentTextBox.Text = dialog.Items
                                         .Select(i => i.Path)
                                         .FirstOrDefault() ?? "";
            }
        }
        protected async override void OnClick()
        {
            try
            {
                /// Read a file for line-delinated directory paths, and attempt to add them to the Project's Folder Connections
                OpenItemDialog openDialog = new OpenItemDialog();
                openDialog.Title = "Select a Folder Connections file";
                openDialog.MultiSelect = false;
                openDialog.Filter = ItemFilters.textFiles;

                /// If the user clicks OK in the dialog, load the listed directories from the file to the Project's Folder Connections
                if (openDialog.ShowDialog() == true)
                {
                    IEnumerable<Item> selectedItem = openDialog.Items;
                    foreach (Item i in selectedItem)
                    {
                        System.IO.StreamReader file = new System.IO.StreamReader(i.Path);
                        string line;
                        while ((line = file.ReadLine()) != null)
                        {
                            /// Add all folder connections to the current Project's folder connections
                            string notFound = "";
                            if (Directory.Exists(line))
                            {
                                var folderToAdd = ItemFactory.Create(line);
                                await Project.Current.AddAsync(folderToAdd);
                            }
                            else
                            {
                                notFound += "\r\n" + line;
                            }

                            /// Report any folder connections that could not be found
                            if (notFound != "")
                            {
                                MessageBox.Show("The following directories were not found and could not be added to the Folder Connections: " + notFound);
                            }

                        }
                    }
                }
            }

            catch (Exception ex)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error adding a folder to the project: " + ex.ToString());
            }
        }
        internal static async void BrowseToProject(bool bProjects = true)
        {
            try
            {
                var dlg        = new OpenItemDialog();
                var myDocs     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var initFolder = Path.Combine(System.IO.Path.Combine(myDocs, "ArcGIS"), "Projects");
                if (!bProjects)
                {
                    initFolder = @"C:\Program Files\ArcGIS\Pro\Resources\ProjectTemplates";
                }
                if (!Directory.Exists(initFolder))
                {
                    initFolder = myDocs;
                }
                dlg.Title           = "Open Project";
                dlg.InitialLocation = initFolder;
                dlg.Filter          = bProjects ? ItemFilters.projects : ItemFilters.project_templates;

                if (!(dlg.ShowDialog() ?? false))
                {
                    return;
                }
                var item = dlg.Items.FirstOrDefault();
                if (item == null)
                {
                    return;
                }
                if (bProjects)
                {
                    await Project.OpenAsync(item.Path);
                }
                else
                {
                    var ps = new CreateProjectSettings()
                    {
                        Name         = System.IO.Path.GetFileNameWithoutExtension(item.Name),
                        LocationPath = ConfigWithStartWizardModule.DefaultFolder(),
                        TemplatePath = item.Path
                    };
                    await Project.CreateAsync(ps);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"Error in open project: {ex}");
            }
        }
Exemple #25
0
        public static void NewFilterFromDAMLDeclaration()
        {
            ///Create and use a filter defined in DAML. The filter displays line feature classes in a file GDB.
            ///The browse filter is used in an OpenItemDialog.

            var bf = new BrowseProjectFilter("NewLineFeatures_Filter");
            //Display the filter in an Open Item dialog
            OpenItemDialog op = new OpenItemDialog
            {
                Title           = "Open Line Feature classes",
                InitialLocation = @"C:\Data",
                MultiSelect     = false,
                BrowseFilter    = bf
            };
            bool?ok = op.ShowDialog();
        }
Exemple #26
0
 public static void UseProFilterGeodatabases()
 {
     //Create a browse filter that uses Pro's "esri_browseDialogFilters_geodatabases" filter.
     //The browse filter is used in an OpenItemDialog.
     BrowseProjectFilter bf = new BrowseProjectFilter("esri_browseDialogFilters_geodatabases");
     //Display the filter in an Open Item dialog
     OpenItemDialog aNewFilter = new OpenItemDialog
     {
         Title           = "Open Geodatabases",
         InitialLocation = @"C:\Data",
         MultiSelect     = false,
         //Set the BrowseFilter property to Pro's Geodatabase filter.
         BrowseFilter = bf
     };
     bool?ok = aNewFilter.ShowDialog();
 }
        private void OnSelectOutputDirectoryClicked(object sender, RoutedEventArgs e)
        {
            //var dialog = new CommonOpenFileDialog { IsFolderPicker = true };
            var dialog = new OpenItemDialog()
            {
                Title        = "Select Output Directory",
                BrowseFilter = _workspaceBrowseFilter
            };

            if (dialog.ShowDialog() == true)
            {
                OutputDirectoryTextBox.Text = dialog.Items
                                              .Select(i => i.Path)
                                              .FirstOrDefault() ?? "";
            }
        }
Exemple #28
0
 protected override void OnClick()
 {
     //esri_browseDialogFilters_styleFiles
     //Create instance of BrowseProjectFilter using the id for Pro's file geodatabase filter
     BrowseProjectFilter bf = new BrowseProjectFilter("esri_browseDialogFilters_geodatabases");
     //Display the filter in an Open Item dialog
     OpenItemDialog aNewFilter = new OpenItemDialog
     {
         Title           = "Open Geodatabases",
         InitialLocation = @"C:\Data",
         MultiSelect     = false,
         //Set the BrowseFilter property to Pro's Geodatabase filter.
         BrowseFilter = bf
     };
     bool?ok = aNewFilter.ShowDialog();
 }
        public void OpenFile()
        {
            string fileName = string.Empty;
            // System.Windows.Forms.OpenFileDialog OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
            // OpenFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            OpenItemDialog oid = new OpenItemDialog
            {
                // oid.BrowseFilter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

                Title       = "Open a text file",
                Filter      = ItemFilters.textFiles,
                MultiSelect = true
            };
            bool?ok = oid.ShowDialog();

            //System.Threading.Thread.Sleep(300);


            if (ok == true)
            {
                IEnumerable <Item> selected = oid.Items;

                fileName = selected.First().Path;
                //MessageBox.Show("LayerList is updated using "+fileName);

                //pass the text file path to Button1, so it can read the file too.
                AddLayersToMap addLayersToMap = AddLayersToMap.Current;

                Button1 b1 = addLayersToMap.B1; //// get the instance of the current one, do not create a new Button1
                //Button1 b1 = new Button1();
                if (b1 != null)
                {
                    b1.FILE_NAME = fileName;
                    if (b1.Enabled == false)
                    {
                        b1.Enabled = true;
                    }
                }
                readText(fileName);
            }
            else
            {
                MessageBox.Show("No file selected");
                return;
            }
        }
        private static string GetSelectedItemPath(string title, string filter,
                                                  BrowseProjectFilter browseFilter)
        {
            var dialog = new OpenItemDialog
            {
                BrowseFilter = browseFilter,
                Filter       = filter,
                Title        = title
            };

            if (dialog.ShowDialog().HasValue&& dialog.Items.ToList().Count > 0)
            {
                return(dialog.Items.FirstOrDefault()?.Path);
            }

            _msg.Info("No Issue Geodatabase selected");
            return(null);
        }
        /// <summary>
        /// Prompts the user to choose a File workspace
        /// </summary>
        private void GetFileWorkspace()
        {
            OpenItemDialog dialog = new OpenItemDialog();

            dialog.Title       = "Select A File Workspace";
            dialog.MultiSelect = false;
            dialog.Filter      = ItemFilters.folders;

            if (Directory.Exists(_FileWorkspace))
            {
                dialog.InitialLocation = _FileWorkspace;
            }


            if (dialog.ShowDialog() == true)
            {
                FileWorkspace = dialog.Items.First().Path;
            }
        }
        /// <summary>
        /// This method is used to get the path of all Reviewer Batch jobs that user selects by browsing
        /// </summary>
        /// <returns></returns>
        private static IEnumerable<string> OpenBrowseBatchJobFileDialog()
        {
            IEnumerable<string> batchJobs = null;

            OpenItemDialog browseGeodatabaseDialog = new OpenItemDialog();

            browseGeodatabaseDialog.Title = "Browse Reviewer Batch Jobs";
            if (string.IsNullOrEmpty(_lastBrowseLocation))
                browseGeodatabaseDialog.InitialLocation = @"C:\";
            else
                browseGeodatabaseDialog.InitialLocation = _lastBrowseLocation;

            //esri_browseDialogFilters_batchjobs is the filter for Reviewer Batch Job
            browseGeodatabaseDialog.Filter = "esri_browseDialogFilters_batchjobs";

            browseGeodatabaseDialog.MultiSelect = true;
            browseGeodatabaseDialog.ShowDialog();

            if ((browseGeodatabaseDialog.Items == null) || (browseGeodatabaseDialog.Items.Count() < 1))
                return null;

            batchJobs = browseGeodatabaseDialog.Items.Select(item => item.Path);

            if(null != batchJobs && batchJobs.Count()>0)
                _lastBrowseLocation = new System.IO.FileInfo(batchJobs.FirstOrDefault()).Directory.FullName;

            return batchJobs;
        }
        private void OpenGdbDialog()
        {
            OpenItemDialog searchGdbDialog = new OpenItemDialog
            {
                Title = "Find GDB",
                InitialLocation = @"C:\Data",
                MultiSelect = false,
                Filter = ItemFilters.geodatabases
            };

            var ok = searchGdbDialog.ShowDialog();
            if (ok != true) return;
            var selectedItems = searchGdbDialog.Items;
            foreach (var selectedItem in selectedItems)
                GdbPath = selectedItem.Path;
        }
        /// <summary>
        /// This method is used to get the path of the geodatabase that user selects by browsing
        /// </summary>
        /// <param name="eResourceType"></param>
        /// <returns></returns>
        private static string OpenBrowseGeodatabaseDialog()
        {
            OpenItemDialog browseGeodatabaseDialog = new OpenItemDialog();

            browseGeodatabaseDialog.Title = "Browse Reviewer Workspace";
            if (string.IsNullOrEmpty(_lastBrowseLocation))
                browseGeodatabaseDialog.InitialLocation = @"C:\";
            else
                browseGeodatabaseDialog.InitialLocation = _lastBrowseLocation;

            browseGeodatabaseDialog.Filter = ItemFilters.geodatabases;
            
            
            browseGeodatabaseDialog.MultiSelect = false;
            browseGeodatabaseDialog.ShowDialog();

            if ((browseGeodatabaseDialog.Items == null) || (browseGeodatabaseDialog.Items.Count() < 1))
                return null;

            string strPath = browseGeodatabaseDialog.Items.FirstOrDefault().Path;

            //If the selected item is a file geodatabase
            if(System.IO.Directory.Exists(strPath)) 
                _lastBrowseLocation = System.IO.Directory.GetParent(strPath).FullName;
            else //If the selected item is a sde geodatabase file
                _lastBrowseLocation = new System.IO.FileInfo(strPath).Directory.FullName;

            return strPath;
        }