/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (0 == m_hookHelper.FocusMap.LayerCount) { return; } //get the weather layer IEnumLayer layers = m_hookHelper.FocusMap.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while (layer != null) { if (layer is RSSWeatherLayerClass) { m_weatherLayer = (RSSWeatherLayerClass)layer; break; } layer = layers.Next(); } //in case that the layer exists if (null != m_weatherLayer) { //launch the zipCode input dialog ZipCodeDlg dlg = new ZipCodeDlg(); if (DialogResult.OK == dlg.ShowDialog()) { long zipCode = dlg.ZipCode; if (0 != zipCode) { //add the weather item to the layer m_weatherLayer.AddItem(zipCode); //if the user checked the 'ZoomTo' checkbox, zoom to the item if (dlg.ZoomToItem) { m_weatherLayer.ZoomTo(zipCode); } } } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (0 == m_hookHelper.FocusMap.LayerCount) return; //get the weather layer IEnumLayer layers = m_hookHelper.FocusMap.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while(layer != null) { if(layer is RSSWeatherLayerClass) { m_weatherLayer = (RSSWeatherLayerClass)layer; break; } layer = layers.Next(); } //in case that the layer exists if(null != m_weatherLayer) { //launch the zipCode input dialog ZipCodeDlg dlg = new ZipCodeDlg(); if(DialogResult.OK == dlg.ShowDialog()) { long zipCode = dlg.ZipCode; if(0 != zipCode) { //add the weather item to the layer m_weatherLayer.AddItem(zipCode); //if the user checked the 'ZoomTo' checkbox, zoom to the item if(dlg.ZoomToItem) { m_weatherLayer.ZoomTo(zipCode); } } } } } catch(Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }