예제 #1
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();
        }
예제 #2
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()}");
     }
 }
예제 #3
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();
        }
예제 #4
0
        private void GetSelectedFilterDAML()
        {
            var browseFilter = new BrowseProjectFilter(SelectedDisplayItem.Row["id"].ToString());

            SelectedItemDetailLabel = $"DAML definition for {SelectedDisplayItem.Row["id"]}:";
            SelectedItemDetails     = ArcGIS.Desktop.Internal.Core.BrowseFilter.BrowseFilterUtils.GetDamlFromBrowseFilter(browseFilter);
        }
        //
        // 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);
        }
 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}");
     }
 }
예제 #7
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;
            }
        }
예제 #8
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;
            }
        }
        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);
                    });
                }
            }
        }
        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);
                        });
                    }
                }
            }
        }
예제 #11
0
        // 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
                });
            });
        }
예제 #12
0
        private static string BrowseGeodatabase()
        {
            const string title        = "Select Existing Issue Geodatabase";
            var          browseFilter =
                BrowseProjectFilter.GetFilter(DAML.Filter.esri_browseDialogFilters_geodatabases_file);

            return(GetSelectedItemPath(title, ItemFilters.geodatabases, browseFilter));
        }
예제 #13
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);
        }
예제 #14
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);
                        }
                    });
                }
            }
        }
예제 #16
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);
        }
예제 #17
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();
 }
예제 #18
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();
        }
예제 #19
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();
 }
예제 #20
0
 protected override void OnClick()
 {
     try
     {
         if (Module1.Geometries == null || Module1.Geometries.Count <= 0)
         {
             MessageBox.Show($@"You have to first render a geometry before you can export the Geometry");
             return;
         }
         var bpf = new BrowseProjectFilter("esri_browseDialogFilters_json_file")
         {
             Name = "Specify JSON file to export Geometries to"
         };
         var saveItemDialog = new SaveItemDialog {
             BrowseFilter = bpf
         };
         var result = saveItemDialog.ShowDialog();
         if (result.Value == false)
         {
             return;
         }
         var jsonPath = $@"{saveItemDialog.FilePath}.json";
         var folder   = System.IO.Path.GetDirectoryName(jsonPath);
         if (!System.IO.Directory.Exists(folder))
         {
             System.IO.Directory.CreateDirectory(folder);
         }
         var exists = System.IO.File.Exists(jsonPath);
         if (exists)
         {
             var isYes = MessageBox.Show($@"The export will write over the existing file {jsonPath}", "Override File", System.Windows.MessageBoxButton.YesNo);
             if (isYes != System.Windows.MessageBoxResult.Yes)
             {
                 return;
             }
             System.IO.File.Delete(jsonPath);
         }
         GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(Module1.Geometries,
                                                                Module1.Geometries[0].SpatialReference);
         System.IO.File.WriteAllText(jsonPath, bag.ToJson());
         MessageBox.Show($@"Export saved to {jsonPath}");
     }
     catch (Exception ex)
     {
         MessageBox.Show($@"Export Exception: {ex}");
     }
 }
예제 #21
0
        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);
        }
예제 #22
0
        protected override void OnClick()
        {
            var bf = new BrowseProjectFilter();

            //This allows us to view the .quake custom item (the "container")
            bf.AddCanBeTypeId("acme_quake_handler"); //TypeID for the ".quake" custom project item
            //This allows the .quake item to be browsable to access the events inside
            bf.AddDoBrowseIntoTypeId("acme_quake_handler");
            //This allows us to view the quake events contained in the .quake item
            bf.AddCanBeTypeId("acme_quake_event"); //TypeID for the quake events contained in the .quake item
            bf.Name = "Quake Item";

            var openItemDialog = new OpenItemDialog
            {
                Title           = "Open Quake Item",
                InitialLocation = @"E:\Data\CustomItem\QuakeCustomItem",
                BrowseFilter    = bf
            };
            bool?ok = openItemDialog.ShowDialog();
        }
예제 #23
0
        public static void NewFilterCompositeFilter()
        {
            ///Create and use a Composite Filter that displays "lyr" or "lyrx" files.
            ///The composite filter is used in an OpenItemDialog.
            BrowseProjectFilter compositeFilter = new BrowseProjectFilter();

            compositeFilter.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_layers_lyr"));
            compositeFilter.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_layers_lyrx"));
            compositeFilter.Includes.Add("FolderConnection");
            compositeFilter.Excludes.Add("esri_browsePlaces_Online");
            //Display the filter in an Open Item dialog
            OpenItemDialog op = new OpenItemDialog
            {
                Title           = "Open LYR or LYRX files",
                InitialLocation = @"C:\Data",
                MultiSelect     = false,
                BrowseFilter    = compositeFilter
            };
            bool?ok = op.ShowDialog();
        }
        private async Task AddGeoJSON()
        {
            //Display the filter in an Open Item dialog
            BrowseProjectFilter bf = new BrowseProjectFilter("esri_browseDialogFilters_browseFiles");

            bf.Name              = "GeoJSON";
            bf.FileExtension     = "*.geojson";
            bf.BrowsingFilesMode = true;

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

            bool?ok = dlg.ShowDialog();

            if (ok == true)
            {
                if (MapView.Active == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map is not active");
                    return;
                }
                else
                {
                    var item = dlg.Items.First();

                    ProgressDialog progressDialog;
                    progressDialog = new ProgressDialog("Importing AOI GeoJSON Polygon ...");
                    progressDialog.Show();

                    await ConvertGeoJSONToFeatures(item.Path);

                    progressDialog.Hide();
                }
            }
        }
        private void InitBrowseFilter()
        {
            // C:\Program Files\ArcGIS\Pro\Resources\SearchResources\Schema\BrowseFilters.xml
            _featureClassBrowseFilter = new BrowseProjectFilter("esri_browseDialogFilters_featureClasses_all")
            {
                Name = "Shape Files/Feature Classes/Zip Files"
            };
            _featureClassBrowseFilter.AddCanBeTypeId("file_zip");

            // use "esri_browseDialogFilters_workspaces_all" to include geodatabase locations
            _workspaceBrowseFilter = new BrowseProjectFilter("esri_browseDialogFilters_folders")
            {
                Name = "Folders/Datasets"
            };

            // use "esri_browseDialogFilters_shapefiles" for shape files only
            _outputExtentBrowseFilter = new BrowseProjectFilter("esri_browseDialogFilters_featureClasses_all")
            {
                Name = "Shape Files/Feature Classes"
            };
        }
예제 #26
0
        public static void ModifyExistingProLyrxFilter()
        {
            //Creates a new browse filter from Pro's "esri_browseDialogFilters_layers_lyrx" browse filter to display lyr files also.
            //The browse filter is used in an OpenItemDialog.
            BrowseProjectFilter lyrXLyrGeneral = new BrowseProjectFilter("esri_browseDialogFilters_layers_lyrx");

            lyrXLyrGeneral.Name = "Layer Files (LYRX) and Layer Files (LYR)";
            lyrXLyrGeneral.AddCanBeTypeId("layer_general");
            lyrXLyrGeneral.AddDontBrowseIntoFlag(BrowseProjectFilter.FilterFlag.DontBrowseFiles);
            //Display only folders and GDB in the browse dialog
            lyrXLyrGeneral.Includes.Add("FolderConnection");
            lyrXLyrGeneral.Includes.Add("GDB");
            //Does not display Online places in the browse dialog
            lyrXLyrGeneral.Excludes.Add("esri_browsePlaces_Online");
            //Display the filter in an Open Item dialog
            OpenItemDialog aNewFilter = new OpenItemDialog
            {
                Title           = "Open LyrX and Lyr General files",
                InitialLocation = @"C:\Data",
                MultiSelect     = false,
                BrowseFilter    = lyrXLyrGeneral
            };
            bool?ok = aNewFilter.ShowDialog();
        }
 public ProFilterItem(string filterID, string filterName)
 {
     _filterID             = filterID;
     _filterName           = filterName;
     _openItemBrowseFilter = new BrowseProjectFilter(filterID);
 }