public async Task RedrawObservationAsync() { await QueuedTask.Run(() => { _disposeInnerLine?.Dispose(); _disposeOuterLine?.Dispose(); if (_measurementPoint?.IsObservationVisible() ?? false) { MapView thisView = MapView.Active; MapPoint measPoint = _measurementPoint?.Point; MapPoint mapPointObsLine; if ((measPoint != null) && (!double.IsNaN(measPoint.X)) && (!double.IsNaN(measPoint.Y))) { Point winMeasPoint = thisView.MapToScreen(measPoint); Point winObsPoint = thisView.MapToScreen(Point); double xdir = ((winMeasPoint.X - winObsPoint.X) * 3) / 2; double ydir = ((winMeasPoint.Y - winObsPoint.Y) * 3) / 2; Point winPointObsLine = new Point(winObsPoint.X + xdir, winObsPoint.Y + ydir); mapPointObsLine = thisView.ScreenToMap(winPointObsLine); } else { mapPointObsLine = MapPointBuilder.CreateMapPoint((Point.X + (XDir * DistLine)), (Point.Y + (YDir * DistLine))); } IList <MapPoint> linePointList = new List <MapPoint>(); linePointList.Add(mapPointObsLine); linePointList.Add(Point); Polyline polyline = PolylineBuilder.CreatePolyline(linePointList); Color outerColorLine = Viewer?.Color ?? Color.DarkGray; CIMColor cimOuterColorLine = ColorFactory.Instance.CreateColor(Color.FromArgb(255, outerColorLine)); CIMLineSymbol cimOuterLineSymbol = SymbolFactory.Instance.DefaultLineSymbol; cimOuterLineSymbol.SetColor(cimOuterColorLine); cimOuterLineSymbol.SetSize(OuterLineSize); CIMSymbolReference cimOuterLineSymbolRef = cimOuterLineSymbol.MakeSymbolReference(); _disposeOuterLine = thisView.AddOverlay(polyline, cimOuterLineSymbolRef); Color innerColorLine = Color.LightGray; CIMColor cimInnerColorLine = ColorFactory.Instance.CreateColor(innerColorLine); CIMLineSymbol cimInnerLineSymbol = SymbolFactory.Instance.DefaultLineSymbol; cimInnerLineSymbol.SetColor(cimInnerColorLine); cimInnerLineSymbol.SetSize(InnerLineSize); CIMSymbolReference cimInnerLineSymbolRef = cimInnerLineSymbol.MakeSymbolReference(); _disposeInnerLine = thisView.AddOverlay(polyline, cimInnerLineSymbolRef); } }); }
private async void getData(Geometry geometry, GeometryDimension dimension) { properties = new NecessaryProperties(); ArcGIS.Desktop.Mapping.MapView view = ArcGIS.Desktop.Mapping.MapView.Active; var layersTOC = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetLayersAsFlattenedList(); FeatureLayer parcelsLayer = (FeatureLayer)layersTOC.Where((layer) => { return(layer.Name.Contains(config.getConfig("Działki", "parcelsLayer"))); }).First(); var parcels = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetLayersAsFlattenedList(); foreach (var f in parcels) { var feat = f.Name.Equals(config.getConfig("Działki", "parcelsLayer")); if (feat) { this.parcellayer = (FeatureLayer)f; } } this.getParcel(parcelsLayer, geometry, dimension); CIMLineSymbol symbol = new CIMLineSymbol(); symbol.SetColor(ColorFactory.Instance.CreateRGBColor(255, 255, 255, 0)); foreach (ParcelModel parcelModel in properties.parcels) { object result = null; var pointsFromShape = parcelModel.parcel.TryGetValue("Shape", out result); } Polygon shp = null; foreach (Layer layer in layersTOC) { try { FeatureLayer fLayer = (FeatureLayer)layer; if (fLayer.Name.Contains(config.getConfig("MPZP", "MPZPlayer"))) { this.getMPZP(fLayer, geometry, dimension); } else if (fLayer.Name.Contains(config.getConfig("Wydzielenia", "precintLayer"))) { this.getResolution(fLayer, geometry, dimension); } else if (fLayer.Name.Contains(config.getConfig("Obręby", "areaLayer"))) { this.getPrecints(fLayer, geometry, dimension); } }catch (Exception) { } } }
private async Task RedrawConeAsync() { await QueuedTask.Run(() => { GlobeSpotter globeSpotter = GlobeSpotter.Current; if ((globeSpotter.InsideScale()) && (!_mapPoint.IsEmpty) && (Color != null)) { var thisColor = (SystCol)Color; MapView thisView = MapView.Active; Map map = thisView.Map; SpatialReference mapSpat = map.SpatialReference; SpatialReference mapPointSpat = _mapPoint.SpatialReference; ProjectionTransformation projection = ProjectionTransformation.Create(mapPointSpat, mapSpat); _mapPoint = GeometryEngine.Instance.ProjectEx(_mapPoint, projection) as MapPoint; WinPoint point = thisView.MapToScreen(_mapPoint); double angleh = (_hFov *Math.PI) / 360; double angle = (((270 + _angle) % 360) * Math.PI) / 180; double angle1 = angle - angleh; double angle2 = angle + angleh; double x = point.X; double y = point.Y; double size = Size / 2; WinPoint screenPoint1 = new WinPoint((x + (size * Math.Cos(angle1))), (y + (size * Math.Sin(angle1)))); WinPoint screenPoint2 = new WinPoint((x + (size * Math.Cos(angle2))), (y + (size * Math.Sin(angle2)))); MapPoint point1 = thisView.ScreenToMap(screenPoint1); MapPoint point2 = thisView.ScreenToMap(screenPoint2); IList <MapPoint> polygonPointList = new List <MapPoint>(); polygonPointList.Add(_mapPoint); polygonPointList.Add(point1); polygonPointList.Add(point2); polygonPointList.Add(_mapPoint); Polygon polygon = PolygonBuilder.CreatePolygon(polygonPointList); Color colorPolygon = SystCol.FromArgb(_blinking ? BlinkAlpha : NormalAlpha, thisColor); CIMColor cimColorPolygon = ColorFactory.Instance.CreateColor(colorPolygon); CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.DefaultPolygonSymbol; polygonSymbol.SetColor(cimColorPolygon); polygonSymbol.SetOutlineColor(null); CIMSymbolReference polygonSymbolReference = polygonSymbol.MakeSymbolReference(); IDisposable disposePolygon = thisView.AddOverlay(polygon, polygonSymbolReference); IList <MapPoint> linePointList = new List <MapPoint>(); linePointList.Add(point1); linePointList.Add(_mapPoint); linePointList.Add(point2); Polyline polyline = PolylineBuilder.CreatePolyline(linePointList); Color colorLine = _active ? SystCol.Yellow : SystCol.Gray; CIMColor cimColorLine = ColorFactory.Instance.CreateColor(colorLine); CIMLineSymbol cimLineSymbol = SymbolFactory.Instance.DefaultLineSymbol; cimLineSymbol.SetColor(cimColorLine); cimLineSymbol.SetSize(_blinking ? BorderSizeBlinking : BorderSize); CIMSymbolReference lineSymbolReference = cimLineSymbol.MakeSymbolReference(); IDisposable disposePolyLine = thisView.AddOverlay(polyline, lineSymbolReference); _disposePolygon?.Dispose(); _disposePolygon = disposePolygon; _disposePolyLine?.Dispose(); _disposePolyLine = disposePolyLine; if (_blinking) { var blinkEvent = new AutoResetEvent(true); var blinkTimerCallBack = new TimerCallback(ResetBlinking); _blinkTimer = new Timer(blinkTimerCallBack, blinkEvent, BlinkTime, -1); } } else { _disposePolygon?.Dispose(); _disposePolyLine?.Dispose(); } }); }