Ejemplo n.º 1
0
        /// <summary>
        /// 获取默认的编辑控制器
        /// </summary>
        /// <param name="objectType">对象类型</param>
        /// <param name="editorType">编辑器类型</param>
        /// <returns>默认编辑控制器</returns>
        public static BaseEditController GetOrCreateEditControllerFromStorage(Type objectType, Type editorType)
        {
            var editController = EditorPublic.GetEditControllerFromStorage(objectType, editorType);

            if (editController == null)
            {
                editController = editorType.CreateInstance() as BaseEditController;
                EditorPublic.SetEditControllerToStorage(objectType, editController);
            }
            return(editController);
        }
Ejemplo n.º 2
0
        protected override void OnClose()
        {
            var editValue  = EditValue;
            var controller = Controller as ObjectPropertyEditController;

            if (controller != null)
            {
                controller.LayoutData = this.PropertyGridControl.GetLayoutData();
                // 如果设置了ObjectType,则保存默认配置
                if (controller.StaticType && editValue != null)
                {
                    EditorPublic.SetEditControllerToStorage(editValue.GetType(), controller);
                }
            }
            base.OnClose();
        }
Ejemplo n.º 3
0
        protected override void OnClose()
        {
            var controller = Controller as ObjectLayoutEditController;

            if (controller != null)
            {
                controller.LayoutData = this.DataLayoutControl.GetLayoutData();
                // 如果设置了ObjectType,则保存默认配置
                if (controller.StaticType && ObjectType != null)
                {
                    EditorPublic.SetEditControllerToStorage(ObjectType, controller);
                }
            }

            base.OnClose();
        }
Ejemplo n.º 4
0
        public static BaseEditController GetEditController(PropertyDescriptor propertyDescriptor)
        {
            BaseEditController editController = null;
            var editorType = EditorPublic.GetEditorTypeByReflection(propertyDescriptor);

            if (editorType == null)
            {
                editController = GetEditController(propertyDescriptor.PropertyType);
            }
            else
            {
                editController = editorType.CreateInstance() as BaseEditController;
                EditorPublic.SetEditControllerToStorage(propertyDescriptor.PropertyType, editController);
            }

            return(editController);
        }
Ejemplo n.º 5
0
        /// 通用获取或创建编辑器步骤:(BaseObjectEditController中)
        /// 1. 从BaseObjectEditController中的PredefinedEditors属性中获取编辑控制器;
        /// 2. 通过类或属性的EditorTypeAttribute获取编辑控制器类型;
        /// 3. 根据类型获取默认的编辑控制器;
        /// 4. 从客户端存储中获取编辑控制器的配置;
        /// 5. 创建编辑器;
        ///
        /// 指定数据类型获取编辑器的步骤:
        /// 1. 通过类或属性的EditorTypeAttribute获取编辑控制器类型;
        /// 2. 根据类型获取默认的编辑控制器;
        /// 3. 从客户端存储中获取编辑控制器的配置;
        /// 4. 创建编辑器;
        ///
        /// 指定编辑器类型创建编辑器的步骤:
        /// 1. 从客户端存储中获取编辑控制器的配置;
        /// 3. 创建编辑器;

        public static BaseEditController GetEditController(Type objectType)
        {
            BaseEditController editController = null;
            var editorType = EditorPublic.GetEditorTypeByReflection(objectType);

            if (editorType == null)
            {
                editorType = GetDefaultEditorType(objectType);
            }

            if (editorType == null)
            {
                return(null);
            }

            editController = EditorPublic.GetEditControllerFromStorage(objectType, editorType);
            if (editController == null)
            {
                editController = editorType.CreateInstance() as BaseEditController;
                EditorPublic.SetEditControllerToStorage(objectType, editController);
            }
            return(editController);
        }