/// <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);
            }
        }
Пример #2
0
        public void Dispose()
        {
            if (!m_identifyDlg.IsDisposed)
            {
                m_identifyDlg.Dispose();
            }

            m_weatherLayer = null;
            m_propset      = null;
        }
Пример #3
0
        /// <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);;
        }
Пример #4
0
        protected override void OnPageApply()
        {
            base.OnPageApply();

            PropertySheet propSheet = Objects[0] as PropertySheet;

            RSSWeatherLayerClass layer = propSheet.RSSWatherLayer;

            if (null == layer)
            {
                return;
            }
        }
            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();
                }

                //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);
            }
        }
        protected override void OnPageActivate(IntPtr hWndParent, Rectangle Rect, bool bModal)
        {
            base.OnPageActivate(hWndParent, Rect, bModal);

            PropertySheet propSheet = Objects[0] as PropertySheet;

            RSSWeatherLayerClass layer = propSheet.RSSWatherLayer;

            if (null == layer)
            {
                return;
            }

            txtSymbolSize.Text = layer.SymbolSize.ToString();

            m_symbolSize = layer.SymbolSize;
        }
        /// <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;
                }
            }
        }
Пример #9
0
        /// <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();
        }
Пример #10
0
        protected override void OnPageActivate(IntPtr hWndParent, Rectangle Rect, bool bModal)
        {
            base.OnPageActivate(hWndParent, Rect, bModal);

            PropertySheet propSheet = Objects[0] as PropertySheet;

            RSSWeatherLayerClass layer = propSheet.RSSWatherLayer;

            if (null == layer)
            {
                return;
            }

            //get the cityNames from the layer
            string[] cityNames = layer.GetCityNames();

            //clear the listbox
            listBoxCityNames.Items.Clear();
            listBoxCityNames.Items.AddRange(cityNames);
        }
        protected override void OnPageApply()
        {
            base.OnPageApply();

            PropertySheet propSheet = Objects[0] as PropertySheet;

            RSSWeatherLayerClass layer = propSheet.RSSWatherLayer;

            if (null == layer)
            {
                return;
            }

            int symbolSize;

            int.TryParse(txtSymbolSize.Text, out symbolSize);
            if (0 != symbolSize && m_symbolSize != symbolSize)
            {
                layer.SymbolSize = symbolSize;
            }
        }
        /// <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);
            }
        }
        /// <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);
            }
        }
Пример #14
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                //search for the weatherLayer first
                ILayer layer = null;
                RSSWeatherLayerClass RSSLayer = null;

                if (m_pHookHelper.FocusMap.LayerCount == 0)
                {
                    return;
                }

                IEnumLayer layers = m_pHookHelper.FocusMap.get_Layers(null, false);
                layers.Reset();
                layer = layers.Next();
                while (layer != null)
                {
                    if (layer is RSSWeatherLayerClass)
                    {
                        RSSLayer = (RSSWeatherLayerClass)layer;
                        break;
                    }
                    layer = layers.Next();
                }

                //In case that the weather layer wasn't found,just return
                if (null == RSSLayer)
                {
                    return;
                }


                //Launch the layer's properties
                Type   typ;
                object obj;
                Guid[] g;

                // METHOD 1: Instantiating a COM object and displaying its property pages
                // ONLY WORKS ON TRUE COM OBJECTS!  .NET objects that have rolled their own
                // ISpecifyPropertyPages implementation will error out when you try to cast
                // the instantiated object to your own ISpecifyPropertyPages implementation.

                // Get the typeinfo for the ActiveX common dialog control
                typ = Type.GetTypeFromProgID("MSComDlg.CommonDialog");

                // Create an instance of the control.  We pass it to the property frame function
                // so the property pages have an object from which to get current settings and apply
                // new settings.
                obj = Activator.CreateInstance(typ);
                // This handy function calls IPersistStreamInit->New on COM objects to initialize them
                ActiveXMessageFormatter.InitStreamedObject(obj);

                // Get the property pages for the control using the direct CAUUID method
                // This only works for true COM objects and I demonstrate it here only
                // to show how it is done.  Use the static method
                // PropertyPage.GetPagesForType() method for real-world use.
                ISpecifyPropertyPages pag = (ISpecifyPropertyPages)obj;
                CAUUID cau = new CAUUID(0);
                pag.GetPages(ref cau);
                g = cau.GetPages();

                // Instantiating a .NET object and displaying its property pages
                // WORKS ON ALL OBJECTS, .NET or COM

                // Create an instance of the .NET control, MyUserControl
                typ = Type.GetTypeFromProgID("RSSWeatherLayer.PropertySheet");

                // Retrieve the pages for the control
                g = PropertyPage.GetPagesForType(typ);

                // Create an instance of the control that we can give to the property pages
                obj = Activator.CreateInstance(typ);

                //add the RSS layer to the property-sheet control
                ((PropertySheet)obj).RSSWatherLayer = RSSLayer;

                // Display the OLE Property page for the control
                object[] items = new object[] { obj };

                PropertyPage.CreatePropertyFrame(IntPtr.Zero, 500, 500, "RSS Layer properties", items, g);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }