/// <summary> /// class constructor /// </summary> /// <param name="weatherLayer"></param> public WeatherItemSelectionDlg(RSSWeatherLayerClass weatherLayer, IActiveView activeView) { InitializeComponent(); //get the layer m_weatherLayer = weatherLayer; m_activeView = activeView; //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 { 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(m_pHookHelper.FocusMap.LayerCount == 0) return; //get the weather layer IEnumLayer layers = m_pHookHelper.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(); } if(m_weatherLayer != null) { if(null == m_selectionDlg || m_selectionDlg.IsDisposed) { m_selectionDlg = new WeatherItemSelectionDlg(m_weatherLayer, m_pHookHelper.ActiveView); } m_selectionDlg.Show(); } } 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; }
/// <summary> /// Indicates if the object can identify the specified layer /// </summary> /// <param name="pLayer"></param> /// <returns></returns> public bool CanIdentify(ILayer pLayer) { if(!(pLayer is RSSWeatherLayerClass)) return false; //cache the layer m_weatherLayer = (RSSWeatherLayerClass)pLayer; return true;; }
/// <summary> /// Listen to ActiveViewEvents.ItemDeleted in order to track whether the layer has been /// removed from the TOC /// </summary> /// <param name="Item"></param> void OnItemDeleted(object Item) { //test that the deleted layer is RSSWeatherLayerClass if (Item is RSSWeatherLayerClass) { if (m_bConnected && null != m_weatherLayer) { m_bConnected = false; //disconnect from the service m_weatherLayer.Disconnect(); //dispose the layer m_weatherLayer = null; m_bOnce = true; } } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if(!m_bConnected) { //check first that the layer was added to the globe if(m_bOnce == true) { //instantiate the layer m_weatherLayer = new RSSWeatherLayerClass(); m_invokeHelper = new InvokeHelper(m_pHookHelper.ActiveView, m_weatherLayer); m_bOnce = false; } //test whether the layer has been added to the map bool bLayerHasBeenAdded = false; ILayer layer = null; if(m_pHookHelper.FocusMap.LayerCount != 0) { IEnumLayer layers = m_pHookHelper.FocusMap.get_Layers(null, false); layers.Reset(); layer = layers.Next(); while(layer != null) { if(layer is RSSWeatherLayerClass) { bLayerHasBeenAdded = true; break; } layer = layers.Next(); } } //add the layer to the map if(!bLayerHasBeenAdded) { layer = (ILayer)m_weatherLayer; layer.Name = "RSS Weather Layer"; try { m_pHookHelper.FocusMap.AddLayer(layer); //wires layer's events m_weatherLayer.OnWeatherItemAdded += new WeatherItemAdded(OnWeatherItemAdded); m_weatherLayer.OnWeatherItemsUpdated += new WeatherItemsUpdated(OnWeatherItemsUpdated); } catch(Exception ex) { System.Diagnostics.Trace.WriteLine("Failed" + ex.Message); } } //connect to the service m_weatherLayer.Connect(); } else { //disconnect from the service m_weatherLayer.Disconnect(); //un-wires layer's events m_weatherLayer.OnWeatherItemAdded -= new WeatherItemAdded(OnWeatherItemAdded); m_weatherLayer.OnWeatherItemsUpdated -= new WeatherItemsUpdated(OnWeatherItemsUpdated); //delete the layer m_pHookHelper.FocusMap.DeleteLayer(m_weatherLayer); //dispose the layer m_weatherLayer = null; m_bOnce = true; } m_bConnected = !m_bConnected; } catch(Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
public InvokeHelper (IActiveView activeView, RSSWeatherLayerClass weatherLayer) { m_activeView = activeView; m_weatherLayer = weatherLayer; CreateHandle(); CreateControl(); m_invalidateExtent = new EnvelopeClass(); m_invalidateExtent.SpatialReference = activeView.ScreenDisplay.DisplayTransformation.SpatialReference; m_point = new PointClass(); m_point.SpatialReference = activeView.ScreenDisplay.DisplayTransformation.SpatialReference; }
/// <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(); } } catch(Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }