DataGridView中绘制晶片图 [英] Datagridview to draw wafer map

查看:1468
本文介绍了DataGridView中绘制晶片图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用的是C#的datagridview绘制晶圆图,其中包含> 500行和> 700列。

Currently I'm using C# datagridview to draw a wafer map which contains >500 rows and >700 columns.

然而,有几个问题:

  1. 降低性能。因为我需要调整列宽,我不得不遍历和单独分配。

  1. Slow performance. As i need to adjust the column width, I have to loop through and assign individually.

for (int i = 0; i < this.dgvCompleteMapGrid.Columns.Count; i++)
{
  this.dgvCompleteMapGrid.Columns[i].Width = 8;
}

  • 我只需要绘制单元格边框的细胞值作为晶圆图有一个近圆形的形状。我使用cellpainting事件:

  • I only need to draw the cell border for cells with value as a wafer map has an almost round shape. I'm using cellpainting event:

     if (e.Value != null) {
            if (e.Value.ToString() == "")
            {
             e.AdvancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.None;                    
            }
            else
            {                    
                if (e.Value.ToString() == "1")
                {
                    e.CellStyle.BackColor = Color.Lime;
                }
                else
                {
                    e.CellStyle.BackColor = Color.Red;
                }
    
                //check if the top border set None for neighbor empty value cell
                if (e.AdvancedBorderStyle.Top.ToString() == "None")
                {
    
           e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.Single;
                }   
                //repeat the same for left right and bottom
            }
        }
    

  • 不过,现在看来似乎将绘制多个边界复制的大多数细胞。

    However, it seems like it will draw multiple border duplicate for most of the cells.

    时的datagridview的建议?我试着画一个矩形面板上的表现更差。

    Is Datagridview recommended? I tried to draw rectangle on a panel and the performance is even worse.

    推荐答案

    下面是我的图片框,允许像素化调整大小(与插值)。例如。类似于在Microsoft画图图片放大

    Here's my Picturebox that allows for pixellated resizing (versus interpolated). E.g. similar to zooming in on a Microsoft Paint picture.

    using System.Windows.Forms;
    
    namespace WireWorld
    {
        public class ZoomablePicturebox : PictureBox
        {
            public ZoomablePicturebox()
            {
            }
    
            protected override void OnPaint(PaintEventArgs pe)
            {
                pe.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                pe.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                pe.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                pe.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                base.OnPaint(pe);
            }
        }
    }
    

    要生成位图,我用的是这样的:

    To generate the bitmap, I use something like this:

    // Pick width and height for your case
    Bitmap MyBitmap = new Bitmap(width, height);
    using (var g = Graphics.FromImage(retVal))
        g.Clear(BackColor); // Pick a background fill color
    // Draw your points, whatever your loop needs to be and your point definition is
    foreach (MyPointDef point in _Points)
    {
        MyBitmap.SetPixel(point.X, point.Y, point.Color);
    }
    

    然后,我把一个图片框在一个面板上我的形式。面板则提供了滚动。我可以设置图片和缩放如下:

    Then I put a picture box in a panel on my form. The panel then provides the scrolling. I can set the picture and zoom as follows:

    canvasPB.SizeMode = PictureBoxSizeMode.Zoom; // Ensures picture is resized as we resize picturebox
    canvasPB.Image = MyBitmap;
    canvasPB.Height = canvasPB.Image.Height * Zoom; // Zoom is 1, 2, 3, etc, for 1X, 2X, ...
    canvasPB.Width = canvasPB.Image.Width * Zoom;
    

    canvasPB作为图片框的名字我的形式我想为我的画布使用。

    canvasPB being the name of the Picturebox on my form I'm trying to use as my canvas.

    这篇关于DataGridView中绘制晶片图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆