|
@@ -0,0 +1,338 @@
|
|
|
+using DevExpress.Utils;
|
|
|
+using OTS.WinFormsUI.Docking;
|
|
|
+using OTSCommon.DBOperate;
|
|
|
+using OTSIncAReportApp.OTSRstMgrFunction;
|
|
|
+using OTSIncAReportApp.OTSSampleReportInfo;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.ComponentModel;
|
|
|
+using System.Data;
|
|
|
+using System.Drawing;
|
|
|
+using System.IO;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Forms;
|
|
|
+using static OTSIncAReportApp.OTSReport_Export;
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
+
|
|
|
+namespace OTSIncAReportApp._1_UI
|
|
|
+{
|
|
|
+ public partial class FormStandardLibraryInformation : DockContent
|
|
|
+ {
|
|
|
+ //测量结果
|
|
|
+ frmReportApp m_frmReportApp = null;
|
|
|
+ frmReportConditionChoose m_condition;
|
|
|
+ public List<string[]> LibraryName = new List<string[]>();
|
|
|
+ private bool isExport = true;
|
|
|
+ public c_TemplateClass m_mbszclass = null;
|
|
|
+ DataTable m_data=new DataTable();
|
|
|
+ public FormStandardLibraryInformation(frmReportApp frmReportApp)
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ m_frmReportApp = frmReportApp;
|
|
|
+ m_condition = frmReportApp.m_conditionChoose;
|
|
|
+ m_mbszclass = new c_TemplateClass();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FormStandardLibraryInformation_Load(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ label1.Text = " ";
|
|
|
+ label2.Text = " ";
|
|
|
+ // 设置ListView为详细视图
|
|
|
+ listView1.View = View.Details;
|
|
|
+ listView1.FullRowSelect = true; // 可选,设置是否选择整行
|
|
|
+ listView1.GridLines = true; // 可选,设置是否显示网格线
|
|
|
+ listView1.Columns.Clear();
|
|
|
+ listView1.Columns.Add(" ", 170, HorizontalAlignment.Left);
|
|
|
+ listView1.Columns.Add(" ", 100, HorizontalAlignment.Left);
|
|
|
+ listView1.Items.Clear();
|
|
|
+ DataLoad();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GetDBData(ResultFile resultFile)
|
|
|
+ {
|
|
|
+ listView1.Items.Clear();
|
|
|
+ ResultFile resfile = resultFile;
|
|
|
+ string Name = "";
|
|
|
+ string rstSTD = resfile.GetSTDName();
|
|
|
+
|
|
|
+ string input1 = rstSTD;
|
|
|
+ string[] fruits1 = input1.Split('.');
|
|
|
+
|
|
|
+ if ("NoSTDDB" == fruits1[0] ||
|
|
|
+ "NoSTDDB.db" == fruits1[0])
|
|
|
+ {
|
|
|
+ Name = "OTSIncASysSTD";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Name = fruits1[0];
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ReadClassification();
|
|
|
+ }
|
|
|
+ catch (Exception ex) { return; }
|
|
|
+
|
|
|
+ //listView1.Columns.Clear();
|
|
|
+ //// 设置ListView为详细视图
|
|
|
+ //listView1.View = View.Details;
|
|
|
+ //listView1.FullRowSelect = true; // 可选,设置是否选择整行
|
|
|
+ //listView1.GridLines = true; // 可选,设置是否显示网格线
|
|
|
+
|
|
|
+
|
|
|
+ // 添加列
|
|
|
+ //listView1.Columns.Add("名称", 160, HorizontalAlignment.Left);
|
|
|
+ //listView1.Columns.Add("颜色", 100, HorizontalAlignment.Left);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (int i=0;i< LibraryName.Count;i++)
|
|
|
+ {
|
|
|
+ string input = LibraryName[i][0];
|
|
|
+ string[] fruits = input.Split('.');
|
|
|
+ if ( Name== fruits[0])
|
|
|
+ {
|
|
|
+ DataTable dt_stl = new DataTable();
|
|
|
+ SqLiteHelper sh = new SqLiteHelper("data source='" + LibraryName[i][1] + "'");
|
|
|
+ dt_stl = sh.ExecuteQuery("select * from ClassifySTD");
|
|
|
+ m_data= dt_stl.Copy();
|
|
|
+ for (int a=0;a<dt_stl.Rows.Count;a++)
|
|
|
+ {
|
|
|
+ ListViewItem item1 = new ListViewItem(dt_stl.Rows[a]["StrName"].ToString());
|
|
|
+ item1.SubItems.Add(dt_stl.Rows[a]["Color"].ToString());
|
|
|
+
|
|
|
+ item1.UseItemStyleForSubItems = false; // 允许为每个 SubItem 设置不同的样式
|
|
|
+ item1.SubItems[1].BackColor = Color.LightBlue; // 这将不会生效,除非我们处理 OwnerDraw
|
|
|
+ listView1.Items.Add(item1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ label1.Text = "分类名";
|
|
|
+ label2.Text = "颜色";
|
|
|
+ // 由于 ListViewItem 不直接支持为 SubItem 设置背景色,我们需要启用 OwnerDrawFixed 模式
|
|
|
+ listView1.OwnerDraw = true;
|
|
|
+ listView1.DrawItem += new DrawListViewItemEventHandler(ListView1_DrawItem);
|
|
|
+ listView1.DrawSubItem += new DrawListViewSubItemEventHandler(ListView1_DrawSubItem);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ static List<string> GetDbFilesInDirectory(string directoryPath)
|
|
|
+ {
|
|
|
+ List<string> files = new List<string>();
|
|
|
+
|
|
|
+ // 使用搜索模式 "*.db" 来查找所有.db文件
|
|
|
+ string[] allDbFiles = Directory.GetFiles(directoryPath, "*.db");
|
|
|
+
|
|
|
+ // 将找到的文件名添加到列表中
|
|
|
+ files.AddRange(allDbFiles.Select(Path.GetFileName)); // 如果只需要文件名,而不是完整路径
|
|
|
+
|
|
|
+ // 如果你需要文件的完整路径,可以直接返回 allDbFiles 数组(转换为List<string>)
|
|
|
+ // return allDbFiles.ToList();
|
|
|
+
|
|
|
+ return files;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ListView1_DrawItem(object sender, DrawListViewItemEventArgs e)
|
|
|
+ {
|
|
|
+ // 这里可以自定义绘制整个 ListViewItem
|
|
|
+ // 但由于我们只关心 SubItem 的颜色,所以主要逻辑将在 DrawSubItem 中
|
|
|
+ e.DrawDefault = true; // 默认情况下使用标准绘制
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ListView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
|
|
|
+ {
|
|
|
+ // 检查是否是我们要自定义颜色的那一列
|
|
|
+ if (e.ColumnIndex == 1) // 第二列的索引是 1
|
|
|
+ {
|
|
|
+ Color color = ColorTranslator.FromHtml(e.SubItem.Text);
|
|
|
+
|
|
|
+ // 自定义绘制 SubItem
|
|
|
+ e.Graphics.FillRectangle(new SolidBrush(color), e.Bounds);
|
|
|
+ TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, e.Bounds, color, TextFormatFlags.Left);
|
|
|
+
|
|
|
+ // 告诉 ListView 我们已经处理了绘制
|
|
|
+ e.DrawDefault = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 对于其他列,使用默认绘制
|
|
|
+ e.DrawDefault = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ReadClassificationNo()
|
|
|
+ {
|
|
|
+ LibraryName.Clear();
|
|
|
+ string MeasurementFiles = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData";
|
|
|
+ // 获取文件夹中的所有文件信息
|
|
|
+ List<string> getNameM = GetDbFilesInDirectory(MeasurementFiles);
|
|
|
+ // 遍历文件信息数组并打印出文件名
|
|
|
+ for (int i = 0; i < getNameM.Count; i++)
|
|
|
+ {
|
|
|
+ string[] vs = new string[] { getNameM[i], MeasurementFiles + "\\" + getNameM[i] };
|
|
|
+ LibraryName.Add(vs);
|
|
|
+ }
|
|
|
+ if (m_mbszclass.M_SY.StandardLibraryName == "NoSTDDB.db")
|
|
|
+ {
|
|
|
+ m_mbszclass.M_SY.StandardLibraryName = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ReadClassification()
|
|
|
+ {
|
|
|
+ LibraryName.Clear();
|
|
|
+ string fullPathM = "";
|
|
|
+ string fullPathR = "";
|
|
|
+ ResultFile resfile = m_frmReportApp.m_rstDataMgr.ResultFilesList[m_frmReportApp.m_rstDataMgr.GetWorkingResultId()];
|
|
|
+ string str_libraryName = resfile.GetSTDName();
|
|
|
+ bool endsWithDb = str_libraryName.EndsWith(".db", StringComparison.OrdinalIgnoreCase);
|
|
|
+ if (!endsWithDb)
|
|
|
+ {
|
|
|
+ str_libraryName = str_libraryName + ".db";
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ fullPathM = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + str_libraryName /*+ ".db"*/;
|
|
|
+ string MeasurementFiles = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData";
|
|
|
+ // 获取文件夹中的所有文件信息
|
|
|
+ List<string> getNameM = GetDbFilesInDirectory(MeasurementFiles);
|
|
|
+ // 遍历文件信息数组并打印出文件名
|
|
|
+ for (int i = 0; i < getNameM.Count; i++)
|
|
|
+ {
|
|
|
+ string[] vs = new string[] { getNameM[i], MeasurementFiles + "\\" + getNameM[i] };
|
|
|
+ LibraryName.Add(vs);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ fullPathR = m_frmReportApp.m_rstDataMgr.CurResultFile.FilePath + "\\" + str_libraryName /*+ ".db"*/;
|
|
|
+ string ReportFile = m_frmReportApp.m_rstDataMgr.CurResultFile.FilePath;
|
|
|
+ // 获取文件夹中的所有文件信息
|
|
|
+ List<string> getNameR = GetDbFilesInDirectory(ReportFile);
|
|
|
+ for (int i = 0; i < getNameR.Count; i++)
|
|
|
+ {
|
|
|
+ string[] vs = new string[] { getNameR[i], ReportFile + "\\" + getNameR[i] };
|
|
|
+ LibraryName.Add(vs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (str_libraryName == "NoSTDDB.db" || m_mbszclass.M_SY.StandardLibraryName == "NoSTDDB.db")
|
|
|
+ {
|
|
|
+ m_mbszclass.M_SY.StandardLibraryName = "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ if (System.IO.File.Exists(fullPathR))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (System.IO.File.Exists(fullPathM))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //MessageBox.Show(table["library_does_not_match"].ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FormStandardLibraryInformation_Activated(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ //DataLoad();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DataRefresh()
|
|
|
+ {
|
|
|
+ DataLoad();
|
|
|
+ listView1.View = View.Details;
|
|
|
+ listView1.FullRowSelect = true; // 可选,设置是否选择整行
|
|
|
+ listView1.GridLines = true; // 可选,设置是否显示网格线
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DataDeletion()
|
|
|
+ {
|
|
|
+ listView1.Items.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DataLoad()
|
|
|
+ {
|
|
|
+ if (m_condition.m_CurrentConditions.Count == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ listView1.Items.Clear();
|
|
|
+ string sou = m_condition.m_CurrentConditions[OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
|
|
|
+ if (sou.Contains("+"))
|
|
|
+ {
|
|
|
+ for (int i = 0; i < sou.Split('+').Length; i++)
|
|
|
+ {
|
|
|
+ ResultFile resultFile = m_frmReportApp.m_rstDataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
|
|
|
+ if (resultFile != null)
|
|
|
+ {
|
|
|
+ GetDBData(resultFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int i = 0; i < m_frmReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
|
|
|
+ {
|
|
|
+ if (sou == m_frmReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString())
|
|
|
+ {
|
|
|
+ GetDBData(m_frmReportApp.m_rstDataMgr.ResultFilesList[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ////根据标签索引 显示默认的数据图表
|
|
|
+ //if (m_frmReportApp.m_ChartsWindow.Controls != null)
|
|
|
+ //{
|
|
|
+ // if (m_frmReportApp.m_ChartsWindow.Controls.Count == 0)
|
|
|
+ // {
|
|
|
+ // m_frmReportApp.m_conditionChoose.tabIndex = DisplayPicutureType.AnalyzeStandardLibrary;
|
|
|
+ // m_frmReportApp.m_conditionChoose.ShowsTheDefaultPic();
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //m_frmReportApp.m_RstWindow.SelectWorkSampleNode();
|
|
|
+ ////设置每个功能模块限制菜单的显示
|
|
|
+ //if (this.Controls.Count != 0)
|
|
|
+ //{
|
|
|
+ // m_frmReportApp.m_RibbonFun.SetRibbonButnStatu_ByModule(DisplayPicutureType.AnalyzeStandardLibrary);
|
|
|
+ //}
|
|
|
+
|
|
|
+ ////判断样品属性与样品窗口在主窗体的位置
|
|
|
+ //if (m_frmReportApp.m_conditionChoose.DockState != m_frmReportApp.m_RstWindow.DockState)
|
|
|
+ //{
|
|
|
+ // m_frmReportApp.m_RstWindow.Activate();
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if (!m_frmReportApp.m_conditionChoose.Focus())
|
|
|
+ // {
|
|
|
+ // m_frmReportApp.m_RstWindow.Activate();
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|