www.pudn.com > WorkflowDesigner.rar > MainMenuBar.cs, change:2007-11-16,size:4757b


using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Windows.Forms; 
namespace WorkflowDesigner 
{ 
    /// <summary> 
    /// 控制工具工具栏 
    /// </summary> 
    public class MainMenuBar 
    { 
         
        /// <summary> 
        /// 构造函数 
        /// </summary> 
        /// <param name="toolbar"></param> 
        /// <param name="toolMenu"></param> 
        public MainMenuBar(ToolStrip toolbar,ToolStripMenuItem toolMenu) 
        { 
            this._toolbar = toolbar; 
            this._toolMenu = toolMenu; 
        } 
        private ToolStrip _toolbar; 
        private ToolStripMenuItem _toolMenu; 
 
 
        public void DisableAllWorkflowItem() 
        { 
            foreach (ToolStripItem tool in _toolbar.Items) 
            { 
                tool.Enabled= false; 
            } 
 
            foreach (ToolStripItem toolMenuItem in _toolMenu.DropDownItems) 
            { 
                toolMenuItem.Enabled = false; 
            } 
        } 
 
        public void EnableAllWorkflowItem() 
        { 
            foreach (ToolStripItem tool in _toolbar.Items) 
            { 
                tool.Enabled = true; 
            } 
 
            foreach (ToolStripItem toolMenuItem in _toolMenu.DropDownItems) 
            { 
                toolMenuItem.Enabled = true; 
            } 
        } 
 
        public void DisableStartActivityItem() 
        { 
            _toolbar.Items["TSBStart"].Enabled = false; 
            _toolMenu.DropDownItems["MIStart"].Enabled = false; 
        } 
 
        public void EnableStartActivityItem() 
        { 
            _toolbar.Items["TSBStart"].Enabled = true; 
            _toolMenu.DropDownItems["MIStart"].Enabled = true; 
        } 
 
        public void CheckAllWorkFlowItem(bool Flag) 
        { 
            foreach (ToolStripItem tool in _toolbar.Items) 
            { 
                if (tool is ToolStripButton) 
                { 
                    (tool as ToolStripButton).Checked = Flag; 
                } 
            } 
 
            foreach (ToolStripItem toolMenuItem in _toolMenu.DropDownItems) 
            { 
                if (toolMenuItem is ToolStripMenuItem) 
                { 
                    (toolMenuItem as ToolStripMenuItem).Checked = Flag; 
                } 
            } 
        } 
        public void CheckButton(StateButton button) 
        { 
            this.CheckButton(button, true); 
        } 
         
        public void CheckButton(StateButton button,bool Flag) 
        { 
            String ToolbuttonNewKeyName = ""; 
            String MenuItemNewKeyName = ""; 
            switch (button) 
            { 
                case StateButton.Select: 
                    ToolbuttonNewKeyName = "TSBSelect"; 
                    MenuItemNewKeyName = "MISelect"; 
                    break; 
                case StateButton.Activity: 
                    ToolbuttonNewKeyName = "TSBActive"; 
                    MenuItemNewKeyName = "MIActive"; 
                    break; 
                case StateButton.StartActivity: 
                    ToolbuttonNewKeyName = "TSBStart"; 
                    MenuItemNewKeyName = "MIStart"; 
                    break; 
                case StateButton.EndActivity: 
                    ToolbuttonNewKeyName = "TSBEnd"; 
                    MenuItemNewKeyName = "MIEnd"; 
                    break; 
                case StateButton.Transition: 
                    ToolbuttonNewKeyName = "TSBTrans"; 
                    MenuItemNewKeyName = "MITrans"; 
                    break; 
                case StateButton.BrachActivity: 
                    ToolbuttonNewKeyName = "TSBBacth"; 
                    MenuItemNewKeyName = "MIBatch"; 
                    break; 
                case StateButton.GatherActivity: 
                    ToolbuttonNewKeyName = "TSBConverge"; 
                    MenuItemNewKeyName = "MIconverge"; 
                    break; 
                case StateButton.Back: 
                    ToolbuttonNewKeyName = "TSBBack"; 
                    MenuItemNewKeyName = "MIBack"; 
                    break; 
            } 
            ((ToolStripButton)_toolbar.Items[ToolbuttonNewKeyName]).Checked = Flag; 
 
             
             if((this._toolMenu.DropDownItems[MenuItemNewKeyName]) is ToolStripItem) 
            { 
                ((ToolStripMenuItem)this._toolMenu.DropDownItems[MenuItemNewKeyName]).Checked=true; 
            } 
         } 
 
        public enum StateButton 
        { 
            Select, 
            Activity, 
            StartActivity, 
            EndActivity, 
            Transition, 
            Back, 
            BrachActivity, 
            GatherActivity 
        } 
 
    } 
}