コード例 #1
0
        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)
                    {
                    }
                }
            }
        }
        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)
                    {
                    }
                }
            }
        }
コード例 #3
0
        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;
                }
            }
        }