Exemplo n.º 1
0
        private void BuildButton(MapToolExtensionNode mnode, ToolStripButton btn)
        {
            try
            {
                btn.Image       = mnode.Icon;
                btn.Text        = mnode.Id;
                btn.ToolTipText = mnode.Tooltip;
                btn.Tag         = mnode;
                btn.AutoToolTip = true;
                if (btn.Image == null)
                {
                    btn.DisplayStyle = ToolStripItemDisplayStyle.Text;
                }
                else
                {
                    btn.DisplayStyle = ToolStripItemDisplayStyle.Image;
                }

                btn.Click += new EventHandler(btn_Click);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not load tool named {0}: {1}", mnode.Id, ex.Message);
            }
        }
Exemplo n.º 2
0
        void btn_Click(object sender, EventArgs e)
        {
            ToolStripButton      btn  = sender as ToolStripButton;
            MapToolExtensionNode node = btn.Tag as MapToolExtensionNode;

            if (currentTool != null)
            {
                currentTool.SetInactive();
            }

            currentTool = node.Tool;

            if (currentTool != null)
            {
                currentTool.SetActive(this, node.Tag);
            }
        }