/// <summary> /// Create unique valueClasses based on the weather url's /// </summary> /// <param name="imagevalues"></param> /// <returns></returns> private static CIMUniqueValueClass[] CreateUniqueValueClasses(List <string> imagevalues) { List <CIMUniqueValueClass> cimclasses = new List <CIMUniqueValueClass>(); foreach (string imageUrl in imagevalues) { CIMPictureMarker marker = new CIMPictureMarker() { Size = 30, URL = BuildPictureMarkerURL(new Uri(imageUrl)) }; CIMUniqueValue uniqueValue = new CIMUniqueValue { FieldValues = new string[] { imageUrl } }; CIMUniqueValueClass uniqueValueClass = new CIMUniqueValueClass { Symbol = SymbolFactory.Instance.ConstructPointSymbol(marker).MakeSymbolReference(), Values = new CIMUniqueValue[] { uniqueValue } }; cimclasses.Add(uniqueValueClass); } return(cimclasses.ToArray()); }
public async Task RedrawPointAsync() { await QueuedTask.Run(() => { GlobeSpotter globeSpotter = GlobeSpotter.Current; MeasurementList measurementList = globeSpotter.MeasurementList; _disposeText?.Dispose(); if ((globeSpotter.InsideScale() && (!_isDisposed) && (Point != null) && ((Measurement?.IsOpen ?? false) || ((Measurement?.IsPointMeasurement ?? false) && (measurementList.Sketch == null))) && (Measurement?.DrawPoint ?? false) && (!double.IsNaN(Point.X)) && (!double.IsNaN(Point.Y)))) { MapView thisView = MapView.Active; Point winPoint = thisView.MapToScreen(Point); float fontSize = _constants.MeasurementFontSize; int fontSizeT = (int)(fontSize * 2); int fontSizeR = (int)((fontSize * 3) / 2); int fontSizeK = (int)(fontSize / 4); int txt = (Measurement?.IsOpen ?? true) ? Index : measurementList.GetMeasurementNumber(Measurement); string text = txt.ToString(_ci); int characters = text.Length; Bitmap bitmap = new Bitmap((fontSizeT *characters), fontSizeT); double pointSize = _constants.MeasurementPointSize; double pointSizePoint = (pointSize * 6) / 4; Point winPointText = new Point { X = (winPoint.X + pointSizePoint), Y = (winPoint.Y - pointSizePoint) }; MapPoint pointText = thisView.ScreenToMap(winPointText); using (var sf = new StringFormat()) { using (Graphics g = Graphics.FromImage(bitmap)) { g.Clear(Color.Transparent); Font font = new Font("Arial", fontSize); sf.Alignment = StringAlignment.Center; Rectangle rectangle = new Rectangle(fontSizeK, fontSizeK, (fontSizeR *characters), fontSizeR); g.DrawString(text, font, Brushes.Black, rectangle, sf); } } BitmapSource source = bitmap.ToBitmapSource(); var frame = BitmapFrame.Create(source); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(frame); using (MemoryStream stream = new MemoryStream()) { encoder.Save(stream); byte[] imageBytes = stream.ToArray(); string base64String = Convert.ToBase64String(imageBytes); string url = $"data:image/bmp;base64,{base64String}"; CIMPictureMarker marker = new CIMPictureMarker { URL = url, Enable = true, ScaleX = 1, Size = fontSizeR }; CIMPointSymbol symbol = SymbolFactory.Instance.ConstructPointSymbol(marker); CIMSymbolReference symbolReference = symbol.MakeSymbolReference(); _disposeText = thisView.AddOverlay(pointText, symbolReference); } } }); }