コード例 #1
0
        void UICommand_Click(object sender, EventArgs e)
        {
            //ToolStripButton pTempBtn = sender as ToolStripButton;
            ButtonItem pTemp = sender as ButtonItem;
            //ToolStripMenuItem pTempMenuItem = sender as ToolStripMenuItem;
            //ToolStripItem pItem = pTempBtn;
            //if (null == pTempBtn)
            //{
            //    pItem = pTempMenuItem;
            //}
            //if (null == pItem)
            //{
            //    return;
            //}
            string strKey = pTemp.AccessibleName;

            //当前Command被按下时,CurrentTool设置为null
            //MapControl和PageLayoutControl的也设置为null
            _App.CurrentTool                   = null;
            _App.MapControl.CurrentTool        = null;
            _App.PageLayoutControl.CurrentTool = null;
            //一切在Command被按下前未完成的Tool操作都可能使Tool的Checked为true
            //此项必须设置为False
            //遍历所有的Command,设置每一个Command的选择状态为False
            ToolStripButton UICmd = null;

            //foreach (var item in pItem.GetCurrentParent().Items)
            //{
            //    UICmd = item as ToolStripButton;
            //    if (null == UICmd)
            //        continue;
            //    UICmd.Checked = false;
            //}


            MyPluginEngine.ICommand cmd = _CommandCol[strKey];
            ////在状态栏显示插件信息
            this.statusButton1.Text = "当前操作:" + cmd.Message;
            if (null != pTemp)
            {
                pTemp.Checked = true;
            }
            //((ToolStripButton)sender).Checked = true;
            //设置Map控件的鼠标
            axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            cmd.OnClick();
            //((ToolStripButton)sender).Checked = false;
            if (null != pTemp)
            {
                pTemp.Checked = false;
            }
        }
コード例 #2
0
ファイル: MainGIS.cs プロジェクト: hahahuahai/MyPluginEngine
        void UICommand_Click(object sender, EventArgs e)
        {
            ButtonItem pTemp  = sender as ButtonItem;
            string     strKey = pTemp.AccessibleName;

            //当前Command被按下时,CurrentTool设置为null
            if (_App.CurrentTool != null)
            {
                MyPluginEngine.ITool lastTool = _ToolCol[_App.CurrentTool];
                //先判断上一个Tool是不是工具栏中的
                ButtonItem lastItem = GetButtonItemFromTools(lastTool.Caption);
                if (lastItem != null)
                {
                    lastItem.Checked = false;
                }
                else    //若不是工具栏中的,则判断是不是菜单栏中得到Tool
                {
                    lastItem = GetButtonItemFromMenus(lastTool.Caption);
                    if (lastItem != null)
                    {
                        lastItem.Checked = false;
                    }
                }
                _App.CurrentTool = null;
            }
            _App.MapControl.CurrentTool        = null;
            _App.PageLayoutControl.CurrentTool = null;

            ToolStripButton UICmd = null;

            MyPluginEngine.ICommand cmd = _CommandCol[strKey];
            ////在状态栏显示插件信息
            this.statusButton1.Text = "当前操作:" + cmd.Message;
            if (null != pTemp)
            {
                pTemp.Checked = true;
            }
            //设置Map控件的鼠标
            axMapControl1.MousePointer        = esriControlsMousePointer.esriPointerDefault;
            axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            cmd.OnClick();
            if (null != pTemp)
            {
                pTemp.Checked = false;
            }
        }