示例#1
0
        private SizeD CalculateSize()
        {
            ListField         listField   = ListField;
            int               count       = this.GetItemCount(listField);
            double            height      = HeaderBounds.Height + listField.GetItemHeight(this) * count;
            double            width       = 0;
            BarkerEntityShape entityShape = ParentShape as BarkerEntityShape;

            string   entityName     = entityShape.AccessibleName;
            StyleSet styleSet       = StyleSet;
            Font     defaultFont    = styleSet.GetFont(listField.NormalFontId);
            Font     alternateFont  = styleSet.GetFont(listField.AlternateFontId);
            Font     entityNameFont = entityShape.StyleSet.GetFont(new StyleSetResourceId(string.Empty, "ShapeTextBold10"));

            using (Graphics g = Graphics.FromHwnd(GetDesktopWindow()))
            {
                double entityNameWidth = (double)g.MeasureString(entityName, entityNameFont, int.MaxValue, DefaultStringFormat).Width + BarkerEntityExtraWidth;

                // Changes the width if the current width is less than the width of the table name.
                if (width < entityNameWidth)
                {
                    width = entityNameWidth;
                }
                // Iterates through the column list to check the widths of the column names.
                for (int i = 0; i < count; ++i)
                {
                    ItemDrawInfo itemDrawInfo = new ItemDrawInfo();
                    GetItemDrawInfo(listField, i, itemDrawInfo);
                    bool   isMandatory = (this.Items[i] as Barker.Attribute).IsMandatory;
                    string text        = itemDrawInfo.Text;

                    // Gets the size of the column name in the context of the compartment
                    double stringWidth = (double)g.MeasureString(text, isMandatory ? alternateFont : defaultFont, int.MaxValue, DefaultStringFormat).Width + AttributeExtraWidth;

                    // Changes the width if the current width is less than the width of the column name.
                    if (width < stringWidth)
                    {
                        width = stringWidth;
                    }
                }
            }
            return(new SizeD(width, height));
        }
示例#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));
                                }
                            }
                        }
                    }
                }
            }
        }