Why this geometry transform doesn't work?
private void DrawElement(DrawingVisual dv)
{
using (var dvc = dv.RenderOpen())
{
GeometryGroup gg = new GeometryGroup();
var pen = new Pen(Brushes.Black, 2);
TranslateTransform tt = new TranslateTransform(0, (!IsInverted ? -1 : 1) * _pixelsPerMillimeter);
TransformGroup tg = new TransformGroup();
Point lu, lb, ru, rb;
lu = new Point(rct_center.Left, (!IsMaxillar ? rct_center.Bottom - _pixelsPerMillimeter : _pixelsPerMillimeter + rct_center.Top));//
lb = new Point(lu.X, lu.Y + (!IsInverted ? -1 : 1) * rct_center.Height / 2);//
ru = new Point(rct_center.Right - _pixelsPerMillimeter, lu.Y);//
rb = new Point(ru.X, lb.Y);//
LineGeometry upperLeft = new LineGeometry(lu, new Point(lu.X + _pixelsPerMillimeter, lu.Y));
LineGeometry bottomLeft = new LineGeometry(lb, new Point(lb.X + _pixelsPerMillimeter, lb.Y));
LineGeometry upperRight = new LineGeometry(ru, new Point(ru.X + _pixelsPerMillimeter, ru.Y));
LineGeometry bottomRight = new LineGeometry(rb, new Point(rb.X + _pixelsPerMillimeter, rb.Y));
gg.Children.Add(upperLeft);
gg.Children.Add(bottomLeft);
gg.Children.Add(upperRight);
gg.Children.Add(bottomRight);
for (int j = 30 - 1; j >= 0; --j) //-1 because the start line isn't drawn.
{
dvc.DrawGeometry(Brushes.Transparent, pen, gg);
tg.Children.Add(tt);
gg.Transform = tg;
}
}
}
I want to draw repeatedly the 4 lines group below the previous or viceversa (if IsInverted). When I debug the transformgroup matrix is modified, but the transformation isn't applied in the geometry group. I'm newbie in wpf, from winforms and i'm a little bit lost without GDI GraphicsPath.
There is someway to do it better? Maybe i'm thinking a lot in GDI way to do it.