Correct if starting form is off screen

This commit is contained in:
Tim Young 2017-02-20 16:50:33 +03:00
parent 08a84e875b
commit 1a0b42b727
2 changed files with 39 additions and 21 deletions

View File

@ -60,12 +60,14 @@
this.twoNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.twoNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.threeNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.threeNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.firewallsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.firewallsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.VLANToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toSolveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toSolveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.solvedDHCPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.solvedDHCPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.solvedOneNetworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.solvedOneNetworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.solvedTwoNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.solvedTwoNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SolvedThreeNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SolvedThreeNetworksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.firewallsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.firewallsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.SolvedVLANToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.panelChoices = new System.Windows.Forms.Panel(); this.panelChoices = new System.Windows.Forms.Panel();
this.lbMessages = new System.Windows.Forms.ListBox(); this.lbMessages = new System.Windows.Forms.ListBox();
this.lblStatus = new System.Windows.Forms.Label(); this.lblStatus = new System.Windows.Forms.Label();
@ -78,8 +80,6 @@
this.HelpPanel = new System.Windows.Forms.Panel(); this.HelpPanel = new System.Windows.Forms.Panel();
this.cbViewTitles = new System.Windows.Forms.CheckBox(); this.cbViewTitles = new System.Windows.Forms.CheckBox();
this.myProgressBar = new System.Windows.Forms.ProgressBar(); this.myProgressBar = new System.Windows.Forms.ProgressBar();
this.VLANToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SolvedVLANToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.msMainMenuStrip.SuspendLayout(); this.msMainMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit();
this.HelpPanel.SuspendLayout(); this.HelpPanel.SuspendLayout();
@ -289,7 +289,7 @@
// puzzlesToolStripMenuItem // puzzlesToolStripMenuItem
// //
this.puzzlesToolStripMenuItem.Name = "puzzlesToolStripMenuItem"; this.puzzlesToolStripMenuItem.Name = "puzzlesToolStripMenuItem";
this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.puzzlesToolStripMenuItem.Size = new System.Drawing.Size(140, 26);
this.puzzlesToolStripMenuItem.Text = "Puzzles"; this.puzzlesToolStripMenuItem.Text = "Puzzles";
this.puzzlesToolStripMenuItem.Click += new System.EventHandler(this.puzzlesToolStripMenuItem_Click); this.puzzlesToolStripMenuItem.Click += new System.EventHandler(this.puzzlesToolStripMenuItem_Click);
// //
@ -303,7 +303,7 @@
this.firewallsToolStripMenuItem, this.firewallsToolStripMenuItem,
this.VLANToolStripMenuItem}); this.VLANToolStripMenuItem});
this.solvedToolStripMenuItem.Name = "solvedToolStripMenuItem"; this.solvedToolStripMenuItem.Name = "solvedToolStripMenuItem";
this.solvedToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.solvedToolStripMenuItem.Size = new System.Drawing.Size(140, 26);
this.solvedToolStripMenuItem.Text = "Solved"; this.solvedToolStripMenuItem.Text = "Solved";
// //
// dHCPToolStripMenuItem // dHCPToolStripMenuItem
@ -341,6 +341,13 @@
this.firewallsToolStripMenuItem.Text = "Firewalls"; this.firewallsToolStripMenuItem.Text = "Firewalls";
this.firewallsToolStripMenuItem.Click += new System.EventHandler(this.firewallsToolStripMenuItem_Click); this.firewallsToolStripMenuItem.Click += new System.EventHandler(this.firewallsToolStripMenuItem_Click);
// //
// VLANToolStripMenuItem
//
this.VLANToolStripMenuItem.Name = "VLANToolStripMenuItem";
this.VLANToolStripMenuItem.Size = new System.Drawing.Size(187, 26);
this.VLANToolStripMenuItem.Text = "VLAN";
this.VLANToolStripMenuItem.Click += new System.EventHandler(this.VLANToolStripMenuItem_Click);
//
// toSolveToolStripMenuItem // toSolveToolStripMenuItem
// //
this.toSolveToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toSolveToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -351,7 +358,7 @@
this.firewallsToolStripMenuItem1, this.firewallsToolStripMenuItem1,
this.SolvedVLANToolStripMenuItem1}); this.SolvedVLANToolStripMenuItem1});
this.toSolveToolStripMenuItem.Name = "toSolveToolStripMenuItem"; this.toSolveToolStripMenuItem.Name = "toSolveToolStripMenuItem";
this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.toSolveToolStripMenuItem.Size = new System.Drawing.Size(140, 26);
this.toSolveToolStripMenuItem.Text = "To Solve"; this.toSolveToolStripMenuItem.Text = "To Solve";
// //
// solvedDHCPToolStripMenuItem // solvedDHCPToolStripMenuItem
@ -389,6 +396,13 @@
this.firewallsToolStripMenuItem1.Text = "Firewalls"; this.firewallsToolStripMenuItem1.Text = "Firewalls";
this.firewallsToolStripMenuItem1.Click += new System.EventHandler(this.firewallsToolStripMenuItem1_Click); this.firewallsToolStripMenuItem1.Click += new System.EventHandler(this.firewallsToolStripMenuItem1_Click);
// //
// SolvedVLANToolStripMenuItem1
//
this.SolvedVLANToolStripMenuItem1.Name = "SolvedVLANToolStripMenuItem1";
this.SolvedVLANToolStripMenuItem1.Size = new System.Drawing.Size(187, 26);
this.SolvedVLANToolStripMenuItem1.Text = "VLAN";
this.SolvedVLANToolStripMenuItem1.Click += new System.EventHandler(this.SolvedVLANToolStripMenuItem1_Click);
//
// panelChoices // panelChoices
// //
this.panelChoices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.panelChoices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -522,7 +536,7 @@
// //
this.cbViewTitles.AutoSize = true; this.cbViewTitles.AutoSize = true;
this.cbViewTitles.Location = new System.Drawing.Point(7, 9); this.cbViewTitles.Location = new System.Drawing.Point(7, 9);
this.cbViewTitles.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.cbViewTitles.Margin = new System.Windows.Forms.Padding(4);
this.cbViewTitles.Name = "cbViewTitles"; this.cbViewTitles.Name = "cbViewTitles";
this.cbViewTitles.Size = new System.Drawing.Size(18, 17); this.cbViewTitles.Size = new System.Drawing.Size(18, 17);
this.cbViewTitles.TabIndex = 10; this.cbViewTitles.TabIndex = 10;
@ -539,20 +553,6 @@
this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.myProgressBar.TabIndex = 11; this.myProgressBar.TabIndex = 11;
// //
// VLANToolStripMenuItem
//
this.VLANToolStripMenuItem.Name = "VLANToolStripMenuItem";
this.VLANToolStripMenuItem.Size = new System.Drawing.Size(187, 26);
this.VLANToolStripMenuItem.Text = "VLAN";
this.VLANToolStripMenuItem.Click += new System.EventHandler(this.VLANToolStripMenuItem_Click);
//
// SolvedVLANToolStripMenuItem1
//
this.SolvedVLANToolStripMenuItem1.Name = "SolvedVLANToolStripMenuItem1";
this.SolvedVLANToolStripMenuItem1.Size = new System.Drawing.Size(187, 26);
this.SolvedVLANToolStripMenuItem1.Text = "VLAN";
this.SolvedVLANToolStripMenuItem1.Click += new System.EventHandler(this.SolvedVLANToolStripMenuItem1_Click);
//
// BuilderWindow // BuilderWindow
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -572,6 +572,7 @@
this.Text = "Network Builder"; this.Text = "Network Builder";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BuilderWindow_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BuilderWindow_FormClosing);
this.Load += new System.EventHandler(this.BuilderWindow_Load); this.Load += new System.EventHandler(this.BuilderWindow_Load);
this.Shown += new System.EventHandler(this.BuilderWindow_Shown);
this.ResizeEnd += new System.EventHandler(this.BuilderWindow_ResizeEnd); this.ResizeEnd += new System.EventHandler(this.BuilderWindow_ResizeEnd);
this.Resize += new System.EventHandler(this.BuilderWindow_Resize); this.Resize += new System.EventHandler(this.BuilderWindow_Resize);
this.msMainMenuStrip.ResumeLayout(false); this.msMainMenuStrip.ResumeLayout(false);

View File

@ -1413,5 +1413,22 @@ namespace EduNetworkBuilder
} }
} }
private void BuilderWindow_Shown(object sender, EventArgs e)
{
//Console.WriteLine(this.DesktopLocation.X);
//Console.WriteLine(Screen.FromControl(this).WorkingArea.ToString());
int x = this.DesktopLocation.X;
int y = this.DesktopLocation.Y;
if (x + this.Width > Screen.FromControl(this).WorkingArea.X)
x = Screen.FromControl(this).WorkingArea.X - this.Width;
if (x < 0) x = 0;
if (y + this.Height > Screen.FromControl(this).WorkingArea.Y)
y = Screen.FromControl(this).WorkingArea.Y - this.Height;
if (y < 0) y = 0;
this.DesktopLocation = new Point(x, y);
}
} }
} }