public static Eto.Drawing.PointF ScreenToLogical(this sd.Point point, swf.Screen sdscreen = null) { sdscreen = sdscreen ?? swf.Screen.FromPoint(point); var location = sdscreen.GetLogicalLocation(); var pixelSize = sdscreen.GetLogicalPixelSize(); var x = location.X + (point.X - sdscreen.Bounds.X) / pixelSize; var y = location.Y + (point.Y - sdscreen.Bounds.Y) / pixelSize; return(new Drawing.PointF(x, y)); }
public static Eto.Drawing.PointF ScreenToLogical(this sd.Point point, swf.Screen sdscreen = null) { sdscreen = sdscreen ?? swf.Screen.FromPoint(point); var location = sdscreen.GetLogicalLocation(); var pixelSize = sdscreen.GetLogicalPixelSize(); var sdscreenBounds = sdscreen.GetBounds(); var x = location.X + (point.X - sdscreenBounds.X) / pixelSize; var y = location.Y + (point.Y - sdscreenBounds.Y) / pixelSize; // Console.WriteLine($"In: {point}, out: {x},{y}"); return(new Drawing.PointF(x, y)); }
public static Eto.Drawing.RectangleF ScreenToLogical(this Eto.Drawing.Rectangle rect, swf.Screen screen) { screen = screen ?? swf.Screen.FromPoint(rect.Location.ToSD()); var location = screen.GetLogicalLocation(); var pixelSize = screen.GetLogicalPixelSize(); var screenBounds = screen.GetBounds(); return(new Eto.Drawing.RectangleF( location.X + (rect.X - screenBounds.X) / pixelSize, location.Y + (rect.Y - screenBounds.Y) / pixelSize, rect.Width / pixelSize, rect.Height / pixelSize )); }
public static Eto.Drawing.SizeF GetLogicalSize(this swf.Screen screen) => (Eto.Drawing.SizeF)screen.Bounds.Size.ToEto() / screen.GetLogicalPixelSize();
public static Eto.Drawing.PointF GetLogicalLocation(this swf.Screen screen) { var bounds = screen.Bounds; float x, y; if (bounds.X > 0) { var left = screen.FindLeftScreen(); if (left != null) { x = GetLogicalLocation(left).X + GetLogicalSize(left).Width; } else { x = bounds.X / GetMaxLogicalPixelSize(); } } else if (bounds.X < 0) { var right = screen.FindRightScreen(); if (right != null) { x = GetLogicalLocation(right).X - GetLogicalSize(screen).Width; } else { x = bounds.X / screen.GetLogicalPixelSize(); } } else { x = bounds.X; } if (bounds.Y > 0) { var top = screen.FindTopScreen(); if (top != null) { y = GetLogicalLocation(top).Y + GetLogicalSize(top).Height; } else { y = bounds.Y / GetMaxLogicalPixelSize(); } } else if (bounds.Y < 0) { var bottom = screen.FindBottomScreen(); if (bottom != null) { y = GetLogicalLocation(bottom).Y - GetLogicalSize(screen).Height; } else { y = bounds.Y / screen.GetLogicalPixelSize(); } } else { y = bounds.Y; } return(new Eto.Drawing.PointF(x, y)); }