Ejemplo n.º 1
0
        public static object InitUmlInterfaceFocus(IFocus focus, object model)
        {
            var facade = MemopadApplication.Instance;
            //((StyledTextFocus) focus).IsEmacsEdit = facade.Settings.KeyScheme == KeySchemeKind.Emacs;

            var elem = (UmlClassifier)model;

            if (elem != null)
            {
                var stereotypeRun = new Run(UmlTextUtil.GetStereotypeText(elem, "interface"));
                var nameRun       = new Run(elem.Name);
                var para          = new Paragraph(stereotypeRun);
                var line          = new LineSegment();
                line.InsertAfter(nameRun);
                para.InsertAfter(line);
                para.HorizontalAlignment = HorizontalAlignment.Center;
                para.Padding             = Insets.Empty;
                return(new StyledText(para)
                {
                    Font = MemopadApplication.Instance.Settings.GetDefaultUmlFont(),
                    VerticalAlignment = VerticalAlignment.Top,
                });
            }
            else
            {
                return(new StyledText());
            }
        }
Ejemplo n.º 2
0
        protected override void RefreshEditor(RefreshContext context, UmlClassFigure figure, UmlClass model)
        {
            var stereotypeRun = string.IsNullOrEmpty(model.Stereotype)?
                                null:
                                new Run(UmlTextUtil.GetStereotypeText(model));
            var nameRun = new Run(model.Name);

            var para = default(Paragraph);

            if (stereotypeRun == null)
            {
                para = new Paragraph(nameRun)
                {
                    Padding             = Insets.Empty,
                    HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Center,
                };
            }
            else
            {
                para = new Paragraph(stereotypeRun)
                {
                    Padding             = Insets.Empty,
                    HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Center,
                };
                var line = new LineSegment();
                line.InsertBefore(nameRun);
                para.InsertAfter(line);
            }
            var st = new StyledText.Core.StyledText(para)
            {
                Font = MemopadApplication.Instance.Settings.GetDefaultUmlFont(),
                VerticalAlignment = Mkamo.Common.DataType.VerticalAlignment.Top,
            };

            if (model.IsAbstract)
            {
                nameRun.Font = new FontDescription(nameRun.Font, nameRun.Font.Style | FontStyle.Italic);
            }

            figure.StyledText = st;

            var layout = (ListLayout)figure.Layout;

            layout.Padding = new Insets(
                0,
                figure.StyledTextBounds.Height + figure.Padding.Height,
                0,
                0
                );
            figure.InvalidateLayout();

            figure.AdjustSize();

            UpdateMemoMarkHandles(model);
        }
Ejemplo n.º 3
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);
                }
            }
        }