|
@@ -16,6 +16,7 @@ using System.Drawing;
|
|
|
using System.Drawing.Imaging;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Reflection;
|
|
|
using System.Threading;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
@@ -77,8 +78,8 @@ namespace OTSIncAReportGrids
|
|
|
|
|
|
|
|
|
FieldData fieldData;
|
|
|
-
|
|
|
- private string m_filename = "";
|
|
|
+ DataTable particlesAll;
|
|
|
+ ParticleData Particledata;
|
|
|
|
|
|
#region 分页器相关
|
|
|
|
|
@@ -161,17 +162,25 @@ namespace OTSIncAReportGrids
|
|
|
{
|
|
|
m_ReportApp = ReportApp;
|
|
|
result = m_ReportApp.m_DataMgrFun.resultFilesList[m_ReportApp.m_DataMgrFun.WorkingResult];
|
|
|
+ //设置窗体的双缓冲,以保证大数据时拖动不卡
|
|
|
+ this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
|
|
|
+ this.UpdateStyles();
|
|
|
+
|
|
|
InitializeComponent();
|
|
|
|
|
|
- m_frm_userprogress = new Frm_UserProgress();
|
|
|
-
|
|
|
- m_mythread_state = false;
|
|
|
- m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
|
|
|
+ //利用反射设置DataGridView的双缓冲
|
|
|
+ Type dgvType = this.dgV_ParticlesDevidePage.GetType();
|
|
|
+ PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
+ pi.SetValue(this.dgV_ParticlesDevidePage, true, null);
|
|
|
|
|
|
lan = new Language(this);
|
|
|
table = lan.GetNameTable(this.Name);
|
|
|
|
|
|
+ m_mythread_state = false;
|
|
|
+ m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
|
|
|
+ //m_frm_userprogress = new Frm_UserProgress();
|
|
|
fieldData = new FieldData(result.FilePath);
|
|
|
+ Particledata = new ParticleData(result.FilePath);
|
|
|
}
|
|
|
|
|
|
private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
|
|
@@ -179,25 +188,9 @@ namespace OTSIncAReportGrids
|
|
|
//初始化底层操作类
|
|
|
m_OTSIncAReportGridsFun = new OTSReportGridsFun(m_ReportApp, this);
|
|
|
|
|
|
- if (Language.ReadDefaultLanguage() == "EN")
|
|
|
- {
|
|
|
- cbB_order.Items.Add("Default");
|
|
|
- cbB_order.Items.Add("ParticlesName");
|
|
|
- cbB_order.Items.Add("Dmax Ascend");
|
|
|
- cbB_order.Items.Add("Dmax Descend");
|
|
|
- cbB_order.Items.Add("Area Ascend");
|
|
|
- cbB_order.Items.Add("Area Descend");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cbB_order.Items.Add("默认");
|
|
|
- cbB_order.Items.Add("颗粒名称");
|
|
|
- cbB_order.Items.Add("最大直径 升序");
|
|
|
- cbB_order.Items.Add("最大直径 降序");
|
|
|
- cbB_order.Items.Add("面积 升序");
|
|
|
- cbB_order.Items.Add("面积 降序");
|
|
|
- }
|
|
|
- cbB_order.SelectedIndex = 0;
|
|
|
+ ProgressStart();
|
|
|
+
|
|
|
+ UpdateTable();
|
|
|
|
|
|
cbB_PageSize.Items.Add("20");
|
|
|
cbB_PageSize.Items.Add("100");
|
|
@@ -205,13 +198,30 @@ namespace OTSIncAReportGrids
|
|
|
cbB_PageSize.Items.Add("1000");
|
|
|
cbB_PageSize.Items.Add("5000");
|
|
|
cbB_PageSize.Items.Add("All");
|
|
|
- cbB_PageSize.SelectedIndexChanged -= new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
|
|
|
cbB_PageSize.SelectedIndex = 0;
|
|
|
- cbB_PageSize.SelectedIndexChanged += new System.EventHandler(this.cbB_PageSize_SelectedIndexChanged);
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 自定义方法
|
|
|
+ void UpdateTable()
|
|
|
+ {
|
|
|
+ //多次测试发现 读取数据库时间耗时长,但读取条数目对读取数据库时长影响不大,故此处直接读取所有数据库信息,以取代多次连接数据库方式,优化分页速度
|
|
|
+ particlesAll = new DataTable();
|
|
|
+ particlesAll = Particledata.GetInfoForPartucleDevidePage2(condition);
|
|
|
+ DataTable elementchemistry = Particledata.GetElementChemistry();
|
|
|
+
|
|
|
+ for (int i = 0; i < particlesAll.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
|
|
|
+ DataRow[] drs = elementchemistry.Select(str);
|
|
|
+ string ConcatenatedString = "";
|
|
|
+ for (int j = 0; j < drs.Length; j++)
|
|
|
+ {
|
|
|
+ ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
|
|
|
+ }
|
|
|
+ particlesAll.Rows[i]["Element"] = ConcatenatedString;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
|
|
@@ -366,25 +376,12 @@ namespace OTSIncAReportGrids
|
|
|
|
|
|
private void BindDataGridView()
|
|
|
{
|
|
|
- #region 加载显示进度条部份
|
|
|
- this.Cursor = Cursors.WaitCursor;
|
|
|
- m_frm_userprogress = new Frm_UserProgress();
|
|
|
+ dgV_ParticlesDevidePage.Visible = false;
|
|
|
|
|
|
- //显示进度条,计算进度条应该显示的位置和宽度
|
|
|
- Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
|
|
|
- if (ls_main_form == null)
|
|
|
+ if (m_frm_userprogress.IsDisposed)
|
|
|
{
|
|
|
- m_frm_userprogress.Visible = false;
|
|
|
+ ProgressStart();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- string str7 = table["str7"].ToString();
|
|
|
- m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
|
|
|
- m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 80, ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
|
|
|
- m_frm_userprogress.Show();
|
|
|
- m_frm_userprogress.SetProgressValueAndText(0, str7);
|
|
|
- }
|
|
|
- #endregion
|
|
|
|
|
|
dgV_ParticlesDevidePage.Rows.Clear();
|
|
|
dgV_ParticlesDevidePage.Columns.Clear();
|
|
@@ -419,7 +416,6 @@ namespace OTSIncAReportGrids
|
|
|
keyValues.Add("ParticleImage", table["str5"].ToString());
|
|
|
keyValues.Add("SEMPosX", "SEMPosX");
|
|
|
keyValues.Add("SEMPosY", "SEMPosY");
|
|
|
-
|
|
|
for (int i = 0; i < strs.Count(); i++)
|
|
|
{
|
|
|
if (strs[i] == "Area")
|
|
@@ -501,19 +497,25 @@ namespace OTSIncAReportGrids
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- ParticleData fielddata = new ParticleData(result.FilePath);
|
|
|
- DataTable particles = fielddata.GetInfoForPartucleDevidePage(PageIndex, pageSize, OrderFunction, condition);
|
|
|
if(PageSize==-1)
|
|
|
{
|
|
|
- PageSize = particles.Rows.Count;
|
|
|
+ PageSize = particlesAll.Rows.Count;
|
|
|
}
|
|
|
|
|
|
- if (particles == null)
|
|
|
+ if (particlesAll == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ RecordCount = particlesAll.Rows.Count;
|
|
|
+ DataTable particles = particlesAll.Clone();
|
|
|
+ for (int fi = (PageIndex - 1) * pageSize; fi < PageIndex * pageSize; fi++)
|
|
|
+ {
|
|
|
+ if (fi > RecordCount - 1)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ particles.ImportRow(particlesAll.Rows[fi]);
|
|
|
+ }
|
|
|
string particleM = "";
|
|
|
//获取需要显示的元素名
|
|
|
List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
|
|
@@ -521,9 +523,6 @@ namespace OTSIncAReportGrids
|
|
|
{
|
|
|
dgV_ParticlesDevidePage.Columns.Add(ElementTypeSort[i], ElementTypeSort[i]);
|
|
|
}
|
|
|
-
|
|
|
- RecordCount = fielddata.GetParticleAll(condition).Rows.Count;
|
|
|
-
|
|
|
double jd = 95f / (double)particles.Rows.Count;//计算进度刻度
|
|
|
|
|
|
string filePath = result.FilePath + "\\FIELD_FILES\\";
|
|
@@ -531,8 +530,7 @@ namespace OTSIncAReportGrids
|
|
|
for (int i = 0; i < particles.Rows.Count; i++)
|
|
|
{
|
|
|
//更新进度,每100条记录加载完,更新一次进度
|
|
|
- if (i % 5 == 0)
|
|
|
-
|
|
|
+ if (i % 10 == 0)
|
|
|
m_frm_userprogress.SetProgressValueAndText((int)(jd * i), "loading..");
|
|
|
|
|
|
Dictionary<string, string>.Enumerator enl = keyValues.GetEnumerator();
|
|
@@ -547,7 +545,6 @@ namespace OTSIncAReportGrids
|
|
|
if (enl.Current.Key == "rowid")
|
|
|
{
|
|
|
//dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = i + 1;
|
|
|
-
|
|
|
}
|
|
|
if (enl.Current.Key == "ParticleImage")
|
|
|
{
|
|
@@ -558,15 +555,16 @@ namespace OTSIncAReportGrids
|
|
|
string filePatht = result.FilePath + "\\FIELD_FILES\\";
|
|
|
string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
|
|
|
//然后将取出的数据,转换成Bitmap对象
|
|
|
- Bitmap tempbit = fielddata.ReadImageFile(imagePatht);
|
|
|
+ Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
|
|
|
int pixw = tempbit.Width;
|
|
|
double xs = pixw / ScanFieldSize;
|
|
|
|
|
|
particleM = particleM + "," + subt;
|
|
|
- Bitmap bmap = fielddata.GetBitmapForBig(subt, xs, result.FilePath);
|
|
|
+ Bitmap bmap = Particledata.GetBitmapForBig(subt, xs, result.FilePath);
|
|
|
if (bmap != null)
|
|
|
{
|
|
|
- bmap.Tag = new List<string>() { subt.Split(',')[0].Split(':')[0], subt.Split(',')[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
|
|
|
+ string[] str = subt.Split(',');
|
|
|
+ bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
|
|
|
dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
|
|
|
dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
|
|
|
dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
|
|
@@ -584,11 +582,11 @@ namespace OTSIncAReportGrids
|
|
|
if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
|
|
|
{
|
|
|
string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
|
|
|
- FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), fielddata.ReadImageFile(imagePath));
|
|
|
+ FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
|
|
|
}
|
|
|
|
|
|
Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
|
|
|
- Bitmap bmap = fielddata.GetBitmapByParticle(FieldImage.Value, rectangle);
|
|
|
+ Bitmap bmap = Particledata.GetBitmapByParticle(FieldImage.Value, rectangle);
|
|
|
bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString() };
|
|
|
dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
|
|
|
dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
|
|
@@ -648,6 +646,7 @@ namespace OTSIncAReportGrids
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
#region 加载进度条进度部份结束
|
|
|
//加载完成设置鼠标为默认
|
|
@@ -657,6 +656,8 @@ namespace OTSIncAReportGrids
|
|
|
//加载完成,关闭进度条
|
|
|
m_frm_userprogress.Close();
|
|
|
#endregion
|
|
|
+
|
|
|
+ dgV_ParticlesDevidePage.Visible = true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -672,9 +673,6 @@ namespace OTSIncAReportGrids
|
|
|
//用户不能调整 行高
|
|
|
dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
|
|
|
|
|
|
- //改变行的高度;
|
|
|
- //Gview_gz.RowTemplate.Height = 20;
|
|
|
-
|
|
|
//点击选择整行
|
|
|
dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
|
|
|
@@ -1222,10 +1220,39 @@ namespace OTSIncAReportGrids
|
|
|
condition += " and TypeName Like \"%" + tbx_Type.Text + "%\" ";
|
|
|
}
|
|
|
|
|
|
+ if (m_frm_userprogress.IsDisposed)
|
|
|
+ {
|
|
|
+ ProgressStart();
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateTable();
|
|
|
+
|
|
|
lnkFirst_Click(null, null);
|
|
|
SetDataGridViewStyle();
|
|
|
}
|
|
|
|
|
|
+ void ProgressStart()
|
|
|
+ {
|
|
|
+ #region 加载显示进度条部份
|
|
|
+ this.Cursor = Cursors.WaitCursor;
|
|
|
+ m_frm_userprogress = new Frm_UserProgress();
|
|
|
+
|
|
|
+ //显示进度条,计算进度条应该显示的位置和宽度
|
|
|
+ Form ls_main_form = this.ParentForm.ParentForm;//取出父窗体
|
|
|
+ if (ls_main_form == null)
|
|
|
+ {
|
|
|
+ m_frm_userprogress.Visible = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_frm_userprogress.Width = (int)(MyPrimaryScreen.DESKTOP.Width / MyPrimaryScreen.ScaleX * 0.9);
|
|
|
+ m_frm_userprogress.Location = new Point(ls_main_form.Location.X + 200, ls_main_form.Location.Y + 200 + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
|
|
|
+ m_frm_userprogress.Show();
|
|
|
+ m_frm_userprogress.SetProgressValueAndText(0, "Loading data of particles...");
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
private void cbB_order_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
int ordernum = cbB_order.SelectedIndex;
|
|
@@ -1366,6 +1393,7 @@ namespace OTSIncAReportGrids
|
|
|
pageSize = int.Parse(cbB_PageSize.SelectedItem.ToString());
|
|
|
}
|
|
|
lnkFirst_Click(null, null);
|
|
|
+ SetDataGridViewStyle();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|