本文整理汇总了C#中System.Windows.Forms.Button.PointToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Button.PointToScreen方法的具体用法?C# Button.PointToScreen怎么用?C# Button.PointToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Button
的用法示例。
在下文中一共展示了Button.PointToScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ControlPanelForm
public ControlPanelForm()
{
if (Instance != null)
{
Instance.WindowState = FormWindowState.Normal;
Instance.Activate();
return;
}
Instance = this;
Global.BusyForms.Enqueue(busyForm);
InitializeComponent();
int interfaceHeight = 260;
int interfaceWidth = 750;
// resize
Size minimumSize = new Size(interfaceWidth + 26, (interfaceHeight + 6) * Global.NetworkInterfaces.Count + 78);
Rectangle screenRectangle = RectangleToScreen(ClientRectangle);
int titleBarHeight = screenRectangle.Top - Top;
int borderThickness = screenRectangle.Left - Left;
Rectangle workingArea = Screen.GetWorkingArea(this);
Size clientSize = new Size();
if (minimumSize.Width > workingArea.Width - 2 * borderThickness)
clientSize.Width = workingArea.Width - 2 * borderThickness;
else
clientSize.Width = minimumSize.Width;
if (minimumSize.Height > workingArea.Height - titleBarHeight - borderThickness)
clientSize.Height = workingArea.Height - titleBarHeight - borderThickness;
else
clientSize.Height = minimumSize.Height;
AutoScrollMinSize = new System.Drawing.Size(minimumSize.Width, minimumSize.Height);
ClientSize = new Size(clientSize.Width, clientSize.Height);
// populate
int i = 0;
foreach (NetworkInterface nic in Global.NetworkInterfaces.Values)
{
GroupBox groupBox = new GroupBox();
groupBox.Name = "interface" + nic.Guid;
groupBox.Tag = nic.Guid;
groupBox.Width = interfaceWidth;
groupBox.Height = interfaceHeight;
groupBox.Location = new Point(13, 68 + interfaceHeight * i);
groupBox.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
groupBox.MinimumSize = new System.Drawing.Size(interfaceWidth, interfaceHeight);
groupBox.Controls.Add(CreateLabel(nic.Name, 10, 15, 340, true, "name"));
groupBox.Controls["name"].Anchor = AnchorStyles.Left;
if (!Global.Config.Gadget.HiddenInterfaces.Contains(nic.Guid))
groupBox.Controls["name"].Font = new System.Drawing.Font(DefaultFont, FontStyle.Bold);
if (Global.InternetInterface != null)
if (nic.Guid == Global.InternetInterface)
{
groupBox.Controls["name"].ForeColor = Color.Blue;
toolTip1.SetToolTip(groupBox.Controls["name"], "Internet (remote network connections) goes through this interface");
}
groupBox.Controls.Add(CreateListView("ipProperties"));
Button button = new Button();
button.Name = "interfaceTools";
button.Text = "Interface tools";
button.Location = new Point(360, 15);
button.Anchor = AnchorStyles.Right;
button.Width = 100;
button.Height = 20;
ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
ToolStripItem toolStripItem;
toolStripItem = contextMenuStrip.Items.Add("Configure");
toolStripItem.Click += new EventHandler((s, e) => { new ConfigureInterface.ConfigureInterfaceForm(nic.Guid); });
toolStripItem = contextMenuStrip.Items.Add("Make primary");
toolStripItem.Click += new EventHandler((s, e) => {
DialogResult result = MessageBox.Show(
"This will configure all network interfaces so that \"" + nic.Name + "\" has the smallest metrics values of all, which will cause remote connectios to go through this interface when there are multiple NICs with a default gateway.\n\nDo you want to continue ?",
"Make an interface primary",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == System.Windows.Forms.DialogResult.Yes)
MakeInterfacePrimary(nic.Guid);
});
toolStripItem.MouseHover += new EventHandler((s, e) =>
{
new BalloonTip(
"Make an interface primary",
"This will configure all network interfaces so that \"" + nic.Name + "\" has the smallest metrics values of all, which will cause remote connectios to go through this interface when there are multiple NICs with a default gateway."
, button, BalloonTip.ICON.INFO, 100000, false, false,
(short)(button.PointToScreen(Point.Empty).X + button.Width / 2),
(short)(button.PointToScreen(Point.Empty).Y + button.Height * 2.5));
});
toolStripItem.MouseLeave += new EventHandler((s, e) => { BalloonTip.CloseAll(); });
// TODO: add speed and lattency test
//contextMenuStrip.Items.Add("Test speed").Enabled = false;
//contextMenuStrip.Items.Add("Test lattency").Enabled = false;
button.Click += new EventHandler((s, e) => { contextMenuStrip.Show((Control)s, 0, ((Control)s).Height); });
groupBox.Controls.Add(button);
groupBox.Controls.Add(CreateLabel("Adapter GUID:", 360, 40, 120));
groupBox.Controls.Add(CreateLabel("Description:", 360, 55, 120));
groupBox.Controls.Add(CreateLabel("Type:", 360, 70, 120));
groupBox.Controls.Add(CreateLabel("Interface Index:", 360, 85, 120));
groupBox.Controls.Add(CreateLabel("MAC Address", 360, 100, 120));
groupBox.Controls.Add(CreateLabel("Interface Metric:", 360, 115, 120));
groupBox.Controls.Add(CreateLabel("Lowest IPv4 metrics", 360, 145, 120, false, "lowestMetrics"));
groupBox.Controls["lowestMetrics"].Font = new System.Drawing.Font(DefaultFont, FontStyle.Underline);
groupBox.Controls.Add(CreateLabel("Gateway Metric:", 360, 160, 120));
groupBox.Controls.Add(CreateLabel("Route Metric:", 360, 175, 120));
//.........这里部分代码省略.........