本文整理汇总了C#中Gtk.Window.GetSize方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GetSize方法的具体用法?C# Window.GetSize怎么用?C# Window.GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Window
的用法示例。
在下文中一共展示了Window.GetSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Node n = null;
if (args.Length == 0){
Console.WriteLine ("Must specify the XML file with the data to load");
return;
}
try {
n = LoadNodes (args [0], "Size", "Foo");
} catch {
Console.WriteLine ("Unable to load {0}", args [0]);
throw;
}
Gtk.Application.Init ();
MoonlightRuntime.Init ();
Gtk.Window w = new Gtk.Window ("Foo");
var v = new Gtk.VBox (false, 0);
w.DeleteEvent += delegate {
Gtk.Application.Quit ();
};
w.SetSizeRequest (width, height);
MoonlightHost h = new MoonlightHost ();
v.PackStart (h, true, true, 0);
var back = new Gtk.Button ("Back");
v.PackStart (back, false, false, 0);
w.Add (v);
w.ShowAll ();
// Make it pretty, skip all levels that are just 1 element
while (n.Children.Count == 1)
n = n.Children [0];
// Render
TreemapRenderer r = new TreemapRenderer (n, "");
r.KeyDown += delegate (object sender, KeyEventArgs e) {
if (e.Key == Key.Back)
r.Back ();
};
back.Clicked += delegate {
r.Back ();
};
SetSize (r, width, height);
h.Application.RootVisual = r;
w.ResizeChecked += delegate(object sender, EventArgs e) {
int new_width, new_heigth;
w.GetSize (out new_width, out new_heigth);
SetSize (r, new_width, new_heigth);;
};
Gtk.Application.Run ();
}
示例2: CenterWindow
/// <summary>Centers a window relative to its parent.</summary>
static void CenterWindow (Window child, Window parent)
{
child.Child.Show ();
int w, h, winw, winh, x, y, winx, winy;
child.GetSize (out w, out h);
parent.GetSize (out winw, out winh);
parent.GetPosition (out winx, out winy);
x = Math.Max (0, (winw - w) /2) + winx;
y = Math.Max (0, (winh - h) /2) + winy;
child.Move (x, y);
}
示例3: CenterWindow
/// <summary>Centers a window relative to its parent.</summary>
static void CenterWindow (Window child, Window parent)
{
if (child == null || parent == null)
return;
child.Child.Show ();
int w, h, winw, winh, x, y, winx, winy;
child.GetSize (out w, out h);
parent.GetSize (out winw, out winh);
parent.GetPosition (out winx, out winy);
x = System.Math.Max (0, (winw - w) /2) + winx;
y = System.Math.Max (0, (winh - h) /2) + winy;
child.Move (x, y);
}