public bool Save() { var args = new CancelEventArgs(); string filename = _filename; var state = State; _broadcaster.BroadcastEvent(p => p.ProjectSaving_, this, args); if (args.Cancel) { return(false); } bool newProject = state == ProjectState.NotSaved || state == ProjectState.Empty; if (newProject) { if (!_fileService.SaveFile(ProjectFilter, ref filename)) { return(false); } } SaveProject(filename); if (newProject) { // OnProjectChanged(); } _broadcaster.BroadcastEvent(p => p.ProjectSaved_, this, args); return(true); }
public static void ExportSelected(this IFeatureSet fs, IFileDialogService dialogService, ILayerService layerService) { if (fs == null) { throw new ArgumentNullException("fs"); } if (dialogService == null) { throw new ArgumentNullException("dialogService"); } if (layerService == null) { throw new ArgumentNullException("layerService"); } if (fs.NumSelected == 0) { MessageService.Current.Info("No shapes are selected."); return; } string filename = string.Empty; dialogService.Title = "Select shapefile name to export selected shapes into"; if (!dialogService.SaveFile(@"Shapefiles (*.shp)|*.shp", ref filename)) { return; } var fsNew = fs.ExportSelection(); if (fsNew != null) { if (!fsNew.SaveAsEx(filename, true)) { MessageService.Current.Warn("Failed to save shapefile: " + filename + "."); return; } fsNew.Dispose(); } else { MessageService.Current.Warn("Failed to export selection."); return; } if (MessageService.Current.Ask("Do you want to load the new shapefile?")) { bool result = layerService.AddLayersFromFilename(filename); if (!result) { MessageService.Current.Warn("Failed to open exported shapefile: " + filename + "."); } } }
private void OnSaveClick(object sender, EventArgs e) { string filter = _dialogService.GetLayerFilter(_layerType); string filename = textBoxExt1.Text; if (_dialogService.SaveFile(filter, ref filename)) { _filename = filename; RefreshControls(); } }
public bool Save() { string filename = _filename; var state = State; bool newProject = state == ProjectState.NotSaved || state == ProjectState.Empty; if (newProject) { if (!_fileService.SaveFile(ProjectFilter, ref filename)) { return(false); } } SaveProject(filename); if (newProject) { // OnProjectChanged(); } return(true); }
private bool SaveFeatureSet(ILayer layer) { var fs = layer.FeatureSet; if (fs.SourceType == FeatureSourceType.InMemory) { string filename = layer.Name; if (_dialogService.SaveFile(FeatureSet.OpenDialogFilter, ref filename)) { return(fs.SaveAsEx(filename, true)); } return(false); } return(fs.StopEditingShapes()); }
private bool SaveFeatureSet(ILayer layer) { var fs = layer.FeatureSet; if (fs.SourceType == FeatureSourceType.InMemory) { if (bIgnoreSavingOfInMemoryShapes == false) { string filename = layer.Name; if (_dialogService.SaveFile(FeatureSet.OpenDialogFilter, ref filename)) { if (File.Exists(filename)) { String fname = filename; if (fname.IndexOf(".shp") != -1) { fname = fname.Remove(fname.Length - 4, 4); } File.Delete(fname + ".dbf"); File.Delete(fname + ".shx"); File.Delete(fname + ".prj"); File.Delete(fname + ".shp"); return(fs.SaveAsEx(filename, true)); } else { return(fs.SaveAsEx(filename, true)); } } return(false); } else { return(true); } } return(fs.StopEditingShapes()); }