private void LoadNextImageFromPicesList() { if (picesImages == null) { return; } if (lastImageIndexLoaded >= picesImages.Count) { UpdateDisplayTimer.Enabled = false; return; } Font font = new System.Drawing.Font("Courier New", 8.0f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Image image = null; PicesDataBaseImage pi = picesImages[lastImageIndexLoaded]; lastImageIndexLoaded++; image = pi.Thumbnail(); if (image == null) { return; } float ratio = 1.0f; int maxDim = Math.Max(image.Height, image.Width); if (maxDim > 150) { ratio = 150.0f / (float)maxDim; } PictureBox pb = new PictureBox(); pb.BorderStyle = BorderStyle.FixedSingle; int h = (int)((float)image.Height * ratio); int w = (int)((float)image.Width * ratio); pb.Height = h + 2; pb.Width = w + 2; //pb.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(PicesThumbNail_MouseDoubleClick); pb.MouseClick += new MouseEventHandler(MouseClickEvent); pb.Name = pi.ImageFileName; Image thumbNail = image.GetThumbnailImage(w, h, GetThumbnailImageAbort, thumbNailCallBackData); pb.Image = thumbNail; FlowLayoutPanel pan = new FlowLayoutPanel(); pan.Size = new Size(Math.Max(170, w + 10), 200); //pan.Height = h + 80; //pan.Width = Math.Max (160, w + 10); String rootName = OSservices.GetRootName(pi.ImageFileName); pan.Controls.Add(pb); TextBox tb = new TextBox(); tb.Width = pan.Width - 8; tb.Text = "Depth " + pi.Depth.ToString("##0.0"); tb.Font = font; pan.Controls.Add(tb); pan.BorderStyle = BorderStyle.FixedSingle; pan.BackColor = Color.White; thumbNails.Add(pan); ImageDisplayPanel.Controls.Add(pan); } /* LoadNextImageFromPicesList */
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts ) { // Call the base class method to paint the default cell appearance. base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts ); bool selected = ((cellState & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected); int borderWidth = 1; graphics.FillRectangle(selected ? thumbNailSelectedBrush : thumbNailBackGround, cellBounds); if ((value == null) || (value.GetType() != typeof(PicesDataBaseImage))) { graphics.DrawRectangle(thumbNailBorderPen, cellBounds); return; } PicesDataBaseImage dbImage = (PicesDataBaseImage)value; int availWidth = cellBounds.Width - 2 * borderWidth - 2; int availHeight = cellBounds.Height - 2 * borderWidth; int heightNeededForText = 2 * thumbNailFont.Height // (Probability and Break-Tie) + (Size and Depth) + (String.IsNullOrEmpty(dbImage.ValidatedClassName) ? 0 : thumbNailFont.Height) + (displayClass1 ? thumbNailFont.Height : 0) + (displayClass2 ? thumbNailFont.Height : 0); if (!String.IsNullOrEmpty(dbImage.ValidatedClassName)) { heightNeededForText += thumbNailFont.Height; } int heightAvailForImage = availHeight - heightNeededForText; Image displayImage = dbImage.Thumbnail(); if ((displayImage.Height > heightAvailForImage) || (displayImage.Width > availWidth)) { displayImage = MakeImageFit(displayImage, heightAvailForImage, availWidth); } // we want to paint the image in the center int paintRow = cellBounds.Y + borderWidth + (heightAvailForImage - displayImage.Height) / 2; int paintCol = cellBounds.X + borderWidth + (availWidth - displayImage.Width) / 2; graphics.DrawImage(displayImage, paintCol, paintRow, displayImage.Width, displayImage.Height); int curPixelRow = heightAvailForImage + cellBounds.Y; // This is where 1st line of text must go int leftCol = cellBounds.X + borderWidth; if (!String.IsNullOrEmpty(dbImage.ValidatedClassName)) { RectangleF rec = new RectangleF(leftCol + 20, curPixelRow - 1, cellBounds.Width - 22, thumbNailFont.Height); graphics.DrawString("V:", thumbNailFont, thumbNailLabelBrush, leftCol + 1, curPixelRow); graphics.DrawString(dbImage.ValidatedClassName, thumbNailFont, thumbNailDataBrush, rec, stringFormat); curPixelRow += thumbNailFont.Height; } if (displayClass1) { RectangleF rec = new RectangleF(leftCol + 20, curPixelRow - 1, cellBounds.Width - 22, thumbNailFont.Height); graphics.DrawString("C1:", thumbNailFont, thumbNailLabelBrush, leftCol + 1, curPixelRow); graphics.DrawString(dbImage.Class1Name, thumbNailFont, thumbNailDataBrush, rec, stringFormat); curPixelRow += thumbNailFont.Height; } if (displayClass2) { RectangleF rec = new RectangleF(leftCol + 20, curPixelRow - 1, cellBounds.Width - 22, thumbNailFont.Height); graphics.DrawString("C2:", thumbNailFont, thumbNailLabelBrush, leftCol + 1, curPixelRow); graphics.DrawString(dbImage.Class2Name, thumbNailFont, thumbNailDataBrush, rec, stringFormat); curPixelRow += thumbNailFont.Height; } graphics.DrawString("P:", thumbNailFont, thumbNailLabelBrush, leftCol + 1, curPixelRow); graphics.DrawString((dbImage.Class1Prob).ToString("##0.0%"), thumbNailFont, thumbNailDataBrush, leftCol + 20, curPixelRow); graphics.DrawString("B:", thumbNailFont, thumbNailLabelBrush, leftCol + 71, curPixelRow); graphics.DrawString((dbImage.BreakTie).ToString("##0.0%"), thumbNailFont, thumbNailDataBrush, leftCol + 90, curPixelRow); curPixelRow += thumbNailFont.Height; graphics.DrawString("S:", thumbNailFont, thumbNailLabelBrush, leftCol + 1, curPixelRow); graphics.DrawString(dbImage.PixelCount.ToString("###,##0"), thumbNailFont, thumbNailDataBrush, leftCol + 20, curPixelRow); graphics.DrawString("D:", thumbNailFont, thumbNailLabelBrush, leftCol + 71, curPixelRow); graphics.DrawString(dbImage.Depth.ToString("#,##0.0"), thumbNailFont, thumbNailDataBrush, leftCol + 90, curPixelRow); curPixelRow += thumbNailFont.Height; graphics.DrawRectangle(thumbNailBorderPen, cellBounds); for (int zed = 1; zed < borderWidth; zed++) { Rectangle r = new Rectangle(cellBounds.X + borderWidth, cellBounds.Y + borderWidth, cellBounds.Width - 2 * borderWidth, cellBounds.Height - 2 * borderWidth); graphics.DrawRectangle(thumbNailBorderPen, cellBounds); } return; } /* Paint */