private void toolStripStudyButton_Click(object sender, EventArgs e) { toolStripProbeButton.Checked = false; mStudyPictureBox = null; mStudyPoint1 = NotDefinedPoint; mStudyPoint2 = NotDefinedPoint; }
// This is called when the parent form resizes or ImageRows/ImageColumns changes private void ResizePictureBoxes() { if (imageLayoutPanel == null) { return; } int newImageWidth = (int)((float)imageLayoutPanel.Width / (float)(pictureBoxes.GetUpperBound(0) + 1)) - 2; // HACK_2008_02_26 #3: ugh all of a sudden the scroll bar is covering up part of the imageLayoutPanel...have an expert-exchange question out //int imagePanelHeight = this.ClientSize.Height - this.scrollPanel.Height; int imagePanelHeight = imageLayoutPanel.Height; // HACK_2008_02_26 #3: Console.WriteLine(imageLayoutPanel.Height + " " + this.Height + " " + this.scrollPanel.Height + " " + this.ClientSize.Height); // HACK_2008_02_26 #3: without the imageLayoutPanel.BringToFront() below this debug output makes imageLayoutPanel.Height the same as this.Height and this.ClientSize.Height...and we loose part of it udner the scrollPanel int newImageHeight = (int)((float)imagePanelHeight / (float)(pictureBoxes.GetUpperBound(1) + 1)) - 2; int switchValue = pictureBoxes.GetUpperBound(0) * (newImageWidth + 2); for (int y = 0; y <= pictureBoxes.GetUpperBound(1); y++) { for (int x = 0; x <= pictureBoxes.GetUpperBound(0); x++) { OperationPictureBox picBox = pictureBoxes[x, y]; picBox.Size = new Size(newImageWidth, newImageHeight); picBox.Location = new Point(x * (newImageWidth + 2), y * (newImageHeight + 2)); } } imageLayoutPanel.BringToFront();// TODO: needed? HACK_2008_02_26 #3: if I comment this out then the bottom row of PicBox's get partially covered by the scrollPanel. WHY? There must be a better/right-er way }
public ImageBigViewForm(OperationForm parentForm) { InitializeComponent(); TabText = "Big View"; mOpForm = parentForm; mOpPictureBox = new OperationPictureBox(this, new ImageDisplayDef(parentForm.CurrentSequence)); imageLayoutPanel.Controls.Add(mOpPictureBox); Resize += new EventHandler(ImageBigViewForm_Resize); FormClosing += new FormClosingEventHandler(ImageBigViewForm_FormClosing); this.Disposed += new EventHandler(OperationLogForm_Disposed); }
private void LoadImagesIntoPictureBoxes() { for (int x = 0; x < ImageColumns; x++) { for (int y = 0; y < ImageRows; y++) { // TODO: currently we are doing this more often than needed I think. We should only have to update the image if our view changes...not on every repaint (e.g. resizing window) OperationPictureBox picBox = pictureBoxes[x, y]; int offsetIndex = historyScroll.Value + picBox.mIndex; if (OpForm().CurrentTestCollection == null || offsetIndex >= OpForm().CurrentTestCollection.mExecutions.Count) { picBox.TestExecution = null; } else { picBox.TestExecution = (TestExecution)OpForm().CurrentTestCollection.mExecutions[offsetIndex]; } } } }
private void ResizeImageTable(int newNumCol, int newNumRows) { OperationPictureBox[,] newPicBoxArray = new OperationPictureBox[newNumCol, newNumRows]; ImageDisplayDef imageDisplayDef; int newColumnsAdded = newNumCol - pictureBoxes.GetUpperBound(0) - 1; if (newColumnsAdded >= 0) { // copy old picture boxes to the new array for (int y = 0; y <= Math.Min(pictureBoxes.GetUpperBound(1), newPicBoxArray.GetUpperBound(1)); y++) { for (int x = 0; x <= pictureBoxes.GetUpperBound(0); x++) { newPicBoxArray[x, y] = pictureBoxes[x, y]; pictureBoxes[x, y] = null; // remove it from the old array so that we don't remove it from the Panel during cleanup (below) } } } else if (newColumnsAdded < 0) { // copy old picture boxes to the new array...slide them over to the left while we are at it for (int y = 0; y <= Math.Min(pictureBoxes.GetUpperBound(1), newPicBoxArray.GetUpperBound(1)); y++) { for (int x = 0; x <= newPicBoxArray.GetUpperBound(0); x++) { newPicBoxArray[x, y] = pictureBoxes[x, y]; pictureBoxes[x, y] = null; // remove it from the old array so that we don't remove it from the Panel during cleanup (below) } } } // fill in any newly created slots with new picture boxes for (int y = 0; y <= newPicBoxArray.GetUpperBound(1); y++) { if (newPicBoxArray[0, y] != null && newPicBoxArray[0, y].ImageDisplayDef != null) { imageDisplayDef = newPicBoxArray[0, y].ImageDisplayDef; } else { imageDisplayDef = new ImageDisplayDef(mParentForm.CurrentSequence); } for (int x = 0; x <= newPicBoxArray.GetUpperBound(0); x++) { if (newPicBoxArray[x, y] == null) { OperationPictureBox newPicBox = new OperationPictureBox(this, imageDisplayDef); newPicBox.mIndex = x; newPicBoxArray[x, y] = newPicBox; imageLayoutPanel.Controls.Add(newPicBox); } newPicBoxArray[x, y].mIndex = x; // update pictureBoxes' index in case columns were shifted } } // remove obsolete picture boxes from the panel for (int y = 0; y <= pictureBoxes.GetUpperBound(1); y++) { for (int x = 0; x <= pictureBoxes.GetUpperBound(0); x++) { if (pictureBoxes[x, y] != null) { imageLayoutPanel.Controls.Remove(pictureBoxes[x, y]); } } } pictureBoxes = newPicBoxArray; ResizePictureBoxes(); }