Example #1
0
        public IDictionary<string, IFiledEditor> BuildEditUI( ComponentDesignControl designer , ComponentSet set, object obj)
        {
            foreach (FieldSet p in set.Fields)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);

                TableCell cell = new TableCell();
                cell.CssClass = designer.NameCellCssClass;
                cell.Width = NameColumnWidth;
                row.Cells.Add(cell);

                if (set.Depth == 0)
                    cell.Text = FormatDisplayName(p.DisplayName, designer);
                else
                    cell.Text = this.GenSpace(set.Depth + 2) + FormatDisplayName(p.DisplayName, designer);

                cell = new TableCell();
                cell.CssClass = designer.ValueCellCssClass;
                cell.Width = ValueColumnWidth;
                row.Cells.Add(cell);

                System.Web.UI.WebControls.WebControl ctl = FieldEditorFactory.GetFieldEditor(p);

                ctl.ID = p.UniqueName;

                IFiledEditor fe = (IFiledEditor)ctl;
                fe.FieldValue = p.GetValue(obj);

                this.FieldSetEditors.Add(p.UniqueName, fe);

                cell.Controls.Add(ctl);

                designer.RaiseControlCreatedEvent(ctl, p);
            }

            foreach (ComponentSet subSet in set.SubSet)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);

                TableCell cell = new TableCell();
                cell.ColumnSpan = 2;
                row.Cells.Add(cell);
                cell.Text = this.GenSpace(subSet.ParentSet.Depth) + FormatDisplayName(subSet.DisplayName,designer);

                BuildEditUI( designer , subSet, subSet.GetValue(obj));
            }

            return FieldSetEditors;
        }
Example #2
0
        /// <summary>
        /// ��̬�����༭����
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="set"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public IDictionary<string, IFiledEditor> BuildEditUI( ComponentDesignControl designer , ComponentSet set, object obj)
        {
            if (_RepeatColumns % 2 != 0)
                _RepeatColumns += 1;
            int FieldNums = set.Fields.Count;
            int surplus = FieldNums % (_RepeatColumns / 2);
            int rowCount = GetRepeatRows(FieldNums, _RepeatColumns / 2);

            for (int i = 0; i < rowCount; i++)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);
                int tmp = GetRepeatCols(i, FieldNums, _RepeatColumns/2, rowCount);

                for (int j = 0; j < tmp; j++)
                {
                    FieldSet p = set.Fields[i * _RepeatColumns / 2 + j];
                    TableCell cell = new TableCell();
                    cell.CssClass = designer.NameCellCssClass;
                        cell.Text = p.DisplayName;
                    row.Cells.Add(cell);

                    cell = new TableCell();
                    row.Cells.Add(cell);
                    System.Web.UI.WebControls.WebControl ctl = FieldEditorFactory.GetFieldEditor(p);
                    ctl.CssClass = designer.ValueCellCssClass;
                    ctl.ID = p.UniqueName;

                    IFiledEditor fe = (IFiledEditor)ctl;
                    fe.FieldValue = p.GetValue(obj);

                    this.FieldSetEditors.Add(p.UniqueName, fe);

                    cell.Controls.Add(ctl);

                    designer.RaiseControlCreatedEvent(ctl, p);
                }
            }

            return FieldSetEditors;
        }
        public static ComponentSet GetMetaData(Type t)
        {
            return new ComponentSet(t); //��ʱ���û���

            if ( _ComponentSets.ContainsKey(t.FullName) )
            {
                return _ComponentSets[t.FullName];
            }
            else
            {
                ComponentSet set = new ComponentSet( t);

                try
                {
                    _ComponentSets.Add(t.FullName, set);
                }
                catch { } //��ֹ���߳�����

                return set;
            }
        }
Example #4
0
        private void InitControls()
        {
            if (this.ViewState[DESIENED_OBJECT] != null)
            {
                this.Rows.Clear();

                _DesignedObject = this.ViewState[DESIENED_OBJECT];

                _ComponentSet = ComponentMetaDataFactctory.GetMetaData(_DesignedObject.GetType());

                if (ReadOnly)
                    UIBuilder.BuildViewUI(this, _ComponentSet, _DesignedObject);
                else
                    this.FieldSetEditors = UIBuilder.BuildRetrieveUI(this, _ComponentSet);
            }
        }
Example #5
0
 public void ShowComponent(object obj)
 {
     _ComponentSet = ComponentMetaDataFactctory.GetMetaData(obj.GetType());
     //BuildReadonlyUI(_ComponentSet, obj);
     UIBuilder.BuildViewUI(this, _ComponentSet, obj);
 }
Example #6
0
        /// <summary>
        /// ��ʼ��������UI
        /// </summary>
        /// <param name="obj"></param>
        public void EditComponent(object obj)
        {
            this.Rows.Clear();

            Type t = obj.GetType();
            _DesignedObject = obj;

            _ComponentSet = ComponentMetaDataFactctory.GetMetaData(t);

            this.ViewState[DESIENED_OBJECT] = obj;

            if( ReadOnly )
                UIBuilder.BuildViewUI(this, _ComponentSet, _DesignedObject);
            else
                this.FieldSetEditors = UIBuilder.BuildEditUI(this, _ComponentSet, _DesignedObject);
        }
Example #7
0
        /// <summary>
        /// ��̬������ͼ����
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="set"></param>
        /// <param name="obj"></param>
        public void BuildViewUI(ComponentDesignControl designer ,ComponentSet set, object obj)
        {
            if (_RepeatColumns % 2 != 0)
                _RepeatColumns += 1;
            int FieldNums = set.Fields.Count;
            int surplus = FieldNums % (_RepeatColumns/2);
            int rows = FieldNums / (_RepeatColumns/2);
            int rowCount = 0;

            //IList<FieldSet> sortedFields = FieldsSort(set.Fields);
            if (surplus > 0)
            {
                rowCount = rows + 1;
            }
            else
            {
                rowCount = rows;
            }

            for (int i = 0; i < rowCount; i++)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);
                int tmp = 0;
                if (i == rowCount - 1 && surplus == 0)
                {
                    tmp = _RepeatColumns/2;
                }
                else if (i == rowCount - 1 && surplus > 0)
                {
                    tmp = surplus;
                }
                else
                    tmp = _RepeatColumns/2;

                for (int j = 0; j < tmp; j++)
                {
                    FieldSet p = set.Fields[i * _RepeatColumns / 2 + j];

                    TableCell cell = new TableCell();

                    cell.Width = new Unit("131px");
                    row.Cells.Add(cell);
                    cell.Text = p.DisplayName;
                    cell = new TableCell();
                    row.Cells.Add(cell);
                    cell.Text = "" + p.GetValue(obj);
                }
            }
        }
Example #8
0
        /// <summary>
        /// ��̬�����ش�����
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="set"></param>
        /// <returns></returns>
        public IDictionary<string, IFiledEditor> BuildRetrieveUI(ComponentDesignControl designer, ComponentSet set)
        {
            this.FieldSetEditors.Clear();
            if (_RepeatColumns % 2 != 0)
                _RepeatColumns += 1;
            int FieldNums = set.Fields.Count;
            int surplus = FieldNums % (_RepeatColumns / 2);
            int rows = FieldNums / (_RepeatColumns / 2);

            int rowCount = 0;
            if (surplus > 0)
            {
                rowCount = rows + 1;
            }
            else
            {
                rowCount = rows;
            }

            for (int i = 0; i < rowCount; i++)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);
                int tmp = 0;
                if (i == rowCount - 1 && surplus == 0)
                {
                    tmp = _RepeatColumns/2;
                }
                else if (i == rowCount - 1 && surplus > 0)
                {
                    tmp = surplus;
                }
                else
                    tmp = _RepeatColumns/2;

                for (int j = 0; j < tmp; j++)
                {
                    FieldSet p = set.Fields[i * (_RepeatColumns / 2) + j];
                    TableCell cell = new TableCell();
                    row.Cells.Add(cell);
                    cell.Text = p.DisplayName;
                    cell.CssClass = designer.NameCellCssClass;

                    cell = new TableCell();
                    System.Web.UI.WebControls.WebControl ctl = FieldEditorFactory.GetFieldEditor(p);
                    ctl.CssClass = designer.ValueCellCssClass;
                    ctl.ID = p.UniqueName;

                    IFiledEditor fe = (IFiledEditor)ctl;

                        this.FieldSetEditors.Add(p.UniqueName, fe);

                    cell.Controls.Add(ctl);
                    row.Cells.Add(cell);

                    designer.RaiseControlCreatedEvent(ctl, p);
                }
            }

            return FieldSetEditors;
        }
Example #9
0
        public void BuildViewUI(ComponentDesignControl designer ,ComponentSet set, object obj)
        {
            foreach (FieldSet p in set.Fields)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);

                TableCell cell = new TableCell();
                cell.Width = NameColumnWidth;
                cell.CssClass = designer.NameCellCssClass;
                row.Cells.Add(cell);

                if (set.Depth == 0)
                    cell.Text = FormatDisplayName(p.DisplayName, designer);
                else
                    cell.Text = this.GenSpace(set.Depth + 2) + FormatDisplayName(p.DisplayName, designer);

                //
                cell = new TableCell();
                cell.CssClass = designer.ValueCellCssClass;
                cell.Width = ValueColumnWidth;
                row.Cells.Add(cell);
                cell.Text = "" + p.GetValue(obj);
            }

            foreach (ComponentSet subSet in set.SubSet)
            {
                TableRow row = new TableRow();
                designer.Rows.Add(row);

                TableCell cell = new TableCell();
                cell.ColumnSpan = 2;
                row.Cells.Add(cell);
                cell.Text = this.GenSpace(subSet.ParentSet.Depth) + FormatDisplayName( subSet.DisplayName,designer);

                BuildViewUI(designer,subSet, subSet.GetValue(obj));
            }
        }
Example #10
0
        /// <summary>
        /// ����Ԫ����
        /// </summary>
        /// <param name="t"></param>
        internal ComponentSet( Type t)
        {
            Type = t;

            PropertyInfo[] ps = t.GetProperties();

            this.Name = t.Name;

            //this.DisplayName = ComponentSet.GetDisplayName(t);

            foreach (PropertyInfo p in ps)
            {
                if (p.PropertyType.IsValueType || p.PropertyType == typeof(String))
                {
                    FieldSet f = new FieldSet(p, this);

                    if( f.Ignore ==false )
                        this.Fields.Add(f);

                }
                else if (p.PropertyType.IsClass)
                {
                    ComponentSet set = new ComponentSet(this, p );

                    if( set.Ignore == false )
                        this.SubSet.Add(set);
                }
            }
            IList<FieldSet> sortedFields = FieldsSort(this.Fields);
            Fields = sortedFields;
        }
Example #11
0
        internal FieldSet(PropertyInfo p, ComponentSet ownerObjSet)
        {
            this.Name = p.Name;
            this.Property = p;
            this.Type = p.PropertyType;
            this.ParentSet = ownerObjSet;

            EditorAttribute disAtt = ComponentSet.GetEditorAttribute(p);

            if (disAtt != null)
            {
                this.DisplayName = disAtt.DisplayName;
                this.MaxLength = disAtt.MaxLength;
                this.EditorType = disAtt.EditorType;
                this.EditorArgs = disAtt.EditorArgs;
                this.CheckValues = disAtt.CheckValues;
                this.ValidationType = disAtt.ValidationType;
                this.ValidationExpression = disAtt.ValidationExpression;
                this.Sequence = disAtt.Sequence;

                this.CheckValuesProvider = this.GetCheckValuesProvider(disAtt);

                this.Ignore = disAtt.Ignore;
                //
            }

            if (String.IsNullOrEmpty(this.DisplayName))
                this.DisplayName = this.Name;
        }
Example #12
0
        /// <summary>
        /// �Ӷ���Ԫ���� 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="property"></param>
        private ComponentSet(ComponentSet parent, PropertyInfo property)
        {
            this.Property = property ;

            Type t = property.PropertyType;

            this.ParentSet = parent;
            this.Depth = parent.Depth + 1;

            EditorAttribute disAtt = ComponentSet.GetEditorAttribute(property);

            if (disAtt != null)
            {
                this.DisplayName = disAtt.DisplayName;

                this.Ignore = disAtt.Ignore;
            }

            if (String.IsNullOrEmpty(this.DisplayName))
                this.DisplayName = this.Name;

            PropertyInfo[] ps = t.GetProperties();

            this.Name = t.Name;

            foreach (PropertyInfo p in ps)
            {
                if (p.PropertyType.IsValueType || p.PropertyType == typeof(String))
                {
                    FieldSet f = new FieldSet(p, this);

                    if (f.Ignore == false)
                        this.Fields.Add(f);

                }
                else if (p.PropertyType.IsClass && p.PropertyType != parent.Type ) //��ֹ�ݹ�����
                {
                    ComponentSet set = new ComponentSet(this, p);

                    if (set.Ignore == false)
                        this.SubSet.Add(set);
                }
            }
            IList<FieldSet> sortedFields = FieldsSort(this.Fields);
            Fields = sortedFields;
        }