private void Redraw() { Sequence <IGraphicsElement> elements = drawing.Draw(); if (elements == null) { return; } canvas.Children.Clear(); ViewTransform vt = new ViewTransform(canvasPos.Left, canvasPos.Top, canvasSize.Y * zoom); IGraphicsElement element; elements.Reset(); while (elements.Next(out element)) { if (!element.AABB.IntersectsWith(canvasPos)) { continue; } UIElement[] shapes = element.Draw(vt); for (int j = 0; j < shapes.Length; ++j) { canvas.Children.Add(shapes[j]); } } this.elements = elements; }
public UIElement[] Draw(ViewTransform vt) { Point p1 = vt.Transform.Transform(new Point(X1, Y1)); Point p2 = vt.Transform.Transform(new Point(X2, Y2)); return(new UIElement[] { new Line() { Stroke = Fill, StrokeThickness = Thickness, X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y } }); }
public UIElement[] Draw(ViewTransform vt) { TextBlock tb = CreateTextBlock(); TransformGroup tg = new TransformGroup() { Children = new TransformCollection() { new TranslateTransform(X, Y), vt.Transform } }; tb.RenderTransform = tg; return(new UIElement[] { tb }); }
public UIElement[] Draw(ViewTransform vt) { Shape[] shapes = Model.Draw(); TransformGroup tg = new TransformGroup() { Children = new TransformCollection() { new ScaleTransform(Scale, Scale), new RotateTransform(Angle), new TranslateTransform(X, Y), vt.Transform } }; for (int i = 0; i < shapes.Length; ++i) { Shape shape = shapes[i]; ((TransformGroup)shape.RenderTransform).Children.Add(tg); shape.Fill = Fill; } return(shapes); }