コード例 #1
0
ファイル: PenTest.cs プロジェクト: nlhepler/mono
		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");
			}
		}
コード例 #2
0
ファイル: PenTest.cs プロジェクト: nlhepler/mono
		public void ScaleTransform ()
		{
			using (Pen p = new Pen (Brushes.Red)) {
				p.ScaleTransform (2, 4);
				float[] elements = p.Transform.Elements;
				Assert.AreEqual (2, 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 (4, elements[3], 0.1, "matrix.3");
				Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
				Assert.AreEqual (0, elements[5], 0.1, "matrix.5");

				p.ScaleTransform (0.5f, 0.25f);
				Assert.IsTrue (p.Transform.IsIdentity, "Transform.IsIdentity");
			}
		}
コード例 #3
0
ファイル: PenTest.cs プロジェクト: nlhepler/mono
		public void ScaleTransform_MaxMin ()
		{
			using (Pen p = new Pen (Brushes.Red)) {
				p.ScaleTransform (Single.MaxValue, Single.MinValue);
				float[] elements = p.Transform.Elements;
				Assert.AreEqual (Single.MaxValue, elements[0], 1e33, "matrix.0");
				Assert.AreEqual (0, elements[1], 0.1, "matrix.1");
				Assert.AreEqual (0, elements[2], 0.1, "matrix.2");
				Assert.AreEqual (Single.MinValue, elements[3], 1e33, "matrix.3");
				Assert.AreEqual (0, elements[4], 0.1, "matrix.4");
				Assert.AreEqual (0, elements[5], 0.1, "matrix.5");
			}
		}
コード例 #4
0
ファイル: TestSystemPens.cs プロジェクト: nlhepler/mono
		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");
			}
		}