public void loadNode(Node newtarget) { childForms = new List<sensorFrm>(); target = newtarget; int n = 0; int formHeight = this.Height; int formWidth = this.Width; foreach (sensor thisSensor in target.sensors.Values) { sensorFrm newSensorForm; try { newSensorForm = new sensorFrm(thisSensor); newSensorForm.Visible = false; newSensorForm.Show(); newSensorForm.MdiParent = this; newSensorForm.Left = (newSensorForm.Width * n); newSensorForm.Top = 0; formWidth = newSensorForm.Width + newSensorForm.Left + SystemInformation.Border3DSize.Width; formHeight = newSensorForm.Height + SystemInformation.Border3DSize.Height; newSensorForm.Visible = true; newSensorForm.OnSetIcon += setIcon; childForms.Add(newSensorForm); } catch (commsException) { MessageBox.Show("An exception occurred interrogating the node. Please retry."); } catch (Exception) { MessageBox.Show("A serious, unhandled exception occurred interrogating the node. This is bad."); } n++; } int borderX = (this.Width - this.ClientRectangle.Width) + SystemInformation.Border3DSize.Height; int borderY = (this.Height - this.ClientRectangle.Height) + SystemInformation.Border3DSize.Width; this.Width = formWidth + borderX ; this.Height = formHeight + borderY ; }
private void moveToNewFloatingWindowToolStripMenuItem1_Click(object sender, EventArgs e) { // Create a new sensor form which isn't an MDI child of anything. sensorFrm newSensor = new sensorFrm(_sensor); newSensor.Show(); newSensor.Controls.Remove(newSensor.ctlSensor1); newSensor.ctlSensor1 = this.copyOf(); newSensor.Controls.Add(newSensor.ctlSensor1); // then remove the old window. this.ParentForm.Dispose(); }
private void copyToNewfloatingWindowToolStripMenuItem_Click(object sender, EventArgs e) { // Create a new sensor form which isn't an MDI child of anything. sensorFrm newSensor = new sensorFrm(_sensor); newSensor.Show(); newSensor.Controls.Remove(newSensor.ctlSensor1); newSensor.ctlSensor1 = this.copyOf(); newSensor.Size = this.ParentForm.Size ; if (null != this.ParentForm.MdiParent) { newSensor.Opacity = this.ParentForm.MdiParent.Opacity ; } else { newSensor.Opacity = this.ParentForm.Opacity; } if (alwaysOnTopToolStripMenuItem.Checked) newSensor.TopMost = true; newSensor.Controls.Add(newSensor.ctlSensor1); }