public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport) { if (_bgWorker == null) { _bgWorker = new BackgroundWorker(); } /* * while (_bgWorker.IsBusy) { * Thread.Sleep (00001); * } */ _bgWorker.RunWorkerCompleted += (sender, e) => { var layer = e.Result as CALayer; if (layer != null) { var styleKey = style.GetHashCode().ToString(); feature[styleKey] = layer; } }; _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e) { var layer = RenderImage(multiPolygon, style, viewport); e.Result = layer; }; _bgWorker.RunWorkerAsync(); }
public void RenderGeometry(MultiPolygon multiPolygon, IStyle style, IFeature feature, IViewport viewport) { if (_bgWorker == null) _bgWorker = new BackgroundWorker(); /* while (_bgWorker.IsBusy) { Thread.Sleep (00001); } */ _bgWorker.RunWorkerCompleted += (sender, e) => { var layer = e.Result as CALayer; if (layer != null) { var styleKey = style.GetHashCode().ToString(); feature[styleKey] = layer; } }; _bgWorker.DoWork += delegate(object sender, DoWorkEventArgs e) { var layer = RenderImage(multiPolygon, style, viewport); e.Result = layer; }; _bgWorker.RunWorkerAsync(); }
public static Func <ExportContext, SharpKml.Dom.Style> CreateFromSharpmapStyle(IStyle sharpmapStyle) { if (sharpmapStyle == null) { throw new ArgumentNullException("sharpmapStyle"); } var vectorStyle = sharpmapStyle as VectorStyle; if (vectorStyle == null) { return(null); } SharpKml.Dom.Style style = null; var install = new Action <ExportContext>(context => { style = new SharpKml.Dom.Style { Id = sharpmapStyle.GetHashCode().ToString(CultureInfo.InvariantCulture) }; if (vectorStyle.Line != null) { var lineStyle = new LineStyle(); style.Line = lineStyle; var color = vectorStyle.Line.Color; lineStyle.Color = new Color32(color.A, color.B, color.G, color.R); lineStyle.ColorMode = ColorMode.Normal; lineStyle.Width = vectorStyle.Line.Width; } var solidColor = ConvertToColor32(vectorStyle.Fill); if (solidColor != null) { var polygonStyle = new PolygonStyle(); style.Polygon = polygonStyle; polygonStyle.Fill = true; polygonStyle.Color = solidColor; } if (vectorStyle.Symbol == null) { if (vectorStyle.PointSize > 0) { var iconStyle = new IconStyle(); var pointColor = vectorStyle.PointColor != null ? ConvertToColor32(vectorStyle.PointColor) ?? new Color32(255, 0, 0, 0) : new Color32(255, 0, 0, 0); iconStyle.Color = pointColor; iconStyle.ColorMode = ColorMode.Normal; iconStyle.Icon = new IconStyle.IconLink(Pushpins.ShadedDot); iconStyle.Scale = vectorStyle.PointSize / 6; style.Icon = iconStyle; } } else { var additionalFile = SaveImagetoDisk(vectorStyle.Symbol); Debug.Assert(additionalFile != null, "additionalFile != null"); context.AdditionalFiles.Add(additionalFile); var iconStyle = new IconStyle { Icon = new IconStyle.IconLink(new Uri(context.IsKmz ? Path.GetFileName(additionalFile) : additionalFile, UriKind.Relative)), Scale = vectorStyle.SymbolScale }; style.Icon = iconStyle; } }); EventHandler endedHandler = delegate { style = null; }; return(context => { if (style == null && sharpmapStyle.Enabled) { install(context); context.Exporter.Ended -= endedHandler; context.Exporter.Ended += endedHandler; } return style; }); }
public static Func<ExportContext, SharpKml.Dom.Style> CreateFromSharpmapStyle(IStyle sharpmapStyle) { if (sharpmapStyle == null) throw new ArgumentNullException("sharpmapStyle"); var vectorStyle = sharpmapStyle as VectorStyle; if (vectorStyle == null) return null; SharpKml.Dom.Style style = null; var install = new Action<ExportContext>(context => { style = new SharpKml.Dom.Style { Id = sharpmapStyle.GetHashCode().ToString(CultureInfo.InvariantCulture) }; if (vectorStyle.Line != null) { var lineStyle = new LineStyle(); style.Line = lineStyle; var color = vectorStyle.Line.Color; lineStyle.Color = new Color32(color.A, color.B, color.G, color.R); lineStyle.ColorMode = ColorMode.Normal; lineStyle.Width = vectorStyle.Line.Width; } var solidColor = ConvertToColor32(vectorStyle.Fill); if (solidColor != null) { var polygonStyle = new PolygonStyle(); style.Polygon = polygonStyle; polygonStyle.Fill = true; polygonStyle.Color = solidColor; } if (vectorStyle.Symbol == null) { if (vectorStyle.PointSize > 0) { var iconStyle = new IconStyle(); var pointColor = vectorStyle.PointColor != null ? ConvertToColor32(vectorStyle.PointColor) ?? new Color32(255, 0, 0, 0) : new Color32(255, 0, 0, 0); iconStyle.Color = pointColor; iconStyle.ColorMode = ColorMode.Normal; iconStyle.Icon = new IconStyle.IconLink(Pushpins.ShadedDot); iconStyle.Scale = vectorStyle.PointSize / 6; style.Icon = iconStyle; } } else { var additionalFile = SaveImagetoDisk(vectorStyle.Symbol); Debug.Assert(additionalFile != null, "additionalFile != null"); context.AdditionalFiles.Add(additionalFile); var iconStyle = new IconStyle { Icon = new IconStyle.IconLink(new Uri(context.IsKmz ? Path.GetFileName(additionalFile) : additionalFile, UriKind.Relative)), Scale = vectorStyle.SymbolScale }; style.Icon = iconStyle; } }); EventHandler endedHandler = delegate { style = null; }; return context => { if (style == null && sharpmapStyle.Enabled) { install(context); context.Exporter.Ended -= endedHandler; context.Exporter.Ended += endedHandler; } return style; }; }