public void Set(WmsClient wmsClient)
        {
            Clear();
            _wmsClient = wmsClient;
            if (null != _wmsClient)
            {
                _comboBoxImageFormat.Enabled = _comboBoxImageFormat.Items.Count > 0;
                _comboBoxImageFormat.SelectedItem = _wmsClient.MimeType;

                _comboBoxProjection.SelectedIndexChanged += new EventHandler(_comboBoxProjection_SelectedIndexChanged);

                _checkBoxTransparent.Enabled = true;
                _checkBoxTransparent.Checked = wmsClient.Transparent;

                _pictureBoxBGColor.Enabled = true;
                _pictureBoxBGColor.BackColor = _wmsClient.BGColor;

                LoadLayerList();
                LoadSrsList();

                _wmsClient.LayerAdded += new MapInfo.Wms.WmsClient.LayerAddedHandler(wmsClient_LayerAdded);
                _wmsClient.LayerRemoved += new MapInfo.Wms.WmsClient.LayerRemovedHandler(wmsClient_LayerRemoved);
                _wmsClient.LayerMovedDown += new MapInfo.Wms.WmsClient.LayerMovedDownHandler(wmsClient_LayerMovedDown);
                _wmsClient.LayerMovedUp += new MapInfo.Wms.WmsClient.LayerMovedUpHandler(wmsClient_LayerMovedUp);
                _wmsClient.ClientSrsChanged += new MapInfo.Wms.WmsClient.ClientSrsChangedHandler(wmsClient_ClientSrsChanged);
            }
        }
 private void wmsClient_LayerRemoved(WmsClient client, int layer)
 {
     CheckSrs();
     _listBoxLayers.Items.RemoveAt(layer);
     _listBoxLayers.SelectedIndex = client.HasLayers ? Math.Min(layer, _listBoxLayers.Items.Count - 1) : -1;
     _listBoxLayers.Enabled = _listBoxLayers.Items.Count > 0;
 }
        public void Clear()
        {
            _comboBoxImageFormat.Enabled = false;
            _checkBoxTransparent.Enabled = false;
            _pictureBoxBGColor.Enabled = false;

            _comboBoxProjection.Enabled = false;
            _comboBoxProjection.Items.Clear();
            _comboBoxProjection.SelectedIndexChanged -= new EventHandler(_comboBoxProjection_SelectedIndexChanged);

            _srsState.Clear();

            _listBoxLayers.SelectedIndexChanged -= new EventHandler(_listBoxLayers_SelectedIndexChanged);
            _listBoxLayers.Enabled = false;
            _listBoxLayers.Items.Clear();

            _layerState.Clear();

            if (null != _wmsClient)
            {
                _wmsClient.LayerAdded -= new MapInfo.Wms.WmsClient.LayerAddedHandler(wmsClient_LayerAdded);
                _wmsClient.LayerRemoved -= new MapInfo.Wms.WmsClient.LayerRemovedHandler(wmsClient_LayerRemoved);
                _wmsClient.LayerMovedDown -= new MapInfo.Wms.WmsClient.LayerMovedDownHandler(wmsClient_LayerMovedDown);
                _wmsClient.LayerMovedUp -= new MapInfo.Wms.WmsClient.LayerMovedUpHandler(wmsClient_LayerMovedUp);
                _wmsClient.ClientSrsChanged -= new MapInfo.Wms.WmsClient.ClientSrsChangedHandler(wmsClient_ClientSrsChanged);
            }
            _wmsClient = null;
        }
 private void wmsClient_LayerMovedDown(WmsClient client, int layer)
 {
     if (layer >= 0)
     {
         Object o = _listBoxLayers.Items[layer];
         _listBoxLayers.Items.RemoveAt(layer);
         layer += 1;
         if (layer > _listBoxLayers.Items.Count)
             _listBoxLayers.Items.Add(o);
         else
             _listBoxLayers.Items.Insert(layer, o);
         _listBoxLayers.SelectedIndex = layer;
     }
 }
 private void wmsClient_LayerMovedUp(WmsClient client, int layer)
 {
     if (layer >= 0)
     {
         Object o = _listBoxLayers.Items[layer];
         _listBoxLayers.Items.RemoveAt(layer);
         layer -= 1;
         _listBoxLayers.Items.Insert(layer, o);
         _listBoxLayers.SelectedIndex = layer;
     }
 }
 private void wmsClient_LayerAdded(WmsClient client, WmsMapLayer layer)
 {
     CheckSrs();
     _listBoxLayers.Items.Add(new WmsMapLayerWrapper(layer, _wmsClient.Capabilities));
     _listBoxLayers.SelectedIndex = client.GetLayerIndex(layer);
     _listBoxLayers.Enabled = _listBoxLayers.Items.Count > 0;
 }
 private void wmsClient_ClientSrsChanged(WmsClient client, string srs)
 {
     SetCurrentSrs(srs);
 }
 private void SwitchFeatureLayer(WmsClient wmsClient)
 {
     _mapControlWms.Map.Layers.Clear();
     if (wmsClient.HasLayers && null != _featureLayer.CoordSys)
     {
         _mapControlWms.Map.Layers.Add(_featureLayer);
         SetMapBounds(wmsClient);
     }
 }
 private void SetMapBounds(WmsClient wmsClient)
 {
     _mapControlWms.Map.Bounds = _featureLayer.Bounds;
 }
 private void wmsClient_ClientImagePropertiesChanged(WmsClient client)
 {
     if (0 == _mapControlWms.Map.Layers.Count)
     {
         SwitchFeatureLayer(client);
     }
 }