Пример #1
0
        void okClicked(object param)
        {
            string proxy = param as string;

            if (proxy != SecureServicesHelper.GetProxyUrl())
            {
                SecureServicesHelper.SetProxyUrl(proxy);
            }
        }
Пример #2
0
 public SecureServicesConfigViewModel()
 {
     if (View.Instance != null)
     {
         View.Instance.ProxyUrlChanged += Instance_ProxyUrlChanged;
     }
     Proxy     = SecureServicesHelper.GetProxyUrl();
     OKCommand = new DelegateCommand(okClicked);
 }
        static void OnProxyUseChange(DependencyObject o, DependencyPropertyChangedEventArgs args)
        {
            SecureServicesLayerConfigViewModel vm = o as SecureServicesLayerConfigViewModel;

            ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetUsesProxy(vm.layer, vm.UsesProxy);
            if (vm.UsesProxy)
            {
                if (vm.layer != null && ViewerApplicationControl.Instance != null && ViewerApplicationControl.Instance.ViewerApplication != null)
                {
                    SecureServicesHelper.SetProxyUrl(vm.layer, SecureServicesHelper.GetProxyUrl());
                }
            }
            else
            {
                SecureServicesHelper.SetProxyUrl(vm.layer, null);
            }
        }
 void Current_SelectedLayerChanged(object sender, EventArgs e)
 {
     layer = MapApplication.Current.SelectedLayer;
     if (layer != null)
     {
         if (SecureServicesHelper.SupportsProxyUrl(layer))
         {
             this.IsEnabled = true;
             this.UsesProxy = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsesProxy(layer);
         }
         else
         {
             this.IsEnabled = false;
             this.UsesProxy = false;
         }
     }
 }
        public static void UpdateProxyUrl(string proxyUrl)
        {
            Map map = (MapApplication.Current != null) ? MapApplication.Current.Map : null;

            if (map == null)
            {
                return;
            }

            bool mapRequiresRefresh = false;

            #region Check if layers can be updated in-place
            List <Layer> layersForRefresh = new List <Layer>();
            foreach (Layer layer in map.Layers)
            {
                if (ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsesProxy(layer))
                {
                    if (ProxyUrlHelper.CanChangeProxyUrl(layer))
                    {
                        layersForRefresh.Add(layer);
                    }
                    else
                    {
                        mapRequiresRefresh = true;
                        break;
                    }
                }
            }
            #endregion
            #region Set proxy url if layers can be updated
            if (!mapRequiresRefresh)
            {
                foreach (Layer layer in layersForRefresh)
                {
                    SecureServicesHelper.SetProxyUrl(layer, proxyUrl);
                }
            }
            #endregion
            #region Else, serialize/deserialize map, remove and re-add layers
            else
            {
                MapXamlWriter writer = new MapXamlWriter(true);
                try
                {
                    string mapXaml = writer.MapToXaml(map);

                    if (!string.IsNullOrEmpty(mapXaml))
                    {
                        Map newMap = System.Windows.Markup.XamlReader.Load(mapXaml) as Map;
                        if (newMap != null && newMap.Layers.Count == map.Layers.Count)
                        {
                            map.Layers.Clear();
                            map.Extent = newMap.Extent;
                            List <Layer> layers = new List <Layer>();
                            foreach (Layer layer in newMap.Layers)
                            {
                                if (ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsesProxy(layer))
                                {
                                    SecureServicesHelper.SetProxyUrl(layer, proxyUrl);
                                }
                                layers.Add(layer);
                            }
                            newMap.Layers.Clear();
                            foreach (Layer layer in layers)
                            {
                                map.Layers.Add(layer);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogError(ex);
                    MessageBoxDialog.Show(ESRI.ArcGIS.Mapping.Controls.Resources.Strings.ErrorChangingProxies);
                }
            }
            #endregion
        }
Пример #6
0
 void Instance_ProxyUrlChanged(object sender, System.EventArgs e)
 {
     Proxy = SecureServicesHelper.GetProxyUrl();
 }