public Measurement(int entityId, string entityType, bool drawPoint, API api)
        {
            _detailPane = MeasurementDetail.Get();
            GlobeSpotter globeSpotter = GlobeSpotter.Current;

            _measurementList = globeSpotter.MeasurementList;

            _ci                = CultureInfo.InvariantCulture;
            _api               = api;
            _settings          = Settings.Instance;
            EntityId           = entityId;
            DrawPoint          = drawPoint;
            _updateMeasurement = false;
            SetDetailPanePoint(null);

            switch (entityType)
            {
            case "pointMeasurement":
                _geometryType = GeometryType.Point;
                break;

            case "surfaceMeasurement":
                _geometryType = GeometryType.Polygon;
                break;

            case "lineMeasurement":
                _geometryType = GeometryType.Polyline;
                break;

            default:
                _geometryType = GeometryType.Unknown;
                break;
            }
        }
        public GlobeSpotter()
        {
            InitializeComponent();
            _apiKey               = ApiKey.Instance;
            _settings             = FileSettings.Instance;
            _constants            = ConstantsViewer.Instance;
            _historicalRecordings = HistoricalRecordings.Instance;

            _login = FileLogin.Instance;
            _login.PropertyChanged += OnLoginPropertyChanged;

            _configuration = FileConfiguration.Instance;
            _configuration.PropertyChanged += OnConfigurationPropertyChanged;

            _openNearest          = new List <string>();
            _crossCheck           = null;
            _lastSpatialReference = null;
            _layers           = new List <CycloMediaLayer>();
            _startOpenNearest = false;

            GetVectorLayerListAsync();
            ModuleGlobeSpotter globeSpotterModule = ModuleGlobeSpotter.Current;

            _viewerList           = globeSpotterModule.ViewerList;
            _measurementList      = globeSpotterModule.MeasurementList;
            _cycloMediaGroupLayer = globeSpotterModule.CycloMediaGroupLayer;
            Initialize();
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string imageId = value as string;
            var    image   = new Bitmap(80, 20);

            if (parameter != null)
            {
                string strParameter = parameter.ToString();
                float  fontSize     = float.Parse(strParameter);

                ModuleGlobeSpotter globeSpotter = ModuleGlobeSpotter.Current;
                ViewerList         viewerList   = globeSpotter.ViewerList;
                Viewer             thisViewer   = viewerList.Get(imageId);
                Color color = thisViewer?.Color ?? Color.Gray;
                Brush brush = new SolidBrush(Color.FromArgb(255, color));

                using (var sf = new StringFormat())
                {
                    using (var ga = Graphics.FromImage(image))
                    {
                        ga.Clear(Color.Transparent);
                        Rectangle rectangle = new Rectangle(2, 2, 76, 16);
                        ga.DrawRectangle(new Pen(Brushes.Black, 1), rectangle);
                        ga.FillRectangle(brush, rectangle);
                        sf.Alignment = StringAlignment.Center;
                        Font font = new Font("Arial", fontSize);
                        ga.DrawString(imageId, font, Brushes.Black, rectangle, sf);
                    }
                }
            }

            return(image.ToBitmapSource());
        }
        private async void OnImageIdChanged(object sender, TextChangedEventArgs e)
        {
            TextBox           textBox           = sender as TextBox;
            string            imageId           = textBox?.Text ?? string.Empty;
            PaneImageIdSearch paneImageIdSearch = ((dynamic)DataContext);

            paneImageIdSearch.ImageInfo.Clear();

            if (imageId.Length == 8)
            {
                ModuleGlobeSpotter   globeSpotter = ModuleGlobeSpotter.Current;
                CycloMediaGroupLayer groupLayer   = globeSpotter.CycloMediaGroupLayer;

                foreach (var layer in groupLayer)
                {
                    SpatialReference spatialReference = await layer.GetSpatialReferenceAsync();

                    string            epsgCode          = $"EPSG:{spatialReference.Wkid}";
                    FeatureCollection featureCollection = FeatureCollection.Load(imageId, epsgCode);

                    if (featureCollection.NumberOfFeatures >= 1)
                    {
                        foreach (Recording recording in featureCollection.FeatureMembers.Recordings)
                        {
                            paneImageIdSearch.ImageInfo.Add(recording);
                        }
                    }
                }
            }
        }
        public bool IsObservationVisible()
        {
            GlobeSpotter    globeSpotter    = GlobeSpotter.Current;
            MeasurementList measurementList = globeSpotter.MeasurementList;

            return(globeSpotter.InsideScale() && (!_isDisposed) &&
                   ((Measurement?.IsOpen ?? false) ||
                    ((Measurement?.IsPointMeasurement ?? false) && (measurementList.Sketch == null))) &&
                   ((bool)Measurement?.DrawPoint));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string               result       = string.Empty;
            string               imageId      = value as string;
            ModuleGlobeSpotter   globeSpotter = ModuleGlobeSpotter.Current;
            CycloMediaGroupLayer groupLayer   = globeSpotter.CycloMediaGroupLayer;
            AutoResetEvent       taskWaiter   = new AutoResetEvent(false);
            const int            timeOut      = 3000;

            Task.Run(async() =>
            {
                Recording recording = await groupLayer.GetRecordingAsync(imageId);
                double stdX         = recording == null ? 0 : (recording.LongitudePrecision ?? 0);
                double stdY         = recording == null ? 0 : (recording.LatitudePrecision ?? 0);
                double stdZ         = recording == null ? 0 : (recording.HeightPrecision ?? 0);
                result = $"{stdX:0.00} {stdY:0.00} {stdZ:0.00}";
                taskWaiter.Set();
            });

            taskWaiter.WaitOne(timeOut);
            return(result);
        }
        private async void GetVectorLayerListAsync()
        {
            ModuleGlobeSpotter globeSpotterModule = ModuleGlobeSpotter.Current;

            _vectorLayerList = await globeSpotterModule.GetVectorLayerListAsync();
        }
        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);
                    }
                }
            });
        }