示例#1
0
        /// <summary>
        /// 初始化属性
        /// </summary>
        private void InitPropertys()
        {
            _lstProperty = new List <UIModelItem>();


            List <ClrProperty>   lstClrProperty = EntityConfig.GetAllMember <ClrProperty>(_classType, true);
            EntityConfig         entity         = new EntityConfig(_classType, DesignerInfo);
            Stack <EntityConfig> stkEntity      = EntityConfig.GetEntity(entity, DesignerInfo);

            foreach (ClrProperty property in lstClrProperty)
            {
                UIModelItem item = new UIModelItem(property);


                EntityParamField finfo = EntityConfig.FindParamInfoByName(stkEntity, item.PropertyName);
                if (finfo != null)
                {
                    bool      isPK  = EnumUnit.ContainerValue((int)finfo.EntityPropertyType, (int)EntityPropertyType.PrimaryKey);
                    TableInfo tinfo = new TableInfo(isPK, finfo.ParamName, finfo.Length, finfo.ReadOnly, (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), finfo.DbType).Value);
                    item.TabInfo = tinfo;
                }
                else
                {
                    EntityRelationItem rel = EntityConfig.FindRelInfoByName(stkEntity, item.PropertyName);
                    if (rel != null)
                    {
                        RelationInfo rinfo = new RelationInfo(rel.TargetProperty, rel.SourceProperty, rel.IsParent, rel.TypeName, rel.TypeFullName);
                        item.RelInfo = rinfo;
                    }
                }



                _lstProperty.Add(item);
            }
        }
示例#2
0
        // Methods
        public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)
        {
            base.DoPaint(e, parentShape);
            Font          font        = this.GetFont(e.View);
            CDCompartment compartment = parentShape as CDCompartment;

            if (compartment != null)
            {
                ListField listField = null;
                foreach (ShapeField field2 in compartment.ShapeFields)
                {
                    if (field2 is ListField)
                    {
                        listField = field2 as ListField;
                        break;
                    }
                }
                float MemberLineHeight  = (float)listField.GetItemHeight(parentShape);
                float MemberStartMargin = 0f;
                float stringMargin      = 0.02f;
                if (listField != null)
                {
                    int itemCount = compartment.GetItemCount(listField);
                    for (int i = 0; i < itemCount; i++)
                    {
                        ItemDrawInfo itemDrawInfo = new ItemDrawInfo();
                        MemberStartMargin = (float)listField.GetItemRectangle(parentShape, i, 0).Y;
                        compartment.GetItemDrawInfo(listField, i, itemDrawInfo);
                        if (itemDrawInfo.Disabled)
                        {
                            continue;
                        }
                        string[] strArray = itemDrawInfo.Text.Split(new char[] { ':', '(', '{', '<' });

                        Member menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim());
                        if ((menberByName == null))
                        {
                            continue;
                        }
                        string docSummary      = menberByName.DocSummary;
                        string genericTypeName = "";

                        genericTypeName = menberByName.MemberTypeShortName;

                        BackBrush.Color     = Color.White;
                        VarBrush.Color      = Color.Blue;
                        ModifierBrush.Color = Color.Blue;
                        NameBrush.Color     = Color.Black;
                        SummaryBrush.Color  = Color.Green;
                        SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes;
                        if (seleShapes != null)
                        {
                            foreach (DiagramItem item in seleShapes)
                            {
                                if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i))
                                {
                                    this.BackBrush.Color = SystemColors.Highlight;
                                    VarBrush.Color       = Color.White;
                                    NameBrush.Color      = Color.White;
                                    SummaryBrush.Color   = Color.White;
                                    ModifierBrush.Color  = Color.White;
                                    break;
                                }
                            }
                        }



                        float      recX  = (float)itemDrawInfo.ImageMargin;//0.16435f
                        RectangleD bound = parentShape.BoundingBox;

                        float width = (float)bound.Width;
                        //float MemberStartMargin = 0.26f;


                        e.Graphics.FillRectangle(this.BackBrush, VSConfigManager.CurConfig.MemberMarginX,
                                                 MemberStartMargin, width,
                                                 MemberLineHeight);

                        float curX = VSConfigManager.CurConfig.MemberMarginX;

                        string memberTypeName = menberByName.MemberTypeName.TrimEnd('?', '[', ']');
                        if (BackBrush.Color == Color.White)//非选中状态
                        {
                            if ((memberTypeName != "void") && (menberByName.MemberTypeLookupName == memberTypeName))
                            {
                                VarBrush.Color = Color.DodgerBlue;
                            }
                            //if (!menberByName.IsSpecialName)
                            //{
                            //    VarBrush.Color = Color.DodgerBlue;
                            //}
                        }
                        string curStr = null;

                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.TypeName))
                        {
                            if (menberByName.IsStatic)
                            {
                                curStr = "static";
                                e.Graphics.DrawString(curStr, font, ModifierBrush, curX,
                                                      MemberStartMargin + stringMargin);
                                curX += e.Graphics.MeasureString(curStr, font).Width;
                            }


                            curStr = genericTypeName + " ";
                            e.Graphics.DrawString(curStr, font, this.VarBrush, curX,
                                                  MemberStartMargin + stringMargin);
                            curX += e.Graphics.MeasureString(curStr, font).Width;
                        }
                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName))
                        {
                            curStr = menberByName.Name;
                            if (menberByName is ClrMethod)
                            {
                                curStr += "()";
                            }


                            e.Graphics.DrawString(curStr, font, this.NameBrush, curX,
                                                  MemberStartMargin + stringMargin);
                            curX += e.Graphics.MeasureString(curStr, font).Width;
                        }
                        if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary))
                        {
                            if (!string.IsNullOrEmpty(curStr))
                            {
                                curStr = ":";
                            }
                            else
                            {
                                curStr = "";
                            }
                            curStr += HttpUtility.HtmlDecode(docSummary);
                            e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX,
                                                  MemberStartMargin + stringMargin);
                        }
                    }
                }
            }
        }
示例#3
0
        // Methods
        public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)
        {
            base.DoPaint(e, parentShape);
            Font          font        = this.GetFont(e.View);
            CDCompartment compartment = parentShape as CDCompartment;

            if (compartment != null)
            {
                ListField listField = null;
                foreach (ShapeField field2 in compartment.ShapeFields)
                {
                    if (field2 is ListField)
                    {
                        listField = field2 as ListField;
                        break;
                    }
                }
                float MemberLineHeight = (float)listField.GetItemHeight(parentShape);
                if (listField != null)
                {
                    int itemCount = compartment.GetItemCount(listField);
                    for (int i = 0; i < itemCount; i++)
                    {
                        ItemDrawInfo itemDrawInfo = new ItemDrawInfo();
                        compartment.GetItemDrawInfo(listField, i, itemDrawInfo);
                        if (!itemDrawInfo.Disabled)
                        {
                            string[] strArray     = itemDrawInfo.Text.Split(new char[] { ':', '(', '{' });
                            Member   menberByName = this.GetMenberByName(parentShape.ParentShape, strArray[0].Trim());
                            if ((menberByName != null))
                            {
                                string docSummary = menberByName.DocSummary;
                                this.BackBrush.Color    = Color.White;
                                this.SummaryBrush.Color = Color.Green;
                                this.NameBrush.Color    = Color.Black;
                                SelectedShapesCollection seleShapes = this._FromAddin.SelectedShapes;
                                if (seleShapes != null)
                                {
                                    foreach (DiagramItem item in seleShapes)
                                    {
                                        if (((item.Shape == compartment) && (item.Field == listField)) && (item.SubField.SubFieldHashCode == i))
                                        {
                                            this.BackBrush.Color    = SystemColors.Highlight;
                                            this.SummaryBrush.Color = Color.White;
                                            this.NameBrush.Color    = Color.White;
                                            break;
                                        }
                                    }
                                }
                                float      height = 0.19f;
                                float      recX   = (float)itemDrawInfo.ImageMargin;//0.16435f
                                RectangleD bound  = parentShape.BoundingBox;
                                float      width  = (float)bound.Width;



                                e.Graphics.FillRectangle(this.BackBrush, 0f,
                                                         (0f + MemberLineHeight * (float)i),
                                                         width, MemberLineHeight);

                                DBConfigInfo dbInfo = DBConfigInfo.LoadInfo(_FromAddin.GetDesignerInfo());

                                string curStr = null;
                                float  curX   = 0f;
                                if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.MemberName))
                                {
                                    curStr = menberByName.Name;

                                    e.Graphics.DrawString(curStr, font, this.NameBrush, curX,
                                                          (0f + MemberLineHeight * (float)i + 0.02f));
                                    curX += e.Graphics.MeasureString(curStr, font).Width;
                                }
                                if (EnumUnit.ContainerValue((int)_summaryShowInfo, (int)SummaryShowItem.Summary))
                                {
                                    if (!string.IsNullOrEmpty(curStr))
                                    {
                                        curStr = ":";
                                    }
                                    else
                                    {
                                        curStr = "";
                                    }
                                    curStr += HttpUtility.HtmlDecode(menberByName.DocSummary);
                                    e.Graphics.DrawString(curStr, font, this.SummaryBrush, curX,
                                                          (0f + MemberLineHeight * (float)i + 0.02f));
                                }
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public string DisplayInfo(KeyWordInfomation info, string tableName)
        {
            StringBuilder sb             = new StringBuilder();
            IDBAdapter    idba           = info.DBInfo.CurrentDbAdapter;
            bool          isPrimary      = EnumUnit.ContainerValue((int)_propertyType, (int)EntityPropertyType.PrimaryKey);
            bool          isAutoIdentity = EnumUnit.ContainerValue((int)_propertyType, (int)EntityPropertyType.Identity);


            bool needIdentity = false;
            bool putType      = true;

            sb.Append(idba.FormatParam(ParamName) + " ");

            if (isAutoIdentity && TableChecker.IsIdentityType(SqlType))
            {
                if (idba.IdentityIsType)
                {
                    sb.Append(idba.DBIdentity(tableName, _paramName));
                    sb.Append(" ");
                    putType = false;
                }
                else
                {
                    needIdentity = true;
                }
            }


            if (putType)
            {
                sb.Append(idba.DBTypeToSQL(SqlType, Length) + " ");
            }

            bool allowNULL = _allowNull & (!isPrimary);

            //if (isPrimary)
            //{
            //    sb.Append(" primary key ");
            //}
            //else
            //{
            if (isPrimary && info.PrimaryKeys == 1)
            {
                sb.Append(" PRIMARY KEY ");
            }
            else
            {
                if (allowNULL)
                {
                    sb.Append("NULL ");
                }
                else
                {
                    sb.Append("NOT NULL ");
                }
            }
            //}
            if (needIdentity && isAutoIdentity && TableChecker.IsIdentityType(SqlType))
            {
                sb.Append(idba.DBIdentity(tableName, _paramName));
            }
            string comment = idba.GetColumnDescriptionSQL(this, info.DBInfo);

            if (!string.IsNullOrEmpty(comment))
            {
                sb.Append(" ");
                sb.Append(comment);
            }

            return(sb.ToString());
        }