Esempio n. 1
0
        public void Draw()
        {
            if (caption.GetTextBox() != null || caption.GetTextBox().Width > 0 ||
                caption.GetTextBox().Height > 0)
            {
                switch (context.CaptionPosition)
                {
                case "top":
                    offset = new Point(0, (int)MathF.Round((float)-20));
                    break;

                case "bottom":
                    offset = new Point(0, (int)MathF.Round((float)context.shape.GetShape().Height));
                    break;

                case "left":
                    offset = new Point(-5 * caption.GetTextBox().Text.Length, 0);
                    caption.GetTextBox().HorizontalContentAlignment = HorizontalAlignment.Right;
                    break;

                case "right":
                    offset = new Point((int)MathF.Round((float)context.shape.GetShape().Width), 0);
                    break;

                default:
                    offset = new Point(0, 0);
                    break;
                }
            }
            //caption.SetText("Yeet");
            caption.SetPosition(new Point(context.shape.GetPosition().X + offset.X, context.shape.GetPosition().Y + offset.Y));
        }
Esempio n. 2
0
 public CaptionDecorator(DecoratorContext context, IDecorator parent = null)
 {
     this.context = context;
     this.caption = new Caption(context.shape.GetParent());
     caption.SetText(context.captionText);
     this.parent = parent;
     context.MainWindow.canvas.Children.Add(caption.GetTextBox());
 }