public override void Setup() { base.Setup(); Device.SetFlags(new[] { ExperimentalFlags.ShapesExperimental }); _pointCollectionConverter = new PointCollectionConverter(); }
private void AddPolygonGraphics() { string coordinateString1 = "130,5.59 118.42,3.92 117.3,23.3 143.2,22.9 130,5.59"; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; PointCollectionConverter pointConverter = new PointCollectionConverter(); ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection1 = pointConverter.ConvertFromString(coordinateString1) as ESRI.ArcGIS.Client.Geometry.PointCollection; ESRI.ArcGIS.Client.Geometry.Polygon polygon1 = new ESRI.ArcGIS.Client.Geometry.Polygon(); polygon1.Rings.Add(pointCollection1); Graphic graphic = new Graphic() { Geometry = mercator.FromGeographic(polygon1), Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol }; graphicsLayer.Graphics.Add(graphic); }
private void AddPolygonGraphics() { string coordinateString1 = "14819406,1294088 13066124,751406 13191358,2880391 15570812,2713412 14819406,1294088"; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; PointCollectionConverter pointConverter = new PointCollectionConverter(); ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection1 = pointConverter.ConvertFromString(coordinateString1) as ESRI.ArcGIS.Client.Geometry.PointCollection; ESRI.ArcGIS.Client.Geometry.Polygon polygon1 = new ESRI.ArcGIS.Client.Geometry.Polygon(); polygon1.Rings.Add(pointCollection1); Graphic graphic = new Graphic() { Geometry = polygon1, Symbol = DefaultFillSymbol }; graphicsLayer.Graphics.Add(graphic); }
private ESRI.ArcGIS.Client.Geometry.Geometry getGeometry(string geometrytype) { switch (geometrytype) { case "Point": var point = new MapPoint(-16584535.1432908, 8580553.67499035); return(point); case "Polyline": { string coordinatestring = "-16584535.1432908,8580553.67499035 -16583535.1432908,8585553.67499035 -16580535.1432908,8575553.67499035"; var pointcollection = new PointCollectionConverter().ConvertFromString(coordinatestring) as ESRI.ArcGIS.Client.Geometry.PointCollection; var polygon = new ESRI.ArcGIS.Client.Geometry.Polyline(); polygon.Paths.Add(pointcollection); return(polygon); } case "Polygon": { string coordinatestring = "-16584535.1432908,8580553.67499035 -16583535.1432908,8585553.67499035 -16580535.1432908,8575553.67499035 -16584515.1432908,8580555.67499035 -16584535.1432908,8580553.67499035"; var pointcollection = new PointCollectionConverter().ConvertFromString(coordinatestring) as ESRI.ArcGIS.Client.Geometry.PointCollection; var polygon = new ESRI.ArcGIS.Client.Geometry.Polygon(); polygon.Rings.Add(pointcollection); return(polygon); } case "Multipoint": return(null); case "Envelope": return(null); default: return(null); } }
private ESRI.ArcGIS.Client.Geometry.Geometry getGeometry(string geometrytype) { switch (geometrytype) { case "Point": var point = new MapPoint(-16584535.1432908, 8580553.67499035); return point; case "Polyline": { string coordinatestring = "-16584535.1432908,8580553.67499035 -16583535.1432908,8585553.67499035 -16580535.1432908,8575553.67499035"; var pointcollection = new PointCollectionConverter().ConvertFromString(coordinatestring) as ESRI.ArcGIS.Client.Geometry.PointCollection; var polygon = new ESRI.ArcGIS.Client.Geometry.Polyline(); polygon.Paths.Add(pointcollection); return polygon; } case "Polygon": { string coordinatestring = "-16584535.1432908,8580553.67499035 -16583535.1432908,8585553.67499035 -16580535.1432908,8575553.67499035 -16584515.1432908,8580555.67499035 -16584535.1432908,8580553.67499035"; var pointcollection = new PointCollectionConverter().ConvertFromString(coordinatestring) as ESRI.ArcGIS.Client.Geometry.PointCollection; var polygon = new ESRI.ArcGIS.Client.Geometry.Polygon(); polygon.Rings.Add(pointcollection); return polygon; } case "Multipoint": return null; case "Envelope": return null; default: return null; } }
public void SetUp() { _pointCollectionConverter = new PointCollectionConverter(); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (string.IsNullOrEmpty(values[3].ToString())) { return(null); } string dataStr = values[3].ToString().Substring(1, values[3].ToString().Count() - 2).Replace("L", " "); PointCollectionConverter pcconverter = new PointCollectionConverter(); PointCollection pc = new PointCollection(); pc = (PointCollection)pcconverter.ConvertFromString(dataStr); List <Point> pointList = pc.ToList(); double xMin_color = 0; // 色标最小值 double xMax_color = 60; // 色标最大值 // 定义色标颜色值(彩虹色) Color[] colors = new Color[7] { Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Indigo, Colors.Blue, Colors.Violet }; // 定义色标与数值范围字典表 System.Collections.Generic.Dictionary <string, string> colorDic = new System.Collections.Generic.Dictionary <string, string>(); double interval = Math.Ceiling((xMax_color - xMin_color) / 6); //处理最大值与最小值间隔,保证彩虹色都使用 for (int skip = 0; skip < 7; skip++) { double xRange = xMin_color + (interval * skip); double xNextRange = xMin_color + (interval * (skip + 1)); colorDic.Add(string.Format(@"{0}_{1}", xRange, xNextRange), string.Format(@"{0}_{1}", skip, skip + 1)); if (xNextRange >= xMax_color) { break; } } //colorDic 目前参数没有使用,使用的是静态的,待设置功能开发完,更换 2017-3-22 sjm LinearGradientBrush lineGradientBrush = new LinearGradientBrush(); // 垂直线性渐变 lineGradientBrush.StartPoint = new Point(0.5, 0); lineGradientBrush.EndPoint = new Point(0.5, 1); lineGradientBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0 }); char split = '_'; for (int i = 0; i < pointList.Count; i++) { double xPoint = pointList[i].X > xMax_color ? xMax_color : pointList[i].X; var colorDicValue = colorDic.FirstOrDefault(x => double.Parse(x.Key.Split(split)[0]) <= xPoint && double.Parse(x.Key.Split(split)[1]) >= xPoint ).Value; var colorDicKey = colorDic.FirstOrDefault(q => q.Value == colorDicValue).Key; string[] colorStrs = colorDicValue.Split(split); string[] keyStrs = colorDicKey.Split(split); Color s_color = colors[int.Parse(colorStrs[0])]; Color d_color = colors[int.Parse(colorStrs[1])]; Color vColor = GetGradientColor(s_color, d_color, xPoint, double.Parse(keyStrs[0]), double.Parse(keyStrs[1])); lineGradientBrush.GradientStops.Add(new GradientStop(vColor, (double)i / pointList.Count)); } lineGradientBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 1 }); return(lineGradientBrush); }
public override void Setup() { base.Setup(); _pointCollectionConverter = new PointCollectionConverter(); }