Ejemplo n.º 1
0
        private int DrawTypeMembers(RenderInfo info, int x, int y, int width, UmlTypeMemberSection section)
        {
            var memberCaptionBounds = new Rectangle(x, y, width, 20);

            #region add section header bbox

            var bboxGroup = new BoundingBox();
            bboxGroup.Bounds = memberCaptionBounds;
            bboxGroup.Target = this;
            bboxGroup.Data   = section.CaptionIdentifier;
            info.BoundingBoxes.Add(bboxGroup);

            #endregion

            if (SelectedObject == section.CaptionIdentifier && Selected)
            {
                info.Graphics.FillRectangle(SystemBrushes.Highlight, memberCaptionBounds);
                memberCaptionBounds.X     += 20;
                memberCaptionBounds.Width -= 30;
                memberCaptionBounds.Y     += 3;
                info.Graphics.DrawString(section.Name, Fonts.SectionCaption, SystemBrushes.HighlightText,
                                         memberCaptionBounds);
            }
            else
            {
                Brush sectionCaptionBrush = GetSectionCaptionBrush();
                info.Graphics.FillRectangle(sectionCaptionBrush, memberCaptionBounds);

                memberCaptionBounds.X     += 20;
                memberCaptionBounds.Width -= 30;
                memberCaptionBounds.Y     += 3;
                info.Graphics.DrawString(section.Name, Fonts.SectionCaption, Brushes.Black, memberCaptionBounds);
            }

            #region add section expander bbox

            var bboxGroupExpander = new BoundingBox();
            bboxGroupExpander.Bounds = new Rectangle(x + 4, y + 4, 13, 13);
            bboxGroupExpander.Target = this;
            bboxGroupExpander.Data   = section.ExpanderIdentifier;
            info.BoundingBoxes.Add(bboxGroupExpander);

            #endregion

            if (section.Expanded)
            {
                info.Graphics.DrawImage(Resources.CollapseSection, x + 3, y + 3);
            }
            else
            {
                info.Graphics.DrawImage(Resources.ExpandSection, x + 3, y + 3);
            }


            int currentY = y + 20;
            if (section.Expanded)
            {
                StringFormat sf = StringFormat.GenericTypographic;
                sf.Trimming = StringTrimming.EllipsisCharacter;
                foreach (UmlTypeMember member in section.TypeMembers)
                {
                    var memberBounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16);

                    #region add property bbox

                    var memberBBox = new BoundingBox();
                    memberBBox.Target = this;
                    memberBBox.Bounds = memberBounds;
                    memberBBox.Data   = member;
                    info.BoundingBoxes.Add(memberBBox);

                    #endregion

                    var layoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent,
                                                     currentY, width - 5 - Margins.TypeMemberNameIndent, 16);

                    Font font = GetTypeMemberFont();
                    if (member == SelectedObject && Selected)
                    {
                        var selectionBounds = new Rectangle(x, currentY, width, 16);
                        info.Graphics.FillRectangle(SystemBrushes.Highlight, selectionBounds);
                        info.Graphics.DrawString(member.DataSource.Name, font, SystemBrushes.HighlightText, layoutBounds,
                                                 sf);
                    }
                    else
                    {
                        info.Graphics.DrawString(member.DataSource.Name, font, Brushes.Black, layoutBounds, sf);
                    }
                    info.Graphics.DrawImage(member.DataSource.GetImage(), x + 13, currentY);
                    currentY += 16;
                }

                var newLayoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent,
                                                    currentY, width - 5 - Margins.TypeMemberNameIndent, 16);
                info.Graphics.DrawString("Add new", Fonts.NewTypeMember, Brushes.Blue, newLayoutBounds, sf);

                var newMemberBBox = new BoundingBox();
                newMemberBBox.Target = this;
                newMemberBBox.Bounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16);
                newMemberBBox.Data   = section.AddNewIdentifier;
                info.BoundingBoxes.Add(newMemberBBox);

                currentY += 16;
            }
            return(currentY);
        }
Ejemplo n.º 2
0
        private int DrawTypeMembers(RenderInfo info, int x, int y, int width, UmlTypeMemberSection section)
        {
            var memberCaptionBounds = new Rectangle(x, y, width, 20);

            #region add section header bbox

            var bboxGroup = new BoundingBox();
            bboxGroup.Bounds = memberCaptionBounds;
            bboxGroup.Target = this;
            bboxGroup.Data = section.CaptionIdentifier;
            info.BoundingBoxes.Add(bboxGroup);

            #endregion

            if (SelectedObject == section.CaptionIdentifier && Selected)
            {
                info.Graphics.FillRectangle(SystemBrushes.Highlight, memberCaptionBounds);
                memberCaptionBounds.X += 20;
                memberCaptionBounds.Width -= 30;
                memberCaptionBounds.Y += 3;
                info.Graphics.DrawString(section.Name, Fonts.SectionCaption, SystemBrushes.HighlightText,
                                         memberCaptionBounds);
            }
            else
            {
                Brush sectionCaptionBrush = GetSectionCaptionBrush();
                info.Graphics.FillRectangle(sectionCaptionBrush, memberCaptionBounds);

                memberCaptionBounds.X += 20;
                memberCaptionBounds.Width -= 30;
                memberCaptionBounds.Y += 3;
                info.Graphics.DrawString(section.Name, Fonts.SectionCaption, Brushes.Black, memberCaptionBounds);
            }

            #region add section expander bbox

            var bboxGroupExpander = new BoundingBox();
            bboxGroupExpander.Bounds = new Rectangle(x + 4, y + 4, 13, 13);
            bboxGroupExpander.Target = this;
            bboxGroupExpander.Data = section.ExpanderIdentifier;
            info.BoundingBoxes.Add(bboxGroupExpander);

            #endregion

            if (section.Expanded)
                info.Graphics.DrawImage(Resources.CollapseSection, x + 3, y + 3);
            else
                info.Graphics.DrawImage(Resources.ExpandSection, x + 3, y + 3);

            int currentY = y + 20;
            if (section.Expanded)
            {
                StringFormat sf = StringFormat.GenericTypographic;
                sf.Trimming = StringTrimming.EllipsisCharacter;
                foreach (UmlTypeMember member in section.TypeMembers)
                {
                    var memberBounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16);

                    #region add property bbox

                    var memberBBox = new BoundingBox();
                    memberBBox.Target = this;
                    memberBBox.Bounds = memberBounds;
                    memberBBox.Data = member;
                    info.BoundingBoxes.Add(memberBBox);

                    #endregion

                    var layoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent,
                                                     currentY, width - 5 - Margins.TypeMemberNameIndent, 16);

                    Font font = GetTypeMemberFont();
                    if (member == SelectedObject && Selected)
                    {
                        var selectionBounds = new Rectangle(x, currentY, width, 16);
                        info.Graphics.FillRectangle(SystemBrushes.Highlight, selectionBounds);
                        info.Graphics.DrawString(member.DataSource.Name, font, SystemBrushes.HighlightText, layoutBounds,
                                                 sf);
                    }
                    else
                    {
                        info.Graphics.DrawString(member.DataSource.Name, font, Brushes.Black, layoutBounds, sf);
                    }
                    info.Graphics.DrawImage(member.DataSource.GetImage(), x + 13, currentY);
                    currentY += 16;
                }

                var newLayoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent,
                                                    currentY, width - 5 - Margins.TypeMemberNameIndent, 16);
                info.Graphics.DrawString("Add new", Fonts.NewTypeMember, Brushes.Blue, newLayoutBounds, sf);

                var newMemberBBox = new BoundingBox();
                newMemberBBox.Target = this;
                newMemberBBox.Bounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16);
                newMemberBBox.Data = section.AddNewIdentifier;
                info.BoundingBoxes.Add(newMemberBBox);

                currentY += 16;
            }
            return currentY;
        }