protected override void OnClick() { var saveDlg = new SaveItemDialog { Title = "Specify XML output file for the CIMLayout", Filter = "*.xml" }; if (saveDlg.ShowDialog() == true) { LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { // use activeLayoutView //Get the project item QueuedTask.Run(() => { //Get the layout Layout layout = activeLayoutView.Layout; if (layout != null) { // Define CIMSpatialMapSeries in CIMLayout CIMLayout layCIM = layout.GetDefinition(); System.IO.File.WriteAllText(saveDlg.FilePath, layCIM.ToXml()); } }); } } }
protected override void OnClick() { /// Create the list of Folder Connections IEnumerable<FolderConnectionProjectItem> projectFolders = Project.Current.GetItems<FolderConnectionProjectItem>(); string folders = null; foreach (var item in projectFolders) folders += item.Path + "\n"; /// Create the log file and write the current Folder-Connection's to it SaveItemDialog saveDialog = new SaveItemDialog(); saveDialog.Title = "Save all current of Folder Connections"; saveDialog.OverwritePrompt = true; saveDialog.DefaultExt = "txt"; saveDialog.Filter = ItemFilters.textFiles; /// If the save dialog was not dismissed, create the file if (saveDialog.ShowDialog() == true) { using (StreamWriter sw = new StreamWriter(saveDialog.FilePath)) { sw.WriteLine(folders.TrimEnd(new char[] { '\r', '\n' })); sw.Close(); } } }
protected override void OnClick() { // Create the list of Folder Connections IEnumerable <FolderConnectionProjectItem> projectFolders = Project.Current.GetItems <FolderConnectionProjectItem>(); string folders = null; foreach (var item in projectFolders) { folders += item.Path + Environment.NewLine; } // Create the log file and write the current Folder-Connection's to it SaveItemDialog saveDialog = new SaveItemDialog(); saveDialog.Title = "Save all current of Folder Connections"; saveDialog.OverwritePrompt = true; saveDialog.DefaultExt = "txt"; saveDialog.Filter = ItemFilters.textFiles; // If the save dialog was not dismissed, create the file if (saveDialog.ShowDialog() == true) { using (StreamWriter sw = new StreamWriter(saveDialog.FilePath)) { sw.WriteLine(folders.TrimEnd(new char[] { '\r', '\n' })); sw.Close(); } } }
/// <summary> /// Prompts the user to save features /// </summary> /// <param name="featureShapeChecked"></param> /// <returns></returns> public string PromptUserWithSaveDialog(bool featureShapeChecked) { //Prep the dialog SaveItemDialog saveItemDlg = new SaveItemDialog(); saveItemDlg.Title = "Select output"; saveItemDlg.OverwritePrompt = true; var saveType = (featureShapeChecked) ? "feature-shape" : "kml"; if (string.IsNullOrEmpty(previousSaveType)) { previousSaveType = saveType; } if (!string.IsNullOrEmpty(previousLocation) && previousSaveType == saveType) { saveItemDlg.InitialLocation = previousLocation; } else { if (featureShapeChecked) { saveItemDlg.InitialLocation = ArcGIS.Desktop.Core.Project.Current.DefaultGeodatabasePath; } else { saveItemDlg.InitialLocation = ArcGIS.Desktop.Core.Project.Current.HomeFolderPath; } } previousSaveType = saveType; // Set the filters and default extension if (featureShapeChecked) { saveItemDlg.Filter = ItemFilters.featureClasses_all; } else { saveItemDlg.Filter = ItemFilters.kml; saveItemDlg.DefaultExt = "kmz"; } bool?ok = saveItemDlg.ShowDialog(); //Show the dialog and get the response if (ok == true) { if (ContainsInvalidChars(Path.GetFileName(saveItemDlg.FilePath))) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show( DistanceAndDirectionLibrary.Properties.Resources.FeatureClassNameError, DistanceAndDirectionLibrary.Properties.Resources.DistanceDirectionLabel, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation); return(null); } previousLocation = Path.GetDirectoryName(saveItemDlg.FilePath); return(saveItemDlg.FilePath); } return(null); }
/// <summary> /// Prompts the user to save features /// /// </summary> /// <returns>The path to selected output (fgdb/shapefile)</returns> public string PromptUserWithSaveDialog(bool featureChecked, bool shapeChecked, bool kmlChecked) { //Prep the dialog SaveItemDialog saveItemDlg = new SaveItemDialog(); saveItemDlg.Title = "Select output"; saveItemDlg.OverwritePrompt = true; string saveType = featureChecked ? "gdb" : "file"; if (string.IsNullOrEmpty(previousSaveType)) { previousSaveType = saveType; } if (!string.IsNullOrEmpty(previousLocation) && previousSaveType == saveType) { saveItemDlg.InitialLocation = previousLocation; } else { if (featureChecked) { saveItemDlg.InitialLocation = ArcGIS.Desktop.Core.Project.Current.DefaultGeodatabasePath; } else { saveItemDlg.InitialLocation = ArcGIS.Desktop.Core.Project.Current.HomeFolderPath; } } previousSaveType = saveType; // Set the filters and default extension if (featureChecked) { saveItemDlg.Filter = ItemFilters.geodatabaseItems_all; } else if (shapeChecked) { saveItemDlg.Filter = ItemFilters.shapefiles; saveItemDlg.DefaultExt = "shp"; } else if (kmlChecked) { saveItemDlg.Filter = ItemFilters.kml; saveItemDlg.DefaultExt = "kmz"; } bool?ok = saveItemDlg.ShowDialog(); //Show the dialog and get the response if (ok == true) { string folderName = System.IO.Path.GetDirectoryName(saveItemDlg.FilePath); previousLocation = folderName; return(saveItemDlg.FilePath); } return(null); }
public void SaveNoteFile() { try { string startLocation; if (_dialogPath == false) { startLocation = System.IO.Path.GetDirectoryName(Project.Current.URI); } else { startLocation = AppSettings.Default.NoteFilePath; } string currentNoteValue = EditNoteComboBox.Text; // Save the values found in the Note values combobox to a file SaveItemDialog saveDialog = new SaveItemDialog() { Title = "Save the Note values to a file", Filter = ItemFilters.textFiles, DefaultExt = "txt", InitialLocation = startLocation }; if (saveDialog.ShowDialog() == true) { // IEnumerable<Item> selectedItem = openDialog.Items; // If the file is there, open it, or else it will be created System.IO.StreamWriter writer; writer = new System.IO.StreamWriter(saveDialog.FilePath, true); string selectedNotevalue; for (int i = 0; i < EditNoteComboBox.ItemCollection.Count; i++) { EditNoteComboBox.SelectedIndex = i; selectedNotevalue = EditNoteComboBox.SelectedItem.ToString(); writer.WriteLine(selectedNotevalue); } writer.Close(); EditNoteComboBox.Text = currentNoteValue; string savePath = System.IO.Path.GetDirectoryName(saveDialog.FilePath); AppSettings.Default.NoteFilePath = savePath; AppSettings.Default.Save(); _dialogPath = true; // is now set } } catch (Exception ex) { MessageBox.Show("Error in SaveNoteFile: " + ex.ToString(), "Error"); } }
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}"); } }
/// <summary> /// Prompts the user to save features /// /// </summary> /// <returns>The path to selected output (fgdb/shapefile)</returns> public string PromptUserWithSaveDialog(bool featureChecked, bool shapeChecked, bool kmlChecked, bool csvChecked) { //Prep the dialog SaveItemDialog saveItemDlg = new SaveItemDialog(); saveItemDlg.Title = CoordinateConversionLibrary.Properties.Resources.TitleSelectOutput; saveItemDlg.OverwritePrompt = true; if (!string.IsNullOrEmpty(previousLocation)) { saveItemDlg.InitialLocation = previousLocation; } // Set the filters and default extension if (featureChecked) { saveItemDlg.Filter = ItemFilters.geodatabaseItems_all; } else if (shapeChecked) { saveItemDlg.Filter = ItemFilters.shapefiles; saveItemDlg.DefaultExt = "shp"; } else if (kmlChecked) { saveItemDlg.Filter = ItemFilters.kml; saveItemDlg.DefaultExt = "kmz"; } else if (csvChecked) { saveItemDlg.Filter = ""; saveItemDlg.DefaultExt = "csv"; } bool?ok = saveItemDlg.ShowDialog(); //Show the dialog and get the response if (ok == true) { string folderName = System.IO.Path.GetDirectoryName(saveItemDlg.FilePath); previousLocation = folderName; return(saveItemDlg.FilePath); } return(null); }
/// <summary> /// Prompts the user to save features /// /// </summary> /// <returns>The path to selected output (fgdb/shapefile)</returns> public string PromptUserWithSaveDialog(bool featureChecked, bool shapeChecked, bool kmlChecked) { //Prep the dialog SaveItemDialog saveItemDlg = new SaveItemDialog(); saveItemDlg.Title = "Select output"; saveItemDlg.OverwritePrompt = true; if (!string.IsNullOrEmpty(previousLocation)) saveItemDlg.InitialLocation = previousLocation; // Set the filters and default extension if (featureChecked) { saveItemDlg.Filter = ItemFilters.geodatabaseItems_all; } else if (shapeChecked) { saveItemDlg.Filter = ItemFilters.shapefiles; saveItemDlg.DefaultExt = "shp"; } else if (kmlChecked) { saveItemDlg.Filter = ItemFilters.kml; saveItemDlg.DefaultExt = "kmz"; } bool? ok = saveItemDlg.ShowDialog(); //Show the dialog and get the response if (ok == true) { string folderName = System.IO.Path.GetDirectoryName(saveItemDlg.FilePath); previousLocation = folderName; return saveItemDlg.FilePath; } return null; }
/// <summary> /// Code Samples for Browse Dialog /// </summary> public async Task BrowseDialogCodeSample() { // Variables not used in samples OpenItemDialog selectItemDialog = new OpenItemDialog(); // in #region BrowseDialogItems #region OpenItemDialog /// Adds a single item to a map OpenItemDialog addToMapDialog = new OpenItemDialog() { Title = "Add To Map", InitialLocation = @"C:\Data\NewYork\Counties\Erie\Streets", Filter = ItemFilters.composite_addToMap }; #endregion //OpenItemDialog #region Show_OpenItemDialog OpenItemDialog addToProjectDialog = new OpenItemDialog(); addToMapDialog.Title = "Add To Project"; addToMapDialog.InitialLocation = @"C:\Data\NewYork\Counties\Maps"; addToMapDialog.MultiSelect = true; addToMapDialog.Filter = ItemFilters.composite_maps_import; bool?ok = addToMapDialog.ShowDialog(); if (ok == true) { IEnumerable <Item> selectedItems = addToMapDialog.Items; foreach (Item selectedItem in selectedItems) { Mapping.MapFactory.Instance.CreateMapFromItem(selectedItem); } } #endregion //Show_OpenItemDialog #region SaveItemDialog SaveItemDialog saveLayerFileDialog = new SaveItemDialog() { Title = "Save Layer File", InitialLocation = @"C:\Data\ProLayers\Geographic\Streets", Filter = ItemFilters.layers_allFileTypes }; #endregion //SaveItemDialog #region Show_SaveItemDialog SaveItemDialog saveMapFileDialog = new SaveItemDialog() { Title = "Save Map File", InitialLocation = @"C:\Data\NewYork\Counties\Maps", DefaultExt = @"mapx", Filter = ItemFilters.maps_all, OverwritePrompt = true }; bool?result = saveMapFileDialog.ShowDialog(); if (result == true) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Returned file name: " + saveMapFileDialog.FilePath); } #endregion //Show_SaveItemDialog #region BrowseDialogItems IEnumerable <Item> selectedDialogItems = selectItemDialog.Items; foreach (Item selectedDialogItem in selectedDialogItems) { Mapping.MapFactory.Instance.CreateMapFromItem(selectedDialogItem); } #endregion //BrowseDialogItems }