12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979 |
- using SmartCoalApplication.Core;
- using SmartCoalApplication.SystemLayer;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using SmartCoalApplication.Base.AutoMeasure;
- using System.Xml;
- using OpenCvSharp;
- using SmartCoalApplication.Base.MeasureModel;
- using SmartCoalApplication.Base.CommTool;
- using System.IO;
- using Resources;
- using SmartCoalApplication.Annotation;
- using SmartCoalApplication.Base.SettingModel;
- using SmartCoalApplication.Core.DbOpreate.DbModel;
- using SmartCoalApplication.Resources;
- using SmartCoalApplication.AutomaticMeasurement.Model;
- using System.Text.RegularExpressions;
- namespace SmartCoalApplication.AutomaticMeasurement
- {
- internal partial class AutomaticMeasurement : Form
- {
- private MeasureInfoModel infoModel;//窗體共用,傳遞信息
- private int erjimuluCount = new int();//有检验项目的分类数目
- private List<Bitmap> bitmaps = new List<Bitmap>();//每次添加的图片
- private List<string> bitNames = new List<string>();//每次添加的图片的名称
- private List<string> filePathList = new List<string>();
- private Kongjian kongjians = new Kongjian();//自动显示的控件
- private int[] counts;//计数器,每行显示5张图
- public List<List<Bitmap>> pictures = new List<List<Bitmap>>();//所有的图片集合
- private List<List<string>> pictureNames = new List<List<string>>();//所有的图片名称集合
- private List<List<string>> picturePathNames = new List<List<string>>();//所有的图片名称集合
- private List<string> erjimulusName = new List<string>();//分类名称
- Dictionary<string, string> _listHoleType = new Dictionary<string, string>();
- Dictionary<string, bool> _listHoleTypePos = new Dictionary<string, bool>();
- private MeasureMaintenanceTypeList measureMaintenanceTypeList;
- private AppWorkspace appWorkspace;
- private Dictionary<string, List<Mat>> everyHoleImg = new Dictionary<string, List<Mat>>();
- private Dictionary<int, List<GraphicsList>> everyHoleImgGraphicsList = new Dictionary<int, List<GraphicsList>>();
- private Dictionary<int, List<bool>> everyHoleImgisConductive = new Dictionary<int, List<bool>>();
- private Dictionary<int, List<bool>> everyHoleImgisFanweibuchang = new Dictionary<int, List<bool>>();
- private Dictionary<int, List<bool>> everyHoleImgisErzhichuli = new Dictionary<int, List<bool>>();
- Dictionary<string, Dictionary<string ,double>> pidRuleDic = new Dictionary<string, Dictionary<string, double>>();
- /// <summary>
- /// 树状结构数据
- /// </summary>
- protected MeasureMaintenanceTreeData measureMaintenanceTreeData;
- /// <summary>
- /// 换算完的标尺信息,包含所有系统内得单位
- /// </summary>
- public Dictionary<int, double> rules = new Dictionary<int, double>();
- public AutomaticMeasurement(AppWorkspace appWorkspace)
- {
- var res = getResult("[[100-50] - [200 - 50 + (100 - 50 + (200 - 100) + [50])]] - 100");
- InitializeComponent();
- InitializeComponent2();
- this.Icon = PdnInfo.AppIcon;
- this.appWorkspace = appWorkspace;
- //初始化數據
- infoModel = new MeasureInfoModel();
- infoModel.stop = 0;
- CreatHoleType();
- #region [测试分类下拉选]
- string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceTypeList.xml";
- if (!System.IO.File.Exists(filePath))
- {
- measureMaintenanceTypeList = new MeasureMaintenanceTypeList();
- measureMaintenanceTypeList.measureMaintenanceTypeList = new List<MeasureMaintenanceType>();
- }
- else
- {
- measureMaintenanceTypeList = XmlSerializeHelper.DESerializer<MeasureMaintenanceTypeList>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- }
- comboMingcheng.DataSource = measureMaintenanceTypeList.measureMaintenanceTypeList;
- this.comboMingcheng.SelectedIndexChanged -= new System.EventHandler(this.comboBox4_SelectedIndexChanged);
- comboMingcheng.DisplayMember = "measureMaintenanceName";
- this.comboMingcheng.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged);
- this.FormClosing += new FormClosingEventHandler(AutoFormClosed);
- #endregion
- #region [获取各项下拉选值]
- ReadXml2();
- #endregion
- this.comboBox4_SelectedIndexChanged(null, null);
- }
- /// <summary>
- /// 获取绝对值
- /// </summary>
- private double getResult(string formula)
- {
- formula = formula.Replace("[", "Math.abs(").Replace("]", ")");
- double res = Math.Abs(Convert.ToDouble(FormulaHelper.CaleByFormule(formula)));
- return res;
- }
- private void AutoFormClosed(object sender, FormClosingEventArgs e)
- {
- for (int i = 0; i < pictures.Count; i++)
- {
- for (int k = 0; k < pictures[i].Count; k++)
- {
- if (pictures[i][k] != null)
- {
- pictures[i][k].Dispose();
- }
- }
- }
- }
- /// <summary>
- ///
- /// </summary>
- private void InitializeComponent2()
- {
- this.Text = PdnResources.GetString("NewStartTestProcedure");
- this.groupBox2.Text = PdnResources.GetString("NewSelectTestProcedure");
- this.label1.Text = PdnResources.GetString("NewName");
- this.groupBox1.Text = PdnResources.GetString("NewOperation");
- this.buttonCancelMeasurement.Text = PdnResources.GetString("NewCancelMeasurement");
- this.buttonStartMeasuring.Text = PdnResources.GetString("NewStartMeasuring");
- this.label14.Text = PdnResources.GetString("NewDefaultRuler");
- this.label13.Text = PdnResources.GetString("NewRuler");
- this.groupBox3.Text = PdnResources.GetString("NewEssentialInformation");
- this.label11.Text = PdnResources.GetString("NewUnit") + ":";
- this.label10.Text = PdnResources.GetString("NewLayers") + ":";
- this.label7.Text = PdnResources.GetString("NewUseFactory") + ":";
- this.label6.Text = PdnResources.GetString("NewElectroplatingLine") + ":";
- this.label5.Text = PdnResources.GetString("NewMadeOf") + ":";
- this.label4.Text = PdnResources.GetString("NewBatchNumber") + ":";
- this.label3.Text = PdnResources.GetString("NewOrderNo") + ":";
- this.label2.Text = PdnResources.GetString("NewItemNo") + ":";
- this.label8.Text = PdnResources.GetString("NewLaboratory") + ":";
- this.label9.Text = PdnResources.GetString("NewFrequency") + ":";
- this.groupBox4.Text = PdnResources.GetString("NewcCassification");
- this.groupOutInfo.Text = PdnResources.GetString("NewOutputInformation");
- }
- /// <summary>
- /// 从硬盘选择多张图片
- /// </summary>
- private List<Bitmap> ChooseImagesFromImgDisk(List<string> imageNames, string id)
- {
- List<Bitmap> listBitmap = new List<Bitmap>();
- bitNames = new List<string>();
- filePathList = new List<string>();
- string pPath = null;
- foreach (string imgName in imageNames)
- {
- if (pPath == null)
- pPath = System.IO.Path.GetDirectoryName(imgName);
- string xmlPath = pPath + "\\" + Path.GetFileNameWithoutExtension(imgName) + ".xml";
- double ruleData = 1;
- ConfigModel configModel = Program.instance.configModel;
- //如果xml存在
- if (System.IO.File.Exists(xmlPath))
- {
- var configModel1 = XmlSerializeHelper.DESerializer<PicConfigModel>(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open));
- ruleData = configModel1.rule.pixel_length == 0 ? 1 : Convert.ToDouble(configModel1.rule.physical_length / configModel1.rule.pixel_length);
- InitRulerInfo(configModel1.rule.ruler_units, ruleData);
- }
- else
- {
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- if (measureMaintenanceTreeData != null)
- {
- MeasureMaintenanceTreeSpecificData data;
- this.appWorkspace.RecursionGetData(id, measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- if (data.ruleMessage != null)
- {
- ruleData = data.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(data.ruleMessage.physicalLength / Convert.ToDecimal(data.ruleMessage.pixelLength));
- InitRulerInfo(data.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- if (measureMaintenanceType.ruleMessage != null)
- {
- ruleData = measureMaintenanceType.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(measureMaintenanceType.ruleMessage.physicalLength / Convert.ToDecimal(measureMaintenanceType.ruleMessage.pixelLength));
- InitRulerInfo(measureMaintenanceType.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- ruleData = ruler.pixel_length == 0 ? 1 : Convert.ToDouble(ruler.physical_length / Convert.ToDecimal(ruler.pixel_length));
- InitRulerInfo(ruler.ruler_units, ruleData);
- }
- }
- }
- }
- else
- {
- if (measureMaintenanceType.ruleMessage != null)
- {
- ruleData = measureMaintenanceType.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(measureMaintenanceType.ruleMessage.physicalLength / Convert.ToDecimal(measureMaintenanceType.ruleMessage.pixelLength));
- InitRulerInfo(measureMaintenanceType.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- ruleData = ruler.pixel_length == 0 ? 1 : Convert.ToDouble(ruler.physical_length / Convert.ToDecimal(ruler.pixel_length));
- InitRulerInfo(ruler.ruler_units, ruleData);
- }
- }
- }
- }
- if (this.rules.ContainsKey(configModel.Unit))
- {
- this.rules.TryGetValue(configModel.Unit, out ruleData);
- }
- if (pidRuleDic.ContainsKey(id))
- {
- if (pidRuleDic[id].ContainsKey(Path.GetFileName(imgName)))
- {
- pidRuleDic[id][Path.GetFileName(imgName)] = ruleData;
- }
- else
- {
- pidRuleDic[id].Add(Path.GetFileName(imgName), ruleData);
- }
- }
- else
- {
- Dictionary<string, double> dataKeyValue = new Dictionary<string, double>();
- dataKeyValue.Add(Path.GetFileName(imgName), ruleData);
- pidRuleDic.Add(id, dataKeyValue);
- }
- Image image = Image.FromFile(imgName);
- listBitmap.Add(new Bitmap(image));
- bitNames.Add(System.IO.Path.GetFileName(imgName));
- filePathList.Add(System.IO.Path.GetDirectoryName(imgName));
- }
- return listBitmap;
- }
- /// <summary>
- /// 从硬盘选择多张图片
- /// </summary>
- private List<Bitmap> ChooseImagesFromHardDisk(string id)
- {
- var openFileDialog = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
- openFileDialog.Multiselect = true;
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- string pPath = null;// System.IO.Path.GetDirectoryName(cmbInput.Text);
- string[] imageNames = openFileDialog.FileNames;
- List<Bitmap> listBitmap = new List<Bitmap>();
- bitNames = new List<string>();
- filePathList = new List<string>();
- foreach (string imgName in imageNames)
- {
- if (pPath == null)
- pPath = System.IO.Path.GetDirectoryName(imgName);
- string xmlPath = pPath + "\\" + Path.GetFileNameWithoutExtension(imgName) + ".xml";
- double ruleData = 1;
- ConfigModel configModel = Program.instance.configModel;
- //如果xml存在
- if (System.IO.File.Exists(xmlPath))
- {
- var configModel1 = XmlSerializeHelper.DESerializer<PicConfigModel>(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open));
- ruleData = configModel1.rule.pixel_length == 0 ? 1 : Convert.ToDouble(configModel1.rule.physical_length / configModel1.rule.pixel_length);
- InitRulerInfo(configModel1.rule.ruler_units, ruleData);
- }
- else {
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- if (measureMaintenanceTreeData != null)
- {
- MeasureMaintenanceTreeSpecificData data;
- this.appWorkspace.RecursionGetData(id, measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- if (data.ruleMessage != null)
- {
- ruleData = data.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(data.ruleMessage.physicalLength / Convert.ToDecimal(data.ruleMessage.pixelLength));
- InitRulerInfo(data.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- if (measureMaintenanceType.ruleMessage != null)
- {
- ruleData = measureMaintenanceType.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(measureMaintenanceType.ruleMessage.physicalLength / Convert.ToDecimal(measureMaintenanceType.ruleMessage.pixelLength));
- InitRulerInfo(measureMaintenanceType.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- ruleData = ruler.pixel_length == 0 ? 1 : Convert.ToDouble(ruler.physical_length / Convert.ToDecimal(ruler.pixel_length));
- InitRulerInfo(ruler.ruler_units, ruleData);
- }
- }
- }
- }
- else
- {
- if (measureMaintenanceType.ruleMessage != null)
- {
- ruleData = measureMaintenanceType.ruleMessage.pixelLength == 0 ? 1 : Convert.ToDouble(measureMaintenanceType.ruleMessage.physicalLength / Convert.ToDecimal(measureMaintenanceType.ruleMessage.pixelLength));
- InitRulerInfo(measureMaintenanceType.ruleMessage.rulerUnits, ruleData);
- }
- else
- {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- ruleData = ruler.pixel_length == 0 ? 1 : Convert.ToDouble(ruler.physical_length / Convert.ToDecimal(ruler.pixel_length));
- InitRulerInfo(ruler.ruler_units, ruleData);
- }
- }
- }
- }
- if (this.rules.ContainsKey(configModel.Unit)) {
- this.rules.TryGetValue(configModel.Unit, out ruleData);
- }
- if (pidRuleDic.ContainsKey(id))
- {
- if (pidRuleDic[id].ContainsKey(Path.GetFileName(imgName)))
- {
- pidRuleDic[id][Path.GetFileName(imgName)] = ruleData;
- }
- else {
- pidRuleDic[id].Add(Path.GetFileName(imgName), ruleData);
- }
- }
- else
- {
- Dictionary<string, double> dataKeyValue = new Dictionary<string, double>();
- dataKeyValue.Add(Path.GetFileName(imgName), ruleData);
- pidRuleDic.Add(id, dataKeyValue);
- }
- Image image = Image.FromFile(imgName);
- listBitmap.Add(new Bitmap(image));
- bitNames.Add(System.IO.Path.GetFileName(imgName));
- filePathList.Add(System.IO.Path.GetDirectoryName(imgName));
- }
- return listBitmap;
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 初始化标尺信息,图片对应的xml中读取
- /// 然后根据标尺的单位,换算出所有单位的数据
- /// </summary>
- public void InitRulerInfo(int units,double unitLength)
- {
- this.rules.Clear();
- switch (units)
- {
- case (int)1://英寸
- this.rules.Add(1, unitLength); //英寸
- this.rules.Add(7, 1000 * unitLength); //米尔
- this.rules.Add(2, 2.54 * unitLength); //厘米
- this.rules.Add(3, 25.4 * unitLength); //毫米
- this.rules.Add(4, 25400 * unitLength); //微米
- this.rules.Add(5, 25400000 * unitLength); //纳米
- break;
- case (int)7://米尔
- this.rules.Add(1, 0.001 * unitLength); //英寸
- this.rules.Add(7, unitLength); //米尔
- this.rules.Add(2, 0.00254 * unitLength); //厘米
- this.rules.Add(3, 0.0254 * unitLength); //毫米
- this.rules.Add(4, 25.4 * unitLength); //微米
- this.rules.Add(5, 25400 * unitLength); //纳米
- break;
- case (int)2://厘米
- this.rules.Add(1, 0.3937008 * unitLength); //英寸
- this.rules.Add(7, 393.7008 * unitLength); //米尔
- this.rules.Add(2, unitLength); //厘米
- this.rules.Add(3, 10 * unitLength); //毫米
- this.rules.Add(4, 10000 * unitLength); //微米
- this.rules.Add(5, 10000000 * unitLength); //纳米
- break;
- case (int)3://毫米
- this.rules.Add(1, 0.0393701 * unitLength); //英寸
- this.rules.Add(7, 39.3701 * unitLength); //米尔
- this.rules.Add(2, 0.1 * unitLength); //厘米
- this.rules.Add(3, unitLength); //毫米
- this.rules.Add(4, 1000 * unitLength); //微米
- this.rules.Add(5, 1000000 * unitLength); //纳米
- break;
- case (int)4://微米
- this.rules.Add(1, 0.00003937007874 * unitLength); //英寸
- this.rules.Add(7, 0.03937007874 * unitLength); //米尔
- this.rules.Add(2, 0.0001 * unitLength); //厘米
- this.rules.Add(3, 0.001 * unitLength); //毫米
- this.rules.Add(4, unitLength); //微米
- this.rules.Add(5, 1000 * unitLength); //纳米
- break;
- case (int)5://纳米
- this.rules.Add(1, 3.9370e-8 * unitLength); //英寸
- this.rules.Add(7, 3.9370e-5 * unitLength); //米尔
- this.rules.Add(2, 1e-7 * unitLength); //厘米
- this.rules.Add(3, 1e-6 * unitLength); //毫米
- this.rules.Add(4, 0.001 * unitLength); //微米
- this.rules.Add(5, unitLength); //纳米
- break;
- }
- }
- /// <summary>
- /// 點擊下拉列表時顯示(選擇規程名稱)
- /// 顯示輸出信息、基礎信息以及圖片分類信息
- /// </summary>
- private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (comboMingcheng.SelectedIndex == -1)
- {
- return;
- }
- #region [读取树状结构]
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceType\\";
- var fileName = measureMaintenanceType.measureMaintenanceName;
- filePath = $"{filePath}{fileName}.xml";
- if (System.IO.File.Exists(filePath))
- {
- measureMaintenanceTreeData = XmlSerializeHelper.DESerializer<MeasureMaintenanceTreeData>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- }
-
- #endregion
-
- #region [获取标尺]
- if (measureMaintenanceType.ruleMessage != null)
- {
- //计算每像素物理长度
- double proportion = Math.Round((double)measureMaintenanceType.ruleMessage.physicalLength / measureMaintenanceType.ruleMessage.pixelLength, 4);
- string content = proportion.ToString() + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), measureMaintenanceType.ruleMessage.rulerUnits)))].ToString() + "/" + PdnResources.GetString("MeasurementUnit.Pixel");
- label14.Text = $"{measureMaintenanceType.ruleMessage.ruleName} {content}";
- }
- else {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- ConfigModel configModel = Program.instance.configModel;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- double proportion = ruler.pixel_length == 0 ? 1 : Math.Round((double)ruler.physical_length / ruler.pixel_length, 4);
- string content = proportion.ToString() + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), ruler.ruler_units)))].ToString() + "/" + PdnResources.GetString("MeasurementUnit.Pixel");
- label14.Text = $"{ruler.ruler_name} {content}";
- }
- else {
- label14.Text = PdnResources.GetString("NewBatchNumber") + ":1/1";
- }
- }
- #endregion
- #region [基础信息赋值]
- textLiaohao.Text = string.Empty;//料號
- comboBanci.SelectedIndex = -1;//班次
- comboShiyanshi.SelectedIndex = -1;//實驗室
- comboShiyongchangqu.SelectedIndex = -1;//使用廠區
- comboZhichengbie.SelectedIndex = -1;//製成別
- textDanhao.Text = string.Empty;//單號
- textPihao.Text = string.Empty;//批號
- comboCengbie.SelectedIndex = -1;//層別
- comboDianduxianbie.Text = string.Empty;//電鍍綫別
- textLiaohao.Text = measureMaintenanceType.measureMaintenanceBasicDataList[0].measureMaintenanceBasicDataValue;//料號
- comboBanci.SelectedItem = measureMaintenanceType.measureMaintenanceBasicDataList[1].measureMaintenanceBasicDataValue;//班次
- comboShiyanshi.SelectedItem = measureMaintenanceType.measureMaintenanceBasicDataList[2].measureMaintenanceBasicDataValue;//實驗室
- comboShiyongchangqu.SelectedItem = measureMaintenanceType.measureMaintenanceBasicDataList[3].measureMaintenanceBasicDataValue;//使用廠區
- comboZhichengbie.SelectedItem = measureMaintenanceType.measureMaintenanceBasicDataList[4].measureMaintenanceBasicDataValue;//製成別
- textDanhao.Text = measureMaintenanceType.measureMaintenanceBasicDataList[5].measureMaintenanceBasicDataValue;//單號
- textPihao.Text = measureMaintenanceType.measureMaintenanceBasicDataList[6].measureMaintenanceBasicDataValue;//批號
- comboCengbie.SelectedItem = measureMaintenanceType.measureMaintenanceBasicDataList[7].measureMaintenanceBasicDataValue;//層別
- comboDianduxianbie.Text = measureMaintenanceType.measureMaintenanceBasicDataList[8].measureMaintenanceBasicDataValue;//電鍍綫別
- if (measureMaintenanceType.ruleMessage != null)
- {
- label12.Text = InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), measureMaintenanceType.ruleMessage.rulerUnits)))].ToString();//單位
- }
- else {
- List<mic_rulers> list = Program.instance.mic_rulersAll;
- ConfigModel configModel = Program.instance.configModel;
- var ruler = list.Where(m => m.id.Equals(configModel.RulerId)).FirstOrDefault();
- if (ruler != null)
- {
- label12.Text = InvariantData.unitsDictionary[configModel.Unit].ToString();//單位
- }
- }
- #endregion
- OutInfoShow();
- OperationControlInitialization();
- this.everyHoleImgGraphicsList.Clear();
- this.everyHoleImgisConductive.Clear();
- this.everyHoleImgisFanweibuchang.Clear();
- this.everyHoleImgisErzhichuli.Clear();
- }
- /// <summary>
- /// 輸出信息顯示
- /// </summary>
- private void OutInfoShow()
- {
- if (comboMingcheng.SelectedIndex == -1)
- {
- return;
- }
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- panelOutInfo.Controls.Clear();
- int height = 38;
- int width = (groupOutInfo.Size.Width - 14) / 4;
- string[] titles = { PdnResources.GetString("NewHoleTypeName"), PdnResources.GetString("NewTestItemsName"), PdnResources.GetString("NewSpecificationName"), PdnResources.GetString("NewMeasuringPositionName") };
- string[] titleNames = { "kongxing", "jianyanxiangmu", "guige", "celiangweizhi" };
- List<Label> positions = new List<Label>();
- List<Label> specifications = new List<Label>();
- List<Label> testItems = new List<Label>();
- List<Label> holeTypes = new List<Label>();
- int i, k;
- for (i = 0; i < 4; i++)
- {
- Label title = new Label();
- title.AutoSize = false;
- title.TextAlign = ContentAlignment.MiddleCenter;
- title.BorderStyle = BorderStyle.FixedSingle;
- title.Location = new System.Drawing.Point(3 + (width - 1) * i, 1);
- title.Name = titleNames[i];
- title.Size = new System.Drawing.Size(width, height);
- title.TabIndex = 2;
- title.Text = titles[i];
- panelOutInfo.Controls.Add(title);
- }
- var list1 = measureMaintenanceType.MeasureMaintenanceTreeFourthDataList.GroupBy(m => m.HoleType);
- foreach (var item in list1)
- {
- int rowInt = 0;
- var list2 = item.GroupBy(m => m.TestItems);
- foreach (var item2 in list2)
- {
- k = 0;
- foreach (var item3 in item2)
- {
- #region [測量位置]
- Label position = new Label();
- position.AutoSize = false;
- position.TextAlign = ContentAlignment.MiddleCenter;
- position.BorderStyle = BorderStyle.FixedSingle;
- if (positions.Count == 0)
- position.Location = new System.Drawing.Point(3 + (width - 1) * 3, height);
- else
- position.Location = new System.Drawing.Point(3 + (width - 1) * 3, positions[positions.Count - 1].Location.Y + height - 1);
- position.Name = item3.FormulaParentId + "3";
- position.Size = new System.Drawing.Size(width, height);
- position.TabIndex = 2;
- position.Text = item3.FormulaName;
- panelOutInfo.Controls.Add(position);
- positions.Add(position);
- #endregion
- k++;
- rowInt++;
- }
- #region [規格]
- Label specification = new Label();
- specification.AutoSize = false;
- specification.TextAlign = ContentAlignment.MiddleCenter;
- specification.BorderStyle = BorderStyle.FixedSingle;
- if (specifications.Count == 0)
- specification.Location = new System.Drawing.Point(3 + (width - 1) * 2, height);
- else
- specification.Location = new System.Drawing.Point(3 + (width - 1) * 2, specifications[specifications.Count - 1].Location.Y + specifications[specifications.Count - 1].Size.Height - 1);
- specification.Name = item2.First().Specification + "2";
- specification.Size = new System.Drawing.Size(width, height * k - (k - 1));
- specification.TabIndex = 2;
- #region
- item2.First().Specification = item2.First().Specification.Replace("LQ", "<=");
- item2.First().Specification = item2.First().Specification.Replace("L", "<");
- #endregion
- specification.Text = item2.First().Specification;
- panelOutInfo.Controls.Add(specification);
- specifications.Add(specification);
- #endregion
- #region [檢驗項目]
- Label testItem = new Label();
- testItem.AutoSize = false;
- testItem.TextAlign = ContentAlignment.MiddleCenter;
- testItem.BorderStyle = BorderStyle.FixedSingle;
- if (testItems.Count == 0)
- testItem.Location = new System.Drawing.Point(3 + (width - 1) * 1, height);
- else
- testItem.Location = new System.Drawing.Point(3 + (width - 1) * 1, testItems[testItems.Count - 1].Location.Y + testItems[testItems.Count - 1].Size.Height - 1);
- testItem.Name = item2.Key + "1";
- testItem.Size = new System.Drawing.Size(width, height * k - (k - 1));
- testItem.TabIndex = 2;
- testItem.Text = item2.Key;
- panelOutInfo.Controls.Add(testItem);
- testItems.Add(testItem);
- #endregion
- }
- #region [孔型]
- Label holeType = new Label();
- holeType.AutoSize = false;
- holeType.TextAlign = ContentAlignment.MiddleCenter;
- holeType.BorderStyle = BorderStyle.FixedSingle;
- if (holeTypes.Count == 0)
- holeType.Location = new System.Drawing.Point(3, height);
- else
- holeType.Location = new System.Drawing.Point(3, holeTypes[holeTypes.Count - 1].Location.Y + holeTypes[holeTypes.Count - 1].Size.Height - 1);
- holeType.Name = item.Key + "0";
- holeType.Size = new System.Drawing.Size(width, height * rowInt - (rowInt - 1));
- holeType.TabIndex = 2;
- holeType.Text = item.Key;
- panelOutInfo.Controls.Add(holeType);
- holeTypes.Add(holeType);
- #endregion
- }
- }
- /// <summary>
- /// 操作界面控件初始化
- /// </summary>
- private void OperationControlInitialization()
- {
- if (comboMingcheng.SelectedIndex == -1)
- {
- return;
- }
- panel1.Controls.Clear();
- erjimulusName.Clear();
- everyHoleImg.Clear();
-
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- for (int i = 0; i < pictures.Count; i++)
- {
- for (int k = 0; k < pictures[i].Count; k++)
- {
- if (pictures[i][k] != null)
- {
- pictures[i][k].Dispose();
- }
- }
- }
- pictures.Clear();
- pictureNames.Clear();
- picturePathNames.Clear();
- kongjians = new Kongjian();
- List<string> ruleList = new List<string>();
- List<string> holeTypeIDList = new List<string>();
- //尋找具有檢驗項目的二級目錄
- var list = measureMaintenanceType.MeasureMaintenanceTreeFourthDataList.GroupBy(m => m.HoleType);
- foreach (var item in list)
- {
- erjimulusName.Add(item.Key);
- holeTypeIDList.Add(item.FirstOrDefault().HoleTypeId);
- if (measureMaintenanceTreeData != null)
- {
- MeasureMaintenanceTreeSpecificData data;
- this.appWorkspace.RecursionGetData(item.FirstOrDefault().HoleTypeId, measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- string ruleName;
- if (data.ruleMessage == null)
- {
- ruleName = label14.Text;
- }
- else
- {
- //计算每像素物理长度
- double proportion = Math.Round((double)data.ruleMessage.physicalLength / data.ruleMessage.pixelLength, 4);
- string content = proportion.ToString() + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), data.ruleMessage.rulerUnits)))].ToString() + "/" + PdnResources.GetString("MeasurementUnit.Pixel");
- ruleName = $"{data.ruleMessage.ruleName} {content}";
- }
- ruleList.Add(ruleName);
- }
- else {
- ruleList.Add(label14.Text);
- }
- everyHoleImg.Add(item.FirstOrDefault().HoleTypeId,new List<Mat>() { });
- }
- erjimuluCount = erjimulusName.Count();
- //選擇的圖片計數,//圖片列表//删除按钮列表//加載圖片//圖片名
- counts = new int[erjimuluCount];
- for (int i = 0; i < erjimuluCount; i++)
- {
- counts[i] = 1;
- List<PictureBox> newPictureBox = new List<PictureBox>();
- kongjians.pictureBoxes.Add(newPictureBox);
- List<Button> newButton = new List<Button>();
- kongjians.shanchus.Add(newButton);
- List<Bitmap> bitmaps = new List<Bitmap>();
- pictures.Add(bitmaps);
- List<string> pictureName = new List<string>();
- List<string> picturePathName = new List<string>();
- pictureNames.Add(pictureName);
- picturePathNames.Add(picturePathName);
- }
- //新建label名稱
- List<string> labelNames = new List<string>();
- for (int i = 0; i < erjimulusName.Count; i++)
- {
- labelNames.Add("label" + erjimulusName[i]);
- }
- //新建操作信息與按鈕
- for (int i = 0; i < erjimulusName.Count; i++)
- {
- Label newFenleimingcheng = new Label();
- newFenleimingcheng.AutoSize = true;
- if (i == 0)
- {
- newFenleimingcheng.Location = new System.Drawing.Point(3, 10 + 100 * i);
- }
- else {
- newFenleimingcheng.Location = new System.Drawing.Point(3, 30 + 20 * (i - 1) + 100 * i);
- }
- newFenleimingcheng.Name = labelNames[i];
- newFenleimingcheng.Size = new System.Drawing.Size(98, 18);
- newFenleimingcheng.TabIndex = 2;
- newFenleimingcheng.Text = PdnResources.GetString("NewCategoryName") + ":" + erjimulusName[i];
- kongjians.fenleimingchengs.Add(newFenleimingcheng);
- Label newBiaochimingcheng = new Label();
- newBiaochimingcheng.AutoSize = true;
- if (i == 0)
- {
- newBiaochimingcheng.Location = new System.Drawing.Point(newFenleimingcheng.Width + 30, 10 + 100 * i);
- }
- else
- {
- newBiaochimingcheng.Location = new System.Drawing.Point(newFenleimingcheng.Width + 30, 30 + 20 * (i - 1) + 100 * i);
- }
- newBiaochimingcheng.Name = holeTypeIDList[i];
- newBiaochimingcheng.Size = new System.Drawing.Size(98, 18);
- newBiaochimingcheng.TabIndex = 2;
- newBiaochimingcheng.Text = PdnResources.GetString("NewRuler") + ruleList[i];
- kongjians.biaochimingchengs.Add(newBiaochimingcheng);
- Label newTupianweizhi = new Label();
- newTupianweizhi.AutoSize = true;
- if (i == 0)
- {
- newTupianweizhi.Location = new System.Drawing.Point(3, 30 + 100 * i);
- }
- else
- {
- newTupianweizhi.Location = new System.Drawing.Point(3, 50 + 20 * (i - 1) + 100 * i);
- }
- newTupianweizhi.Name = "tupianweizhi" + i.ToString();
- newTupianweizhi.Size = new System.Drawing.Size(98, 18);
- newTupianweizhi.TabIndex = 2;
- newTupianweizhi.Text = PdnResources.GetString("NewPictureLocation") + ":";
- kongjians.tupianweizhis.Add(newTupianweizhi);
- Button newWenjianxuanze = new Button();
- if (i == 0)
- {
- newWenjianxuanze.Location = new System.Drawing.Point(353, 10 + 100 * i);
- }
- else
- {
- newWenjianxuanze.Location = new System.Drawing.Point(353, 30 + 20 * (i - 1) + 100 * i);
- }
- newWenjianxuanze.Name = "wenjianxuanze" + i.ToString();
- newWenjianxuanze.Size = new System.Drawing.Size(73, 28);
- newWenjianxuanze.TabIndex = 0;
- newWenjianxuanze.Text = PdnResources.GetString("newWenjianxuanze");
- newWenjianxuanze.UseVisualStyleBackColor = true;
- newWenjianxuanze.Click += new System.EventHandler(this.buttonWenjianxuanze_Click);
- kongjians.wenjianxuanzes.Add(newWenjianxuanze);
- Button newHuizhifanwei = new Button();
- if (i == 0)
- {
- newHuizhifanwei.Location = new System.Drawing.Point(353, 40 + 100 * i);
- }
- else
- {
- newHuizhifanwei.Location = new System.Drawing.Point(353, 60 + 20 * (i - 1) + 100 * i);
- }
- newHuizhifanwei.Name = "buttonHuizhifanwei" + erjimulusName[i];
- newHuizhifanwei.Size = new System.Drawing.Size(73, 28);
- newHuizhifanwei.TabIndex = 0;
- newHuizhifanwei.Text = PdnResources.GetString("NewDrawRange") + "";
- newHuizhifanwei.UseVisualStyleBackColor = true;
- newHuizhifanwei.Click += new System.EventHandler(this.buttonHuizhitupian_Click);
- kongjians.huizhifanweis.Add(newHuizhifanwei);
- Button newQingkongquanbu = new Button();
- if (i == 0)
- {
- newQingkongquanbu.Location = new System.Drawing.Point(353, 70 + 100 * i);
- }
- else
- {
- newQingkongquanbu.Location = new System.Drawing.Point(353, 90 + 20 * (i - 1) + 100 * i);
- }
- newQingkongquanbu.Name = "buttonQingkongquanbu" + erjimulusName[i];
- newQingkongquanbu.Size = new System.Drawing.Size(73, 28);
- newQingkongquanbu.TabIndex = 0;
- newQingkongquanbu.Text = PdnResources.GetString("NewEmptyAll");
- newQingkongquanbu.UseVisualStyleBackColor = true;
- newQingkongquanbu.Click += new System.EventHandler(this.buttonQingkongquanbu_Click);
- kongjians.qingkongquanbus.Add(newQingkongquanbu);
- Button newTianjiatupian = new Button();
- if (i == 0)
- {
- newTianjiatupian.Location = new System.Drawing.Point(70, 30 + 100 * i);
- }
- else
- {
- newTianjiatupian.Location = new System.Drawing.Point(70, 50 + 20 * (i - 1) + 100 * i);
- }
- newTianjiatupian.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
- newTianjiatupian.Name = "buttonTianjiatupian" + i.ToString();
- newTianjiatupian.Size = new System.Drawing.Size(50, 70);
- newTianjiatupian.TabIndex = 0;
- newTianjiatupian.Text = "+";
- newTianjiatupian.UseVisualStyleBackColor = true;
- newTianjiatupian.Click += new System.EventHandler(this.buttonTianjiatupian_Click);
- kongjians.tianjiatupians.Add(newTianjiatupian);
- Label dividingLine = new Label();
- dividingLine.AutoSize = false;
- dividingLine.Location = new System.Drawing.Point(0, (newTianjiatupian.Location.Y + newTianjiatupian.Height + 10));
- dividingLine.Name = "dividingLine" + i.ToString();
- dividingLine.Size = new System.Drawing.Size(panel1.Width - 20, 2);
- dividingLine.TabIndex = 2;
- dividingLine.BorderStyle = BorderStyle.Fixed3D;
- kongjians.dividingLines.Add(dividingLine);
- panel1.Controls.Add(kongjians.fenleimingchengs[i]);
- panel1.Controls.Add(kongjians.biaochimingchengs[i]);
- panel1.Controls.Add(kongjians.tupianweizhis[i]);
- panel1.Controls.Add(kongjians.wenjianxuanzes[i]);
- panel1.Controls.Add(kongjians.tianjiatupians[i]);
- panel1.Controls.Add(kongjians.huizhifanweis[i]);
- panel1.Controls.Add(kongjians.qingkongquanbus[i]);
- panel1.Controls.Add(dividingLine);
- }
- GC.Collect();
- }
- /// <summary>
- /// 文件夹选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void buttonWenjianxuanze_Click(object sender, EventArgs e)
- {
- string path = string.Empty;
- Button button = (Button)sender;
- int rowOfFenlei = 0;
- for (int i = 0; i < kongjians.wenjianxuanzes.Count; i++)
- {
- if (kongjians.wenjianxuanzes[i].Name == button.Name)
- {
- rowOfFenlei = i;
- break;
- }
- }
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "請選擇文件路徑";
- dialog.SelectedPath = path;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- string foldPath = dialog.SelectedPath;
- List<string> pathList = FileOperationHelper.GetAllImgList(foldPath);
- bitmaps = ChooseImagesFromImgDisk(pathList, kongjians.biaochimingchengs[rowOfFenlei].Name);
- if (bitmaps != null && bitmaps.Count > 0)
- {
- PictureShow(rowOfFenlei);
- }
- }
- }
- /// <summary>
- /// 點擊添加图片
- /// </summary>
- private void buttonTianjiatupian_Click(object sender, EventArgs e)
- {
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- if (measureMaintenanceType == null)
- {
- MessageBox.Show(PdnResources.GetString("NoAvaliableRule"));
- return;
- }
- Button button = (Button)sender;
- int rowOfFenlei = 0;
- for (int i = 0; i < kongjians.tianjiatupians.Count; i++)
- {
- if (kongjians.tianjiatupians[i].Name == button.Name)
- {
- rowOfFenlei = i;
- break;
- }
- }
- bitmaps = ChooseImagesFromHardDisk(kongjians.biaochimingchengs[rowOfFenlei].Name);
- if (bitmaps != null && bitmaps.Count > 0)
- {
- PictureShow(rowOfFenlei);
- }
- }
- /// <summary>
- /// 點擊删除图片
- /// </summary>
- private void buttonShanchu_Click(object sender, EventArgs e)
- {
- Button button = (Button)sender;
- int rowsOfFenlei = 0;
- int position = 0;
- for (int i = 0; i < kongjians.shanchus.Count; i++)
- {
- for (int j = 0; j < kongjians.shanchus[i].Count; j++)
- {
- if (kongjians.shanchus[i][j].Name == button.Name)
- {
- rowsOfFenlei = i;
- position = j;
- }
- }
- }
- panel1.Controls.Remove(kongjians.shanchus[rowsOfFenlei][position]);
- panel1.Controls.Remove(kongjians.pictureBoxes[rowsOfFenlei][position]);
- kongjians.shanchus[rowsOfFenlei].RemoveAt(position);
- kongjians.pictureBoxes[rowsOfFenlei].RemoveAt(position);
- kongjians.ResetControlPosition2(rowsOfFenlei, position);
- string name = pictureNames[rowsOfFenlei][position];
- if (pictures[rowsOfFenlei][position] != null)
- {
- pictures[rowsOfFenlei][position].Dispose();
- }
- counts[rowsOfFenlei]--;
- pictureNames[rowsOfFenlei].RemoveAt(position);
- picturePathNames[rowsOfFenlei].RemoveAt(position);
- pictures[rowsOfFenlei].RemoveAt(position);
- if (everyHoleImgGraphicsList.ContainsKey(rowsOfFenlei))
- {
- if (position < everyHoleImgGraphicsList[rowsOfFenlei].Count) {
- everyHoleImgGraphicsList[rowsOfFenlei].RemoveAt(position);
- }
- }
- if (everyHoleImgisConductive.ContainsKey(rowsOfFenlei))
- {
- if (position < everyHoleImgisConductive[rowsOfFenlei].Count)
- {
- everyHoleImgisConductive[rowsOfFenlei].RemoveAt(position);
- }
- }
- if (everyHoleImgisFanweibuchang.ContainsKey(rowsOfFenlei))
- {
- if (position < everyHoleImgisFanweibuchang[rowsOfFenlei].Count)
- {
- everyHoleImgisFanweibuchang[rowsOfFenlei].RemoveAt(position);
- }
- }
- if (everyHoleImgisErzhichuli.ContainsKey(rowsOfFenlei))
- {
- if (position < everyHoleImgisErzhichuli[rowsOfFenlei].Count)
- {
- everyHoleImgisErzhichuli[rowsOfFenlei].RemoveAt(position);
- }
- }
- if (this.pidRuleDic.ContainsKey(kongjians.biaochimingchengs[rowsOfFenlei].Name))
- {
- if (this.pidRuleDic[kongjians.biaochimingchengs[rowsOfFenlei].Name].ContainsKey(name))
- {
- this.pidRuleDic[kongjians.biaochimingchengs[rowsOfFenlei].Name].Remove(name);
- };
- }
-
- GC.Collect();
- }
- /// <summary>
- /// 點擊清除圖片
- /// </summary>
- private void buttonQingkongquanbu_Click(object sender, EventArgs e)
- {
- Button button = (Button)sender;
- int rowOfFenlie = 0;
- for (int i = 0; i < kongjians.qingkongquanbus.Count; i++)
- {
- if (kongjians.qingkongquanbus[i].Name == button.Name)
- {
- rowOfFenlie = i; break;
- }
- }
- int cengshu = kongjians.pictureBoxes[rowOfFenlie].Count / 4;
- for (int i = kongjians.pictureBoxes[rowOfFenlie].Count - 1; i >= 0; i--)
- {
- panel1.Controls.Remove(kongjians.pictureBoxes[rowOfFenlie][i]);
- panel1.Controls.Remove(kongjians.shanchus[rowOfFenlie][i]);
- kongjians.shanchus[rowOfFenlie].RemoveAt(i);
- kongjians.pictureBoxes[rowOfFenlie].RemoveAt(i);
- }
- kongjians.tianjiatupians[rowOfFenlie].Location = new System.Drawing.Point(70, kongjians.tupianweizhis[rowOfFenlie].Location.Y);
- kongjians.dividingLines[rowOfFenlie].Location = new System.Drawing.Point(kongjians.dividingLines[rowOfFenlie].Location.X, kongjians.tianjiatupians[rowOfFenlie].Location.Y + kongjians.tianjiatupians[rowOfFenlie].Height + 20);
- counts[rowOfFenlie] = 1;
- for (int i = 0; i < pictures[rowOfFenlie].Count; i++) {
- if (pictures[rowOfFenlie][i] != null)
- {
- pictures[rowOfFenlie][i].Dispose();
- }
- }
- pictures[rowOfFenlie].Clear();
- pictureNames[rowOfFenlie].Clear();
- picturePathNames[rowOfFenlie].Clear();
- if (this.everyHoleImgGraphicsList.ContainsKey(rowOfFenlie))
- {
- this.everyHoleImgGraphicsList.Remove(rowOfFenlie);
- }
- if (everyHoleImgisConductive.ContainsKey(rowOfFenlie))
- {
- everyHoleImgisConductive.Remove(rowOfFenlie);
- }
- if (everyHoleImgisFanweibuchang.ContainsKey(rowOfFenlie))
- {
- everyHoleImgisFanweibuchang.Remove(rowOfFenlie);
- }
- if (everyHoleImgisErzhichuli.ContainsKey(rowOfFenlie))
- {
- everyHoleImgisErzhichuli.Remove(rowOfFenlie);
- }
- if (this.pidRuleDic.ContainsKey(kongjians.biaochimingchengs[rowOfFenlie].Name))
- {
- this.pidRuleDic[kongjians.biaochimingchengs[rowOfFenlie].Name].Clear();
- }
- kongjians.ResetControlPosition3(rowOfFenlie, cengshu);
- GC.Collect();
- }
- /// <summary>
- /// 點擊繪製範圍
- /// </summary>
- private void buttonHuizhitupian_Click(object sender, EventArgs e)
- {
- Button button = (Button)sender;
- int rowOfFenlie = 0;
- for (int i = 0; i < kongjians.huizhifanweis.Count; i++)
- {
- if (button.Name == kongjians.huizhifanweis[i].Name)
- {
- rowOfFenlie = i;
- break;
- }
- }
- if (pictures[rowOfFenlie].Count == 0) {
- MessageBox.Show(PdnResources.GetString("NewPleaseAddPicturesFirst"));
- return;
- }
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- bool show = false;
- bool showFanweibuchang = false;
- bool showErzhichuli = false;
- List<bool> list = new List<bool>();
- if (measureMaintenanceType != null && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].FatherHoleTypeId == "9")
- {
- show = true;
- if (!this.everyHoleImgisConductive.ContainsKey(rowOfFenlie))
- {
- for (int i = 0; i < pictures[rowOfFenlie].Count; i++)
- {
- if (measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].isConductiveCloth)
- {
- list.Add(true);
- }
- else
- {
- list.Add(false);
- }
- }
- this.everyHoleImgisConductive.Add(rowOfFenlie, list);
- }
- }
- else if (measureMaintenanceType != null && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].FatherHoleTypeId == "10"
- && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].HoleTypeId == "100300")
- {
- showFanweibuchang = true;
- if (!this.everyHoleImgisFanweibuchang.ContainsKey(rowOfFenlie))
- {
- for (int i = 0; i < pictures[rowOfFenlie].Count; i++)
- {
- if (measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].isFanweibuchang)
- {
- list.Add(true);
- }
- else
- {
- list.Add(false);
- }
- }
- this.everyHoleImgisFanweibuchang.Add(rowOfFenlie, list);
- }
- }
- else if (true && measureMaintenanceType != null && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].FatherHoleTypeId == "7"
- && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].HoleTypeId == "100176")
- {
- showErzhichuli = true;
- if (!this.everyHoleImgisErzhichuli.ContainsKey(rowOfFenlie))
- {
- for (int i = 0; i < pictures[rowOfFenlie].Count; i++)
- {
- if (measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[rowOfFenlie].isErzhichuli)
- {
- list.Add(true);
- }
- else
- {
- list.Add(false);
- }
- }
- this.everyHoleImgisErzhichuli.Add(rowOfFenlie, list);
- }
- }
- else {
- for (int i = 0; i < pictures[rowOfFenlie].Count; i++)
- {
- list.Add(false);
- }
- if (this.everyHoleImgisConductive.ContainsKey(rowOfFenlie))
- {
- this.everyHoleImgisConductive[rowOfFenlie] = list;
- }
- else {
- this.everyHoleImgisConductive.Add(rowOfFenlie, list);
- }
- if (this.everyHoleImgisFanweibuchang.ContainsKey(rowOfFenlie))
- {
- this.everyHoleImgisFanweibuchang[rowOfFenlie] = list;
- }
- else
- {
- this.everyHoleImgisFanweibuchang.Add(rowOfFenlie, list);
- }
- if (this.everyHoleImgisErzhichuli.ContainsKey(rowOfFenlie))
- {
- this.everyHoleImgisErzhichuli[rowOfFenlie] = list;
- }
- else
- {
- this.everyHoleImgisErzhichuli.Add(rowOfFenlie, list);
- }
- }
- PlotTheMeasurementRange from2 = new PlotTheMeasurementRange(pictures[rowOfFenlie], pictureNames[rowOfFenlie],this.appWorkspace, this, rowOfFenlie,this.everyHoleImgGraphicsList,this.everyHoleImgisConductive, show
- , this.everyHoleImgisFanweibuchang, showFanweibuchang, this.everyHoleImgisErzhichuli, showErzhichuli);
- from2.StartPosition = FormStartPosition.CenterParent;
- from2.ShowDialog();
- }
- /// <summary>
- /// 添加圖片時顯示
- /// </summary>
- private void PictureShow(int rowOfFenlei)
- {
- int bitmapNumber = bitmaps.Count;
- for (int i = 0; i < bitmapNumber; i++)
- {
- if (counts[rowOfFenlei] % 4 != 0)
- {
- Button newShanchu = new Button();
- newShanchu.Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X + 30, kongjians.tianjiatupians[rowOfFenlei].Location.Y + 50);
- newShanchu.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
- newShanchu.Name = "buttonShanchu" + bitNames[i] + rowOfFenlei.ToString();
- newShanchu.Size = new System.Drawing.Size(20, 20);
- newShanchu.TabIndex = 0;
- newShanchu.Text = "×";
- newShanchu.BackColor = Color.Transparent;
- newShanchu.FlatStyle = FlatStyle.Flat;
- //newShanchu.FlatAppearance.MouseOverBackColor = Color.Transparent;
- //newShanchu.FlatAppearance.MouseDownBackColor = Color.Transparent;
- newShanchu.FlatAppearance.BorderSize = 0;
- newShanchu.ForeColor = Color.Red;
- newShanchu.UseVisualStyleBackColor = true;
- newShanchu.Click += new System.EventHandler(this.buttonShanchu_Click);
- kongjians.shanchus[rowOfFenlei].Add(newShanchu);
- panel1.Controls.Add(kongjians.shanchus[rowOfFenlei][kongjians.shanchus[rowOfFenlei].Count - 1]);
- PictureBox newPicture = new PictureBox();
- newPicture.Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X, kongjians.tianjiatupians[rowOfFenlei].Location.Y);
- newPicture.Name = bitNames[i];
- newPicture.Size = new System.Drawing.Size(50, 70);
- newPicture.TabIndex = 1;
- newPicture.TabStop = false;
- //panel1.Controls.Add(newPicture);
- newPicture.Image = bitmaps[i];
- newPicture.SizeMode = PictureBoxSizeMode.Zoom;
- kongjians.pictureBoxes[rowOfFenlei].Add(newPicture);
- panel1.Controls.Add(kongjians.pictureBoxes[rowOfFenlei][kongjians.pictureBoxes[rowOfFenlei].Count - 1]);
- pictures[rowOfFenlei].Add(bitmaps[i]);
- pictureNames[rowOfFenlei].Add(bitNames[i]);
- picturePathNames[rowOfFenlei].Add(filePathList[i]);
- kongjians.tianjiatupians[rowOfFenlei].Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X + 70, kongjians.tianjiatupians[rowOfFenlei].Location.Y);
- kongjians.dividingLines[rowOfFenlei].Location = new System.Drawing.Point(kongjians.dividingLines[rowOfFenlei].Location.X, kongjians.tianjiatupians[rowOfFenlei].Location.Y + kongjians.tianjiatupians[rowOfFenlei].Height + 20);
- counts[rowOfFenlei]++;
- }
- else
- {
- Button newShanchu = new Button();
- newShanchu.Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X + 30, kongjians.tianjiatupians[rowOfFenlei].Location.Y + 50);
- newShanchu.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
- newShanchu.Name = "buttonShanchu" + bitNames[i] + rowOfFenlei.ToString();
- newShanchu.Size = new System.Drawing.Size(20, 20);
- newShanchu.TabIndex = 0;
- newShanchu.Text = "×";
- newShanchu.BackColor = Color.Transparent;
- newShanchu.FlatStyle = FlatStyle.Flat;
- //newShanchu.FlatAppearance.MouseOverBackColor = Color.Transparent;
- //newShanchu.FlatAppearance.MouseDownBackColor = Color.Transparent;
- newShanchu.FlatAppearance.BorderSize = 0;
- newShanchu.ForeColor = Color.Red;
- newShanchu.UseVisualStyleBackColor = true;
- newShanchu.Click += new System.EventHandler(this.buttonShanchu_Click);
- kongjians.shanchus[rowOfFenlei].Add(newShanchu);
- panel1.Controls.Add(kongjians.shanchus[rowOfFenlei][kongjians.shanchus[rowOfFenlei].Count - 1]);
- PictureBox newPicture = new PictureBox();
- newPicture.Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X, kongjians.tianjiatupians[rowOfFenlei].Location.Y);
- newPicture.Name = bitNames[i];
- newPicture.Size = new System.Drawing.Size(50, 70);
- newPicture.TabIndex = 1;
- newPicture.TabStop = false;
- //panel1.Controls.Add(newPicture);
- newPicture.Image = bitmaps[i];
- newPicture.SizeMode = PictureBoxSizeMode.Zoom;
- kongjians.pictureBoxes[rowOfFenlei].Add(newPicture);
- panel1.Controls.Add(kongjians.pictureBoxes[rowOfFenlei][kongjians.pictureBoxes[rowOfFenlei].Count - 1]);
- pictures[rowOfFenlei].Add(bitmaps[i]);
- pictureNames[rowOfFenlei].Add(bitNames[i]);
- picturePathNames[rowOfFenlei].Add(filePathList[i]);
- kongjians.tianjiatupians[rowOfFenlei].Location = new System.Drawing.Point(kongjians.tianjiatupians[rowOfFenlei].Location.X - 70 * 3, kongjians.tianjiatupians[rowOfFenlei].Location.Y + 70);
- kongjians.dividingLines[rowOfFenlei].Location = new System.Drawing.Point(kongjians.dividingLines[rowOfFenlei].Location.X, kongjians.tianjiatupians[rowOfFenlei].Location.Y + kongjians.tianjiatupians[rowOfFenlei].Height + 20);
- kongjians.ResetControlPosition(rowOfFenlei);
- counts[rowOfFenlei]++;
- }
- }
- }
- /// <summary>
- /// 開始測量,顯示測量進度
- /// </summary>
- private void buttonStartMeasuring_Click(object sender, EventArgs e)
- {
- MeasureMaintenanceType measureMaintenanceType = (MeasureMaintenanceType)comboMingcheng.SelectedItem;
- if (measureMaintenanceType == null || measureMaintenanceType.MeasureMaintenanceTreeFourthDataList == null || measureMaintenanceType.MeasureMaintenanceTreeFourthDataList.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("NewNoMeasurementClassification"));
- return;
- }
- int[] pictureNumber = new int[erjimuluCount];//圖片數量
- int[] yiceliangNumber = new int[erjimuluCount];//已測量圖片數量
- int[] successNumber = new int[erjimuluCount];//已測量圖片數量
- int[] failNumber = new int[erjimuluCount];//已測量圖片數量
- if (infoModel.everyHoleImgName == null) {
- infoModel.everyHoleImgName = new Dictionary<string, List<string>>();
- }
- if (infoModel.everyHoleImgGraphicsList == null)
- {
- infoModel.everyHoleImgGraphicsList = new Dictionary<int, List<GraphicsList>>();
- }
- if (infoModel.everyHoleImgisConductive == null)
- {
- infoModel.everyHoleImgisConductive = new Dictionary<int, List<bool>>();
- }
- if (infoModel.everyHoleImgisFanweibuchang == null)
- {
- infoModel.everyHoleImgisFanweibuchang = new Dictionary<int, List<bool>>();
- }
- if (infoModel.everyHoleImgisErzhichuli == null)
- {
- infoModel.everyHoleImgisErzhichuli = new Dictionary<int, List<bool>>();
- }
- for (int i = 0; i < erjimuluCount; i++)
- {
- pictureNumber[i] = pictures[i].Count;
- yiceliangNumber[i] = 0;
- }
- int hasNoData = 0;
- foreach (var item in pictures)
- {
- if (item.Count == 0)
- {
- hasNoData++;
- }
- }
- //判斷第一個分類是否爲空
- if (hasNoData == pictures.Count)
- {
- MessageBox.Show(PdnResources.GetString("NoClassificationImage"));
- }
- else
- {
- for (int i = 0; i < pictures.Count; i++)
- {
- everyHoleImg[(everyHoleImg.Keys.ToList())[i]].Clear();
- if (infoModel.everyHoleImgName.ContainsKey((everyHoleImg.Keys.ToList())[i]))
- {
- infoModel.everyHoleImgName[(everyHoleImg.Keys.ToList())[i]].Clear(); ;
- }
- if (infoModel.everyHoleImgGraphicsList.ContainsKey(i))
- {
- infoModel.everyHoleImgGraphicsList[i].Clear(); ;
- }
- if (infoModel.everyHoleImgisConductive.ContainsKey(i))
- {
- infoModel.everyHoleImgisConductive[i].Clear(); ;
- }
- if (infoModel.everyHoleImgisFanweibuchang.ContainsKey(i))
- {
- infoModel.everyHoleImgisFanweibuchang[i].Clear(); ;
- }
- if (infoModel.everyHoleImgisErzhichuli.ContainsKey(i))
- {
- infoModel.everyHoleImgisErzhichuli[i].Clear(); ;
- }
- var list = new List<GraphicsList>();
- var list1 = new List<bool>();
- var listFanweibuchang = new List<bool>();
- var listErzhichuli = new List<bool>();
- for (int j = 0; j < pictures[i].Count; j++)
- {
- Mat image = OpenCvSharp.Extensions.BitmapConverter.ToMat(pictures[i][j]);
- everyHoleImg[(everyHoleImg.Keys.ToList())[i]].Add(image);
- if (infoModel.everyHoleImgName.ContainsKey((everyHoleImg.Keys.ToList())[i]))
- {
- infoModel.everyHoleImgName[(everyHoleImg.Keys.ToList())[i]].Add(pictureNames[i][j]);
- }
- else
- {
- infoModel.everyHoleImgName.Add((everyHoleImg.Keys.ToList())[i], new List<string>() { pictureNames[i][j] });
- }
- list.Add(new GraphicsList());
- if (measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].FatherHoleTypeId == "9")
- {
- list1.Add(measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].isConductiveCloth);
- }
- else {
- list1.Add(false);
- }
- if (measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].FatherHoleTypeId == "10"
- && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].HoleTypeId == "100300")
- {
- listFanweibuchang.Add(measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].isFanweibuchang);
- }
- else
- {
- listFanweibuchang.Add(false);
- }
- if (true && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].FatherHoleTypeId == "7"
- && measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].HoleTypeId == "100176")
- {
- listErzhichuli.Add(measureMaintenanceType.MeasureMaintenanceTreeFourthDataList[i].isErzhichuli);
- }
- else
- {
- listErzhichuli.Add(false);
- }
- }
- if (everyHoleImgGraphicsList.ContainsKey(i))
- {
- List<GraphicsList> newGraphicsList = new List<GraphicsList>();
- for (int k = 0; k < everyHoleImgGraphicsList[i].Count; k++)
- {
- GraphicsList graphicsList = new GraphicsList();
- graphicsList.graphicsList = everyHoleImgGraphicsList[i][k].graphicsList;
- newGraphicsList.Add(graphicsList);
- }
- if (infoModel.everyHoleImgGraphicsList.ContainsKey(i))
- {
- infoModel.everyHoleImgGraphicsList[i].AddRange(newGraphicsList);
- }
- else
- {
- infoModel.everyHoleImgGraphicsList.Add(i, newGraphicsList);
- }
- }
- else
- {
- if (infoModel.everyHoleImgGraphicsList.ContainsKey(i))
- {
- infoModel.everyHoleImgGraphicsList[i].AddRange(list);
- }
- else
- {
- infoModel.everyHoleImgGraphicsList.Add(i,list);
- }
- }
- if (everyHoleImgisConductive.ContainsKey(i))
- {
- if (infoModel.everyHoleImgisConductive.ContainsKey(i))
- {
- infoModel.everyHoleImgisConductive[i].AddRange(everyHoleImgisConductive[i]);
- }
- else
- {
- infoModel.everyHoleImgisConductive.Add(i, everyHoleImgisConductive[i]);
- }
- }
- else
- {
- if (infoModel.everyHoleImgisConductive.ContainsKey(i))
- {
- infoModel.everyHoleImgisConductive[i].AddRange(list1);
- }
- else
- {
- infoModel.everyHoleImgisConductive.Add(i, list1);
- }
- }
- if (everyHoleImgisFanweibuchang.ContainsKey(i))
- {
- if (infoModel.everyHoleImgisFanweibuchang.ContainsKey(i))
- {
- infoModel.everyHoleImgisFanweibuchang[i].AddRange(everyHoleImgisFanweibuchang[i]);
- }
- else
- {
- infoModel.everyHoleImgisFanweibuchang.Add(i, everyHoleImgisFanweibuchang[i]);
- }
- }
- else
- {
- if (infoModel.everyHoleImgisFanweibuchang.ContainsKey(i))
- {
- infoModel.everyHoleImgisFanweibuchang[i].AddRange(listFanweibuchang);
- }
- else
- {
- infoModel.everyHoleImgisFanweibuchang.Add(i, listFanweibuchang);
- }
- }
- if (everyHoleImgisErzhichuli.ContainsKey(i))
- {
- if (infoModel.everyHoleImgisErzhichuli.ContainsKey(i))
- {
- infoModel.everyHoleImgisErzhichuli[i].AddRange(everyHoleImgisErzhichuli[i]);
- }
- else
- {
- infoModel.everyHoleImgisErzhichuli.Add(i, everyHoleImgisErzhichuli[i]);
- }
- }
- else
- {
- if (infoModel.everyHoleImgisErzhichuli.ContainsKey(i))
- {
- infoModel.everyHoleImgisErzhichuli[i].AddRange(listErzhichuli);
- }
- else
- {
- infoModel.everyHoleImgisErzhichuli.Add(i, listErzhichuli);
- }
- }
- }
- infoModel.pictureNumber = pictureNumber;
- infoModel.yiceliangNumber = yiceliangNumber;
- infoModel.failNumber = failNumber;
- infoModel.successNumber = successNumber;
- infoModel.text = erjimulusName;
- infoModel.everyHoleImg = everyHoleImg;
-
- measureMaintenanceType.measureMaintenanceBasicDataList[0].measureMaintenanceBasicDataValue = textLiaohao.Text;//料號
- measureMaintenanceType.measureMaintenanceBasicDataList[1].measureMaintenanceBasicDataValue = comboBanci.SelectedItem == null ? "" : comboBanci.SelectedItem.ToString();//班次
- measureMaintenanceType.measureMaintenanceBasicDataList[2].measureMaintenanceBasicDataValue = comboShiyanshi.SelectedItem == null ? "" : comboShiyanshi.SelectedItem.ToString();//實驗室
- measureMaintenanceType.measureMaintenanceBasicDataList[3].measureMaintenanceBasicDataValue = comboShiyongchangqu.SelectedItem == null ? "" : comboShiyongchangqu.SelectedItem.ToString();//使用廠區
- measureMaintenanceType.measureMaintenanceBasicDataList[4].measureMaintenanceBasicDataValue = comboZhichengbie.SelectedItem == null ? "" : comboZhichengbie.SelectedItem.ToString();//製成別
- measureMaintenanceType.measureMaintenanceBasicDataList[5].measureMaintenanceBasicDataValue = textDanhao.Text;//單號
- measureMaintenanceType.measureMaintenanceBasicDataList[6].measureMaintenanceBasicDataValue = textPihao.Text;//批號
- measureMaintenanceType.measureMaintenanceBasicDataList[7].measureMaintenanceBasicDataValue = comboCengbie.SelectedItem == null ? "" : comboCengbie.SelectedItem.ToString();//層別
- measureMaintenanceType.measureMaintenanceBasicDataList[8].measureMaintenanceBasicDataValue = comboDianduxianbie.Text;//電鍍綫別
- measureMaintenanceType.measureMaintenanceBasicDataList[9].measureMaintenanceBasicDataValue = label12.Text;//單位
- string filePath = string.Empty;
- foreach (var item in picturePathNames) {
- if (item.Count == 0) {
- continue;
- }
- filePath = item[0];
- break;
- }
- if (measureMaintenanceTreeData == null)
- {
- string filePathA = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceType\\";
- var fileName = comboMingcheng.Text;
- filePathA = $"{filePathA}{fileName}.xml";
- if (System.IO.File.Exists(filePathA))
- {
- measureMaintenanceTreeData = XmlSerializeHelper.DESerializer<MeasureMaintenanceTreeData>(FileOperationHelper.ReadStringFromFile(filePathA, FileMode.Open));
- }
- }
- MeasureMaintenanceTreeSpecificData data;
- this.appWorkspace.RecursionGetData("100000", measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- if (_listHoleTypePos.ContainsKey("100000"))
- {
- _listHoleTypePos["100000"] = data.MeasureMaintenanceTreeSpecificIsPos;
- }
- else {
- _listHoleTypePos.Add("100000", data.MeasureMaintenanceTreeSpecificIsPos);
- }
- this.appWorkspace.RecursionGetData("100013", measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- if (_listHoleTypePos.ContainsKey("100013"))
- {
- _listHoleTypePos["100013"] = data.MeasureMaintenanceTreeSpecificIsPos;
- }
- else
- {
- _listHoleTypePos.Add("100013", data.MeasureMaintenanceTreeSpecificIsPos);
- }
- this.appWorkspace.RecursionGetData("100031", measureMaintenanceTreeData.MeasureMaintenanceTreeDataList, out data);
- if (_listHoleTypePos.ContainsKey("100031"))
- {
- _listHoleTypePos["100031"] = data.MeasureMaintenanceTreeSpecificIsPos;
- }
- else
- {
- _listHoleTypePos.Add("100031", data.MeasureMaintenanceTreeSpecificIsPos);
- }
- BeingExecuted from3 = new BeingExecuted(infoModel,appWorkspace, _listHoleType, measureMaintenanceType, this.pidRuleDic, filePath, _listHoleTypePos);
- from3.ShowDialog();
- }
- }
- private void ReadXml2()
- {
- XmlDocument xDoc = new XmlDocument();
- string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\basicInformation.xml";
- if (System.IO.File.Exists(filePath))
- {
- xDoc.Load(filePath);
- }
- else
- {
- XmlDeclaration declaration = xDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
- xDoc.AppendChild(declaration);
- //根结点
- XmlElement genjiedian = xDoc.CreateElement("leixings");
- xDoc.AppendChild(genjiedian);
- //规程结点
- for (int i = 0; i < 6; i++)
- {
- XmlElement leixing = xDoc.CreateElement("類型");
- genjiedian.AppendChild(leixing);
- }
- xDoc.Save(filePath);
- }
- XmlNode rootNode = xDoc.SelectSingleNode("leixings");
- XmlNodeList leixingList = rootNode.ChildNodes;
- for (int i = 0; i < leixingList.Count; i++)
- {
- XmlNodeList leixingChild = leixingList[i].ChildNodes;
- List<string> strList = new List<string>();
- for (int j = 0; j < leixingChild.Count; j++)
- {
- string mingcheng = leixingChild[j].InnerText;
- strList.Add(mingcheng);
- }
- switch (i)
- {
- case 0:
- comboShiyongchangqu.DataSource = strList;
- break;
- case 1:
- comboShiyanshi.DataSource = strList;
- break;
- case 2:
- comboCengbie.DataSource = strList;
- break;
- case 3:
- comboZhichengbie.DataSource = strList;
- break;
- case 4:
- comboBanci.DataSource = strList;
- break;
- //case 5:
- // comboDianduxianbie.DataSource = strList;
- // break;
- }
- }
- }
- private void CreatHoleType()
- {
- _listHoleType.Add("100000", "Qianmangkong");
- _listHoleType.Add("100142", "ShuangcengbanYou");
- _listHoleType.Add("100134", "ShuangcengbanZuo");
- _listHoleType.Add("100150", "ShuangcengbanQuan");
- _listHoleType.Add("100103", "SancengbanYou");
- _listHoleType.Add("100093", "SancengbanZuo");
- _listHoleType.Add("100113", "SancengbanQuan");
- _listHoleType.Add("100078", "SicengbanYou");
- _listHoleType.Add("100066", "SicengbanZuo");
- _listHoleType.Add("100090", "SicengbanKongjing");
- _listHoleType.Add("100013", "DancengShenmangkong");
- _listHoleType.Add("100031", "ShuangcengShenmangkong");
- _listHoleType.Add("100167", "DancengShikeyinzi");
- _listHoleType.Add("100171", "ShuangcengShikeyinzi");
- _listHoleType.Add("100209", "Diegou");
- _listHoleType.Add("100198", "GaoduchaZuo");
- _listHoleType.Add("100201", "GaoduchaYou");
- _listHoleType.Add("100204", "GaoduchaQuan");
- _listHoleType.Add("100176", "FanghanMeikaikou");
- _listHoleType.Add("100183", "FanghanYoukaikou");
- _listHoleType.Add("100191", "FanghanShuangmiantong");
- _listHoleType.Add("100300", "Xigao");
- _listHoleType.Add("100305", "XigaoZ");
- }
- private void AutomaticMeasurement_Resize(object sender, EventArgs e)
- {
- panelOutInfo.Controls.Clear();
- OutInfoShow();
- }
- private void AutomaticMeasurement_Load(object sender, EventArgs e)
- {
- //comboMingcheng.SelectedIndex = 14;// 23;// 24;// 19;// 24;// 19;// 17;// 16;// 15;// 14;// 23;// 16;// 15;// 14;// 0;// 23;// 24;// 0;// 16;// 15;// 14;// 19;// 17;// 18;// 19;// 15;// 14;// 19;// 11;// 21;// 11;// 14;// 21;// 8;// 14;// 21;// 8;// 14;// 11;// 10;//通孔双层板(槽孔双层板) 12;
- }
- /// <summary>
- ///
- /// </summary>
- public void getList(Dictionary<int, GraphicsList> dataList,int index)
- {
- if (everyHoleImgGraphicsList.ContainsKey(index))
- {
- everyHoleImgGraphicsList[index].Clear();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- everyHoleImgGraphicsList[index].Add(dataList[i]);
- else
- everyHoleImgGraphicsList[index].Add(new GraphicsList());//避免空数据导致的后续bug: should never go here!
- }
- else {
- List<GraphicsList> list = new List<GraphicsList>();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- list.Add(dataList[i]);
- else
- list.Add(new GraphicsList());//避免空数据导致的后续bug: should never go here!
-
- everyHoleImgGraphicsList.Add(index, list);
- }
- }
- public void getBoolList(Dictionary<int, bool> dataList, int index)
- {
- if (everyHoleImgisConductive.ContainsKey(index))
- {
- everyHoleImgisConductive[index].Clear();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- everyHoleImgisConductive[index].Add(dataList[i]);
- else
- everyHoleImgisConductive[index].Add(false);//避免空数据导致的后续bug: should never go here!
- }
- else
- {
- List<bool> list = new List<bool>();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- list.Add(dataList[i]);
- else
- list.Add(false);//避免空数据导致的后续bug: should never go here!
- everyHoleImgisConductive.Add(index, list);
- }
- }
- public void getIsFanweibuchangList(Dictionary<int, bool> dataList, int index)
- {
- if (everyHoleImgisFanweibuchang.ContainsKey(index))
- {
- everyHoleImgisFanweibuchang[index].Clear();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- everyHoleImgisFanweibuchang[index].Add(dataList[i]);
- else
- everyHoleImgisFanweibuchang[index].Add(false);//避免空数据导致的后续bug: should never go here!
- }
- else
- {
- List<bool> list = new List<bool>();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- list.Add(dataList[i]);
- else
- list.Add(false);//避免空数据导致的后续bug: should never go here!
- everyHoleImgisFanweibuchang.Add(index, list);
- }
- }
- public void getIsErzhichuliList(Dictionary<int, bool> dataList, int index)
- {
- if (everyHoleImgisErzhichuli.ContainsKey(index))
- {
- everyHoleImgisErzhichuli[index].Clear();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- everyHoleImgisErzhichuli[index].Add(dataList[i]);
- else
- everyHoleImgisErzhichuli[index].Add(false);//避免空数据导致的后续bug: should never go here!
- }
- else
- {
- List<bool> list = new List<bool>();
- for (int i = 0; i < dataList.Keys.Count; i++)
- if (dataList.ContainsKey(i))
- list.Add(dataList[i]);
- else
- list.Add(false);//避免空数据导致的后续bug: should never go here!
- everyHoleImgisErzhichuli.Add(index, list);
- }
- }
- private void buttonCancelMeasurement_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void textDanhao_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
- {
- if (!Program.instance.configModel.autoDownload)
- {
- return;
- }
- string singleNumber = this.textDanhao.Text;
- string userName = Program.instance.configModel.UserName;
- string passWord = Program.instance.configModel.PassWord;
- string equId = Program.instance.configModel.EquId;
- string groupId = Program.instance.configModel.GroupId;
- string funId = Program.instance.configModel.FunId4;
- GetDataModel getDataModel = new GetDataModel();
- try
- {
- var result = webServiceDll.ws.getDataFromSer(userName, passWord, equId, groupId, funId, singleNumber, System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
- if (result.Tables.Count > 0)
- {
- if (result.Tables[0].Rows.Count > 0)
- {
- getDataModel.dianDu = result.Tables[0].Rows[0]["v_opendep"].ToString();
- getDataModel.liaoHao = result.Tables[0].Rows[0]["v_material"].ToString();
- getDataModel.piHao = result.Tables[0].Rows[0]["v_product_num"].ToString();
- }
- }
- }
- catch (Exception ex)
- {
- writeLog(ex.Message, "下拉接口错误");
- }
- textLiaohao.Text = getDataModel.liaoHao;
- textPihao.Text = getDataModel.piHao;
- comboDianduxianbie.Text = getDataModel.dianDu;
- }
- }
- private void writeLog(string error, string typeName = "")
- {
- string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\ErrorLog";
- if (!Directory.Exists(filePath))
- {
- Directory.CreateDirectory(filePath);
- }
- using (StreamWriter sw = new StreamWriter(filePath + "\\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + typeName + "log.txt"))
- {
- sw.WriteLine(error);
- }
- }
- }
- }
|