public void TranslateTransform () { using (Pen p = new Pen (Brushes.Red)) { p.TranslateTransform (1, 1); float[] elements = p.Transform.Elements; Assert.AreEqual (1, elements[0], 0.1, "matrix.0"); Assert.AreEqual (0, elements[1], 0.1, "matrix.1"); Assert.AreEqual (0, elements[2], 0.1, "matrix.2"); Assert.AreEqual (1, elements[3], 0.1, "matrix.3"); Assert.AreEqual (1, elements[4], 0.1, "matrix.4"); Assert.AreEqual (1, elements[5], 0.1, "matrix.5"); p.TranslateTransform (-1, -1); elements = p.Transform.Elements; Assert.AreEqual (1, elements[0], 0.1, "revert.matrix.0"); Assert.AreEqual (0, elements[1], 0.1, "revert.matrix.1"); Assert.AreEqual (0, elements[2], 0.1, "revert.matrix.2"); Assert.AreEqual (1, elements[3], 0.1, "revert.matrix.3"); Assert.AreEqual (0, elements[4], 0.1, "revert.matrix.4"); Assert.AreEqual (0, elements[5], 0.1, "revert.matrix.5"); } }
public void Transform_Operations () { using (Pen p = new Pen (Brushes.Red)) { Matrix clone = p.Transform.Clone (); Matrix mul = clone.Clone (); clone.Multiply (mul, MatrixOrder.Append); p.MultiplyTransform (mul, MatrixOrder.Append); Assert.AreEqual (p.Transform, clone, "Multiply/Append"); clone.Multiply (mul, MatrixOrder.Prepend); p.MultiplyTransform (mul, MatrixOrder.Prepend); Assert.AreEqual (p.Transform, clone, "Multiply/Prepend"); clone.Rotate (45, MatrixOrder.Append); p.RotateTransform (45, MatrixOrder.Append); Assert.AreEqual (p.Transform, clone, "Rotate/Append"); clone.Rotate (45, MatrixOrder.Prepend); p.RotateTransform (45, MatrixOrder.Prepend); Assert.AreEqual (p.Transform, clone, "Rotate/Prepend"); clone.Scale (0.25f, 2, MatrixOrder.Append); p.ScaleTransform (0.25f, 2, MatrixOrder.Append); Assert.AreEqual (p.Transform, clone, "Scale/Append"); clone.Scale (0.25f, 2, MatrixOrder.Prepend); p.ScaleTransform (0.25f, 2, MatrixOrder.Prepend); Assert.AreEqual (p.Transform, clone, "Scale/Prepend"); clone.Translate (10, 20, MatrixOrder.Append); p.TranslateTransform (10, 20, MatrixOrder.Append); Assert.AreEqual (p.Transform, clone, "Translate/Append"); clone.Translate (30, 40, MatrixOrder.Prepend); p.TranslateTransform (30, 40, MatrixOrder.Prepend); Assert.AreEqual (p.Transform, clone, "Translate/Prepend"); clone.Reset (); p.ResetTransform (); Assert.AreEqual (p.Transform, clone, "Reset"); } }
void CheckMethods (Pen pen, String tag) { // Try modifying a SystemPen by calling methods. // ArgumentException must be thrown in some cases. /* try { // NotImplemented pen.SetLineCap (LineCap.Flat, LineCap.Round, DashCap.Triangle); Assert.Fail (tag + "#1: must throw ArgumentException"); } catch (ArgumentException) { Assert.IsTrue (tag + "#1", true); } */ pen.ResetTransform (); pen.RotateTransform (90); pen.ScaleTransform (2, 1); pen.TranslateTransform (10, 20); pen.MultiplyTransform (new Matrix ()); pen.Clone (); try { pen.Dispose (); Assert.Fail (tag + "#8: must throw ArgumentException"); } catch (ArgumentException) { Assert.IsTrue (true, tag + "#8"); } }