Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }