本文整理汇总了C#中System.Coordinate.ToStretched方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.ToStretched方法的具体用法?C# Coordinate.ToStretched怎么用?C# Coordinate.ToStretched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Coordinate
的用法示例。
在下文中一共展示了Coordinate.ToStretched方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointInformation
private static string PointInformation()
{
StringBuilder text = new StringBuilder();
Window window = Window.GetWindowAtCursor();
Coordinate pt = new Coordinate(CoordinateType.Absolute, new WindowEntity.Point() { X = Cursor.Position.X, Y = Cursor.Position.Y });
Color color = Desktop.Primary.GetPixelColor(pt);
if(window != null)
{
WindowEntity.Point rel = pt.ToRelative(window);
StretchedPoint st = pt.ToStretched(window);
text.Append("<b>Window</b>: ");
text.AppendFormat("[{0}, {1}] ", window.Width, window.Height);
text.AppendFormat("\"{0}\"", window.Title);
text.AppendLine();
text.Append("<br><b>Color</b>: ");
text.AppendLine(color.ToString());
text.Append("<br><b>Coordinate</b>: Absolute: ");
text.AppendFormat("X = {0}, Y = {1}", pt.X, pt.Y);
text.Append("; Relative: ");
text.AppendFormat("X = {0}, Y = {1}", rel.X, rel.Y);
text.Append("; Stretched: ");
text.AppendFormat(CultureInfo.InvariantCulture, "X = {0}, Y = {1}", st.X, st.Y);
}
else
{
text.Append("<b>Color</b>: ");
text.AppendLine(color.ToString());
text.Append("<br><b>Coordinate</b>: Absolute: ");
text.AppendFormat("{0}, {1}", pt.X, pt.Y);
}
return text.ToString();
}
示例2: WrongPoint
public void WrongPoint()
{
StretchedPoint wrongP1 = new StretchedPoint {X = 100.0, Y = 0.0};
StretchedPoint wrongP2 = new StretchedPoint {X = 0.0, Y = 100.0};
StretchedPoint wrongP3 = new StretchedPoint {X = 100.0, Y = 200.0};
Coordinate c1 = new Coordinate(wrongP1);
Coordinate c2 = new Coordinate(wrongP2);
Coordinate c3 = new Coordinate(wrongP3);
Window w = CreateStdWindow();
Assert.Catch<CoordinatesOutOfRangeException>(() => c1.ToAbsolute(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c2.ToAbsolute(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c3.ToAbsolute(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c1.ToRelative(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c2.ToRelative(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c3.ToRelative(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c1.ToStretched(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c2.ToStretched(w));
Assert.Catch<CoordinatesOutOfRangeException>(() => c3.ToStretched(w));
}
示例3: ToStretched
public void ToStretched()
{
// Init
Point p = CreateStdPoint();
StretchedPoint sp = CreateStdStretchedPoint();
Window w = CreateStdWindow();
Coordinate c1 = new Coordinate(CoordinateType.Absolute, p);
Coordinate c2 = new Coordinate(CoordinateType.Relative, p);
Coordinate c3 = new Coordinate(sp);
// Null argument
Assert.Catch<NullReferenceException>(() => c1.ToStretched(null));
Assert.Catch<NullReferenceException>(() => c2.ToStretched(null));
StretchedPoint s = c3.ToStretched(null);
Assert.AreEqual(s.X, sp.X);
Assert.AreEqual(s.Y, sp.Y);
// Normal calls
StretchedPoint a = c1.ToStretched(w);
Assert.AreEqual(a.X, -0.78125);
Assert.AreEqual(a.Y, -0.625);
StretchedPoint r = c2.ToStretched(w);
Assert.AreEqual(r.X, 0.15625);
Assert.AreEqual(r.Y, 0.41666666666666666);
StretchedPoint s1 = c3.ToStretched(w);
Assert.AreEqual(s1.X, sp.X);
Assert.AreEqual(s1.Y, sp.Y);
}
示例4: WrongCalls
public void WrongCalls()
{
Window w = CreateStdWindow();
Coordinate c0 = new Coordinate();
Assert.Catch<InitializationException>(() => c0.ToAbsolute(null));
Assert.Catch<InitializationException>(() => c0.ToAbsolute(w));
Assert.Catch<InitializationException>(() => c0.ToRelative(null));
Assert.Catch<InitializationException>(() => c0.ToRelative(w));
Assert.Catch<InitializationException>(() => c0.ToStretched(null));
Assert.Catch<InitializationException>(() => c0.ToStretched(w));
}