private async void UpdateHighlightedGraphics() { foreach (var proGraphic in ProGraphicsList) { var aiPoint = CoordinateAddInPoints.FirstOrDefault(p => p.GUID == proGraphic.GUID); if (aiPoint != null) { var s = proGraphic.SymbolRef.Symbol as CIMPointSymbol; if (s == null) { continue; } if (aiPoint.IsSelected) { s.HaloSize = 2; } else { s.HaloSize = 0; } var result = await QueuedTask.Run(() => { var temp = MapView.Active.UpdateOverlay(proGraphic.Disposable, proGraphic.Geometry, proGraphic.SymbolRef); return(temp); }); } } }
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 AddCollectionPoint(MapPoint point) { var guid = await AddGraphicToMap(point, ColorFactory.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; CoordinateAddInPoints.Add(addInPoint); }
private async void AddCollectionPoint(MapPoint point) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list CoordinateAddInPoints.Insert(0, addInPoint); }
private async void AddCollectionPoint(MapPoint point, Dictionary <string, Tuple <object, bool> > fieldsDictionary = null) { var guid = await AddGraphicToMap(point, ColorFactory.Instance.RedRGB, true, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid, FieldsDictionary = fieldsDictionary }; //Add point to the top of the list CoordinateAddInPoints.Add(addInPoint); }
public override void OnDisplayCoordinateTypeChanged(CoordinateConversionLibrary.Models.CoordinateConversionLibraryConfig obj) { base.OnDisplayCoordinateTypeChanged(obj); // update list box coordinates var list = CoordinateAddInPoints.ToList(); CoordinateAddInPoints.Clear(); foreach (var item in list) { CoordinateAddInPoints.Add(item); } }
private void AddCollectionPoint(IPoint point) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; CoordinateAddInPoints.Add(addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true)); }
private void DeletePoints(List <AddInPoint> aiPoints) { if (aiPoints == null || !aiPoints.Any()) { return; } // remove graphics from map var guidList = aiPoints.Select(x => x.GUID).ToList(); RemoveGraphics(guidList); foreach (var point in aiPoints) { CoordinateAddInPoints.Remove(point); } }
private void AddCollectionPoint(IPoint point, Dictionary <string, Tuple <object, bool> > fieldsDictionary = null) { if (point != null && !point.IsEmpty) { var color = (IColor) new RgbColorClass() { Red = 255 }; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, ArcMapHelpers.DefaultMarkerSize); var addInPoint = new AddInPoint() { Point = point, GUID = guid, FieldsDictionary = fieldsDictionary }; //Add point to the top of the list CoordinateAddInPoints.Add(addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true, fieldsDictionary)); } }
private void ClearGraphicsContainer(IMap map) { var graphicsContainer = map as IGraphicsContainer; if (graphicsContainer != null) { //graphicsContainer.DeleteAllElements(); // now we have a collection feature and need to not clear those related graphics graphicsContainer.Reset(); var g = graphicsContainer.Next(); while (g != null) { if (!CoordinateAddInPoints.Any(aiPoint => aiPoint.GUID == ((IElementProperties)g).Name)) { graphicsContainer.DeleteElement(g); } g = graphicsContainer.Next(); } } }
private void AddCollectionPoint(IPoint point) { if (!point.IsEmpty && point != null) { var color = new RgbColorClass() { Red = 255 } as IColor; var guid = ArcMapHelpers.AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSCircle, 7); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; //Add point to the top of the list CoordinateAddInPoints.Insert(0, addInPoint); GraphicsList.Add(new AMGraphic(guid, point, true)); } }
private void OnClearGraphicsCommand(object obj) { /* KG - Use DeletePoints() to Clrea All button * var mxdoc = ArcMap.Application.Document as IMxDocument; * if (mxdoc == null) * return; * var av = mxdoc.FocusMap as IActiveView; * if (av == null) * return; * var gc = av as IGraphicsContainer; * if (gc == null) * return; * //TODO need to clarify what clear graphics button does * // seems to be different than the other Military Tools when doing batch collection * RemoveGraphics(gc, GraphicsList.Where(g => g.IsTemp == false).ToList()); * * //av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); * av.Refresh(); // sometimes a partial refresh is not working */ DeletePoints(CoordinateAddInPoints.ToList()); }
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 void UpdateHighlightedGraphics() { if ((ArcMap.Document == null) && (ArcMap.Document.FocusMap == null)) { return; } var av = (IActiveView)ArcMap.Document.FocusMap; var gc = (IGraphicsContainer)av; gc.Reset(); var element = gc.Next(); while (element != null) { var eProp = (IElementProperties)element; if (eProp != null) { var aiPoint = CoordinateAddInPoints.FirstOrDefault(p => p.GUID == eProp.Name); var doUpdate = false; if (aiPoint != null) { // highlight var markerElement = element as IMarkerElement; if (markerElement != null) { var sms = markerElement.Symbol as ISimpleMarkerSymbol; if (sms != null) { var simpleMarkerSymbol = (ISimpleMarkerSymbol) new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = sms.Color; simpleMarkerSymbol.Size = ArcMapHelpers.DefaultMarkerSize; simpleMarkerSymbol.Style = sms.Style; simpleMarkerSymbol.OutlineSize = 1.7; if (aiPoint.IsSelected) { var color = (IColor) new RgbColorClass() { Green = 255 }; // Marker symbols simpleMarkerSymbol.Size = ArcMapHelpers.DefaultMarkerSize + ArcMapHelpers.DefaultOutlineSize; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = color; doUpdate = true; } else if (markerElement.Symbol.Size > 0) { simpleMarkerSymbol.Outline = false; doUpdate = true; //simpleMarkerSymbol.OutlineColor = sms.Color; } if (doUpdate) { markerElement.Symbol = simpleMarkerSymbol; gc.UpdateElement(element); } } } } } element = gc.Next(); } av.Refresh(); }
/// <summary> /// Notify if collection list has any items /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CoordinateAddInPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.CollectListHasItems, CoordinateAddInPoints.Any()); }
private void UpdateHighlightedGraphics() { var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var gc = av as IGraphicsContainer; gc.Reset(); var element = gc.Next(); while (element != null) { var eProp = element as IElementProperties; if (eProp != null) { var aiPoint = CoordinateAddInPoints.FirstOrDefault(p => p.GUID == eProp.Name); if (aiPoint != null) { // highlight var markerElement = element as IMarkerElement; if (markerElement != null) { var sms = markerElement.Symbol as ISimpleMarkerSymbol; if (sms != null) { var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol; simpleMarkerSymbol.Color = sms.Color; simpleMarkerSymbol.Size = sms.Size; simpleMarkerSymbol.Style = sms.Style; simpleMarkerSymbol.OutlineSize = 1; if (aiPoint.IsSelected) { var color = new RgbColorClass() { Green = 255 } as IColor; // Marker symbols simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = color; } else { simpleMarkerSymbol.Outline = false; //simpleMarkerSymbol.OutlineColor = sms.Color; } markerElement.Symbol = simpleMarkerSymbol; gc.UpdateElement(element); } } } } element = gc.Next(); } av.Refresh(); }
private void OnSaveAsCommand(object obj) { var saveAsDialog = new AMSaveAsFormatView(); var vm = new SaveAsFormatViewModel(); saveAsDialog.DataContext = vm; if (saveAsDialog.ShowDialog() == true) { IFeatureClass fc = null; string path = null; var fcUtils = new FeatureClassUtils(); if (vm.FeatureShapeIsChecked) { path = fcUtils.PromptUserWithGxDialog(ArcMap.Application.hWnd); if (path != null) { SaveAsType saveType = System.IO.Path.GetExtension(path).Equals(".shp") ? SaveAsType.Shapefile : SaveAsType.FileGDB; fc = fcUtils.CreateFCOutput(path, saveType, GraphicsList, ArcMap.Document.FocusMap.SpatialReference); } } else if (vm.KmlIsChecked) { path = PromptSaveFileDialog("kmz", "KMZ File (*.kmz)|*.kmz", CoordinateConversionLibrary.Properties.Resources.KMLLocationMessage); if (path != null) { string kmlName = System.IO.Path.GetFileName(path); string folderName = System.IO.Path.GetDirectoryName(path); string tempShapeFile = folderName + "\\tmpShapefile.shp"; IFeatureClass tempFc = fcUtils.CreateFCOutput(tempShapeFile, SaveAsType.Shapefile, GraphicsList, ArcMap.Document.FocusMap.SpatialReference); if (tempFc != null) { var kmlUtils = new KMLUtils(); kmlUtils.ConvertLayerToKML(path, tempShapeFile, ArcMap.Document.FocusMap); // delete the temporary shapefile fcUtils.DeleteShapeFile(tempShapeFile); } } } else { //Export to CSV path = PromptSaveFileDialog("csv", "CSV File (*.csv)|*.csv", CoordinateConversionLibrary.Properties.Resources.CSVLocationMessage); if (path != null) { string csvName = System.IO.Path.GetFileName(path); string folderName = System.IO.Path.GetDirectoryName(path); string tempFile = System.IO.Path.Combine(folderName, csvName); var aiPoints = CoordinateAddInPoints.ToList(); if (aiPoints == null || !aiPoints.Any()) { return; } var csvExport = new CsvExport(); foreach (var point in aiPoints) { csvExport.AddRow(); csvExport["Coordinates"] = point.Text; } csvExport.ExportToFile(tempFile); System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulMessage + tempFile, CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulCaption); } } if (fc != null) { AddFeatureLayerToMap(fc); } } }
// Call CopyAllCoordinateOutputs event private void OnCopyAllCommand(object obj) { OnCopyAllCoordinateOutputs(CoordinateAddInPoints.ToList()); }
private void OnDeleteAllPointsCommand(object obj) { DeletePoints(CoordinateAddInPoints.ToList()); }
private void OnSaveAsCommand(object obj) { var saveAsDialog = new AMSaveAsFormatView(); var vm = new SaveAsFormatViewModel(); saveAsDialog.DataContext = vm; if (saveAsDialog.ShowDialog() == true) { IFeatureClass fc = null; string path = null; var fcUtils = new FeatureClassUtils(); if (vm.FeatureShapeIsChecked) { path = fcUtils.PromptUserWithGxDialog(ArcMap.Application.hWnd); if (path != null) { var grpList = GetMapPointExportFormat(GraphicsList); SaveAsType saveType = System.IO.Path.GetExtension(path).Equals(".shp") ? SaveAsType.Shapefile : SaveAsType.FileGDB; fc = fcUtils.CreateFCOutput(path, saveType, grpList, ArcMap.Document.FocusMap.SpatialReference); } } else if (vm.KmlIsChecked) { path = PromptSaveFileDialog("kmz", "KMZ File (*.kmz)|*.kmz", CoordinateConversionLibrary.Properties.Resources.KMLLocationMessage); if (path != null) { string kmlName = System.IO.Path.GetFileName(path); string folderName = System.IO.Path.GetDirectoryName(path); var grpList = GetMapPointExportFormat(GraphicsList); var fileNameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(kmlName); IFeatureClass tempFc = fcUtils.CreateFCOutput(fileNameWithoutExt, SaveAsType.KML, grpList, ArcMap.Document.FocusMap.SpatialReference); if (tempFc != null) { var kmlUtils = new KMLUtils(); kmlUtils.ConvertLayerToKML(tempFc, path, fileNameWithoutExt, ArcMap.Document.FocusMap); } } } else { //Export to CSV path = PromptSaveFileDialog("csv", "CSV File (*.csv)|*.csv", CoordinateConversionLibrary.Properties.Resources.CSVLocationMessage); if (path != null) { string csvName = System.IO.Path.GetFileName(path); string folderName = System.IO.Path.GetDirectoryName(path); string tempFile = System.IO.Path.Combine(folderName, csvName); var aiPoints = CoordinateAddInPoints.ToList(); if (!aiPoints.Any()) { return; } var csvExport = new CsvExport(); var displayAmb = CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg; 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; } } } CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = false; } CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = displayAmb; csvExport.ExportToFile(tempFile); System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulMessage + tempFile, CoordinateConversionLibrary.Properties.Resources.CSVExportSuccessfulCaption); } } if (fc != null) { AddFeatureLayerToMap(fc); } } }
private void ClearListBoxSelection() { UpdateHighlightedGraphics(true); Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.CollectListHasItems, CoordinateAddInPoints.Any()); }
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; } } }
private void OnClearGraphicsCommand(object obj) { DeletePoints(CoordinateAddInPoints.ToList()); }