Ejemplo n.º 1
0
        public override VisualItem Draw()
        {
            var visual = new VisualItem();

            using (var context = visual.RenderOpen())
            {
                var text = new FormattedText(
                    this.Text,
                    CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight,
                    new Typeface("Verdana"),
                    12,
                    Brushes.Black);

                double x = IsRotated
                    ? this.X
                    : this.X - (text.Width / 2);

                double y = IsRotated
                    ? this.Y + (text.Width / 2)
                    : this.Y - text.Height;

                if (IsRotated)
                {
                    visual.Transform = new RotateTransform(-90, x, y);
                }

                context.DrawText(text, new Point(x, y));
            }

            return(visual);
        }
Ejemplo n.º 2
0
        public override VisualItem Draw()
        {
            var visual = new VisualItem();

            visual.Id = Id;

            double x           = X - Width / 2;
            double y           = Y - Height / 2;
            double scaleX      = Width / Image.Width;
            double scaleY      = Height / Image.Height;
            double imageScale  = Math.Min(scaleX, scaleY);
            double imageWidth  = Image.Width * imageScale;
            double imageHeight = Image.Height * imageScale;
            double imageX      = X - imageWidth / 2;
            double imageY      = Y - imageHeight / 2;

            var pen = GetPen();

            using (var context = visual.RenderOpen())
            {
                var rectangle = new Rect(x, y, Width, Height);

                context.DrawRectangle(Brushes.White, pen, rectangle);

                var imageRectangle = new Rect(imageX, imageY, imageWidth, imageHeight);

                context.DrawImage(Image, imageRectangle);
            }

            return(visual);
        }
Ejemplo n.º 3
0
        public override VisualItem Draw()
        {
            var background = new VisualItem();

            using (var context = background.RenderOpen())
            {
                var rectangle = new Rect(0, 0, this.Width, this.Height);
                context.DrawRectangle(Brushes.White, null, rectangle);
            }

            return(background);
        }
Ejemplo n.º 4
0
        public override VisualItem Draw()
        {
            var pen = new Pen(Brushes.LightGray, 1);

            var visual = new VisualItem();

            using (var context = visual.RenderOpen())
            {
                context.DrawLine(pen, new Point(X1, Y1), new Point(X2, Y2));
            }

            return(visual);
        }
Ejemplo n.º 5
0
        public override VisualItem Draw()
        {
            var visual = new VisualItem();

            visual.Id = Id;

            // TODO: Move default brush and pen to static fields and intialize / freeze in static constructer
            var brush = new SolidColorBrush(Color);

            brush.Freeze();

            var pen = GetPen();

            using (var context = visual.RenderOpen())
            {
                context.DrawEllipse(brush, pen, new Point(this.X, this.Y), this.Radius, this.Radius);
            }

            return(visual);
        }