Пример #1
0
        /// <summary>
        /// 根据创建的命令格式化操作菜单项。
        /// </summary>
        /// <param name="moduleInfo"></param>
        public void RefreshToolsButtonItem(MB.Util.Model.ModuleTreeNodeInfo moduleInfo)
        {
            foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateButtonItems.Keys)
            {
                butItem.Enabled = true;
            }
            if (!string.IsNullOrEmpty(moduleInfo.RejectCommands))
            {
                string[] rejects = moduleInfo.RejectCommands.Split(',');
                foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateButtonItems.Keys)
                {
                    XMenuInfo     menuInfo = _AllCreateButtonItems[butItem];
                    UICommandType cType    = (UICommandType)menuInfo.CommandID.ID;
                    if (Array.IndexOf(rejects, cType.ToString()) >= 0)
                    {
                        butItem.Enabled = false;
                    }
                }
            }

            MB.WinBase.IFace.IForm activeForm = _CommandExecutor.HostMdiMainForm.GetActiveMdiChildForm();
            if (activeForm == null)
            {
                return;
            }

            //如果是分析界面的话要屏蔽掉操作功能菜单项。
            MB.WinBase.IFace.IClientRule editRule = activeForm.ClientRuleObject as MB.WinBase.IFace.IClientRule;
            if (editRule != null)
            {
                return;
            }

            foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateButtonItems.Keys)
            {
                XMenuInfo menuInfo = _AllCreateButtonItems[butItem];
                var       info     = CommandGroups.EditCommands.FirstOrDefault(o => o.CommandID.Equals(menuInfo.CommandID));
                if (info != null)
                {
                    butItem.Enabled = false;
                    continue;
                }
                if (menuInfo.CommandID.Equals(UICommands.DataImport))
                {
                    butItem.Enabled = false;
                    continue;
                }
            }
        }
Пример #2
0
        //根据当前活动的子窗口 格式化操作的菜单项
        private void refreshToolsButtonItem(MB.Util.Model.ModuleTreeNodeInfo moduleInfo)
        {
            _RejectCommandItems.Clear();
            foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
            {
                butItem.Enabled = true;
            }
            if (!string.IsNullOrEmpty(moduleInfo.RejectCommands))
            {
                string[] rejects = moduleInfo.RejectCommands.Split(',');
                foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                {
                    System.ComponentModel.Design.CommandID cmdID = _AllCreateMenuItems[butItem];
                    UICommandType cType = (UICommandType)cmdID.ID;
                    if (Array.IndexOf(rejects, cType.ToString()) >= 0)
                    {
                        butItem.Enabled = false;
                        if (!_RejectCommandItems.ContainsKey(butItem))
                        {
                            _RejectCommandItems.Add(butItem, false);
                        }
                        else
                        {
                            _RejectCommandItems[butItem] = false;
                        }
                    }
                }
            }

            MB.WinBase.IFace.IForm activeForm = this.GetActiveMdiChildForm();
            if (activeForm == null)
            {
                return;
            }

            //如果是分析界面的话要屏蔽掉操作功能菜单项。
            MB.WinBase.IFace.IClientRule editRule = activeForm.ClientRuleObject as MB.WinBase.IFace.IClientRule;
            if (editRule != null)
            {
                return;
            }

            foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
            {
                System.ComponentModel.Design.CommandID cmdID = _AllCreateMenuItems[butItem];
                var info = CommandGroups.EditCommands.FirstOrDefault(o => o.CommandID.Equals(cmdID));
                if (info != null)
                {
                    butItem.Enabled = false;
                    if (!_RejectCommandItems.ContainsKey(butItem))
                    {
                        _RejectCommandItems.Add(butItem, false);
                    }
                    else
                    {
                        _RejectCommandItems[butItem] = false;
                    }
                    continue;
                }
                if (cmdID.Equals(UICommands.DataImport))
                {
                    butItem.Enabled = false;
                    if (!_RejectCommandItems.ContainsKey(butItem))
                    {
                        _RejectCommandItems.Add(butItem, false);
                    }
                    else
                    {
                        _RejectCommandItems[butItem] = false;
                    }
                    continue;
                }
            }
        }
        //根据当前活动的子窗口 格式化操作的菜单项
        private void refreshToolsButtonItem(MB.Util.Model.ModuleTreeNodeInfo moduleInfo)
        {
            using (MB.Util.MethodTraceWithTime track = new Util.MethodTraceWithTime("XtraRibbonMdiMainForm::refreshToolsButtonItem")) {
                _RejectCommandItems.Clear();

                foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                {
                    butItem.Enabled = true;
                }
                //2009-21-29主要从兼容的角度来处理,以后需要去掉 (新订货会系统中有需要)
                if (!string.IsNullOrEmpty(moduleInfo.RejectCommands))
                {
                    string[] rejects = moduleInfo.RejectCommands.Split(',');
                    foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                    {
                        System.ComponentModel.Design.CommandID cmdID = _AllCreateMenuItems[butItem];
                        UICommandType cType = (UICommandType)cmdID.ID;
                        if (Array.IndexOf(rejects, cType.ToString()) >= 0)
                        {
                            butItem.Enabled = false;
                            if (!_RejectCommandItems.ContainsKey(butItem))
                            {
                                _RejectCommandItems.Add(butItem, false);
                            }
                            else
                            {
                                _RejectCommandItems[butItem] = false;
                            }
                        }
                    }
                }
                MB.WinBase.IFace.IForm activeForm = this.GetActiveMdiChildForm();
                if (activeForm == null || activeForm.ClientRuleObject == null)
                {
                    foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                    {
                        butItem.Enabled = false;
                    }
                    return;
                }

                //根据业务类上的配置项来进行约束操作菜单项。
                var rejectCfg = MB.WinBase.Atts.AttributeConfigHelper.Instance.GetModuleRejectCommands(activeForm.ClientRuleObject.GetType());
                if (rejectCfg != null)
                {
                    foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                    {
                        System.ComponentModel.Design.CommandID cmdID = _AllCreateMenuItems[butItem];
                        UICommandType cType = (UICommandType)cmdID.ID;
                        if ((rejectCfg.RejectCommands & cType) != 0)
                        {
                            butItem.Enabled = false;
                            if (!_RejectCommandItems.ContainsKey(butItem))
                            {
                                _RejectCommandItems.Add(butItem, false);
                            }
                            else
                            {
                                _RejectCommandItems[butItem] = false;
                            }
                        }
                    }
                }

                //如果是分析界面的话要屏蔽掉操作功能菜单项。
                MB.WinBase.IFace.IClientRule editRule = activeForm.ClientRuleObject as MB.WinBase.IFace.IClientRule;
                if (editRule != null)
                {
                    return;
                }

                foreach (DevExpress.XtraBars.BarButtonItem butItem in _AllCreateMenuItems.Keys)
                {
                    System.ComponentModel.Design.CommandID cmdID = _AllCreateMenuItems[butItem];
                    var info = CommandGroups.EditCommands.FirstOrDefault(o => o.CommandID.Equals(cmdID));
                    if (info != null)
                    {
                        butItem.Enabled = false;
                        if (!_RejectCommandItems.ContainsKey(butItem))
                        {
                            _RejectCommandItems.Add(butItem, false);
                        }
                        else
                        {
                            _RejectCommandItems[butItem] = false;
                        }

                        continue;
                    }
                    if (cmdID.Equals(UICommands.DataImport))
                    {
                        butItem.Enabled = false;
                        if (!_RejectCommandItems.ContainsKey(butItem))
                        {
                            _RejectCommandItems.Add(butItem, false);
                        }
                        else
                        {
                            _RejectCommandItems[butItem] = false;
                        }

                        continue;
                    }
                }
            }
        }