当前位置: 首页>>代码示例>>C#>>正文


C# Coordinate.ToRelative方法代码示例

本文整理汇总了C#中System.Coordinate.ToRelative方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.ToRelative方法的具体用法?C# Coordinate.ToRelative怎么用?C# Coordinate.ToRelative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Coordinate的用法示例。


在下文中一共展示了Coordinate.ToRelative方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToRelative

 public void ToRelative()
 {
     // 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.ToRelative(null));
     Point r = c2.ToRelative(null);
     Assert.AreEqual(r.X, p.X);
     Assert.AreEqual(r.Y, p.Y);
     Assert.Catch<NullReferenceException>(() => c3.ToRelative(null));
     // Normal calls
     Point a = c1.ToRelative(w);
     Assert.AreEqual(a.X, -500);
     Assert.AreEqual(a.Y, -300);
     Point r1 = c2.ToRelative(w);
     Assert.AreEqual(r1.X, p.X);
     Assert.AreEqual(r1.Y, p.Y);
     Point s = c3.ToRelative(w);
     Assert.AreEqual(s.X, 96);
     Assert.AreEqual(s.Y, 120);
 }
开发者ID:antgraf,项目名称:BA,代码行数:26,代码来源:CoordinateTest.cs

示例2: 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();
 }
开发者ID:antgraf,项目名称:BA,代码行数:32,代码来源:HtmlRecorder.cs

示例3: 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));
 }
开发者ID:antgraf,项目名称:BA,代码行数:11,代码来源:CoordinateTest.cs

示例4: 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));
 }
开发者ID:antgraf,项目名称:BA,代码行数:19,代码来源:CoordinateTest.cs

示例5: FindImageCoordinate

 private Coordinate FindImageCoordinate(Coordinate topLeft, Coordinate bottomRight, string imageName)
 {
     Bitmap screen = pEveWindow.Screenshot(topLeft, bottomRight);
     SaveDebugImage(screen);
     Bitmap fragment = new Bitmap(Relative2AbsolutePath(imageName));
     pEveWindow.AllowedColorDeviation = pStandardColorDeviation;
     Coordinate found = pEveWindow.FindImageWithColorDeviation(screen, fragment);
     if(found == null)
     {
         return null;
     }
     WindowEntity.Point rel1 = topLeft.ToRelative(pEveWindow);
     WindowEntity.Point rel2 = found.ToRelative(pEveWindow);
     return new Coordinate(CoordinateType.Relative, new WindowEntity.Point() { X = rel1.X + rel2.X, Y = rel1.Y + rel2.Y });
 }
开发者ID:antgraf,项目名称:BaEveCourier,代码行数:15,代码来源:Eve.Public.cs


注:本文中的System.Coordinate.ToRelative方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。