本文整理汇总了C#中Gtk.Window.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GetPosition方法的具体用法?C# Window.GetPosition怎么用?C# Window.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Window
的用法示例。
在下文中一共展示了Window.GetPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModernDialog
public ModernDialog(string title, Window owner)
: base(title)
{
this.WidthRequest = 350;
this.HeightRequest = 180;
this.ShowMinimize = false;
this.WindowPosition = WindowPosition.None;
this.KeepAbove = true;
this.Modal = true;
_response = ResponseType.None;
if (owner != null)
{
int root_x, root_y;
owner.GetPosition(out root_x, out root_y);
this.Move(root_x + (owner.WidthRequest / 2) - (this.WidthRequest / 2),
root_y + (owner.HeightRequest / 2) - (this.HeightRequest / 2));
}
this.text = new global::Gtk.TextView();
this.text.WrapMode = Gtk.WrapMode.Word;
this.text.CanFocus = true;
this.text.Editable = false;
this.text.WidthRequest = (int)(this.WidthRequest * 0.8);
this.GridMain.Add(this.text);
global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.text]));
w2.X = 50;
w2.Y = 70;
this.btn1 = new Button();
this.btn1.Clicked += btn1_Clicked;
this.btn1.WidthRequest = 100;
this.btn1.HeightRequest = 30;
this.GridMain.Add(this.btn1);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn1]));
w2.X = 75;
w2.Y = 120;
this.btn2 = new Button();
this.btn2.Clicked += btn2_Clicked;
this.btn2.WidthRequest = 100;
this.btn2.HeightRequest = 30;
this.GridMain.Add(this.btn2);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn2]));
w2.X = 175;
w2.Y = 120;
this.ShowObjects();
}
示例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: ConfigWindow
public ConfigWindow(Window owner)
: base("config")
{
this.WidthRequest = 500;
this.HeightRequest = 300;
this.ShowMinimize = false;
this.Modal = true;
this.WindowPosition = Gtk.WindowPosition.None;
int root_x, root_y;
owner.GetPosition(out root_x, out root_y);
this.Move(root_x + (owner.WidthRequest / 2) - (this.WidthRequest / 2),
root_y + (owner.HeightRequest / 2) - (this.HeightRequest / 2));
this.lblPort = new global::Gtk.Label();
this.lblPort.LabelProp = "Server Port:";
this.GridMain.Add(this.lblPort);
global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.lblPort]));
w2.X = 40;
w2.Y = 62;
this.txtPort = new global::Gtk.Entry();
this.txtPort.WidthRequest = 100;
this.GridMain.Add(this.txtPort);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.txtPort]));
w2.X = 110;
w2.Y = 60;
this.cbStartup = new CheckButton();
this.cbStartup.Label = "Start the web server when the PC starts up";
this.GridMain.Add(this.cbStartup);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.cbStartup]));
w2.X = 40;
w2.Y = 85;
this.cbMinimize = new CheckButton();
this.cbMinimize.Label = "Minimize on startup";
this.GridMain.Add(this.cbMinimize);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.cbMinimize]));
w2.X = 40;
w2.Y = 105;
this.swNetworkCards = new ScrolledWindow();
this.swNetworkCards.WidthRequest = 400;
this.swNetworkCards.HeightRequest = 100;
this.swNetworkCards.ShadowType = ((global::Gtk.ShadowType)(1));
this.GridMain.Add(this.swNetworkCards);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.swNetworkCards]));
w2.X = 40;
w2.Y = 130;
this.tNetworkCards = new Table(6, 2, false);
this.tNetworkCards.RowSpacing = (6);
this.tNetworkCards.ColumnSpacing = (6);
global::Gtk.Viewport w1 = new global::Gtk.Viewport();
w1.ShadowType = ((global::Gtk.ShadowType)(0));
w1.Add(tNetworkCards);
this.swNetworkCards.Add(w1);
_lstNetworkCards = new List<NetworkCard>();
List<string> ids = Globals.ReadEnvironmentVariables(Globals.V_NetworkID);
IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
NetworkInterface[] netInterfaces = NetworkInterface.GetAllNetworkInterfaces();
uint i = 0;
foreach (NetworkInterface adapter in netInterfaces)
{
var ipProps = adapter.GetIPProperties();
foreach (var ip in ipProps.UnicastAddresses)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
{
CheckButton cbNetworkCard = new CheckButton();
cbNetworkCard.Active = ids.Contains(adapter.Id);
cbNetworkCard.Label = String.Format("{0} - {1}", adapter.Name, ip.Address.ToString());
this.tNetworkCards.Add(cbNetworkCard);
tNetworkCards.Add(cbNetworkCard);
global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.tNetworkCards[cbNetworkCard]));
w3.TopAttach = i++;
w3.YOptions = ((global::Gtk.AttachOptions)(4));
NetworkCard networkCard = new NetworkCard();
networkCard.ID = adapter.Id;
networkCard.NetworkName = adapter.Name;
networkCard.IPAddress = ip.Address.ToString();
networkCard.CheckBox = cbNetworkCard;
_lstNetworkCards.Add(networkCard);
}
}
}
this.btnApply = new Button();
this.btnApply.Clicked += btnApply_Clicked;
this.btnApply.Label = "Apply";
this.btnApply.WidthRequest = 100;
this.GridMain.Add(this.btnApply);
w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.btnApply]));
w2.X = 150;
//.........这里部分代码省略.........
示例4: 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);
}