private void UpdateMemberEndNameLabel(LineEdge figure, UmlProperty end, bool isSource) { var locKind = isSource? "EdgeFirstDistance": "EdgeLastDistance"; var nameLabels = figure.Children.Where( fig => { var constraint = figure.GetLayoutConstraint(fig) as object[]; var kind = (string)constraint[0]; var dir = (LocateDirectionKind)constraint[3]; return(kind == locKind && dir == LocateDirectionKind.Left); } ); var name = end.Name; if (string.IsNullOrEmpty(name)) { foreach (var label in nameLabels.ToArray()) { figure.Children.Remove(label); } } else { var text = name; if (!StringUtil.IsNullOrWhitespace(end.Stereotype)) { text = UmlTextUtil.GetStereotypeText(end) + " " + text; } if (end.Visibility != UmlVisibilityKind.None) { text = UmlTextUtil.GetVisibilityText(end.Visibility) + " " + text; } if (nameLabels.Any()) { var label = nameLabels.First() as INode; label.StyledText = CreateLabelStyledText(text); } else { var label = new Mkamo.Figure.Figures.Label(); label.StyledText = CreateLabelStyledText(text); figure.Children.Add(label); var constraint = IsOrthogonal() ? new object[] { locKind, 4, 0, LocateDirectionKind.Left } : new object[] { locKind, 8, 8, LocateDirectionKind.Left }; figure.SetLayoutConstraint(label, constraint); } } }
// ======================================== // method // ======================================== public static string GetAttributeText(UmlProperty attr) { var text = attr.Name; if (!string.IsNullOrEmpty(attr.Stereotype)) { text = GetStereotypeText(attr) + " " + text; } if (attr.Visibility != UmlVisibilityKind.None) { text = GetVisibilityText(attr.Visibility) + " " + text; } if (attr.IsDerived) { text = "/ " + text; } if (!string.IsNullOrEmpty(attr.TypeName)) { text += ": " + attr.TypeName; } if (!string.IsNullOrEmpty(attr.Default)) { text += " = " + attr.Default; } if (attr.Lower != 1 || attr.Upper != 1 || attr.IsUpperUnlimited) { text += " [" + GetMultiplicityText(attr) + "]"; } if (attr.IsOrdered || attr.IsUnique) { text += " " + GetMultiplicityOptionText(attr); } if (attr.IsReadOnly) { text += " {readOnly}"; } return(text); }
private void UpdateMemberEndMultiplicityLabel(LineEdge figure, UmlProperty end, bool isSource) { var locKind = isSource? "EdgeFirstDistance": "EdgeLastDistance"; var multiLabels = figure.Children.Where( fig => { var constraint = figure.GetLayoutConstraint(fig) as object[]; var kind = (string)constraint[0]; var dir = (LocateDirectionKind)constraint[3]; return(kind == locKind && dir == LocateDirectionKind.Right); } ); var text = UmlTextUtil.GetMultiplicityText(end); if (string.IsNullOrEmpty(text)) { foreach (var label in multiLabels.ToArray()) { figure.Children.Remove(label); } } else { if (multiLabels.Any()) { var label = multiLabels.First() as INode; label.StyledText = CreateLabelStyledText(text); } else { var label = new Mkamo.Figure.Figures.Label(); label.StyledText = CreateLabelStyledText(text); figure.Children.Add(label); var constraint = IsOrthogonal() ? new object[] { locKind, 4, 0, LocateDirectionKind.Right } : new object[] { locKind, 8, 8, LocateDirectionKind.Right }; figure.SetLayoutConstraint(label, constraint); } } }
public UmlDiagramClassProperty(UmlProperty umlProperty) : base(umlProperty) { UmlProperty = umlProperty; }
// ======================================== // constructor // ======================================== public UmlPropertyUIProvider(UmlPropertyController controller, UmlProperty property) : base(controller) { _property = property; }
private void Form1_Load(object sender, EventArgs e) { //if (openFileDialog1.ShowDialog() == DialogResult.OK) //{ // Hashtable classLookup = new Hashtable(); // IDomainMap dm = DomainMap.Load(openFileDialog1.FileName); // foreach (IClassMap classMap in dm.ClassMaps) // { // UmlType umlClass = new UmlType(); // umlClass.TypeName = classMap.Name; // foreach (IPropertyMap propertyMap in classMap.PropertyMaps) // { // UmlProperty umlProperty = new UmlProperty(); // umlProperty.Name = propertyMap.Name; // umlProperty.Type = propertyMap.DataType; // umlClass.Properties.Add(umlProperty); // } // umlClass.Bounds = new Rectangle(0, 0, 200, 10); // umlClass.Expanded = true; // umlDesigner1.Diagram.Shapes.Add(umlClass); // classLookup.Add(umlClass.TypeName, umlClass); // } // foreach (IClassMap classMap in dm.ClassMaps) // { // foreach (IPropertyMap propertyMap in classMap.PropertyMaps) // { // if (propertyMap.ReferenceType != Puzzle.NPersist.Framework.Enumerations.ReferenceType.None) // { // UmlType start = (UmlType)classLookup[classMap.Name]; // UmlType end = (UmlType)classLookup[propertyMap.DataType]; // UmlConnection umlConnection = new UmlConnection(); // umlConnection.Start = start; // umlConnection.End = end; // umlDesigner1.Diagram.Shapes.Add(umlConnection); // } // } // } //} umlDesigner1.AutoLayout(); UmlType person = new UmlType(); person.Bounds = new Rectangle(1 * 21, 1 * 21, 7 * 21, 2 * 21); person.TypeName = "Person"; umlDesigner1.Diagram.Shapes.Add(person); UmlType employee = new UmlType(); employee.Bounds = new Rectangle(3 * 21, 6 * 21, 7 * 21, 2 * 21); employee.Expanded = true; UmlProperty prop = new UmlProperty(); prop.Name = "Name"; prop.Type = "System.String"; employee.Properties.Members.Add(prop); prop = new UmlProperty(); prop.Name = "Age"; prop.Type = "System.Int32"; employee.Properties.Members.Add(prop); employee.InheritsType = person; employee.TypeName = "Employee"; umlDesigner1.Diagram.Shapes.Add(employee); UmlConnection connection1 = new UmlConnection(); connection1.Start = employee; connection1.End = person; umlDesigner1.Diagram.Shapes.Add(connection1); //employee.BorderPen = new Pen(Color.Black, 1); //employee.BorderPen.DashCap = DashCap.Round; //employee.BorderPen.DashStyle = DashStyle.Dash; //person.BorderPen = new Pen(Color.Gray, 2); //person.BorderPen.DashCap = DashCap.Round; //person.BorderPen.DashStyle = DashStyle.Dash; }