本文整理汇总了C#中System.Drawing.Pen.TranslateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.TranslateTransform方法的具体用法?C# Pen.TranslateTransform怎么用?C# Pen.TranslateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.TranslateTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateTransform
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");
}
}
示例2: Transform_Operations
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");
}
}
示例3: CheckMethods
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");
}
}