private static void AvItemAdded(object item)
        {
            try
            {
                if (item != null)
                {
                    var featureLayer = item as IFeatureLayer;
                    var extension    = GsExtension.GetExtension();

                    if ((featureLayer != null) && (extension != null))
                    {
                        CycloMediaGroupLayer cycloGrouplayer = extension.CycloMediaGroupLayer;

                        if (cycloGrouplayer != null)
                        {
                            if (!cycloGrouplayer.IsKnownName(featureLayer.Name))
                            {
                                var dataset = item as IDataset;

                                if (dataset != null)
                                {
                                    var featureWorkspace = dataset.Workspace as IFeatureWorkspace;

                                    if (featureWorkspace != null)
                                    {
                                        var featureClass = featureLayer.FeatureClass;

                                        var vectorLayer = new VectorLayer
                                        {
                                            _featureClass           = featureClass,
                                            _layer                  = featureLayer,
                                            IsVisibleInGlobespotter = StoredLayers.Instance.Get(featureLayer.Name)
                                        };

                                        _layers.Add(vectorLayer);

                                        if (LayerAddEvent != null)
                                        {
                                            LayerAddEvent(vectorLayer);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "VectorLayer.AvItemAdded");
            }
        }
        public void Redraw()
        {
            GsExtension extension = GsExtension.GetExtension();

            if (extension.InsideScale())
            {
                if (_updateTimer == null)
                {
                    StartRedraw();
                }
                else
                {
                    _toUpdateArrow = true;
                }
            }
        }
        private void backgroundImageSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {
                var featureMemberElements = e.Result as List <XElement>;

                if (featureMemberElements != null)
                {
                    string                  imageId    = txtImageId.Text;
                    GsExtension             extension  = GsExtension.GetExtension();
                    CycloMediaGroupLayer    groupLayer = extension.CycloMediaGroupLayer;
                    IList <CycloMediaLayer> layers     = groupLayer.Layers;

                    foreach (var layer in layers)
                    {
                        if (layer.IsVisible)
                        {
                            layer.SaveFeatureMembers(featureMemberElements, null);
                            IMappedFeature mappedFeature = layer.GetLocationInfo(imageId);
                            var            recording     = mappedFeature as Recording;

                            if (recording != null)
                            {
                                DateTime?   recordedAt       = recording.RecordedAt;
                                CultureInfo ci               = CultureInfo.InvariantCulture;
                                string      recordedAtString = (recordedAt == null) ? string.Empty : ((DateTime)recordedAt).ToString(ci);
                                string      imageIdString    = recording.ImageId;
                                IFeature    feature          = layer.GetFeature(imageId);
                                var         items            = new[] { imageIdString, recordedAtString };
                                var         listViewItem     = new ListViewItem(items)
                                {
                                    Tag = new object[] { feature, layer }
                                };
                                lvResults.Items.Add(listViewItem);
                            }
                        }
                    }
                }
            }

            btnFind.Enabled     = true;
            btnCancel.Enabled   = true;
            prSearching.Visible = false;
            txtImageId.Enabled  = true;
        }
Esempio n. 4
0
        public void Update()
        {
            GsExtension extension  = GsExtension.GetExtension();
            IActiveView activeView = ArcUtils.ActiveView;

            if (extension.InsideScale() && (activeView != null))
            {
                var screenDisplay = activeView.ScreenDisplay;

                if (_oldEnvelope != null)
                {
                    screenDisplay.Invalidate(_oldEnvelope, true, (short)esriScreenCache.esriNoScreenCache);
                }

                if (_envelope != null)
                {
                    screenDisplay.Invalidate(_envelope, true, (short)esriScreenCache.esriNoScreenCache);
                }
            }
        }
        private void backgroundImageSearch_DoWork(object sender, DoWorkEventArgs e)
        {
            Web                     web        = Web.Instance;
            string                  imageId    = txtImageId.Text;
            GsExtension             extension  = GsExtension.GetExtension();
            CycloMediaGroupLayer    groupLayer = extension.CycloMediaGroupLayer;
            IList <CycloMediaLayer> layers     = groupLayer.Layers;

            foreach (var layer in layers)
            {
                try
                {
                    List <XElement> featureMemberElements = web.GetByImageId(imageId, layer);
                    e.Result = featureMemberElements;
                }
                catch (Exception)
                {
                    e.Cancel = true;
                }
            }
        }
        // =========================================================================
        // Functions (Static)
        // =========================================================================
        public static IList <WfsLayer> GetCapabilities(string url, string version)
        {
            if (url.Substring(url.Length - 1) == "?")
            {
                url = url.Substring(0, url.Length - 1);
            }

            Web                  web                  = Web.Instance;
            List <XElement>      elements             = web.GetCapabilities(url, version);
            GsExtension          extension            = GsExtension.GetExtension();
            CycloMediaGroupLayer cycloMediaGroupLayer = (extension == null) ? null : extension.CycloMediaGroupLayer;

            return((from element in elements
                    from featureType in element.Descendants(FeatureType.TypeName)
                    where featureType != null
                    select new WfsLayer(cycloMediaGroupLayer)
            {
                Url = url,
                Version = version,
                FeatureType = new FeatureType(featureType)
            }).ToList());
        }
        // =========================================================================
        // Private Functions
        // =========================================================================
        private void AddObs(Bitmap bitmap, FrmGlobespotter frmGlobespotter, int entityId, int pointId,
                            MeasurementObservation observation)
        {
            if (_entityId != entityId)
            {
                _lastPointIdUpd = null;
            }

            string               imageId      = observation.imageId;
            GsExtension          extension    = GsExtension.GetExtension();
            CycloMediaGroupLayer groupLayer   = extension.CycloMediaGroupLayer;
            IMappedFeature       locationInfo = groupLayer.GetLocationInfo(imageId);
            var    recordingInfo = locationInfo as Recording;
            double stdX          = (recordingInfo == null) ? 0 : (recordingInfo.LongitudePrecision ?? 0);
            double stdY          = (recordingInfo == null) ? 0 : (recordingInfo.LatitudePrecision ?? 0);
            double stdZ          = (recordingInfo == null) ? 0 : (recordingInfo.HeightPrecision ?? 0);
            string std           = string.Format("{0:0.00} {1:0.00} {2:0.00}", stdX, stdY, stdZ);

            if ((_entityId != entityId) || (_pointId != pointId))
            {
                ClearForm(false);
                _entityId           = entityId;
                _pointId            = pointId;
                _measurementPoint   = null;
                _measurementPointS  = null;
                txtNumber.Text      = string.Empty;
                txtPosition.Text    = string.Empty;
                txtPositionStd.Text = string.Empty;
                RelO.Image          = null;
                SetOpenClose(false);
            }

            Measurement measurement = Measurement.Get(_entityId);

            if (measurement != null)
            {
                _measurementPointS = measurement[_pointId];
                _measurementPointS.UpdateObservation(imageId, observation.x, observation.y, observation.z);
                txtNumber.Text = _measurementPointS.M.ToString(_ci);

                if (measurement.IsPointMeasurement)
                {
                    SetOpenClose(true);

                    if (_commandItem == null)
                    {
                        _commandItem = ArcMap.Application.CurrentTool;
                        ArcUtils.SetToolActiveInToolBar("esriEditor.EditTool");
                    }
                }
            }

            if (bitmap != null)
            {
                _bitmapImageId.Add(imageId);
                _idBitmap.Add(bitmap);
            }

            bool add = true;

            foreach (ListViewItem item in lvObservations.Items)
            {
                var obs = item.Tag as MeasurementObservation;

                if (obs != null)
                {
                    if (obs.imageId == imageId)
                    {
                        add = false;
                    }
                }
            }

            if (add)
            {
                _frmGlobespotter = frmGlobespotter;
                var items        = new[] { imageId, std, "X" };
                var listViewItem = new ListViewItem(items)
                {
                    Tag = observation
                };
                lvObservations.Items.Add(listViewItem);
                DrawObservations();
                RedrawObservationList();
            }
        }
Esempio n. 8
0
        // =========================================================================
        // Event handlers
        // =========================================================================
        private void AvEventsAfterDraw(IDisplay display, esriViewDrawPhase phase)
        {
            try
            {
                if ((_measurement != null) && (_point != null))
                {
                    if ((phase == esriViewDrawPhase.esriViewForeground) && _measurement.IsOpen && _measurement.DrawPoint &&
                        (!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                    {
                        GsExtension extension = GsExtension.GetExtension();

                        if (extension.InsideScale())
                        {
                            // ReSharper disable UseIndexedProperty
                            // ReSharper disable CSharpWarnings::CS0612
                            display.StartDrawing(display.hDC, (short)esriScreenCache.esriNoScreenCache);
                            IDisplayTransformation dispTrans = display.DisplayTransformation;
                            double distance = dispTrans.FromPoints(PointSize);

                            var fontDisp = new StdFontClass
                            {
                                Bold      = false,
                                Name      = "Arial",
                                Italic    = false,
                                Underline = false,
                                Size      = (decimal)FontSize
                            };

                            ISymbol textSymbol = new TextSymbolClass {
                                Font = fontDisp as IFontDisp
                            };
                            display.SetSymbol(textSymbol);

                            double distanceP = (distance * 3) / 4;
                            IPoint pointText = new PointClass {
                                X = _point.X + distanceP, Y = _point.Y + distanceP
                            };
                            CultureInfo ci   = CultureInfo.InvariantCulture;
                            string      text = _index.ToString(ci);
                            display.DrawText(pointText, text);

                            foreach (var observation in _observations)
                            {
                                double[] obs = observation.Value;

                                if (obs.Length >= 2)
                                {
                                    double xdir    = (_point.X - obs[0]) / 2;
                                    double ydir    = (_point.Y - obs[1]) / 2;
                                    string imageId = observation.Key;

                                    IColor  color      = Converter.ToRGBColor(ObsColor.ContainsKey(imageId) ? ObsColor[imageId] : Color.DarkGray);
                                    ISymbol lineSymbol = new SimpleLineSymbolClass {
                                        Color = color, Width = 1.25
                                    };
                                    display.SetSymbol(lineSymbol);

                                    var polylineClass3 = new PolylineClass();
                                    polylineClass3.AddPoint(new PointClass {
                                        X = _point.X + xdir, Y = _point.Y + ydir
                                    });
                                    polylineClass3.AddPoint(new PointClass {
                                        X = obs[0], Y = obs[1]
                                    });
                                    display.DrawPolyline(polylineClass3);

                                    color      = Converter.ToRGBColor(Color.LightGray);
                                    lineSymbol = new SimpleLineSymbolClass {
                                        Color = color, Width = 0.75
                                    };
                                    display.SetSymbol(lineSymbol);
                                    display.DrawPolyline(polylineClass3);
                                }
                            }

                            display.FinishDrawing();
                            // ReSharper restore CSharpWarnings::CS0612
                            // ReSharper restore UseIndexedProperty
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "MeasurementPoint.avEventsAfterDraw");
            }
        }
Esempio n. 9
0
        private void Save(bool close)
        {
            // determinate smart click permissions
            bool usernameChanged = (txtUsername.Text != _login.Username) || (txtPassword.Text != _login.Password);

            // determinate restart
            bool baseUrlChanged = (txtBaseUrlLocation.Text != _config.BaseUrl) ||
                                  (ckDefaultBaseUrl.Checked != _config.BaseUrlDefault);
            bool recordingServiceChanged = (txtRecordingServiceLocation.Text != _config.RecordingsService) ||
                                           (ckDefaultRecordingService.Checked != _config.RecordingsServiceDefault);
            bool swfChanged = (_config.SwfUrlDefault != ckDefaultSwfUrl.Checked) || (_config.SwfUrl != txtSwfUrlLocation.Text);
            bool cycloramaVectorLayerLocationChanged = (_config.CycloramaVectorLayerLocationDefault !=
                                                        ckDefaultCycloramaVectorLayerLocation.Checked) ||
                                                       (_config.CycloramaVectorLayerLocation !=
                                                        txtCycloramaVectorLayerLocation.Text);
            SpatialReference spat = _config.SpatialReference;
            var  selectedItem     = (SpatialReference)cbSpatialReferences.SelectedItem;
            bool spatChanged      = (spat == null) || ((selectedItem != null) && (spat.ToString() != selectedItem.ToString()));
            bool restart          = usernameChanged || baseUrlChanged || swfChanged || spatChanged || recordingServiceChanged;

            // Save values
            int  proxyPort;
            bool proxyParsed       = int.TryParse(txtProxyPort.Text, out proxyPort);
            int  useProxyPort      = proxyParsed ? proxyPort : 80;
            var  maxViewers        = (uint)nudMaxViewers.Value;
            var  distLayer         = (uint)nudDistVectLayerViewer.Value;
            bool smartClickEnabled = GlobeSpotterConfiguration.MeasureSmartClick && (!usernameChanged)
        ? ckEnableSmartClick.Checked
        : _config.SmartClickEnabled;

            bool proxyChanged = (ckUseProxyServer.Checked != _config.UseProxyServer);

            proxyChanged = proxyChanged || (_config.ProxyAddress != txtProxyAddress.Text);
            proxyChanged = proxyChanged || (_config.ProxyPort != useProxyPort);
            proxyChanged = proxyChanged || (_config.BypassProxyOnLocal != ckBypassProxyOnLocal.Checked);
            proxyChanged = proxyChanged || (_config.ProxyUseDefaultCredentials != ckUseDefaultProxyCredentials.Checked);
            proxyChanged = proxyChanged || (_config.ProxyUsername != txtProxyUsername.Text);
            proxyChanged = proxyChanged || (_config.ProxyPassword != txtProxyPassword.Text);
            proxyChanged = proxyChanged || (_config.ProxyDomain != txtProxyDomain.Text);

            _config.SpatialReference             = selectedItem ?? _config.SpatialReference;
            _config.MaxViewers                   = maxViewers;
            _config.DistanceCycloramaVectorLayer = distLayer;
            _config.BaseUrl                             = txtBaseUrlLocation.Text;
            _config.RecordingsService                   = txtRecordingServiceLocation.Text;
            _config.SwfUrl                              = txtSwfUrlLocation.Text;
            _config.CycloramaVectorLayerLocation        = txtCycloramaVectorLayerLocation.Text;
            _config.BaseUrlDefault                      = ckDefaultBaseUrl.Checked;
            _config.RecordingsServiceDefault            = ckDefaultRecordingService.Checked;
            _config.SwfUrlDefault                       = ckDefaultSwfUrl.Checked;
            _config.CycloramaVectorLayerLocationDefault = ckDefaultCycloramaVectorLayerLocation.Checked;
            _config.SmartClickEnabled                   = smartClickEnabled;
            _config.DetailImagesEnabled                 = ckDetailImages.Checked;
            _config.UseProxyServer                      = ckUseProxyServer.Checked;
            _config.ProxyAddress                        = txtProxyAddress.Text;
            _config.ProxyPort                           = useProxyPort;
            _config.BypassProxyOnLocal                  = ckBypassProxyOnLocal.Checked;
            _config.ProxyUseDefaultCredentials          = ckUseDefaultProxyCredentials.Checked;
            _config.ProxyUsername                       = txtProxyUsername.Text;
            _config.ProxyPassword                       = txtProxyPassword.Text;
            _config.ProxyDomain                         = txtProxyDomain.Text;
            _config.Save();

            // Check restart GlobeSpotter
            bool loginSucces = (usernameChanged || baseUrlChanged || proxyChanged) && Login();

            if (proxyChanged)
            {
                ckEnableSmartClick.Checked = (GlobeSpotterConfiguration.MeasureSmartClick && _config.SmartClickEnabled);
                ckEnableSmartClick.Enabled = GlobeSpotterConfiguration.MeasureSmartClick;
            }

            if (_login.Credentials || loginSucces)
            {
                if (restart && FrmGlobespotter.IsStarted())
                {
                    FrmGlobespotter.Restart();
                }
                else
                {
                    FrmGlobespotter.UpdateParameters();
                }
            }

            // Close form
            if (close)
            {
                Close();
            }

            // Check if the layer has to make empty
            if (usernameChanged || cycloramaVectorLayerLocationChanged)
            {
                GsExtension          extension  = GsExtension.GetExtension();
                CycloMediaGroupLayer groupLayer = extension.CycloMediaGroupLayer;

                if (groupLayer != null)
                {
                    if (usernameChanged)
                    {
                        groupLayer.MakeEmpty();
                    }

                    if (cycloramaVectorLayerLocationChanged)
                    {
                        var layers = groupLayer.Layers;
                        groupLayer.Dispose();

                        foreach (var layer in layers)
                        {
                            extension.AddLayers(layer.Name);
                        }
                    }
                }
            }

            btnApply.Enabled = false;
        }
        private void AvEventsAfterDraw(IDisplay display, esriViewDrawPhase phase)
        {
            try
            {
                if (phase == esriViewDrawPhase.esriViewForeground)
                {
                    GsExtension extension = GsExtension.GetExtension();

                    if ((extension.InsideScale()) && (!_point.IsEmpty))
                    {
                        // ReSharper disable UseIndexedProperty
                        // ReSharper disable CSharpWarnings::CS0612
                        display.StartDrawing(display.hDC, (short)esriScreenCache.esriNoScreenCache);

                        IDisplayTransformation dispTrans  = display.DisplayTransformation;
                        const float            arrowSizeh = ((float)ArrowSize) / 2;
                        double size = dispTrans.FromPoints(arrowSizeh);

                        double angleh = (_hFov * Math.PI) / 360;
                        double angle  = (((450 - _angle) % 360) * Math.PI) / 180;
                        double angle1 = angle - angleh;
                        double angle2 = angle + angleh;
                        double x      = _point.X;
                        double y      = _point.Y;

                        IPoint point1 = new PointClass {
                            X = x, Y = y
                        };
                        IPoint point2 = new PointClass {
                            X = x + (size * Math.Cos(angle1)), Y = y + (size * Math.Sin(angle1))
                        };
                        IPoint point3 = new PointClass {
                            X = x + (size * Math.Cos(angle2)), Y = y + (size * Math.Sin(angle2))
                        };

                        IPolygon4 polygon      = new PolygonClass();
                        var       polygonPoint = polygon as IPointCollection4;
                        polygonPoint.AddPoint(point1);
                        polygonPoint.AddPoint(point2);
                        polygonPoint.AddPoint(point3);
                        polygonPoint.AddPoint(point1);

                        IColor color = Converter.ToRGBColor(_color);
                        color.Transparency        = _blinking ? BlinkAlpha : NormalAlpha;
                        color.UseWindowsDithering = true;
                        var fillSymbol = new SimpleFillSymbolClass {
                            Color = color, Outline = null
                        };
                        display.SetSymbol(fillSymbol);
                        display.DrawPolygon(polygon);

                        IPolyline polyline      = new PolylineClass();
                        var       polylinePoint = polyline as IPointCollection4;
                        polylinePoint.AddPoint(point2);
                        polylinePoint.AddPoint(point1);
                        polylinePoint.AddPoint(point3);

                        var outlineSymbol = new SimpleLineSymbolClass
                        {
                            Color = Converter.ToRGBColor(_active ? Color.Yellow : Color.Gray),
                            Width = _blinking ? BorderSizeBlinkingArrow : BorderSizeArrow
                        };

                        display.SetSymbol(outlineSymbol);
                        display.DrawPolyline(polyline);
                        display.FinishDrawing();

                        if (_blinking)
                        {
                            var blinkEvent         = new AutoResetEvent(true);
                            var blinkTimerCallBack = new TimerCallback(ResetBlinking);
                            _blinkTimer = new Timer(blinkTimerCallBack, blinkEvent, BlinkTime, -1);
                        }

                        // ReSharper restore CSharpWarnings::CS0612
                        // ReSharper restore UseIndexedProperty
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "Arrow.avEventsAfterDraw");
            }
        }