/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { IScene scene = m_scene; //get the weather layer IEnumLayer layers = scene.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while (layer != null) { if (layer is RSSWeatherLayer3DClass) { m_weatherLayer = (RSSWeatherLayer3DClass)layer; break; } layer = layers.Next(); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
public void Dispose() { if (!m_identifyDlg.IsDisposed) { m_identifyDlg.Dispose(); } m_weatherLayer = null; m_propset = null; }
public bool CanIdentify(ILayer pLayer) { if (!(pLayer is RSSWeatherLayer3DClass)) { return(false); } m_weatherLayer = (RSSWeatherLayer3DClass)pLayer; return(true);; }
/// <summary> /// Ctor /// </summary> /// <param name="weatherLayer"></param> public WeatherItemSelectionDlg(RSSWeatherLayer3DClass weatherLayer) { InitializeComponent(); //get the layer m_weatherLayer = weatherLayer; //get the list of all citynames for all items in the layer m_cityNames = m_weatherLayer.GetCityNames(); //create a table to host the citynames m_weatherItemsTable = new DataTable("CityNames"); m_weatherItemsTable.Columns.Add("CITYNAME", typeof(string)); //populate the listbox and build a table containing the items PopulateList(); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { //get the weather layer IEnumLayer layers = m_scene.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while (layer != null) { if (layer is RSSWeatherLayer3DClass) { m_weatherLayer = (RSSWeatherLayer3DClass)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 (m_scene.LayerCount == 0) { return; } //get the weather layer IEnumLayer layers = m_scene.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while (layer != null) { if (layer is RSSWeatherLayer3DClass) { m_weatherLayer = (RSSWeatherLayer3DClass)layer; break; } layer = layers.Next(); } if (m_weatherLayer != null) { if (null == m_selectionDlg || m_selectionDlg.IsDisposed) { m_selectionDlg = new WeatherItemSelectionDlg(m_weatherLayer); } m_selectionDlg.Show(); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //test whether connected to the service if (!m_bConnected) //in case not connected. { IGlobe globe = m_globeHookHelper.Globe; m_scene = globe as IScene; //create the instance of the layer if (null == m_weatherLayer) { m_weatherLayer = new RSSWeatherLayer3DClass(); } //test whether the layer has been added to the globe (allow for only one instance of the layer) bool bLayerHasBeenAdded = false; IEnumLayer layers = m_scene.get_Layers(null, false); layers.Reset(); ILayer layer = layers.Next(); while (layer != null) { if (layer is RSSWeatherLayer3DClass) { bLayerHasBeenAdded = true; break; } layer = layers.Next(); } //in case that the layer hasn't been added if (!bLayerHasBeenAdded) { layer = (ILayer)m_weatherLayer; layer.Name = "RSS Weather Layer"; try { //add the layer to the globe globe.AddLayerType(layer, esriGlobeLayerType.esriGlobeLayerTypeDraped, false); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Failed" + ex.Message); } } //connect to the RSS weather service m_weatherLayer.Connect(); } else { //disconnect from the service m_weatherLayer.Disconnect(); //delete the layer from the globe m_scene.DeleteLayer(m_weatherLayer); //dispose the layer m_weatherLayer.Dispose(); m_weatherLayer = null; } //set the connectionflag m_bConnected = !m_bConnected; }