Пример #1
0
 public void RemoveLayers()
 {
     if (CycloMediaGroupLayer != null)
     {
         GsShowInCyclorama.RemoveFromMenu();
         FrmCycloMediaOptions.CloseForm();
         FrmMeasurement.Close();
         FrmIdentify.Close();
         CycloMediaGroupLayer cycloLayer = CycloMediaGroupLayer;
         CycloMediaGroupLayer = null;
         cycloLayer.Dispose();
         FrmGlobespotter.ShutDown(true);
     }
 }
Пример #2
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;
        }