private async void OnSaveAsCommand(object obj) { var saveAsDialog = new ProSaveAsFormatView(); var vm = new ProSaveAsFormatViewModel(); saveAsDialog.DataContext = vm; if (saveAsDialog.ShowDialog() == true) { var fcUtils = new FeatureClassUtils(); string path = fcUtils.PromptUserWithSaveDialog(vm.FeatureIsChecked, vm.ShapeIsChecked, vm.KmlIsChecked, vm.CSVIsChecked); if (path != null) { try { string folderName = System.IO.Path.GetDirectoryName(path); var mapPointList = CoordinateAddInPoints.Select(i => i.Point).ToList(); if (vm.FeatureIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.FileGDB, mapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point); } else if (vm.ShapeIsChecked || vm.KmlIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.Shapefile, mapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point, vm.KmlIsChecked); } else if (vm.CSVIsChecked) { var aiPoints = CoordinateAddInPoints.ToList(); if (aiPoints == null || !aiPoints.Any()) { return; } var csvExport = new CsvExport(); foreach (var point in aiPoints) { csvExport.AddRow(); csvExport["Coordinate"] = point.Text; } csvExport.ExportToFile(path); System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulMessage + path, CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulCaption); } } catch (Exception ex) { } } } }
/// <summary> /// Method to use when you need to move a feedback line to a point /// This forces a new point to be used, sometimes this method projects the point to a different spatial reference /// </summary> /// <param name="point"></param> //internal void FeedbackMoveTo(IPoint point) //{ // if (feedback == null || point == null) // return; // feedback.MoveTo(new Point() { X = point.X, Y = point.Y, SpatialReference = point.SpatialReference }); //} /// <summary> /// Saves graphics to file gdb or shp file /// </summary> /// <param name="obj"></param> private async void OnSaveAs() { var dlg = new ProSaveAsFormatView(); dlg.DataContext = new ProSaveAsFormatViewModel(); var vm = dlg.DataContext as ProSaveAsFormatViewModel; GeomType geomType = GeomType.Polygon; if (dlg.ShowDialog() == true) { // Get the graphics list for the selected tab List <Graphic> typeGraphicsList = new List <Graphic>(); if (this is ProLinesViewModel) { typeGraphicsList = GraphicsList.Where(g => g.GraphicType == GraphicTypes.Line).ToList(); geomType = GeomType.PolyLine; } else if (this is ProCircleViewModel) { typeGraphicsList = GraphicsList.Where(g => g.GraphicType == GraphicTypes.Circle).ToList(); } else if (this is ProEllipseViewModel) { typeGraphicsList = GraphicsList.Where(g => g.GraphicType == GraphicTypes.Ellipse).ToList(); } else if (this is ProRangeViewModel) { typeGraphicsList = GraphicsList.Where(g => g.GraphicType == GraphicTypes.RangeRing).ToList(); geomType = GeomType.PolyLine; } string path = fcUtils.PromptUserWithSaveDialog(vm.FeatureIsChecked, vm.ShapeIsChecked, vm.KmlIsChecked); if (path != null) { try { string folderName = System.IO.Path.GetDirectoryName(path); if (vm.FeatureIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.FileGDB, typeGraphicsList, MapView.Active.Map.SpatialReference, MapView.Active, geomType); } else if (vm.ShapeIsChecked || vm.KmlIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.Shapefile, typeGraphicsList, MapView.Active.Map.SpatialReference, MapView.Active, geomType, vm.KmlIsChecked); } } catch (Exception ex) { } } } }
private async void OnSaveAsCommand(object obj) { var saveAsDialog = new ProSaveAsFormatView(); var vm = new ProSaveAsFormatViewModel(); saveAsDialog.DataContext = vm; if (saveAsDialog.ShowDialog() == true) { var fcUtils = new FeatureClassUtils(); string path = fcUtils.PromptUserWithSaveDialog(vm.FeatureIsChecked, vm.ShapeIsChecked, vm.KmlIsChecked); if (path != null) { try { string folderName = System.IO.Path.GetDirectoryName(path); var mapPointList = CoordinateAddInPoints.Select(i => i.Point).ToList(); if (vm.FeatureIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.FileGDB, mapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point); } else if (vm.ShapeIsChecked || vm.KmlIsChecked) { await fcUtils.CreateFCOutput(path, SaveAsType.Shapefile, mapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point, vm.KmlIsChecked); } } catch (Exception ex) { } } } }
private async void OnSaveAsCommand(object obj) { var saveAsDialog = new ProSaveAsFormatView(); var vm = new ProSaveAsFormatViewModel(); saveAsDialog.DataContext = vm; if (saveAsDialog.ShowDialog() == true) { IsToolActive = false; var fcUtils = new FeatureClassUtils(); string path = fcUtils.PromptUserWithSaveDialog(vm.FeatureIsChecked, vm.ShapeIsChecked, vm.KmlIsChecked, vm.CSVIsChecked); if (path != null) { var displayAmb = CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg; CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = false; try { string folderName = System.IO.Path.GetDirectoryName(path); var mapPointList = CoordinateAddInPoints.Select(i => i.Point).ToList(); if (vm.FeatureIsChecked) { var ccMapPointList = GetMapPointExportFormat(CoordinateAddInPoints); await fcUtils.CreateFCOutput(path, SaveAsType.FileGDB, ccMapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point); } else if (vm.ShapeIsChecked || vm.KmlIsChecked) { var ccMapPointList = GetMapPointExportFormat(CoordinateAddInPoints); await fcUtils.CreateFCOutput(path, SaveAsType.Shapefile, ccMapPointList, MapView.Active.Map.SpatialReference, MapView.Active, CoordinateConversionLibrary.GeomType.Point, vm.KmlIsChecked); } else if (vm.CSVIsChecked) { var aiPoints = CoordinateAddInPoints.ToList(); if (!aiPoints.Any()) { return; } var csvExport = new CsvExport(); foreach (var point in aiPoints) { var results = GetOutputFormats(point); csvExport.AddRow(); foreach (var item in results) { csvExport[item.Key] = item.Value; } if (point.FieldsDictionary != null) { foreach (KeyValuePair <string, Tuple <object, bool> > item in point.FieldsDictionary) { if (item.Key != PointFieldName && item.Key != OutputFieldName) { csvExport[item.Key] = item.Value.Item1; } } } } csvExport.ExportToFile(path); System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulMessage + path, CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulCaption); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = displayAmb; } } }