private void ButtonProperty_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIPublic.ShowWaitingForm();
            var propertyValue = EditValue;

            var objectType = propertyValue.GetType();
            BaseObjectEditControl editControl = null;

            // 如果不是PaoObject类型,则显示默认编辑控件
            if (!objectType.IsAddonType())
            {
                editControl = EditorPublic.CreateEditControl(objectType) as BaseObjectEditControl;
            }

            if (editControl == null)
            {
                var editController = EditorPublic.GetOrCreateEditControllerFromStorage <ObjectLayoutEditController>(objectType);
                editControl = editController.CreateEditControl(objectType) as BaseObjectEditControl;
            }

            editControl.EditValue = IOPublic.ObjectClone(propertyValue);
            UIPublic.CloseWaitingForm();
            if (WinFormPublic.ShowDialog(editControl) == DialogReturn.OK)
            {
                EditValue = editControl.EditValue;
            }
            SetControlStatus();
        }
Exemple #2
0
        /// <summary>
        /// 根据编辑控件重置对象
        /// </summary>
        /// <param name="editControl">编辑控件</param>
        private void ResetNodeValueByEditControl(BaseObjectEditControl editControl)
        {
            var focusedNode = this.TreeListObject.FocusedNode;

            if (focusedNode != null)
            {
                var propDesc  = (PropertyDescriptor)focusedNode.GetValue(ColumnPropertyDescriptor);
                var nodeType  = (ObjectTreeNodeType)focusedNode.GetValue(ColumnPropertyElementType);
                var obj       = focusedNode.GetValue(ColumnObject);
                var newObject = editControl.EditValue;
                SetPropertNewValue(focusedNode, newObject);

                focusedNode.Expanded = true;
            }
        }
        protected override RepositoryItem OnCreateRepositoryItem(Type objectType)
        {
            var repositoryItem = new RepositoryItemButtonEdit();

            WinFormPublic.AddClearButton(repositoryItem);
            repositoryItem.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            repositoryItem.ButtonClick  += (sender, e) =>
            {
                var edit = (ButtonEdit)sender;
                if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)
                {
                    var editValue = edit.EditValue;
                    BaseObjectEditControl editControl = CreateEditControl(objectType) as BaseObjectEditControl;

                    if (edit.EditValue.IsNotNull())
                    {
                        editControl.EditValue = IOPublic.ObjectClone(editValue);
                    }
                    else
                    {
                        editControl.EditValue = null;
                    }
                    if (WinFormPublic.ShowDialog(editControl) == DialogReturn.OK)
                    {
                        edit.EditValue = editControl.EditValue;
                    }
                }
            };
            repositoryItem.CustomDisplayText += (sender, e) => {
                if (e.Value.IsNull())
                {
                    e.DisplayText = "[空]";
                }
                else if (e.Value.GetType().IsAddonListType() || e.Value.GetType().IsAddonDictionaryType())
                {
                    e.DisplayText = e.Value.GetType().GetTypeString();
                }
                else
                {
                    e.DisplayText = e.Value.ToString();
                }
            };
            return(repositoryItem);
        }