Exemple #1
0
        private bool Login()
        {
            bool result = false;

            _login.SetLoginCredentials(txtUsername.Text, txtPassword.Text);

            if (_login.Check())
            {
                FrmGlobespotter.LoginSuccesfull();
                result = true;
            }
            else
            {
                GlobeSpotterConfiguration conf = GlobeSpotterConfiguration.Instance;

                if (conf.LoginFailed)
                {
                    txtUsername.Focus();
                }

                if (conf.LoadException)
                {
                    MessageBox.Show(string.Format("Exception occurred: {0}.", conf.Exception.Message));
                    _mssgBoxShow = true;
                }
            }

            lblLoginStatus.Text = _login.Credentials ? LoginSuccessfully : LoginFailed;
            return(result);
        }
        // =========================================================================
        // Constructor
        // =========================================================================
        public FrmMeasurement()
        {
            InitializeComponent();
            _ci = CultureInfo.InvariantCulture;
            _frmGlobespotter = null;
            SetOpenClose(false);
            _entityId          = 0;
            _pointId           = 0;
            _measurementPoint  = null;
            _imageIdColor      = new Dictionary <string, Color>();
            _bitmapImageId     = new List <string>();
            _idBitmap          = new List <Bitmap>();
            _commandItem       = null;
            _measurementPointS = null;
            _lastPointIdUpd    = null;
            _config            = Config.Instance;
            _goToClicked       = false;

            Font font = SystemFonts.MenuFont;

            lvObservations.Font       = (Font)font.Clone();
            plButtons.Font            = (Font)font.Clone();
            plMeasurementDetails.Font = (Font)font.Clone();
            txtPosition.Font          = (Font)font.Clone();
            txtPositionStd.Font       = (Font)font.Clone();
            txtNumber.Font            = (Font)font.Clone();
        }
        private void lvResults_DoubleClick(object sender, EventArgs e)
        {
            foreach (ListViewItem selectedItem in lvResults.SelectedItems)
            {
                var tag = selectedItem.Tag as object[];

                if ((tag != null) && (tag.Length >= 2) && (selectedItem.SubItems.Count >= 1))
                {
                    var         feature               = tag[0] as IFeature;
                    var         cycloMediaLayer       = tag[1] as CycloMediaLayer;
                    IActiveView activeView            = ArcUtils.ActiveView;
                    ListViewItem.ListViewSubItem item = selectedItem.SubItems[0];

                    if ((feature != null) && (cycloMediaLayer != null) && (activeView != null) && (item != null))
                    {
                        var point = feature.Shape as IPoint;

                        if (point != null)
                        {
                            string imageId = item.Text;
                            FrmGlobespotter.ShowLocation(imageId, cycloMediaLayer);
                            IEnvelope envelope = activeView.Extent;
                            envelope.CenterAt(point);
                            activeView.Extent = envelope;
                            activeView.Refresh();
                        }
                    }
                }
            }
        }
        private void OpenPoint(int entityId, int pointId, FrmGlobespotter frmGlobespotter, MeasurementPoint measurementPoint)
        {
            _frmGlobespotter = frmGlobespotter;

            if ((_entityId != entityId) || (_pointId != pointId))
            {
                UpdatePoint(_frmGlobespotter, measurementPoint, entityId, pointId, true);
                AddObservations(entityId, pointId);
            }

            _measurementPoint = measurementPoint;
            SetOpenClose(true);
        }
        private void UpdatePoint(FrmGlobespotter frmGlobespotter, MeasurementPoint point, int entityId, int pointId, bool alwaysOpen)
        {
            if (_entityId != entityId)
            {
                _lastPointIdUpd = null;
            }

            if (_lastPointIdUpd == null)
            {
                _lastPointIdUpd = pointId;
            }
            else if (pointId > _lastPointIdUpd)
            {
                _lastPointIdUpd = pointId;
            }

            if ((pointId == _lastPointIdUpd) || (_entityId != entityId) || alwaysOpen)
            {
                _frmGlobespotter = frmGlobespotter;
                bool smartClick = _config.SmartClickEnabled;

                if (!smartClick)
                {
                    AddObservations(entityId, pointId);
                }

                if ((entityId != _entityId) || _goToClicked ||
                    (((pointId != _pointId) && (!smartClick)) || ((_lastPointIdUpd > _pointId) && smartClick)))
                {
                    ClearForm(false);
                    _entityId = entityId;
                    _pointId  = pointId;
                    DrawObservations();
                }

                _measurementPoint =
                    ((double.IsNaN(point.x)) && (double.IsNaN(point.y)) && (double.IsNaN(point.z))) ? null : point;
                Measurement measurement = Measurement.Get(_entityId);
                _measurementPointS = measurement[_pointId];
                var circle = new Bitmap(18, 18);

                using (var ga = Graphics.FromImage(circle))
                {
                    ga.Clear(Color.Transparent);
                    Brush color = point.reliableEstimate
                          ? Brushes.Green
                          : ((lvObservations.Items.Count == 0) ? Brushes.Gray : Brushes.Red);
                    ga.DrawEllipse(new Pen(color, 1), 2, 2, 14, 14);
                    ga.FillEllipse(color, 2, 2, 14, 14);
                }

                txtNumber.Text = _measurementPointS.M.ToString(_ci);
                string x = (double.IsNaN(point.x)) ? "---" : point.x.ToString("#0.00", _ci);
                string y = (double.IsNaN(point.y)) ? "---" : point.y.ToString("#0.00", _ci);
                string z = (double.IsNaN(point.z)) ? "---" : point.z.ToString("#0.00", _ci);
                txtPosition.Text = string.Format(_ci, "{0}, {1}, {2}", x, y, z);
                string stdx = (double.IsNaN(point.Std_x)) ? "---" : point.Std_x.ToString("#0.00", _ci);
                string stdy = (double.IsNaN(point.Std_y)) ? "---" : point.Std_y.ToString("#0.00", _ci);
                string stdz = (double.IsNaN(point.Std_z)) ? "---" : point.Std_z.ToString("#0.00", _ci);
                txtPositionStd.Text = string.Format(_ci, "{0}, {1}, {2}", stdx, stdy, stdz);
                RelO.Image          = circle;
                SetOpenClose(_opened);
            }
        }
        // =========================================================================
        // 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();
            }
        }
 public static void UpdateMeasurementPoint(FrmGlobespotter frmGlobespotter, MeasurementPoint measurementPoint, int entityId, int pointId)
 {
     Instance.UpdatePoint(frmGlobespotter, measurementPoint, entityId, pointId, false);
 }
 public static void OpenMeasurementPoint(int entityId, int pointId, FrmGlobespotter frmGlobespotter, MeasurementPoint measurementPoint)
 {
     Instance.OpenPoint(entityId, pointId, frmGlobespotter, measurementPoint);
 }
 public static void AddObservation(Bitmap bitmap, FrmGlobespotter frmGlobespotter, int entityId, int pointId,
                                   MeasurementObservation observation)
 {
     Open();
     Instance.AddObs(bitmap, frmGlobespotter, entityId, pointId, observation);
 }
Exemple #10
0
        // =========================================================================
        // Functions (private)
        // =========================================================================
        private void ChangeDateRange()
        {
            int        yFrom       = _config.YearFrom;
            int        yTo         = _config.YearTo;
            int        mFrom       = _config.MonthFrom;
            int        mTo         = _config.MonthTo;
            int?       hyFrom      = GetElementAt(true);
            int?       hyTo        = GetElementAt(false);
            string     rangeValues = string.Empty;
            int        yearFrom    = (((hyFrom != null) && (hyFrom < yFrom)) ? (int)hyFrom : yFrom) - 1;
            int        yearTo      = (((hyTo != null) && (hyTo > yTo)) ? (int)hyTo : yTo) + 1;
            var        step        = (int)Math.Floor((double)(yearTo - yearFrom) / 16) + 1;
            bool       foundFrom   = false;
            bool       foundTo     = false;
            int        yearRange   = yearTo - yearFrom;
            Graphics   graphics    = rsRecordingSelector.CreateGraphics();
            RectangleF rectangle   = graphics.VisibleClipBounds;

            if (yearRange >= 1)
            {
                while ((!foundFrom) || (!foundTo))
                {
                    rangeValues = string.Empty;
                    var bitmap         = new Bitmap((int)rectangle.Width, 10);
                    var gapLeft        = (int)rsRecordingSelector.GapFromLeftMargin;
                    var calculateWidth = (int)(bitmap.Width - gapLeft - rsRecordingSelector.GapFromRightMargin);

                    using (var g = Graphics.FromImage(bitmap))
                    {
                        g.Clear(Color.Transparent);

                        if (lblPoints.Image != null)
                        {
                            lblPoints.Image.Dispose();
                        }

                        for (int i = yearFrom; i <= yearTo; i = i + step)
                        {
                            rangeValues = string.Format("{0}{1}{2}", rangeValues, ((i == yearFrom) ? string.Empty : ","), i);
                            foundFrom   = (i == yFrom) || foundFrom;
                            foundTo     = (i == yTo) || foundTo;

                            for (int j = i; j < (i + step); j++)
                            {
                                if ((j >= (yearFrom + 1)) && (j <= (yearTo - 1)))
                                {
                                    int?month = ((_yearMonth != null) && _yearMonth.ContainsKey(j)) ? (int?)_yearMonth[j] : null;

                                    if (month != null)
                                    {
                                        yearRange = yearTo - yearFrom;
                                        int   pos   = j - yearFrom;
                                        Color color = FrmGlobespotter.GetColor(j);
                                        int   x     = ((calculateWidth * ((12 * pos) + (int)month)) / (12 * yearRange)) + gapLeft;
                                        color = Color.FromArgb(255, color);
                                        var   pen   = new Pen(color, 1);
                                        Brush brush = new SolidBrush(color);
                                        g.DrawEllipse(pen, (x - 3), 3, 6, 6);
                                        g.FillEllipse(brush, (x - 3), 3, 6, 6);
                                    }
                                }
                            }
                        }
                    }

                    lblPoints.Image = bitmap;
                    yFrom           = foundFrom ? yFrom : (yFrom - 1);
                    yTo             = foundTo ? yTo : (yTo + 1);
                }

                rsRecordingSelector.RangeValues = rangeValues;
                string monthFrom = CalculateMonthString(mFrom);
                string monthTo   = CalculateMonthString(mTo);
                rsRecordingSelector.Range1 = yFrom.ToString(_ci) + monthFrom;
                rsRecordingSelector.Range2 = yTo.ToString(_ci) + monthTo;
            }
        }
Exemple #11
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;
        }