本文整理汇总了C#中Gdk.GetMonitorGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.GetMonitorGeometry方法的具体用法?C# Gdk.GetMonitorGeometry怎么用?C# Gdk.GetMonitorGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk
的用法示例。
在下文中一共展示了Gdk.GetMonitorGeometry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MacGetUsableMonitorGeometry
static Gdk.Rectangle MacGetUsableMonitorGeometry (Gdk.Screen screen, int monitor)
{
InitMac ();
IntPtr array = objc_msgSend_IntPtr (cls_NSScreen, sel_screens);
IntPtr iter = objc_msgSend_IntPtr (array, sel_objectEnumerator);
RectangleF visible, frame;
IntPtr scrn;
int i = 0;
while ((scrn = objc_msgSend_IntPtr (iter, sel_nextObject)) != IntPtr.Zero && i < monitor)
i++;
if (scrn == IntPtr.Zero)
return screen.GetMonitorGeometry (monitor);
objc_msgSend_RectangleF (out visible, scrn, sel_visibleFrame);
objc_msgSend_RectangleF (out frame, scrn, sel_frame);
// VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
// to get the menu height, we just figure out the difference between the visibleFrame height
// and the actual frame height, then subtract the Dock height.
//
// We need to swap the Y offset with the menu height because our callers expect the Y offset
// to be from the top of the screen, not from the bottom of the screen.
float menubar = (frame.Height - visible.Height) - visible.Y;
visible.Y = menubar;
return new Gdk.Rectangle ((int) visible.X, (int) visible.Y, (int) visible.Width, (int) visible.Height);
}
示例2: GetUsableMonitorGeometry
public override Gdk.Rectangle GetUsableMonitorGeometry (Gdk.Screen screen, int monitor_id)
{
Gdk.Rectangle ygeometry = screen.GetMonitorGeometry (monitor_id);
Gdk.Rectangle xgeometry = screen.GetMonitorGeometry (0);
NSScreen monitor = NSScreen.Screens[monitor_id];
RectangleF visible = monitor.VisibleFrame;
RectangleF frame = monitor.Frame;
// Note: Frame and VisibleFrame rectangles are relative to monitor 0, but we need absolute
// coordinates.
visible.X += xgeometry.X;
frame.X += xgeometry.X;
// VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
// to get the menu height, we just figure out the difference between the visibleFrame height
// and the actual frame height, then subtract the Dock height.
//
// We need to swap the Y offset with the menu height because our callers expect the Y offset
// to be from the top of the screen, not from the bottom of the screen.
float x, y, width, height;
if (visible.Height <= frame.Height) {
float dockHeight = visible.Y - frame.Y;
float menubarHeight = (frame.Height - visible.Height) - dockHeight;
height = frame.Height - menubarHeight - dockHeight;
y = ygeometry.Y + menubarHeight;
} else {
height = frame.Height;
y = ygeometry.Y;
}
// Takes care of the possibility of the Dock being positioned on the left or right edge of the screen.
width = Math.Min (visible.Width, frame.Width);
x = Math.Max (visible.X, frame.X);
return new Gdk.Rectangle ((int) x, (int) y, (int) width, (int) height);
}
示例3: GetUsableMonitorGeometry
public override Gdk.Rectangle GetUsableMonitorGeometry (Gdk.Screen screen, int monitor_id)
{
Gdk.Rectangle geometry = screen.GetMonitorGeometry (monitor_id);
List<MonitorInfo> screens = new List<MonitorInfo> ();
EnumDisplayMonitors (IntPtr.Zero, IntPtr.Zero, delegate (IntPtr hmonitor, IntPtr hdc, IntPtr prect, IntPtr user_data) {
var info = new MonitorInfo ();
unsafe {
info.Size = sizeof (MonitorInfo);
}
GetMonitorInfoA (hmonitor, ref info);
// In order to keep the order the same as Gtk, we need to put the primary monitor at the beginning.
if ((info.Flags & MonitorInfoFlagsPrimary) != 0)
screens.Insert (0, info);
else
screens.Add (info);
return 1;
}, IntPtr.Zero);
MonitorInfo monitor = screens[monitor_id];
Rect visible = monitor.VisibleFrame;
Rect frame = monitor.Frame;
// Rebase the VisibleFrame off of Gtk's idea of this monitor's geometry (since they use different coordinate systems)
int x = geometry.X + (visible.Left - frame.Left);
int width = visible.Width;
int y = geometry.Y + (visible.Top - frame.Top);
int height = visible.Height;
return new Gdk.Rectangle (x, y, width, height);
}
示例4: MacGetUsableMonitorGeometry
static Gdk.Rectangle MacGetUsableMonitorGeometry (Gdk.Screen screen, int monitor)
{
IntPtr array = objc_msgSend_IntPtr (cls_NSScreen, sel_screens);
IntPtr iter = objc_msgSend_IntPtr (array, sel_objectEnumerator);
Gdk.Rectangle geometry = screen.GetMonitorGeometry (0);
RectangleF visible, frame;
IntPtr scrn;
int i = 0;
while ((scrn = objc_msgSend_IntPtr (iter, sel_nextObject)) != IntPtr.Zero && i < monitor)
i++;
if (scrn == IntPtr.Zero)
return screen.GetMonitorGeometry (monitor);
objc_msgSend_RectangleF (out visible, scrn, sel_visibleFrame);
objc_msgSend_RectangleF (out frame, scrn, sel_frame);
// Note: Frame and VisibleFrame rectangles are relative to monitor 0, but we need absolute
// coordinates.
visible.X += geometry.X;
visible.Y += geometry.Y;
frame.X += geometry.X;
frame.Y += geometry.Y;
// VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
// to get the menu height, we just figure out the difference between the visibleFrame height
// and the actual frame height, then subtract the Dock height.
//
// We need to swap the Y offset with the menu height because our callers expect the Y offset
// to be from the top of the screen, not from the bottom of the screen.
float x, y, width, height;
if (visible.Height < frame.Height) {
float dockHeight = visible.Y;
float menubarHeight = (frame.Height - visible.Height) - dockHeight;
height = frame.Height - menubarHeight - dockHeight;
y = menubarHeight;
} else {
height = frame.Height;
y = frame.Y;
}
// Takes care of the possibility of the Dock being positioned on the left or right edge of the screen.
width = System.Math.Min (visible.Width, frame.Width);
x = System.Math.Max (visible.X, frame.X);
return new Gdk.Rectangle ((int) x, (int) y, (int) width, (int) height);
}