public ToolStripItemEditView(string groupId) { InitializeComponent(); Unity.ApplyResource(this); ApplyLanguageResource(); _groupId = groupId; PropertyGridTypeWrapper typeWrapper = new PropertyGridTypeWrapper(typeof(ToolStripItemAbstract)); typeWrapper.ActOnSubClass = true; typeWrapper.VisibleAll = true; typeWrapper.VisibleException.AddRange(new string[] { ToolStripItemAbstract.Property_Name, ToolStripItemAbstract.Property_Code }); propertyGrid.AddTypeWrapper(typeWrapper); this.txtCode.Regex = CoreConstant.ENTITY_CODE_REGEX; this.txtCode.CustomValidate = CodeValidateMethod; this._userControlEvent = new UserControlEvent(null); this._userControlEvent.FormEntity = null; this._userControlEvent.Dock = DockStyle.Fill; }
public ExplorerPropertyView() { InitializeComponent(); this.TabText = Language.Current.Explorer_PropertyView_TabText; PropertyGridTypeWrapper toolStripPageEntityWrapper = new PropertyGridTypeWrapper(typeof(ToolStripPageEntity)) { ActOnSubClass = true, VisibleAll = true, }; toolStripPageEntityWrapper.VisibleException.Add(EntityBase.Property_Remark); propertyGrid.AddTypeWrapper(toolStripPageEntityWrapper); PropertyGridTypeWrapper toolStripGroupEntityWrapper = new PropertyGridTypeWrapper(typeof(ToolStripGroupEntity)) { ActOnSubClass = true, VisibleAll = true }; toolStripGroupEntityWrapper.VisibleException.Add(EntityBase.Property_Remark); propertyGrid.AddTypeWrapper(toolStripGroupEntityWrapper); PropertyGridValidator toolStripItemValidator = new PropertyGridValidator(typeof(EntityBase)) { ActOnSub = true, }; toolStripItemValidator.Validator = (e) => { bool success = true; string message = null; if (e.Property == EntityBase.Property_Code) { if (Keywords.Container(e.Value.ToString())) { success = false; message = CommonLanguage.Current.ValueInefficacyUseKeywords; } else { Debug.Assert(e.Objects.Length == 1, "验证 Code 时对象数目只能是一个"); object obj = e.Objects[0]; #if DEBUG Type objType = obj.GetType(); if (ReflectionHelper.IsSubOf(objType, typeof(ToolStripItemAbstract)) == false && ReflectionHelper.IsSubOf(objType, typeof(ToolStripPageEntity)) == false && ReflectionHelper.IsSubOf(objType, typeof(ToolStripGroupEntity)) == false && ReflectionHelper.IsSubOf(objType, typeof(MenuEntity)) == false) { Debug.Assert(false, "obj 不是有效的用于菜单或工具栏的对象类型"); } #endif string value = e.Value.ToString(); if (_toolStripArchive.CheckExistByCode(value) || _toolStripArchive.PageExistByCode(value) || _toolStripArchive.GroupExistByCode(value) || _menuStripArchive.CheckExistByCode(value)) { success = false; message = Language.Current.Explorer_PropertyView_MessageCodeExist; } } } return(new PropertyGridValidateResult(success, message)); }; propertyGrid.AddValidator(toolStripItemValidator); propertyGrid.PropertyChanged += new PropertyGridPad.OnPropertyChangeHandler(propertyGrid_PropertyChanged); }