Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when a user clicks on a toolbar button or menu item.
        /// </summary>
        /// <param name="ItemName">The name of the item clicked on.</param>
        /// <param name="Handled">Reference parameter.  Setting Handled to true prevents other plugins from receiving this event.</param>
        public void ItemClicked(string ItemName, ref bool Handled)
        {
            try
            {
                switch (ItemName)
                {
                case _btnNameLoadData:
                    UserActivatedPlugin = true;
                    Handled             = true;
                    //Open the form:
                    frm = new TemplatePluginVS2008.Forms.frmLayers(_mapWin);
                    //Show it on top of MapWindow
                    frm.Show(Form.FromHandle(new IntPtr(_parentHandle)));

                    break;

                default:
                    if (frm == null)
                    {
                        UserActivatedPlugin = false;     //Some other button was clicked and the form was closed
                    }
                    break;
                }
            }
            catch (System.Exception ex)
            {
                _mapWin.ShowErrorDialog(ex);
            }
        }
Ejemplo n.º 2
0
        public void fillVisibleLayers(TemplatePluginVS2008.Forms.frmLayers frm)
        {
            //C#3.0: Implicitly Typed Local Variables and Arrays:
            //The layers need to be in a List or else LINQ doesn't work:
            var layersList = getLayers(_mapWin.Layers);

            int counter = 0;

            frm.cboLayers.Items.Clear();

            //C#3.0: LINQ to Entities: Language-Integrated Query:
            var visibleLayers = from l in layersList
                                where l.Visible == true
                                select new MyLayersList {
                Name          = l.Name
                , LayerHandle = l.Handle
                , LayerType   = l.LayerType
            };

            foreach (var l in visibleLayers)
            {
                frm.cboLayers.Items.Add(l);
                if (_mapWin.Layers.CurrentLayer == l.LayerHandle)
                {
                    frm.cboLayers.SelectedIndex = counter;
                }
                counter++;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This method is called when a plugin is unloaded.  The plugin should remove all toolbars, buttons and menus that it added.
 /// </summary>
 public void Terminate()
 {
     _mapWin.Toolbar.RemoveButton(_btnNameLoadData);
     if (_mapWin.Toolbar.NumToolbarButtons(_toolbarName) == 0)
     {
         //If all buttons are removed, remove toolbar as well:
         _mapWin.Toolbar.RemoveToolbar(_toolbarName);
     }
     //Clean up:
     _mapWin = null;
     frm     = null;
     GC.Collect();
 }