// Open or close 'Spike Scope' window private void btnSpikeWindow_Click(object sender, EventArgs e) { if (spikeWindowVisible) { spikeWindowOffset.X = frmMagnifyForm.Location.X - this.Location.X; spikeWindowOffset.Y = frmMagnifyForm.Location.Y - this.Location.Y; frmMagnifyForm.Close(); frmMagnifyForm.Dispose(); spikeWindowVisible = false; btnSpikeWindow.Text = "Open Spike Scope"; } else { frmMagnifyForm = new MagnifyForm(); frmMagnifyForm.Location = new Point(this.Location.X + spikeWindowOffset.X, this.Location.Y + spikeWindowOffset.Y); frmMagnifyForm.Show(); frmMagnifyForm.SetSpikeRecord(mySpikeRecord); frmMagnifyForm.SetUpGraphicsAndSound(myContext); frmMagnifyForm.UpdateYScale(yScaleIndex); spikeWindowVisible = true; btnSpikeWindow.Text = "Close Spike Scope"; } }