缘起
同事负责的项目中,会扫描硬件中的某个东西是否存在,因此老板希望对这些扫描结果,能有个图像画的介面可以查看
因此做了个小工具,可读取同事提供的数据,并将其视觉化显示
那显示扫描结果最容易的就是示波器了,但第三方控件的示波器功能又太繁琐,最终就决定自己做个简单的
反正对我来说用GDI来绘制,跟花时间去研究没用过的第三方控件,时间也不会差太多
思路
复制代码 代码如下:
int max = m_mappingDatas[m_mappingDatas.Count - 1];
m_Ratio = (max + m_mappingDatas[0]*2) / m_width;
// Draw Wafer data
for (int i = 1, j = 0; i < m_mappingDatas.Count; i+=2 ,j++)
{
float xStart = m_mappingDatas[i - 1];
float xEnd = m_mappingDatas[i];
graphics.DrawLine(pen, xStart / m_Ratio, m_yPositionOfWafer,
xEnd / m_Ratio, m_yPositionOfWafer);
graphics.DrawString((j+1).ToString(), Control.DefaultFont, brush,
(xStart / m_Ratio) - 2, m_yPositionOfNoWafer + 1);
}
// Draw No Wafer data
graphics.DrawLine(pen, 0, m_yPositionOfNoWafer,
m_mappingDatas[0] / m_Ratio, m_yPositionOfNoWafer);
for (int i = 2; i < m_mappingDatas.Count; i += 2)
{
float xStart = m_mappingDatas[i - 1];
float xEnd = m_mappingDatas[i];
graphics.DrawLine(pen, xStart / m_Ratio, m_yPositionOfNoWafer,
xEnd / m_Ratio, m_yPositionOfNoWafer);
}
graphics.DrawLine(pen, m_mappingDatas[m_mappingDatas.Count - 1] / m_Ratio, m_yPositionOfNoWafer,
m_width, m_yPositionOfNoWafer);
// Draw vertical line
for (int i = 1; i < m_mappingDatas.Count; i += 2)
{
float X1 = m_mappingDatas[i - 1];
float X2 = m_mappingDatas[i];
graphics.DrawLine(pen, X1 / m_Ratio, m_yPositionOfWafer,
X1 / m_Ratio, m_yPositionOfNoWafer);
graphics.DrawLine(pen, X2 / m_Ratio, m_yPositionOfWafer,
X2 / m_Ratio, m_yPositionOfNoWafer);
}
新闻热点
疑难解答
图片精选