EC属性面板 自定义属性信息提示

在元素属性面板中,对于自定义EC属性,可不可以实现鼠标悬浮(或点击)某个属性,出现一些相关提示信息。EC shcema文件自定义属性时有“description”属性的定义,能否通过这个实现。就比方说鼠标放在构件类型属性处,会出现一些提示。

  • 悬浮应该是没办法的,点击的话,可以在输入焦点进入到属性后的输入框时,触发某个函数,详细用法可参考这篇wiki里边用到的ECPropertyUITypeEditor,communities.bentley.com/.../ec---ecpropertyuitypeeditor

  • 我理解是可以通过对属性面板的自定义,添加某些控件来实现类似功能。就像上图类似,点击Text时,下面面板就会出现提示。是可以这样理解的吧?提示信息是不是可以从EC shcema文件里面进行提取呢,就比方说提取“description”属性

  • 这个实现起来挺麻烦的:

                var ecProp = ecclass.FindProperty("PropDou");
                IECInstance customExtendedType = ECPropertyPane.CreateExtendedType("CustomType");
                ECPropertyPane.SetExtendedTypePropertyValueUIHandler(customExtendedType, new System.Drawing.Design.PropertyValueUIHandler(MyPropertyValueUIHandler));
                ECPropertyPane.SetExtendedType(ecProp, customExtendedType);

    其中MyPropertyValueUIHandler如下所示:

            static bool is_init = true;
            public static void MyPropertyValueUIHandler(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
            {
                if(!is_init)
                {
                    return;
                }
                is_init = false;
                Type t = context.GetType();
                System.Reflection.PropertyInfo propertyInfo = t.GetProperty("OwnerGrid");
                object labelTxtColor = propertyInfo.GetValue(context, null);
                MultiPropertyGrid muPropGrid = labelTxtColor as MultiPropertyGrid;
                var type = labelTxtColor.GetType();
                var propInfo = type.GetProperty("Controls");
                var controls = propInfo.GetValue(labelTxtColor) as Control.ControlCollection;
                propInfo = propInfo = type.GetProperty("Container");
                var container = propInfo.GetValue(labelTxtColor) as IContainer;
                if (null != controls)
                {
                    foreach (var curVar in controls)
                    {
                        if (curVar.GetType().Name != "PropertyGridView")
                            continue;
                        Control curCtl = curVar as Control;
                        foreach (var curSubCtl in curCtl.Controls)
                        {
    
                            if (null != curSubCtl)
                            {
                                if (((System.Windows.Forms.Control)curSubCtl).AccessibleName == "PropDou")
                                {
                                    ToolTip toolTip1 = new ToolTip();
                                    toolTip1.SetToolTip(curSubCtl as Control, "My double value");
                                }
                            }
                        }
    
                    }
                }
            }

    效果如下所示: