Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Display 'Properties' as class attributes?

dv7
2010-04-12
2013-04-30
  • dv7
    dv7
    2010-04-12

    Wondering if it is just me to prefer Properties displayed as attributes, group together with other fields? (I may be wrong)

    CompositeTypeShape.cs (my temp. solution)

            protected override void DrawContent(IGraphics g, Style style)
            {
                Rectangle record = new Rectangle(
                    Left + MarginSize, Top + HeaderHeight + MarginSize,
                    Width - MarginSize * 2, MemberHeight);
                // Draw fields
                foreach (Field field in CompositeType.Fields)
                {
                    DrawMember(g, field, record, style);
                    record.Y += MemberHeight;
                }
                // Draw properties
                foreach (Operation operation in CompositeType.Operations)
                {
                    if (operation.MemberType == MemberType.Property)
                    {
                        DrawMember(g, operation, record, style);
                        record.Y += MemberHeight;
                    }
                }
                
                //Draw separator line 
                if (CompositeType.SupportsFields)
                {
                    DrawSeparatorLine(g, record.Top + MarginSize);
                    record.Y += MarginSize * 2;
                }
                // Draw operations (excludes properties)
                foreach (Operation operation in CompositeType.Operations)
                {
                    if (operation.MemberType != MemberType.Property)
                    {
                        DrawMember(g, operation, record, style);
                        record.Y += MemberHeight;
                    }
                }
            }
    
     
  • Balazs Tihanyi
    Balazs Tihanyi
    2010-06-19

    Well, properties are basically methods. I know that they should be used like fields, but they aren't exactly class attributes.
    For automatic properties (from C# 3.0) they are like fields indeed. I'll add support for automatic properties in future versions of NClass, then they will be displayed among attributes just as you prefer.

     
  • dv7
    dv7
    2010-08-05

    Thanks for looking into this.

    I would propose something like Visual Studio Class Diagram. It separates the groups into Fields, Properties, Methods and Events and it looks very nice.

    Well I tried to modified the code, how ever I find the NClass.DiagramEditor.ClassDiagram.Shapes.CompositeType.SelectMember() always miscalculate the index I'm selecting.

     
  • Balazs Tihanyi
    Balazs Tihanyi
    2010-08-10

    Visual Studio's Class Designer is not strict UML. I know, properties and events are not part of the UML class diagrams, but I don't want to separate the classes into more parts like VS does. I think properties and events should be considered as special methods, so no further grouping within classes is needed.

    Anyway, thanks for sharing your thoughts about this issue.