| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608 |
- using OTSCommon.DBOperate;
- using OTSCommon.DBOperate.Model;
- using OTSIncAReportApp;
- using OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage;
- using OTSIncAReportApp._2_CommonFunction.CommonClass;
- using OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.OTSRstMgrFunction;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGraph.Class;
- using OTSIncAReportGraph.Controls;
- using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
- using OTSIncAReportGrids.OTSIncAReportGridsFuncation;
- using OTSIncAReportMailInterface;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SQLite;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Threading;
- using System.Windows.Forms;
- using static OTSDataType.otsdataconst;
- namespace OTSIncAReportGrids
- {
- public partial class ParticlesGridDevidePage : UserControl
- {
- #region 变量定义
- private ParticlesGridDevidePageShowConfig m_particlesGridDevidePageShowConfig = null;
- //设置模拟数据表
- public DataTable m_dt = new DataTable();
- //底层操作类
- private SEMAndEDSOperate m_OTSIncAReportGridsFun = null;
- //进度条窗体
- public Frm_UserProgress m_frm_userprogress;
- //移动SEM到指定位置发生线程
- private Thread m_mythread;
- //记录线程是否已经运行完成的状态
- private bool m_mythread_state = false;
- //导出图像文件的路径
- private string m_imagefilepath = "";
- //显示元素列表
- public List<string> m_list_elementscolname = null;
- //单个数据源所拥有的列数,这里保存下来,供导出模块使用
- public int m_oneresult_columncount = 0;
- private OTSImageDisHelp m_ReportFun = null;
- public OTSImageDisHelp ReportFun
- {
- get => m_ReportFun;
- set => m_ReportFun = value;
- }
- /// <summary>
- /// 选择颗粒缓存表
- /// </summary>
- private List<Particle> Particleslist_selecttodisplay = new List<Particle>();
- //多个数据源,每个数据源拥有的列数,这里保存下来,供分组使用
- public List<int> m_list_oneresult_columncount;
- //国际化
- private Language lan;
- public Hashtable table;
- //测量结果
- public ResultFile result = null;
- private frmReportConditionChoose m_condition;
- private FieldData fieldData;
- private DataTable particlesAll;
- private DataTable particlesFilter;
- public ParticleData Particledata;
- public UserSTDDbAccess userSTDDb;
- public FieldImage fldImgAccess;
- private DataTable userSTDDbData;
- List<string> elementTypeSort;
- private readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
- private enum SelItem
- {
- analyticalParticle = 0,
- otherParticles = 1,
- MergeParticles = 2,
- allParticles = 3
- }
- #region 分页器相关
- #region 分页字段和属性
- private string condition = "";
- public string FileName = null;
- private int pageIndex = 1;
- /// <summary>
- /// 当前页面
- /// </summary>
- public virtual int PageIndex
- {
- get { return pageIndex; }
- set { pageIndex = value; }
- }
- private int pageSize = 20;
- /// <summary>
- /// 每页记录数
- /// </summary>
- public virtual int PageSize
- {
- get { return pageSize; }
- set { pageSize = value; }
- }
- private int recordCount = 0;
- /// <summary>
- /// 总记录数
- /// </summary>
- public virtual int RecordCount
- {
- get { return recordCount; }
- set { recordCount = value; }
- }
- private int pageCount = 0;
- /// <summary>
- /// 总页数
- /// </summary>
- public int PageCount
- {
- get
- {
- pageCount = GetPageCount();
- return pageCount;
- }
- }
- /// <summary>
- /// 计算总页数
- /// </summary>
- /// <returns></returns>
- private int GetPageCount()
- {
- if (PageSize <= 0)
- {
- return 0;
- }
- return (RecordCount + PageSize - 1) / PageSize;
- }
- #endregion
- private frmReportApp m_ReportApp;
- #endregion
- #endregion
- #region UI层方法
- #region 初始化
- public ParticlesGridDevidePage(frmReportApp ReportApp)
- {
- m_ReportApp = ReportApp;
- m_condition = ReportApp.m_conditionChoose;
- string sou = m_condition.m_CurrentConditions[OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
- if (sou.Contains("+"))
- {
- MessageBox.Show("This function does not support multiple samples!");
- result = m_ReportApp.m_rstDataMgr.ResultFilesList[0];
- }
- else
- {
- result = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE)];
- }
- ReportFun = new OTSImageDisHelp(result);
- //设置窗体的双缓冲,以保证大数据时拖动不卡
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
- this.UpdateStyles();
- InitializeComponent();
- //利用反射设置DataGridView的双缓冲
- Type dgvType = this.dgV_ParticlesDevidePage.GetType();
- PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
- pi?.SetValue(this.dgV_ParticlesDevidePage, true, null);
- this.control_XRayTable1 = new Control_XRayTable(null);
- this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.control_XRayTable1.GBInfoStr = "";
- this.control_XRayTable1.GoodChineseName = "";
- this.control_XRayTable1.MaterialName = "";
- this.control_XRayTable1.Location = new System.Drawing.Point(0, 400);
- this.control_XRayTable1.Name = "control_XRayTable1";
- this.control_XRayTable1.ShowAnalysisXray = true;
- this.control_XRayTable1.ShowSearchXray = false;
- this.control_XRayTable1.Size = new System.Drawing.Size(1004, 200);
- this.control_XRayTable1.STDName = "";
- this.control_XRayTable1.Visible = false;
- this.control_XRayTable1.label_close.Visible = true;
- this.Controls.Add(this.control_XRayTable1);
- }
- private bool Init()
- {
- if (result == null)
- {
- return false;
- }
- try
- {
- lan = new Language(this);
- table = lan.GetNameTable(this.Name);
- m_mythread_state = false;
- m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
- fieldData = new FieldData(result.FilePath);
- Particledata = new ParticleData(result.FilePath);
- fldImgAccess = new FieldImage(result.FilePath);
- var systype = m_ReportApp.m_RptConfigFile.Systype;
- if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
- {
- string str_STDDbName = result.GetSTDName();
- userSTDDb = new UserSTDDbAccess(str_STDDbName, result.FilePath + "\\");
-
- userSTDDbData = userSTDDb.GetSqlHelper() != null ?
- userSTDDb.GetSubAttributeFromDatabase() : null;
- }
- //初始化底层操作类
- m_OTSIncAReportGridsFun = new SEMAndEDSOperate();
- return true;
- }
- catch (Exception ex)
- {
- log.Error(ex.ToString());
- return false;
- }
- }
- private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
- {
- if (!Init())
- {
- return;
- }
- ProgressStart();
- if (!UpdateDataGrid())
- {
- return;
- }
- InitializePageSizeComboBox();
- InitializeTypeTextBox();
- dgV_ParticlesDevidePage.Focus();
- }
- private Dictionary<string, string> InitializeTable(ref string str_ElementsColName)
- {
- dgV_ParticlesDevidePage.Rows.Clear();
- dgV_ParticlesDevidePage.Columns.Clear();
- var startFun = m_ReportApp.m_RptConfigFile.Systype;
- string str_DefaultComputedColName = ""; str_ElementsColName = "";
- DataSet ds = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData"); DataTable dt = ds.Tables["Member"];
- foreach (DataRow element in dt.Rows)
- {
- string regName = element["RegName"].ToString();
- if (regName == "DefaultComputedColName")
- {
- str_DefaultComputedColName = element["strValue"].ToString();
- }
- else if (regName == "ElementsColName")
- {
- str_ElementsColName = element["strValue"].ToString();
- }
- }
- string[] strs = str_DefaultComputedColName.Split(',');
- var keyValues = new Dictionary<string, string>
- {
- ["rowid"] = table["str4"].ToString(),
- ["TypeName"] = table["str6"].ToString(),
- ["ParticleImage"] = table["str5"].ToString(),
- ["FieldId"] = "FieldId",
- ["ParticleId"] = "ParticleId",
- ["SEMPosX"] = "SEMPosX",
- ["SEMPosY"] = "SEMPosY"
- };
- foreach (string str in strs)
- {
- switch (str)
- {
- case "ParticleCoordinate":
- keyValues["AbPosX"] = "PosX";
- keyValues["AbPosY"] = "PosY"; break;
- case "Area":
- keyValues["Area"] = table["str21"].ToString();
- break;
- case "EquivalentCircleDiameter":
- keyValues["Equivalent"] = table["str22"].ToString();
- break;
- case "MaxDiameter":
- keyValues["DMAX"] = table["str23"].ToString();
- break;
- case "MinDiameter":
- keyValues["DMIN"] = table["str24"].ToString();
- break;
- case "DiameterRatio":
- keyValues["DiameterRatio"] = table["str25"].ToString(); break;
- case "FerretDiameter":
- keyValues["DFERET"] = table["str26"].ToString();
- break;
- case "PERP":
- keyValues["DPERP"] = table["str27"].ToString();
- break;
- case "PERI":
- keyValues["PERIMETER"] = table["str28"].ToString();
- break;
- case "INSCR":
- keyValues["DINSCR"] = table["str29"].ToString();
- break;
- case "MEAN":
- keyValues["DMEAN"] = table["str30"].ToString();
- break;
- case "ELONG":
- keyValues["DELONG"] = table["str31"].ToString();
- break;
- case "ASPECT_ELONG":
- keyValues["ASPECT_ELONG"] = table["str32"].ToString();
- break;
- case "Orientation":
- keyValues["ORIENTATION"] = table["str33"].ToString();
- break;
- case "XRayDataCount":
- keyValues["XRayDataCount"] = "XRay计数";
- break;
- }
- if (startFun == OTS_SysType_ID.TCCleannessA || startFun == OTS_SysType_ID.BatteryCleannessA)
- {
- switch (str)
- {
- case "Hardness":
- keyValues["Hardness"] = table["str34"].ToString();
- break;
- case "Density":
- keyValues["Density"] = table["str35"].ToString();
- break;
- case "Electrical_conductivity":
- keyValues["Electrical_conductivity"] = table["str36"].ToString();
- break;
- }
- }
- }
- keyValues["Element"] = "Element";
- return keyValues;
- }
- private void InitializePageSizeComboBox()
- {
- cbB_PageSize.Items.AddRange(new object[] { "20", "100", "500", "1000", "5000", "All" });
- cbB_PageSize.SelectedIndex = 0;
- }
- private void InitializeTypeTextBox()
- {
- DataTable classificationTable = GetClassificationOfAllParticles();
- if (classificationTable?.Rows.Count > 0)
- {
- tbx_Type.Text = string.Join("$", classificationTable.AsEnumerable()
- .Select(row => row["TypeName"].ToString()));
- }
- }
- // 新增:为 userSTDDbData 建立索引以加速查找
- private Dictionary<string, DataRow> BuildUserStdLookup()
- {
- var dict = new Dictionary<string, DataRow>();
- if (userSTDDbData == null)
- return dict;
- foreach (DataRow r in userSTDDbData.Rows)
- {
- var key = Convert.ToString(r["STDId"]);
- if (!dict.ContainsKey(key))
- dict.Add(key, r);
- }
- return dict;
- }
- private void InitializeGridViewColumns(Dictionary<string, string> keyValues)
- {
- dgV_ParticlesDevidePage.Rows.Clear();
- dgV_ParticlesDevidePage.Columns.Clear();
- foreach (var kvp in keyValues)
- {
- if (kvp.Key == "ParticleImage")
- {
- var iconColumn = new DataGridViewImageColumn
- {
- Name = kvp.Key,
- HeaderText = kvp.Value
- };
- dgV_ParticlesDevidePage.Columns.Add(iconColumn);
- }
- else if (kvp.Key != "Element")
- {
- dgV_ParticlesDevidePage.Columns.Add(kvp.Key, kvp.Value);
- if (IsNumericColumn(kvp.Key))
- {
- int id = dgV_ParticlesDevidePage.Columns.Count;
- dgV_ParticlesDevidePage.Columns[id - 1].Tag = "NumericType";
- }
- }
- }
- }
- #endregion
- #region 数据加载
- private DataTable GetParticleDataBySelection(int selection)
- {
- switch (selection)
- {
- case (int)SelItem.analyticalParticle:
- return Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
- case (int)SelItem.otherParticles:
- return Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
- case (int)SelItem.MergeParticles:
- return Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
- case (int)SelItem.allParticles:
- return Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
- default:
- return new DataTable();
- }
- }
- private bool UpdateDataGrid()
- {
- int sel = m_ReportApp.m_conditionChoose.m_conditionData
- .GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
- particlesAll = GetParticleDataBySelection(sel);
- if (particlesAll == null)
- {
- log.Error("There is an exception in the data of the database!");
- CloseProgressIfNeeded();
- return false;
- }
- // 添加必要列
- particlesAll.Columns.Add("Hardness");
- particlesAll.Columns.Add("Density");
- particlesAll.Columns.Add("Electrical_conductivity");
- // 使用字典索引 userSTDDbData,避免对每行使用 DataTable.Select(性能瓶颈)
- var userStdLookup = BuildUserStdLookup();
- UpdateHardnessDensityData(userStdLookup);
- btn_Sel.Enabled = true;
- DataTable elementchemistry = Particledata.GetElementChemistry();
- var elemIndex = BuildElementChemistryIndex(elementchemistry);
- UpdateElementData(elemIndex);
- particlesAll.Columns.Add("XRayDataCount");
- DataTable XRayData = Particledata.GetXRayData();
- var xrayIndex = BuildXRayDataIndex(XRayData);
- UpdateXRayDataCount(xrayIndex);
- return true;
- }
- private void UpdateHardnessDensityData(Dictionary<string, DataRow> userStdLookup)
- {
- string emptyValue = "";
- for (int i = 0; i < particlesAll.Rows.Count; i++)
- {
- string key = Convert.ToString(particlesAll.Rows[i]["TypeId"]);
- if (userSTDDbData != null && userStdLookup.TryGetValue(key, out var dr))
- {
- particlesAll.Rows[i]["Hardness"] = dr["Hardness"].ToString();
- particlesAll.Rows[i]["Density"] = dr["Density"].ToString();
- particlesAll.Rows[i]["Electrical_conductivity"] = dr["Electrical_conductivity"].ToString();
- }
- else
- {
- particlesAll.Rows[i]["Hardness"] = emptyValue;
- particlesAll.Rows[i]["Density"] = emptyValue;
- particlesAll.Rows[i]["Electrical_conductivity"] = emptyValue;
- }
- }
- }
- private Dictionary<string, List<DataRow>> BuildElementChemistryIndex(DataTable elementchemistry)
- {
- var elemIndex = new Dictionary<string, List<DataRow>>();
- foreach (DataRow er in elementchemistry.Rows)
- {
- string key = $"XRayId = {er["XRayId"]} and fieldid = {er["fieldid"]}";
- if (!elemIndex.TryGetValue(key, out var list))
- {
- list = new List<DataRow>();
- elemIndex[key] = list;
- }
- list.Add(er);
- }
- return elemIndex;
- }
- private void UpdateElementData(Dictionary<string, List<DataRow>> elemIndex)
- {
- for (int i = 0; i < particlesAll.Rows.Count; i++)
- {
- string key = $"XRayId = {particlesAll.Rows[i]["particleId"]} and fieldid = {particlesAll.Rows[i]["fieldid"]}";
- string concatenatedString = "";
- if (elemIndex.TryGetValue(key, out var drList))
- {
- concatenatedString = string.Join(";", drList.Select(dr => $"{dr["name"]}-{dr["Percentage"]}"));
- }
- particlesAll.Rows[i]["Element"] = concatenatedString;
- }
- }
- private Dictionary<string, byte[]> BuildXRayDataIndex(DataTable XRayData)
- {
- var xrayIndex = new Dictionary<string, byte[]>();
- foreach (DataRow xr in XRayData.Rows)
- {
- if (xr.ItemArray.Length >= 3 && xr[2] is byte[] b)
- {
- string key = $" XrayIndex= {xr[0]} and fieldid = {xr[1]}";
- if (!xrayIndex.ContainsKey(key))
- {
- xrayIndex[key] = b;
- }
- }
- }
- return xrayIndex;
- }
- private void UpdateXRayDataCount(Dictionary<string, byte[]> xrayIndex)
- {
- for (int i = 0; i < particlesAll.Rows.Count; i++)
- {
- string subParticleString = Convert.ToString(particlesAll.Rows[i]["SubParticles"]);
- if (string.IsNullOrEmpty(subParticleString))
- {
- particlesAll.Rows[i]["XRayDataCount"] = 0;
- string str = $" XrayIndex= {particlesAll.Rows[i]["particleId"]} and fieldid = {particlesAll.Rows[i]["fieldid"]}";
- if (xrayIndex.TryGetValue(str, out var bytes))
- {
- uint xraycount = 0;
- int len = bytes.Length / 4;
- for (int j = 0; j < len; j++)
- {
- xraycount += BitConverter.ToUInt32(bytes, j * 4);
- }
- particlesAll.Rows[i]["XRayDataCount"] = xraycount;
- }
- }
- else
- {
- particlesAll.Rows[i]["XRayDataCount"] = 0;
- DataRow dgvr = particlesAll.Rows[i];
- uint[] Analysis_xray = new uint[2000];
- Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(
- Convert.ToInt32(dgvr["particleId"]),
- Convert.ToInt32(dgvr["fieldid"]),
- out Analysis_xray);
- uint xraycount = 0;
- for (int j = 0; j < Analysis_xray.Length; j++)
- {
- xraycount += Analysis_xray[j];
- }
- particlesAll.Rows[i]["XRayDataCount"] = xraycount;
- }
- }
- }
- private void RefreshGridView()
- {
- dgV_ParticlesDevidePage.Visible = false;
- if (m_frm_userprogress == null || m_frm_userprogress.IsDisposed)
- {
- ProgressStart();
- }
- string str_ElementsColName = null;
- Dictionary<string, string> keyValues = InitializeTable(ref str_ElementsColName);
- // 减少 UI 重绘开销
- dgV_ParticlesDevidePage.SuspendLayout();
-
- try
- {
- InitializeGridViewColumns(keyValues);
- if (PageSize <= 0)
- {
- PageSize = particlesAll?.Rows.Count ?? 0;
- }
- if (particlesAll == null)
- {
- return;
- }
- UpdatePageData();
- InitializeElementColumns(str_ElementsColName);
- LoadParticleData(keyValues);
- }
- finally
- {
- dgV_ParticlesDevidePage.ResumeLayout();
- dgV_ParticlesDevidePage.Visible = true;
- CloseProgress();
- }
- }
- private void UpdatePageData()
- {
- RecordCount = particlesAll.Rows.Count;
- particlesFilter = particlesAll.Clone();
- int startRow = (PageIndex - 1) * pageSize;
- int endRow = Math.Min(startRow + pageSize, RecordCount);
- for (int fi = startRow; fi < endRow; fi++)
- {
- particlesFilter.ImportRow(particlesAll.Rows[fi]);
- }
- }
- private void InitializeElementColumns(string str_ElementsColName)
- {
- elementTypeSort = string.IsNullOrEmpty(str_ElementsColName) ?
- new List<string>() :
- str_ElementsColName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
- .Distinct()
- .ToList();
- foreach (string element in elementTypeSort)
- {
- dgV_ParticlesDevidePage.Columns.Add(element, element);
- int id = dgV_ParticlesDevidePage.Columns.Count;
- dgV_ParticlesDevidePage.Columns[id - 1].Tag = "NumericType";
- }
- }
- private void LoadParticleData(Dictionary<string, string> keyValues)
- {
- if (particlesFilter?.Rows.Count == 0) return;
- double progressStep = particlesFilter.Rows.Count > 0 ? 95.0 / particlesFilter.Rows.Count : 95.0;
- string filePath = Path.Combine(result.FilePath, "FIELD_FILES");
- // 把 fieldpics 缓存提升到循环外,避免对同一 field 多次磁盘读取
- var fieldPics = new Dictionary<string, Bitmap>(StringComparer.OrdinalIgnoreCase);
- for (int i = 0; i < particlesFilter.Rows.Count; i++)
- {
- if (i % 10 == 0 && m_frm_userprogress != null && !m_frm_userprogress.IsDisposed)
- m_frm_userprogress.SetProgressValueAndText((int)(progressStep * i), "loading..");
- int add_rowindex = dgV_ParticlesDevidePage.Rows.Add();
- dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[0].Value =
- (pageSize * (PageIndex - 1) + add_rowindex + 1).ToString();
- LoadParticleRowData(i, add_rowindex, keyValues, fieldPics);
-
- }
- }
- private void ProcessColumnData(int rowIndex, int gridRowIndex, int columnIndex, string columnName, Dictionary<string, Bitmap> fieldPics)
- {
- switch (columnName)
- {
- case "ParticleImage":
- ProcessParticleImageColumn(rowIndex, gridRowIndex, columnIndex, fieldPics);
- break;
- case "DiameterRatio":
- ProcessDiameterRatioColumn(rowIndex, gridRowIndex, columnIndex);
- break;
- case "ASPECT_ELONG":
- ProcessAspectElongColumn(rowIndex, gridRowIndex, columnIndex);
- break;
- case "Element":
- ProcessElementColumn(rowIndex, gridRowIndex);
- break;
- case "TypeName":
- ProcessTypeNameColumn(rowIndex, gridRowIndex, columnIndex);
- break;
- case "Equivalent":
- ProcessEquivalentColumn(rowIndex, gridRowIndex, columnIndex);
- break;
- case "Hardness":
- ProcessHardnessColumn(rowIndex, gridRowIndex, columnIndex);
- break;
- case "AbPosX":
- ProcessAbPosColumn(rowIndex, gridRowIndex);
- break;
- default:
- break;
- }
- AdjustTheFormatOfTheUnitValues(rowIndex, gridRowIndex, columnIndex, columnName);
- }
- private void ProcessParticleImageColumn(int rowIndex, int gridRowIndex, int columnIndex, Dictionary<string, Bitmap> fieldPics)
- {
- string subParticleString = Convert.ToString(particlesFilter.Rows[rowIndex]["SubParticles"]);
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Height = 70;
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Style.BackColor = Color.Azure;
- Bitmap bmap = null;
- if (!string.IsNullOrEmpty(subParticleString) && subParticleString != "IsSubParticle")
- {
- bmap = CreateMergedParticleImage(subParticleString);
- }
- else if (subParticleString != "IsSubParticle")
- {
- bmap = CreateSingleParticleImage(rowIndex, fieldPics);
- }
- bmap.Tag = new List<string>() { particlesFilter.Rows[rowIndex]["fieldid"].ToString(), particlesFilter.Rows[rowIndex]["ParticleId"].ToString() };
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = bmap;
- }
- private void LoadParticleRowData(int rowIndex, int gridRowIndex, Dictionary<string, string> keyValues, Dictionary<string, Bitmap> fieldPics)
- {
- foreach (var kvp in keyValues)
- {
- int columnIndex = dgV_ParticlesDevidePage.Columns.IndexOf(dgV_ParticlesDevidePage.Columns[kvp.Key]);
- //if (columnIndex < 0) continue;
- ProcessColumnData(rowIndex, gridRowIndex, columnIndex, kvp.Key, fieldPics);
- }
- }
- private void ProcessElementColumn(int rowIndex, int gridRowIndex)
- {
- List<string> elementtemp = new List<string>(elementTypeSort);
- string[] strcbo = particlesFilter.Rows[rowIndex]["Element"].ToString().Split(';');
- for (int j = 0; j < strcbo.Length; j++)
- {
- if (elementTypeSort.Count == 0)
- {
- break;
- }
- string[] str = strcbo[j].Split('-');
- if (elementTypeSort.Contains(str[0]))
- { dgV_ParticlesDevidePage.Rows[rowIndex].Cells[str[0].ToString()].Value = Math.Round(double.Parse(str[1]), 2).ToString(); }
- elementtemp.Remove(str[0].ToString());
- }
- foreach (var ele in elementtemp)
- {
- dgV_ParticlesDevidePage.Rows[rowIndex].Cells[ele].Value = "0";
- }
- }
- private void ProcessTypeNameColumn(int rowIndex, int gridRowIndex, int columnIndex)
- {
- if (particlesFilter.Rows[rowIndex]["TypeId"].ToString() == "9")
- {
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = "Not Identified";
- }
- }
- private void ProcessEquivalentColumn(int rowIndex, int gridRowIndex, int columnIndex)
- {
- double dSize = Convert.ToDouble(particlesFilter.Rows[rowIndex]["Area"]);
- double diameter = Math.Sqrt(dSize / Math.PI) * 2;
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = Math.Round(diameter, 2);
- }
- private void ProcessHardnessColumn(int rowIndex, int gridRowIndex, int columnIndex)
- {
- string hardnessColor = ChangeHardnessColor(Convert.ToString(particlesFilter.Rows[rowIndex]["Hardness"]));
- if (hardnessColor == "#FF0000")
- {
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Style.ForeColor = Color.Red;
- }
- }
- private void ProcessAbPosColumn(int rowIndex, int gridRowIndex)
- {
- Point semPos = new Point(
- Convert.ToInt32(particlesFilter.Rows[rowIndex]["SEMPosX"]),
- Convert.ToInt32(particlesFilter.Rows[rowIndex]["SEMPosY"]));
- Point particlePos = new Point(
- Convert.ToInt32(particlesFilter.Rows[rowIndex]["PosX"]),
- Convert.ToInt32(particlesFilter.Rows[rowIndex]["PosY"]));
- Point point = CalculateParticleCenterPosition(result, semPos, particlePos);
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells["AbPosX"].Value = point.X;
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells["AbPosY"].Value = point.Y;
- }
- private void ProcessDiameterRatioColumn(int rowIndex, int gridRowIndex, int columnIndex)
- {
- double dmax = Convert.ToDouble(particlesFilter.Rows[rowIndex]["DMAX"]);
- double dmin = Convert.ToDouble(particlesFilter.Rows[rowIndex]["DMIN"]);
- double ratio = dmin != 0 ? dmax / dmin : 0;
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = Math.Round(ratio, 2);
- }
- private void ProcessAspectElongColumn(int rowIndex, int gridRowIndex, int columnIndex)
- {
- double delong = Convert.ToDouble(particlesFilter.Rows[rowIndex]["DELONG"]);
- double dmean = Convert.ToDouble(particlesFilter.Rows[rowIndex]["DMEAN"]);
- double ratio = dmean != 0 ? delong / dmean : 0;
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = Math.Round(ratio, 2);
- }
- /// <summary>
- /// 页面控件呈现
- /// </summary>
- private void DrawControl(bool callEvent)
- {
- RefreshGridView();
- lblTotalCount.Text = RecordCount.ToString();
- lblPageCount.Text = PageCount.ToString();
- txtPageNum.Text = PageIndex.ToString();
- SetFormCtrEnabled();
- if (PageCount == 0 || PageCount == 1) //有且仅有一页
- {
- lnkFirst.Enabled = false;
- lnkPrev.Enabled = false;
- lnkNext.Enabled = false;
- lnkLast.Enabled = false;
- btnGo.Enabled = false;
- }
- else if (PageIndex == 1) //第一页
- {
- lnkFirst.Enabled = false;
- lnkPrev.Enabled = false;
- }
- else if (PageIndex == PageCount) //最后一页
- {
- lnkNext.Enabled = false;
- lnkLast.Enabled = false;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private void DisplayData()
- {
- if (cbB_PageSize.SelectedItem?.ToString() == "All"){pageSize = -1;}
- else if (int.TryParse(cbB_PageSize.SelectedItem?.ToString(), out int parsedSize)){pageSize = parsedSize;}
- lnkFirst_Click(null, null);
- SetDataGridViewStyle();
- }
- #endregion
- #region 健壮性判断
- private bool IsNumericColumn(string columnName)
- {
- string[] numericColumns = {
- "Area", "EquivalentCircleDiameter", "MaxDiameter", "MinDiameter",
- "DiameterRatio", "FerretDiameter", "PERP", "PERI", "INSCR",
- "MEAN", "ELONG", "ASPECT_ELONG", "Orientation"
- };
- return numericColumns.Contains(columnName);
- }
- /// <summary>
- /// 判断条件输入 前<后
- /// </summary>
- /// <param name="min"></param>
- /// <param name="max"></param>
- /// <returns></returns>
- private bool CompareInput(string min, string max)
- {
- if (!double.TryParse(max, out double dmax))
- {
- if (!int.TryParse(max, out int imax))
- return false;
- dmax = imax;
- }
- if (!double.TryParse(min, out double dmin))
- {
- if (!int.TryParse(min, out int imin))
- return false;
- dmin = imin;
- }
- return dmin <= dmax;
- }
- private bool ValidateAndAddCondition(string value, string fieldName, string operatorSymbol)
- {
- if (string.IsNullOrWhiteSpace(value)) return true;
- if (double.TryParse(value, out double dnum) && dnum >= 0)
- {
- condition += $" and {fieldName} {operatorSymbol} {value}";
- return true;
- }
- if (int.TryParse(value, out int inum) && inum >= 0)
- {
- condition += $" and {fieldName} {operatorSymbol} {value}";
- return true;
- }
- ShowErrorMessage("str10");
- return false;
- }
- private bool ValidateIntegerField(string value, string fieldName)
- {
- if (string.IsNullOrWhiteSpace(value)) return true;
- if (int.TryParse(value, out _))
- {
- condition += $" and {fieldName} = {value}";
- return true;
- }
- ShowErrorMessage("str10");
- return false;
- }
- private bool ProcessECDConditions()
- {
- if (!string.IsNullOrWhiteSpace(tbx_ECDMin.Text))
- {
- if (double.TryParse(tbx_ECDMin.Text, out double dnum) && dnum >= 0)
- {
- double area = Math.PI * dnum / 2 * dnum / 2;
- condition += $" and Area > {area}";
- }
- else if (int.TryParse(tbx_ECDMin.Text, out int inum) && inum >= 0)
- {
- double area = Math.PI * inum / 2 * inum / 2;
- condition += $" and Area > {area}";
- }
- else
- {
- ShowErrorMessage("str10");
- return false;
- }
- }
- if (!string.IsNullOrWhiteSpace(tbx_ECDMax.Text))
- {
- if (double.TryParse(tbx_ECDMax.Text, out double dnum) && dnum >= 0)
- {
- double area = Math.PI * dnum / 2 * dnum / 2;
- condition += $" and Area < {area}";
- }
- else if (int.TryParse(tbx_ECDMax.Text, out int inum) && inum >= 0)
- {
- double area = Math.PI * inum / 2 * inum / 2;
- condition += $" and Area < {area}";
- }
- else
- {
- ShowErrorMessage("str10");
- return false;
- }
- }
- if (!string.IsNullOrWhiteSpace(tbx_ECDMin.Text) &&
- !string.IsNullOrWhiteSpace(tbx_ECDMax.Text))
- {
- if (!CompareInput(tbx_ECDMin.Text, tbx_ECDMax.Text))
- {
- ShowErrorMessage("str11");
- return false;
- }
- }
- return true;
- }
- private void ShowErrorMessage(string resourceKey)
- {
- MessageBox.Show(table?[resourceKey].ToString() ?? "输入错误");
- }
- #endregion
- #region 数据处理
- private Bitmap CreateMergedParticleImage(string subParticleString)
- {
- double pix = result.GetPixelSize();
- int width = result.GetImageWidth();
- int height = result.GetImageHeight();
- string vs = "," + subParticleString.Replace(':', '-') + ",";
- DataTable dataTable = Particledata.GetParticleAllForBig(vs);
- var bmap1 = fldImgAccess.GetBitmapForMergedParticle(subParticleString, pix, height, width, dataTable);
- int cellWidth = dgV_ParticlesDevidePage.Columns["ParticleImage"].Width - 20;
- int cellHeight = dgV_ParticlesDevidePage.Rows[0].Height - 20;
- var ratioX = (double)cellWidth / bmap1.Width;
- var ratioY = (double)cellWidth / bmap1.Height;
- var ratio = Math.Min(ratioX, ratioY);
- var bmap = fldImgAccess.ScaleImageProportional(bmap1, ratio);
- return bmap;
- }
- private Bitmap CreateSingleParticleImage(int rowIndex, Dictionary<string, Bitmap> fieldPics)
- {
- string fid = Convert.ToString(particlesFilter.Rows[rowIndex]["fieldid"]);
- if (!fieldPics.ContainsKey(fid))
- {
- string imagePath = "Field" + fid + ".bmp";
- fieldPics[fid] = fldImgAccess.ReadImageFile(imagePath);
- }
- Rectangle rectangle = new Rectangle()
- {
- X = Convert.ToInt32(particlesFilter.Rows[rowIndex]["RectLeft"]),
- Y = Convert.ToInt32(particlesFilter.Rows[rowIndex]["RectTop"]),
- Width = Convert.ToInt32(particlesFilter.Rows[rowIndex]["RectWidth"]),
- Height = Convert.ToInt32(particlesFilter.Rows[rowIndex]["RectHeight"])
- };
- var src = fieldPics[fid];
-
- if (src != null)
- {
- var bmap = fldImgAccess.CapturePic(src, rectangle);
- //dgV_ParticlesDevidePage.Rows[0].Height = bmap.Height + 20;
- return bmap;
- }
- return null;
- }
- /// <summary>
- /// 计算颗粒中心的电镜坐标
- /// </summary>
- /// <param name="resultFile"></param>
- /// <param name="SEMPos"></param>
- /// <param name="ParticlePos"></param>
- /// <returns></returns>
- public static Point CalculateParticleCenterPosition(ResultFile resultFile, Point SEMPos, Point ParticlePos)
- {
- Point point = new Point();
- float scanFieldSizeX = resultFile.GetScanFieldSizeX();
- string leftOrRight = resultFile.GetXAxisDir();
- string downOrUp = resultFile.GetYAxisDir();
- float scanFieldSizeY = resultFile.GetScanFieldSizeY();
- float pixelSize = resultFile.GetPixelSize();
- if (leftOrRight == "RIGHT_TOWARD")
- {
- point.X = (int)(SEMPos.X - scanFieldSizeX / 2 + ParticlePos.X * pixelSize);
- }
- else
- {
- point.X = (int)(SEMPos.X + scanFieldSizeX / 2 - ParticlePos.X * pixelSize);
- }
- if (downOrUp == "UP_TOWARD")
- {
- point.Y = (int)(SEMPos.Y + scanFieldSizeY / 2 - ParticlePos.Y * pixelSize);
- }
- else
- {
- point.Y = (int)(SEMPos.Y - scanFieldSizeY / 2 + ParticlePos.Y * pixelSize);
- }
- return point;
- }
- /// <summary>
- /// 复制选择区域
- /// </summary>
- public void CopySelected()
- {
- //复制选择区域
- object clipboardContent = dgV_ParticlesDevidePage.GetClipboardContent();
- if (clipboardContent != null)
- Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
- }
- /// <summary>
- /// 复制所有
- /// </summary>
- public void CopyAll()
- {
- dgV_ParticlesDevidePage.SelectAll();
- Clipboard.SetDataObject(dgV_ParticlesDevidePage.GetClipboardContent());
- }
- /// <summary>
- /// 以图像的方式将GridView进行截图
- /// </summary>
- public void CopyImage()
- {
- int width = dgV_ParticlesDevidePage.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) + 2;
- int height = this.Height;
- using (Bitmap image = new Bitmap(width, height))
- {
- dgV_ParticlesDevidePage.DrawToBitmap(image, new Rectangle(0, 0, width, height));
- Clipboard.SetImage(image);
- }
- }
- private void dgV_ParticlesDevidePage_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
- {
- //排序中
- if (e.Column.Tag?.ToString() == "NumericType")
- {
- if (double.TryParse(e.CellValue1?.ToString(), out double val1) &&
- double.TryParse(e.CellValue2?.ToString(), out double val2))
- {
- e.SortResult = val1.CompareTo(val2);
- e.Handled = true;
- }
- }
- }
- private string ChangeHardnessColor(string hardness)
- {
- if (string.IsNullOrEmpty(hardness))
- return "";
- string str = System.Text.RegularExpressions.Regex.Replace(hardness, @"[^\d.\d]", "");
- return double.TryParse(str, out double hd) && hd >= 1000 ? "#FF0000" : "";
- }
- private void SaveParticleslist_select()
- {
- ParticleData fielddata = new ParticleData(result.FilePath);
- List<Particle> particles = fielddata.GetParticleAllList();
- Particleslist_selecttodisplay.Clear();
- for (int l = 0; l < dgV_ParticlesDevidePage.SelectedRows.Count; l++)
- {
- //从事先加载的Bitmap对象的Tag中取出List<string>
- DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[l];
- string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
- DataRow[] drs = particlesFilter.Select(str);
- DataRow row = drs[0];
- string subParticleString = row["SubParticles"].ToString();
- int i_ls_fieldid = -1; int i_ls_particleid = -1;
- if (subParticleString != "" && subParticleString != null)
- {
- string[] SubParticlesstrG = subParticleString.Split(',');
- if (SubParticlesstrG.Length > 1)
- {
- string fieldid1 = SubParticlesstrG[0].Split(':')[0];
- string pid1 = SubParticlesstrG[0].Split(':')[1];
- i_ls_fieldid = Convert.ToInt32(fieldid1);
- i_ls_particleid = Convert.ToInt32(pid1);
- }
- }
- else
- {
- Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
- List<string> list_str = (List<string>)ls_bp.Tag;
- if (list_str != null)
- {
- i_ls_fieldid = Convert.ToInt32(list_str[0]);
- i_ls_particleid = Convert.ToInt32(list_str[1]);
- }
- }
- foreach (Particle item in particles)
- {
- if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
- {
- Particleslist_selecttodisplay.Add(item);
- break;
- }
- }
- }
- }
- public List<Particle> GetParticleslist_select()
- {
- return Particleslist_selecttodisplay;
- }
- /// <summary>
- /// 获取所有颗粒的分类信息
- /// </summary>
- /// <returns></returns>
- public DataTable GetClassificationOfAllParticles()
- {
- string str = "";
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
- if (sel == (int)SelItem.analyticalParticle)
- {
- str = "where xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle' ";
- }
- else if (sel == (int)SelItem.otherParticles)
- {
- str = "where SubParticles is not 'IsSubParticle'and(typeid =9 or typeid =-1 or typeid =4)";
- }
- else
- {
- }
- DataTable table = Particledata.GetClassificationOfAllParticles(str);
- return table;
- }
- #endregion
- #region 格式处理
- private void AdjustTheFormatOfTheUnitValues(int rowIndex, int gridRowIndex, int columnIndex, string columnName)
- {
- if (!particlesFilter.Columns.Contains(columnName)) return;
-
- if (columnName== "Element") return;
- var cellValue = particlesFilter.Rows[rowIndex][columnName];
- if (cellValue == null) return;
- if (double.TryParse(cellValue.ToString(), out double num))
- {
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = Math.Round(num, 2);
- }
- else
- {
- dgV_ParticlesDevidePage.Rows[gridRowIndex].Cells[columnIndex].Value = cellValue.ToString();
- }
- }
- private void SetFormCtrEnabled()
- {
- lnkFirst.Enabled = true;
- lnkPrev.Enabled = true;
- lnkNext.Enabled = true;
- lnkLast.Enabled = true;
- btnGo.Enabled = true;
- }
- /// <summary>
- /// 设置DataGridView样式
- /// </summary>
- private void SetDataGridViewStyle()
- {
- //用户不能调整标题的高度
- dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- //用户不能调整 行高
- dgV_ParticlesDevidePage.AllowUserToResizeRows = false;
- //点击选择整行
- dgV_ParticlesDevidePage.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- //居中显示
- DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle
- {
- Alignment = DataGridViewContentAlignment.MiddleCenter
- };
- dgV_ParticlesDevidePage.DefaultCellStyle = dataGridViewCellStyle1;
- dgV_ParticlesDevidePage.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- //再次重覆禁用拖动表头高度,居然有效果了
- dgV_ParticlesDevidePage.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- //设置grid可以复制
- dgV_ParticlesDevidePage.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
- //设置每列的宽度
- if (dgV_ParticlesDevidePage.Columns.Count > 0)
- {
- dgV_ParticlesDevidePage.Columns[0].Width = 40; //第一列序号的宽度设置一下吧,要不太丑
- if (dgV_ParticlesDevidePage.Columns.Count > 1)
- dgV_ParticlesDevidePage.Columns[1].Width = 150;
- }
- //设置序号列不排序
- if (dgV_ParticlesDevidePage.Columns.Count > 0)
- {
- dgV_ParticlesDevidePage.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- if (dgV_ParticlesDevidePage.Columns.Count > 1)
- dgV_ParticlesDevidePage.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- //设置序号列不可以设置宽度
- if (dgV_ParticlesDevidePage.Columns.Count > 0)
- dgV_ParticlesDevidePage.Columns[0].Resizable = DataGridViewTriState.False;
- dgV_ParticlesDevidePage.RowsDefaultCellStyle.BackColor = Color.Azure;
- }
- #endregion
- #region 进度条
- private void CloseProgress()
- {
- //加载完成设置鼠标为默认
- this.Cursor = Cursors.Default;
- string str8 = table?["str8"].ToString() ?? "完成";
- if (m_frm_userprogress != null && !m_frm_userprogress.IsDisposed)
- {
- m_frm_userprogress.SetProgressValueAndText(100, str8);
- m_frm_userprogress.Close();
- }
- }
- private void CloseProgressIfNeeded()
- {
- this.Cursor = Cursors.Default;
- if (m_frm_userprogress != null && !m_frm_userprogress.IsDisposed)
- m_frm_userprogress.Close();
- }
- private 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 + 80,
- ls_main_form.Location.Y + (int)(MyPrimaryScreen.DESKTOP.Height / MyPrimaryScreen.ScaleX) / 2);
- m_frm_userprogress.Show();
- m_frm_userprogress.SetProgressValueAndText(0, "Loading data of particles...");
- }
- #endregion
- }
- #endregion
- #region UI事件
- private void ToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- //复制整个表
- CopyAll();
- }
- private void ToolStripMenuItem2_Click(object sender, EventArgs e)
- {
- //复制选择区域
- CopySelected();
- }
- private void toolStripMenuItem4_Click(object sender, EventArgs e)
- {
- //对gridview进行截图
- CopyImage();
- }
- private void ToolStripMenuItem5_Click(object sender, EventArgs e)
- {
- /*注意:多数据源情况下,只获取第一个数据源的选择了多行的情况下,只获取最后一个选择行的,没有办法,这是为了符合李阳博士提出的要求*/
- //先获取鼠标所选择的行里的颗粒的FieldID和ParticleID
- if (dgV_ParticlesDevidePage.SelectedRows.Count == 0) return;
- string i_ls_fieldid = "";
- string i_ls_particleid = "";
- int cou = dgV_ParticlesDevidePage.SelectedRows.Count;
- DataGridViewRow dgvr = dgV_ParticlesDevidePage.SelectedRows[cou - 1];
- if (dgvr.Cells[2].Value is Bitmap ls_bp && ls_bp.Tag is List<string> list_str)
- {
- i_ls_fieldid = list_str[0];
- i_ls_particleid = list_str[1];
- }
- ParticleData particleData = new ParticleData(result.FilePath);
- Particle particle = particleData.GetParticleByFidAndPid(i_ls_fieldid, i_ls_particleid);
- //取得Field的Position,然后执行线程移动SEM到当前Field的位置
- if (m_mythread == null) return;
- if (m_mythread.ThreadState == ThreadState.Running ||
- m_mythread.ThreadState == ThreadState.WaitSleepJoin)
- {
- return;
- }
- if (m_mythread.ThreadState == ThreadState.Stopped)
- {
- m_mythread = new Thread(new ParameterizedThreadStart(ControlThread_GO));
- }
- Point point = CalculateParticleCenterPosition(result,
- new Point(particle.SEMPosX, particle.SEMPosY),
- new Point(particle.PosX, particle.PosY));
- //改为线程调用,先判断线程状态
- m_mythread.Start(point);
- }
- private void ToolStripMenuItem_exportimagefile_Click(object sender, EventArgs e)
- {
- using (FolderBrowserDialog fbd = new FolderBrowserDialog())
- {
- if (fbd.ShowDialog() != DialogResult.OK) return;
- m_imagefilepath = fbd.SelectedPath;
- for (int i = 0; i < dgV_ParticlesDevidePage.Rows.Count; i++)
- {
- if (dgV_ParticlesDevidePage.Rows[i].Cells[2].Value is Bitmap ls_bp)
- {
- string filePath = Path.Combine(m_imagefilepath, $"{(i + 1)}.jpg");
- ls_bp.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
- }
- }
- string str9 = table?["str9"].ToString() ?? "导出完成,共导出 ";
- MessageBox.Show(str9 + dgV_ParticlesDevidePage.Rows.Count.ToString());
- }
- }
- private void testToolStripMenuItem_Click(object sender, EventArgs e)
- {
- // Empty method placeholder
- }
- private void btn_Sel_Click(object sender, EventArgs e)
- {
- condition = "";
- if (!ValidateAndAddCondition(tBx_AreaMin.Text, "Area", ">"))
- return;
- if (!ValidateAndAddCondition(Tbx_AreaMax.Text, "Area", "<"))
- return;
- if (!string.IsNullOrWhiteSpace(tBx_AreaMin.Text) &&
- !string.IsNullOrWhiteSpace(Tbx_AreaMax.Text))
- {
- if (!CompareInput(tBx_AreaMin.Text, Tbx_AreaMax.Text))
- {
- ShowErrorMessage("str11");
- return;
- }
- }
- if (!ValidateAndAddCondition(tbx_DmaxMin.Text, "DMAX", ">"))
- return;
- if (!ValidateAndAddCondition(tbx_DmaxMax.Text, "DMAX", "<"))
- return;
- if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text) &&
- !string.IsNullOrWhiteSpace(tbx_DmaxMax.Text))
- {
- if (!CompareInput(tbx_DmaxMin.Text, tbx_DmaxMax.Text))
- {
- ShowErrorMessage("str11");
- return;
- }
- }
- if (!ValidateIntegerField(tB_FieldId.Text, "FieldId"))
- return;
- if (!ValidateIntegerField(tB_ParticleId.Text, "ParticleId"))
- return;
- if (!ValidateAndAddCondition(tbx_DferretMin.Text, "DFERET", ">"))
- return;
- if (!ValidateAndAddCondition(tbx_DferretMax.Text, "DFERET", "<"))
- return;
- if (!string.IsNullOrWhiteSpace(tbx_DferretMin.Text) &&
- !string.IsNullOrWhiteSpace(tbx_DferretMax.Text))
- {
- if (!CompareInput(tbx_DferretMin.Text, tbx_DferretMax.Text))
- {
- ShowErrorMessage("str11");
- return;
- }
- }
- if (!ProcessECDConditions())
- return;
- if (!string.IsNullOrWhiteSpace(tbx_Type.Text))
- {
- string[] types = tbx_Type.Text.Split('$');
- condition += " and (";
- for (int i = 0; i < types.Length; i++)
- {
- if (i == 0)
- {
- condition += $" TypeName = '{types[i]}'";
- }
- else
- {
- condition += $" or TypeName = '{types[i]}'";
- }
- }
- condition += ")";
- }
- if (m_frm_userprogress?.IsDisposed != false)
- {
- ProgressStart();
- }
- UpdateDataGrid();
- lnkFirst_Click(null, null);
- SetDataGridViewStyle();
- }
- /// <summary>
- /// 分页属性改变了。
- /// </summary>
- private void txtPageSize_TextChanged(object sender, EventArgs e)
- {
- if (!int.TryParse(txtPageNum.Text.Trim(), out int num) || num <= 0)
- {
- txtPageNum.Text = "1";
- }
- }
- private void lnkFirst_Click(object sender, EventArgs e)
- {
- PageIndex = 1;
- DrawControl(true);
- }
- private void lnkPrev_Click(object sender, EventArgs e)
- {
- PageIndex = Math.Max(1, PageIndex - 1);
- DrawControl(true);
- }
- private void lnkNext_Click(object sender, EventArgs e)
- {
- PageIndex = Math.Min(PageCount, PageIndex + 1);
- DrawControl(true);
- }
- private void lnkLast_Click(object sender, EventArgs e)
- {
- PageIndex = PageCount;
- DrawControl(true);
- }
- /// <summary>
- /// 跳转
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnGo_Click(object sender, EventArgs e)
- {
- if (int.TryParse(txtPageNum.Text.Trim(), out int num) && num > 0)
- {
- if (num > PageCount)
- {
- num = PageCount;
- txtPageNum.Text = PageCount.ToString();
- }
- PageIndex = num;
- DrawControl(true);
- }
- }
- private void cbB_PageSize_SelectedIndexChanged(object sender, EventArgs e)
- {
- DisplayData();
- }
- private void EXCELToolStripMenuItem_Click(object sender, EventArgs e)
- {
- using (var sfd = new OTSIncAReportApp._1_UI.Control_Grids.SpectrumExportConfirmation())
- {
- if (sfd.ShowDialog() != DialogResult.OK) return;
-
- if (m_frm_userprogress?.IsDisposed != false)
- {
- ProgressStart();
- }
- try
- {
- ExcelExport excelExport=new ExcelExport(dgV_ParticlesDevidePage,particlesFilter,Particledata, m_frm_userprogress);
- excelExport.ExportToExcel(sfd);
- }
- finally
- {
- //加载完成,关闭进度条
- if (m_frm_userprogress != null && !m_frm_userprogress.IsDisposed)
- {
- m_frm_userprogress.SetProgressValueAndText(100, "导出完成");
- m_frm_userprogress.Close();
- }
- Cursor = Cursors.Default;
- //导出完成后,打开Excel文件
- if (File.Exists(sfd.FileName))
- {
- System.Diagnostics.Process.Start(sfd.FileName);
- }
- }
- }
- }
- private void ToolStripMenuItem3_Click(object sender, EventArgs e)
- {
- //如果没有选中颗粒退出
- if (dgV_ParticlesDevidePage.SelectedRows.Count == 0)
- {
- return;
- }
- string categoryName = GetSelectedCategoryName();
- var classificationData = GetClassificationData();
- using (var modifyCategoryForm = new ModifyCategoryForm(classificationData, categoryName))
- {
- if (modifyCategoryForm.ShowDialog() != DialogResult.OK ||
- !modifyCategoryForm.DoYouWantToModifyIt)
- {
- return;
- }
- var updateParams = GetUpdateParameters(modifyCategoryForm);
- HandleCategoryUpdate(updateParams);
- }
- }
- private void ToolStripMenuItem_Delete_Particle_Click(object sender, EventArgs e)
- {
- string path = result.FilePath;
- var fieldData = new ParticleData(result.FilePath);
- List<Particle> particles = fieldData.GetParticleAllList();
- DialogResult dr = MessageBox.Show("Remove all these particles permanently?",
- "Tips", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- DeleteSelectedParticles(particles);
- }
- }
- private void btn_particletypesel_Click(object sender, EventArgs e)
- {
- ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
- DialogResult result = particleClassificationSelect.ShowDialog();
- if (result == DialogResult.OK)
- {
- condition = "";
- tbx_Type.Text = "";
- if (particleClassificationSelect.ParticleClassificationSelected != "")
- {
- tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
- btn_Sel_Click(null, null);
- }
- }
- }
- private void btn_showconfig_Click(object sender, EventArgs e)
- {
- var p = particlesFilter; List<string> ele = new List<string>();
- string elementsstr = "";
- foreach (DataRow row in particlesFilter.Rows)
- {
- string[] strcbo = row["Element"].ToString().Split(';');
- for (int j = 0; j < strcbo.Length; j++)
- {
- string[] str = strcbo[j].Split('-');
- if (!ele.Contains(str[0]) && str[0] != "")
- {
- if (str[1] != "" && double.Parse(str[1]) != 0) //咨询demo后,元素含量返回值为零时一般去除此元素
- { ele.Add(str[0]); }
- }
- }
- }
- foreach (var el in ele)
- {
- elementsstr += el.ToString() + ',';
- }
- if (elementsstr != "")
- {
- elementsstr = elementsstr.Remove(elementsstr.Length - 1, 1);
- }
- m_particlesGridDevidePageShowConfig = new ParticlesGridDevidePageShowConfig(m_ReportApp.m_RptConfigFile.Systype, elementsstr);
- m_particlesGridDevidePageShowConfig.ShowDialog();
- if (m_particlesGridDevidePageShowConfig.DialogResult == DialogResult.OK)
- {
- dgV_ParticlesDevidePage.Rows.Clear();
- dgV_ParticlesDevidePage.Columns.Clear();
- RefreshGridView();
- SetDataGridViewStyle();
- }
- }
- private void tbx_Type_Click(object sender, EventArgs e)
- {
- ParticleClassificationSelect particleClassificationSelect = new ParticleClassificationSelect(this, tbx_Type.Text);
- DialogResult result = particleClassificationSelect.ShowDialog();
- if (result == DialogResult.OK)
- {
- condition = "";
- tbx_Type.Text = particleClassificationSelect.ParticleClassificationSelected;
- string[] tr = tbx_Type.Text.Split(',');
- condition += " and (";
- for (int i = 0; i < tr.Length; i++)
- {
- if (i == 0)
- {
- condition += " TypeName = '" + tr[i] + "'";
- }
- else
- {
- condition += " or TypeName = '" + tr[i] + "'";
- }
- }
- condition += ")";
- if (m_frm_userprogress.IsDisposed)
- {
- ProgressStart();
- }
- UpdateDataGrid();
- lnkFirst_Click(null, null);
- SetDataGridViewStyle();
- }
- }
- private void 根据相似度批量修改ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //如果没有选中颗粒退出
- if (dgV_ParticlesDevidePage.SelectedRows.Count != 1)
- {
- MessageBox.Show("Please select one row!");
- return;
- }
- var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
- DataGridViewRow dgvr = SelectRows[0];
- Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
- List<string> list_str = (List<string>)ls_bp.Tag;
- uint[] Analysis_xray = new uint[2000];
- int i_xray_id = 0;
- List<Element> list_celementchemistryclr = new List<Element>();
- string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
- DataRow[] drs = particlesFilter.Select(str);
- DataRow row = drs[0];
- string subParticleString = row["SubParticles"].ToString();
- if (subParticleString != "" && subParticleString != null)
- {
- Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Analysis_xray);
- }
- else
- {
- ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Analysis_xray, out i_xray_id, out list_celementchemistryclr);
- }
- ListOfSimilarParticles Form_listOfSimilarParticles = new ListOfSimilarParticles(this, Analysis_xray, m_ReportApp);
- DialogResult result3 = Form_listOfSimilarParticles.ShowDialog();
- if (result3 == DialogResult.OK)
- {
- UpdateDataGrid();
- lnkFirst_Click(null, null);
- SetDataGridViewStyle();
- DataTable table = GetClassificationOfAllParticles();
- if (table != null)
- {
- if (table.Rows.Count > 0)
- {
- foreach (DataRow rw in table.Rows)
- {
- tbx_Type.Text += rw["TypeName"].ToString() + '$';
- }
- }
- if (tbx_Type.Text != "")
- {
- tbx_Type.Text = tbx_Type.Text.Remove(tbx_Type.Text.Length - 1);
- }
- }
- dgV_ParticlesDevidePage.Focus();
- }
- else
- {
- }
- }
- private void dgV_ParticlesDevidePage_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyData == Keys.Delete)
- {
- ToolStripMenuItem_Delete_Particle_Click(null, null);
- }
- }
- private void dgV_ParticlesDevidePage_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyData == Keys.Down)
- {
- dgV_ParticlesDevidePage_MouseUp(null, null);
- }
- if (e.KeyData == Keys.Up)
- {
- dgV_ParticlesDevidePage_MouseUp(null, null);
- }
- }
- private void dgV_ParticlesDevidePage_MouseUp(object sender, MouseEventArgs e)
- {
- ToolStripMenuItem_SimilarityReclassification.Enabled = false;
- var SelectRows = dgV_ParticlesDevidePage.SelectedRows;
- if (SelectRows.Count != 0)
- {
- if (SelectRows.Count == 1)
- {
- DataGridViewRow dgvr = SelectRows[0];
- Bitmap ls_bp = (Bitmap)dgvr.Cells[2].Value;
- uint[] Analysis_xray = new uint[2000];
- Particle particle = new Particle();
- string str = " particleId= " + dgvr.Cells["particleId"].Value.ToString() + " and fieldid = " + dgvr.Cells["fieldid"].Value.ToString();
- DataRow[] drs = particlesFilter.Select(str);
- DataRow row = drs[0];
- string subParticleString = row["SubParticles"].ToString();
- particle = Particledata.GetXrayByParticleIDAndFieldID(subParticleString, Convert.ToInt32(dgvr.Cells["particleId"].Value), Convert.ToInt32(dgvr.Cells["fieldid"].Value), out Analysis_xray);
- List<ShowElementInfo> list_showelementinfo = Particledata.GetShowElementInfos(particle.ElementList);
- string str_IncAName = "";
- str_IncAName = Convert.ToString(dgvr.Cells[1].Value);
- if (particle == null)
- {
- return;
- }
- control_XRayTable1.SetParticleInfo("Area:" + Math.Round(particle.Area, 2) + " " + "DMAX:" + Math.Round(particle.DMAX, 2) + " " + "DELONG:" + Math.Round(particle.DELONG, 2) + " " + "DFERET:" + Math.Round(particle.DFERET, 2) + " " + "DINSCR:" + Math.Round(particle.DINSCR, 2) + "\n" + "DMEAN:" + Math.Round(particle.DMEAN, 2) + " " + "DMIN:" + Math.Round(particle.DMIN, 2) + " " + "DPERP:" + Math.Round(particle.DPERP, 2) + " " + "ORIENTATION:" + Math.Round(particle.ORIENTATION, 2) + " " + "PERIMETER:" + Math.Round(particle.PERIMETER, 2));
- control_XRayTable1.Visible = true;
- control_XRayTable1.SetXRayShowLineValue(Analysis_xray, list_showelementinfo);
- control_XRayTable1.GBInfoStr = "";
- control_XRayTable1.MaterialName = str_IncAName;
- control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
- DataTable dataTable = new DataTable();
- double pix = result.GetPixelSize();
- int width = result.GetImageWidth();
- int height = result.GetImageHeight();
- Dictionary<string, List<Segment>> segsData = new Dictionary<string, List<Segment>>();
- if (subParticleString == "" || subParticleString == null)
- {
- int fldid = Convert.ToInt32(dgvr.Cells["fieldid"].Value);
- int partid = Convert.ToInt32(dgvr.Cells["particleId"].Value);
- var listseg = Particledata.GetSegmentData(fldid, partid);
- string key = fldid.ToString() + "_" + partid.ToString();
- segsData.Add(key, listseg);
- dataTable = particlesFilter.Clone();
- dataTable.ImportRow(row);
- }
- else
- {
- string vs = "," + subParticleString.Replace(':', '-') + ",";
- dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
- foreach (DataRow dow in dataTable.Rows)
- {
- int fldid = Convert.ToInt32(dow["fieldid"]);
- int partid = Convert.ToInt32(dow["particleId"]);
- var listseg = Particledata.GetSegmentData(fldid, partid);
- string key = dow["fieldid"].ToString() + "_" + dow["particleid"].ToString();
- segsData.Add(key, listseg);
- }
- }
- Bitmap bmap = fldImgAccess.GetBitmapForParticleAll(subParticleString, dataTable, pix, height, width);
- Bitmap bmap1 = fldImgAccess.GetBitmapForParticleAllWithBlackAndWhite(subParticleString, dataTable, segsData, pix, height, width);
- control_XRayTable1.SetBitmapOfPictureBox(bmap, bmap1);
- Invalidate();
- ToolStripMenuItem_SimilarityReclassification.Enabled = true;
- }
- SaveParticleslist_select();
- }
- }
- private void dgV_ParticlesDevidePage_MouseDown(object sender, MouseEventArgs e)
- {
- ToolStripMenuItemDelete_Particle.Visible = true;
- }
- #endregion
- #endregion
- #region 连接电镜相关
- /// <summary>
- /// 移动SEM到指定位置线程函数
- /// </summary>
- private void ControlThread_GO(object in_obj)
- {
- if (m_mythread_state) return;
- m_mythread_state = true;
- try
- {
- Point sem_point = (Point)in_obj;
- //第一步,连接电镜
- m_OTSIncAReportGridsFun?.Connection_ForParticlesGrid();
- Thread.Sleep(500);
- //第二步,移动到指定位置,先读取再设置
- if (m_OTSIncAReportGridsFun?.m_SEMConnectionState == true)
- {
- m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
- }
- Thread.Sleep(1500);
- }
- finally
- {
- m_mythread_state = false;
- }
- }
- #endregion
- #region 类别修改相关
- /// <summary>
- /// 读取标准库的ClassifySTD表
- /// </summary>
- /// <param name="a_address"></param>
- /// <returns></returns>
- private DataTable ReadClassification(string a_address, string STDName)
- {
- DataTable dt_STDGroups = new DataTable();
- DataTable dt_ClassifySTD = new DataTable();
- DataTable dt_IncAData = new DataTable();
- var systype = m_ReportApp.m_RptConfigFile.Systype;
- if (systype == OTS_SysType_ID.IncA)
- {
- dt_ClassifySTD.Columns.Add("STDId");
- dt_ClassifySTD.Columns.Add("StrName");
- dt_ClassifySTD.Columns.Add("Color");
- dt_ClassifySTD.Columns.Add("KeyElementList");
- dt_ClassifySTD.Columns.Add("SubElementList");
- dt_ClassifySTD.Columns.Add("UsingImgPropertyList");
- dt_ClassifySTD.Columns.Add("UsingOtherPropertyList");
- dt_ClassifySTD.Columns.Add("Expression");
- dt_ClassifySTD.Columns.Add("Hardness");
- dt_ClassifySTD.Columns.Add("Density");
- dt_ClassifySTD.Columns.Add("Electrical_conductivity");
- dt_ClassifySTD.Columns.Add("BSE");
- dt_ClassifySTD.Columns.Add("Formula");
- dt_ClassifySTD.Columns.Add("Element");
- dt_ClassifySTD.Columns.Add("IfElementAnalysis");
- dt_ClassifySTD.Columns.Add("ListNum");
- dt_ClassifySTD.Columns.Add("GroupId");
- dt_ClassifySTD.Columns.Add("GroupName");
- dt_ClassifySTD.Columns.Add("GroupColor");
- DataTable da = Particledata.GetParticleListForParticlSizeID("area", "");
- for (int i = 0; i < da.Rows.Count; i++)
- {
- if (Convert.ToInt64(da.Rows[i]["TypeId"]) > 9)
- {
- DataRow newRow = dt_ClassifySTD.NewRow();
- newRow["STDId"] = da.Rows[i]["TypeId"];
- newRow["StrName"] = da.Rows[i]["TypeName"];
- newRow["Color"] = da.Rows[i]["TypeColor"];
- newRow["GroupId"] = da.Rows[i]["GroupId"];
- newRow["GroupName"] = da.Rows[i]["GroupName"];
- newRow["GroupColor"] = da.Rows[i]["GroupColor"];
- dt_ClassifySTD.Rows.Add(newRow);
- }
- }
- }
- else
- {
- SqLiteHelper sh_STDGroups = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
- dt_STDGroups = sh_STDGroups.ExecuteQuery("select * from STDGroups");
- SqLiteHelper sh_ClassifySTD = new SqLiteHelper("data source='" + a_address + "\\" + STDName + ".db" + "'");
- dt_ClassifySTD = sh_ClassifySTD.ExecuteQuery("select * from ClassifySTD");
- dt_ClassifySTD.Columns.Add("GroupName");
- dt_ClassifySTD.Columns.Add("GroupColor");
- for (int i = 0; i < dt_ClassifySTD.Rows.Count; i++)
- {
- for (int a = 0; a < dt_STDGroups.Rows.Count; a++)
- {
- if (dt_ClassifySTD.Rows[i]["GroupId"].ToString() == dt_STDGroups.Rows[a]["id"].ToString())
- {
- dt_ClassifySTD.Rows[i]["GroupName"] = dt_STDGroups.Rows[a]["name"].ToString();
- dt_ClassifySTD.Rows[i]["GroupColor"] = dt_STDGroups.Rows[a]["color"].ToString();
- continue;
- }
- }
- }
- SqLiteHelper sh_Inclusion = new SqLiteHelper("data source='" + a_address + "\\FIELD_FILES\\Inclusion.db" + "'");
- dt_IncAData = sh_Inclusion.ExecuteQuery("select * from IncAData");
- for (int i = 0; i < dt_IncAData.Rows.Count; i++)
- {
- if (Convert.ToInt64(dt_IncAData.Rows[i]["TypeId"]) > 50000)
- {
- DataRow newRow = dt_ClassifySTD.NewRow();
- newRow["STDId"] = dt_IncAData.Rows[i]["TypeId"];
- newRow["StrName"] = dt_IncAData.Rows[i]["TypeName"];
- newRow["Color"] = dt_IncAData.Rows[i]["TypeColor"];
- newRow["GroupId"] = dt_IncAData.Rows[i]["GroupId"];
- newRow["GroupName"] = dt_IncAData.Rows[i]["GroupName"];
- newRow["GroupColor"] = dt_IncAData.Rows[i]["GroupColor"];
- dt_ClassifySTD.Rows.Add(newRow);
- }
- }
- }
- return dt_ClassifySTD;
- }
- private string GetSelectedCategoryName()
- {
- if (dgV_ParticlesDevidePage.SelectedRows.Count > 0)
- {
- DataGridViewRow lastRow = dgV_ParticlesDevidePage.SelectedRows[
- dgV_ParticlesDevidePage.SelectedRows.Count - 1];
- return lastRow.Cells[1].Value?.ToString() ?? "";
- }
- return "";
- }
- private DataTable GetClassificationData()
- {
- string[] resultParts = result.GetSTDName().Split('.');
- return ReadClassification(result.FilePath, resultParts[0]);
- }
- private List<string> GetUpdateParameters(ModifyCategoryForm form)
- {
- return new List<string>
- {
- form.OutTypeAndName[0], // TypeId
- form.OutTypeAndName[1], // TypeName
- form.OutTypeAndName[2], // TypeColor
- form.OutTypeAndName[3], // GroupName
- form.OutTypeAndName[4], // GroupID
- form.OutTypeAndName[5] // GroupColor
- };
- }
- private void HandleCategoryUpdate(List<string> updateParams)
- {
- if (dgV_ParticlesDevidePage.SelectedRows.Count == 1)
- {
- HandleSingleRowUpdate(updateParams);
- }
- else
- {
- HandleMultipleRowsUpdate(updateParams);
- }
- RefreshAfterUpdate();
- }
- private void HandleSingleRowUpdate(List<string> updateParams)
- {
- DialogResult result = MessageBox.Show("是否寻找相似颗粒并重命名?", "Tip",
- MessageBoxButtons.YesNo);
- if (result == DialogResult.Yes)
- {
- HandleSimilarParticleSearch(updateParams);
- }
- else
- {
- ExecuteBatchUpdate(updateParams);
- }
- }
- private void HandleSimilarParticleSearch(List<string> updateParams)
- {
- int sel = m_ReportApp.m_conditionChoose.m_conditionData
- .GetComboDownListIndexByItemName(
- OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.PARTICE_LIST);
- if (sel == (int)SelItem.MergeParticles)
- {
- ExecuteBatchUpdate(updateParams);
- return;
- }
- uint[] analysisXray = new uint[2000];
- if (dgV_ParticlesDevidePage.SelectedRows.Count == 1)
- {
- DataGridViewRow row = dgV_ParticlesDevidePage.SelectedRows[0];
- ReportFun.GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(
- Convert.ToInt32(row.Cells["particleId"].Value),
- Convert.ToInt32(row.Cells["fieldid"].Value),
- out analysisXray,
- out int _, // i_xray_id
- out List<Element> _); // list_celementchemistryclr
- }
- using (var form = new ListOfSimilarParticles(this, analysisXray, updateParams, m_ReportApp))
- {
- if (form.ShowDialog() != DialogResult.OK)
- {
- ExecuteBatchUpdate(updateParams);
- }
- }
- }
- private void HandleMultipleRowsUpdate(List<string> updateParams)
- {
- ExecuteBatchUpdate(updateParams);
- }
- private void ExecuteBatchUpdate(List<string> updateParams)
- {
- var cmdList = new List<KeyValuePair<string, SQLiteParameter[]>>();
- foreach (DataGridViewRow row in dgV_ParticlesDevidePage.SelectedRows)
- {
- UpdateGridRow(row, updateParams[1]); // TypeName
- if (row.Cells[2].Value is Bitmap bitmap && bitmap.Tag is List<string> tagList)
- {
- var particleIds = new List<int>
- {
- Convert.ToInt32(tagList[0]), // fieldId
- Convert.ToInt32(tagList[1]) // particleId
- };
- var cmd = Particledata.GetUpdataAIncACmd(particleIds, updateParams);
- cmdList.Add(cmd);
- }
- row.Cells[1].Value = updateParams[1]; // Update TypeName in grid
- }
- Particledata.ExecuteNonQueryBatch(cmdList);
- }
- private void UpdateGridRow(DataGridViewRow row, string typeName)
- {
- row.Cells[1].Value = typeName;
- }
- private void RefreshAfterUpdate()
- {
- UpdateDataGrid();
- lnkFirst_Click(null, null);
- SetDataGridViewStyle();
- UpdateTypeTextBox();
- dgV_ParticlesDevidePage.Focus();
- }
- private void UpdateTypeTextBox()
- {
- tbx_Type.Text = "";
- DataTable table = GetClassificationOfAllParticles();
- if (table?.Rows.Count > 0)
- {
- tbx_Type.Text = string.Join("$", table.AsEnumerable()
- .Select(row => row["TypeName"].ToString()));
- }
- }
- #endregion
- #region 删除颗粒相关\备份
- private void DeleteSelectedParticles(List<Particle> particles)
- {
- var deletedParticles = new List<Particle>();
- foreach (DataGridViewRow row in dgV_ParticlesDevidePage.SelectedRows)
- {
- if (row.Cells[2].Value is Bitmap bitmap && bitmap.Tag is List<string> tagList)
- {
- int fieldId = Convert.ToInt32(tagList[0]);
- int particleId = Convert.ToInt32(tagList[1]);
- Particle particleToDelete = particles.FirstOrDefault(p =>
- p.FieldId == fieldId && p.ParticleId == particleId);
- if (particleToDelete != null &&
- DeleteParticlesFromSTDDb(particleToDelete.ParticleId, particleToDelete.FieldId))
- {
- RemoveParticleFromDataTable(particleToDelete);
- deletedParticles.Add(particleToDelete);
- }
- else
- {
- MessageBox.Show("Delete failed");
- }
- }
- }
- UpdateUIAfterDeletion(deletedParticles.Count);
- SynchronizeParticleDeletion(deletedParticles);
- }
- private void RemoveParticleFromDataTable(Particle particle)
- {
- for (int i = particlesAll.Rows.Count - 1; i >= 0; i--)
- {
- if (particlesAll.Rows[i]["Fieldid"].ToString() == particle.FieldId.ToString() &&
- particlesAll.Rows[i]["Particleid"].ToString() == particle.ParticleId.ToString())
- {
- particlesAll.Rows.RemoveAt(i);
- break;
- }
- }
- }
- private void UpdateUIAfterDeletion(int deletedCount)
- {
- RecordCount = recordCount - deletedCount;
- lblTotalCount.Text = RecordCount.ToString();
- // Remove rows from grid (in reverse order to avoid index issues)
- var rowsToRemove = dgV_ParticlesDevidePage.SelectedRows.Cast<DataGridViewRow>().ToList();
- foreach (var row in rowsToRemove)
- {
- dgV_ParticlesDevidePage.Rows.Remove(row);
- }
- if (dgV_ParticlesDevidePage.Rows.Count == 0)
- {
- DisplayData();
- }
- else
- {
- // Update row numbers
- for (int j = 0; j < dgV_ParticlesDevidePage.Rows.Count; j++)
- {
- dgV_ParticlesDevidePage.Rows[j].Cells[0].Value =
- (pageSize * (PageIndex - 1) + j + 1).ToString();
- }
- }
- }
- private void SynchronizeParticleDeletion(List<Particle> deletedParticles)
- {
- if (m_ReportApp.im_Control_DrawDistrbutionImageAndBSE != null)
- {
- m_ReportApp.im_Control_DrawDistrbutionImageAndBSE.DeletesParticlesSynchronously(deletedParticles);
- }
- else
- {
- using (var control = new OTSIncAReportGraph.Controls.Control_DrawDistrbutionImageAndBSE(m_ReportApp))
- {
- foreach (var particle in deletedParticles)
- {
- control.DeleteParticlesFromSTDDb(particle.ParticleId, particle.FieldId);
- }
- }
- }
- }
- private bool DeleteParticlesFromSTDDb(int particleId, int fieldId)
- {
- if (!CheckAndCreateBackup())
- return false;
- //防止为空校验判断
- if (result.GetList_OTSField() == null)
- return false;
- try
- {
- Particle particle = result.GetList_OTSField()
- .Find(x => x.FieldID == fieldId)?
- .ParticleList.Find(x => x.ParticleId == particleId);
- if (particle == null)
- return false;
- var particleData = new ParticleData(result.FilePath);
- return particleData.DeleteFromData(
- Convert.ToString(particle.FieldId),
- Convert.ToString(particle.XrayId));
- }
- catch (Exception ex)
- {
- log.Error($"Error deleting particle: {ex.Message}");
- return false;
- }
- }
- private bool CheckAndCreateBackup()
- {
- bool backupExists = Enumerable.Range(1, 200).Any(i =>
- Directory.Exists(Path.Combine(result.FilePath, "FIELD_FILES", "Backups" + i)));
- if (!backupExists)
- {
- return BackupDatabase();
- }
- return true;
- }
- private bool BackupDatabase()
- {
- try
- {
- //创建备份数据库文件夹
- string sourcePath = Path.Combine(result.FilePath, "FIELD_FILES", "Inclusion.db");
- string sourceName = "Inclusion.db";
- string folderPath = Path.Combine(result.FilePath, "FIELD_FILES", "Backups");
- string backupFolder = "";
- for (int i = 1; i <= 200; i++)
- {
- string currentPath = Path.Combine(folderPath, i.ToString());
- if (!Directory.Exists(currentPath))
- {
- Directory.CreateDirectory(currentPath);
- backupFolder = currentPath;
- break;
- }
- }
- if (string.IsNullOrEmpty(backupFolder))
- {
- return false;
- }
- //复制数据库文件
- string targetPath = Path.Combine(backupFolder, sourceName);
- File.Copy(sourcePath, targetPath, true);
- return true;
- }
- catch (Exception ex)
- {
- log.Error($"Error backing up database: {ex.Message}");
- return false;
- }
- }
- #endregion
- #region 报表输出
- /// <summary>
- ///
- /// </summary>
- /// <param name="str_resultPath"></param>
- /// <param name="dataTable"></param>
- /// <param name="vs"></param>
- /// <param name="dt_FIeld"></param>
- public void Out_MarkParticleRectangleOnFieldFile(string str_resultPath, DataTable dataTable,
- out List<string> vs, out DataTable dt_FIeld)
- {
- Init();
- var fieldIds = ExtractFieldIds(dataTable);
- string str_path_FIELD_FILES = Path.Combine(str_resultPath, "FIELD_FILES");
- dt_FIeld = new DataTable();
- vs = new List<string>();
- ResultFile resfile = m_ReportApp.m_rstDataMgr.ResultFilesList[
- m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
- float pixelSize = resfile.GetPixelSize();
- float scanFieldSizeX = resfile.GetScanFieldSizeX();
- int gauge = RulerSelection(scanFieldSizeX);
- float rulerPixels = gauge / pixelSize;
- var fieldData = new FieldData(resfile.FilePath);
- DataTable dt_AllParticle = fieldData.GetAllParticle_DataTable();
- var directoryInfo = new DirectoryInfo(str_path_FIELD_FILES);
- if (directoryInfo.Exists)
- {
- ProcessFieldFiles(directoryInfo, fieldIds, dataTable, dt_AllParticle,
- rulerPixels, gauge, ref dt_FIeld, vs);
- }
- }
- private List<string> ExtractFieldIds(DataTable dataTable)
- {
- return dataTable.AsEnumerable()
- .Where(row => Convert.ToInt32(row["TypeId"]) > 9)
- .Take(10)
- .Select(row => row["Fieldid"].ToString())
- .Distinct()
- .ToList();
- }
- private void ProcessFieldFiles(DirectoryInfo directoryInfo, List<string> fieldIds,
- DataTable dataTable, DataTable allParticles, float rulerPixels, int gauge,
- ref DataTable dt_FIeld, List<string> vs)
- {
- var fieldFiles = directoryInfo.GetFiles("Field*.bmp")
- .ToDictionary(f => GetFieldIdFromFile(f.Name), f => f,
- StringComparer.OrdinalIgnoreCase);
- var resultTable = CreateFieldDataTable();
- foreach (string fieldId in fieldIds.Where(id => fieldFiles.ContainsKey(id)))
- {
- var file = fieldFiles[fieldId];
- int count = dataTable.AsEnumerable()
- .Count(row => row["fieldid"].ToString() == fieldId);
- DataRow dr = resultTable.NewRow();
- dr["fieldid"] = $" fieldid = {fieldId}";
- dr["cunt"] = count;
- dr["fieldName"] = file.Name;
- dr["fieldFullName"] = file.FullName;
- dr["id"] = fieldId;
- resultTable.Rows.Add(dr);
- }
- dt_FIeld = resultTable.Copy();
- dt_FIeld.Columns.Add("Field_pic", typeof(Bitmap));
- ProcessFieldImages(allParticles, rulerPixels, gauge, dt_FIeld, vs);
- }
- private string GetFieldIdFromFile(string fileName)
- {
- string nameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
- return nameWithoutExtension.Length > 5 ?
- nameWithoutExtension.Substring(5) : nameWithoutExtension;
- }
- private DataTable CreateFieldDataTable()
- {
- var dt = new DataTable();
- dt.Columns.Add("fieldid");
- dt.Columns.Add("id");
- dt.Columns.Add("fieldName");
- dt.Columns.Add("cunt", typeof(int));
- dt.Columns.Add("fieldFullName");
- return dt;
- }
- private void ProcessFieldImages(DataTable allParticles, float rulerPixels, int gauge,
- DataTable dt_FIeld, List<string> vs)
- {
- var particleGroups = allParticles.AsEnumerable()
- .GroupBy(row => row["fieldid"].ToString())
- .ToDictionary(g => g.Key, g => g.ToList());
- foreach (DataRow row in dt_FIeld.Rows.Cast<DataRow>().ToList())
- {
- string fieldId = row["id"].ToString();
- if (!particleGroups.ContainsKey(fieldId) ||
- particleGroups[fieldId].Count == 0)
- continue;
- vs.Add(fieldId);
- try
- {
- using (var img = Image.FromFile(row["fieldFullName"].ToString()))
- {
- using (var fieldBitmap = new Bitmap(img.Width, img.Height,
- System.Drawing.Imaging.PixelFormat.Format32bppArgb))
- {
- DrawBaseImage(img, fieldBitmap);
- MarkParticlesOnImage(particleGroups[fieldId], fieldBitmap,
- row, fieldId, rulerPixels, gauge);
- }
- }
- }
- catch (Exception ex)
- {
- log.Error($"Error processing field image: {ex.Message}");
- }
- }
- }
- private void DrawBaseImage(Image sourceImage, Bitmap targetBitmap)
- {
- using (Graphics g = Graphics.FromImage(targetBitmap))
- {
- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
- g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
- g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
- g.DrawImage(sourceImage, new Rectangle(0, 0, sourceImage.Width, sourceImage.Height));
- }
- }
- private void MarkParticlesOnImage(List<DataRow> particles, Bitmap fieldBitmap,
- DataRow fieldRow, string fieldId, float rulerPixels, int gauge)
- {
- foreach (DataRow particleRow in particles)
- {
- string particleId = particleRow["particleid"].ToString();
- var rectangle = new Rectangle(
- Convert.ToInt32(particleRow["RectLeft"]),
- Convert.ToInt32(particleRow["RectTop"]),
- Convert.ToInt32(particleRow["RectWidth"]),
- Convert.ToInt32(particleRow["RectHeight"])
- );
- MarkParticleOnImage(fieldBitmap, rectangle, fieldId, particleId);
- }
- using (var rulerBitmap = DrawRuler(fieldBitmap, (int)(rulerPixels / 2), 2,
- $"{gauge / 2}μm"))
- {
- fieldRow["Field_pic"] = new Bitmap(rulerBitmap);
- }
- }
- private void MarkParticleOnImage(Bitmap fieldBitmap, Rectangle rectangle,
- string fieldId, string particleId)
- {
- using (Graphics g = Graphics.FromImage(fieldBitmap))
- using (var pen = new Pen(Color.Aquamarine))
- {
- g.DrawRectangle(pen, rectangle);
- int textX = rectangle.X + rectangle.Width > fieldBitmap.Width - 10 ?
- rectangle.X - 10 : rectangle.X + rectangle.Width;
- using (var font = new Font("黑体", 8))
- using (var brush = new SolidBrush(Color.Aqua))
- {
- g.DrawString($"{fieldId} {particleId}", font, brush,
- new PointF(textX, rectangle.Y));
- }
- }
- }
- /// <summary>
- /// 在图片上绘制标尺
- /// </summary>
- /// <param name="bitmap">图片</param>
- /// <param name="lineLength">线长(像素)</param>
- /// <param name="lineWidth">线宽(像素)</param>
- /// <param name="text">显示文本</param>
- /// <returns></returns>
- private Bitmap DrawRuler(Bitmap bitmap, int lineLength, int lineWidth, string text)
- {
- if (bitmap == null)
- throw new ArgumentNullException(nameof(bitmap));
- var rgbBitmap = new Bitmap(bitmap.Width, bitmap.Height);
- using (Graphics graphics = Graphics.FromImage(rgbBitmap))
- {
- graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
- Color color = Color.LimeGreen;
- using (var pen = new Pen(color, lineWidth))
- using (var font = new Font("Arial", 20, GraphicsUnit.Pixel))
- using (var brush = new SolidBrush(color))
- {
- var stringFormat = new StringFormat
- {
- Alignment = StringAlignment.Center,
- LineAlignment = StringAlignment.Center
- };
- int startX = 20;
- int startY = bitmap.Height - 30;
- graphics.DrawLine(pen, startX, startY, startX + lineLength, startY);
- graphics.DrawString(text, font, brush,
- new PointF(startX + lineLength / 2, startY - 20), stringFormat);
- }
- }
- return rgbBitmap;
- }
- private int RulerSelection(float scanFieldSizeX)
- {
- // 根据扫描场尺寸选择合适的标尺单位
- if (scanFieldSizeX >= 1000) return 1000;
- if (scanFieldSizeX >= 500) return 500;
- if (scanFieldSizeX >= 200) return 200;
- if (scanFieldSizeX >= 100) return 100;
- if (scanFieldSizeX >= 50) return 50;
- if (scanFieldSizeX >= 20) return 20;
- if (scanFieldSizeX >= 10) return 10;
- if (scanFieldSizeX >= 5) return 5;
- if (scanFieldSizeX >= 2) return 2;
- return 1;
- }
- #endregion
- }
- }
|