public static object InitUmlOperationFocus(IFocus focus, object model)
        {
            var facade = MemopadApplication.Instance;

            //((StyledTextFocus) focus).IsEmacsEdit = facade.Settings.KeyScheme == KeySchemeKind.Emacs;
            focus.Figure.Padding = MemopadConsts.UmlFeaturePadding;

            var ope = model as UmlOperation;

            if (ope != null)
            {
                var visText    = UmlTextUtil.GetVisibilityText(ope.Visibility);
                var visibility = string.IsNullOrEmpty(visText)? "-": visText;
                var paras      = string.IsNullOrEmpty(ope.Parameters)? "": ope.Parameters;
                var typeName   = string.IsNullOrEmpty(ope.TypeName)? "": ope.TypeName;
                var text       = visibility + " " + ope.Name + "(" + paras + ")" + ": " + typeName;

                var para = new Paragraph(new Run(text))
                {
                    HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Left,
                    Padding             = Insets.Empty,
                };
                return(new StyledText(para)
                {
                    Font = MemopadApplication.Instance.Settings.GetDefaultUmlFont(),
                    VerticalAlignment = VerticalAlignment.Top,
                });
            }
            else
            {
                return(new StyledText());
            }
        }
Exemplo n.º 2
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);
                }
            }
        }