PorosityStandardDialog.cs 141 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222
  1. using Metis.DedicatedAnalysis.Porosity;
  2. using Metis.DedicatedAnalysis.Porosity.Model;
  3. using Metis.ParameterSet;
  4. using OpenCvSharp;
  5. using OpenCvSharp.Extensions;
  6. using PaintDotNet.Annotation;
  7. using PaintDotNet.Annotation.Enum;
  8. using PaintDotNet.Annotation.FieldView;
  9. using PaintDotNet.Annotation.Label;
  10. using PaintDotNet.Base;
  11. using PaintDotNet.Base.CommTool;
  12. using PaintDotNet.Base.DedicatedAnalysis.Porosity;
  13. using PaintDotNet.Base.DedicatedAnalysis.Porosity.Model;
  14. using PaintDotNet.Base.Functionodel;
  15. using PaintDotNet.Base.SettingModel;
  16. using PaintDotNet.Base.SettingModel.LVMModel;
  17. using PaintDotNet.CustomControl;
  18. using PaintDotNet.Data.Param;
  19. using PaintDotNet.DbOpreate.DbBll;
  20. using PaintDotNet.DbOpreate.DbModel;
  21. using PaintDotNet.Instrument;
  22. using System;
  23. using System.Collections.Generic;
  24. using System.ComponentModel;
  25. using System.Data;
  26. using System.Drawing;
  27. using System.Drawing.Drawing2D;
  28. using System.IO;
  29. using System.Linq;
  30. using System.Windows.Forms;
  31. using static PaintDotNet.Base.DedicatedAnalysis.Porosity.MethodOfAssessment;
  32. namespace PaintDotNet.DedicatedAnalysis.Porosity
  33. {
  34. internal class PorosityStandardDialog : PdnBaseForm
  35. {
  36. #region 属性
  37. #region 属性
  38. /// <summary>
  39. /// 主控件
  40. /// </summary>
  41. protected AppWorkspace appWorkspace;
  42. /// <summary>
  43. /// 公共按钮
  44. /// </summary>
  45. private CommonControlButtons commonControlButtons;
  46. /// <summary>
  47. /// 图像面板
  48. /// </summary>
  49. protected DocumentWorkspaceWindow documentWorkspace;
  50. //private Dictionary<int, DocumentItem> documentItems;
  51. /// <summary>
  52. /// 当前选择的图片
  53. /// </summary>
  54. protected Bitmap bitmap;
  55. /// <summary>
  56. /// 处理程序
  57. /// </summary>
  58. protected ParamObject action;
  59. protected Dictionary<int, DocumentItem> documentItems;
  60. /// <summary>
  61. /// 外部所有的相
  62. /// </summary>
  63. protected List<PhaseModel> originalPhaseModels = new List<PhaseModel>();
  64. /// <summary>
  65. /// 是否首次选中
  66. /// </summary>
  67. protected int firstChoose = 0;
  68. protected PorosityConfig porosityConfig;
  69. /// <summary>
  70. /// 初始系统参数配置值
  71. /// </summary>
  72. private BinaryExtractionModel binaryExtractionModel = new BinaryExtractionModel();
  73. private Dictionary<DocumentWorkspace, AnalysisResult> analysisResults = new Dictionary<DocumentWorkspace, AnalysisResult>();
  74. private Dictionary<string, List<PhaseModel>> dict = new Dictionary<string, List<PhaseModel>>();
  75. /// <summary>
  76. /// 选择的评定方法
  77. /// </summary>
  78. private MethodOfAssessment methodOfAssessment;
  79. protected AnalysisResult tempAnalysisResult;
  80. /// <summary>
  81. /// 视场
  82. /// </summary>
  83. private List<RectangleF> rectangleF = new List<RectangleF>();
  84. /// <summary>
  85. /// 视场类型
  86. /// </summary>
  87. private List<dynamic> rectangleTypeList = new List<dynamic>();
  88. /// <summary>
  89. /// 视场
  90. /// </summary>
  91. private List<ViewModel> modelList = new List<ViewModel>();
  92. /// <summary>
  93. /// 视场
  94. /// </summary>
  95. private List<DrawObject> oldDrawList = new List<DrawObject>();
  96. /// <summary>
  97. /// 选择的视场
  98. /// </summary>
  99. private int chooseIndex = -1;
  100. /// <summary>
  101. /// 选择高亮视场
  102. /// </summary>
  103. private int chooseGrIndex = -1;
  104. /// <summary>
  105. /// 名字集合
  106. /// </summary>
  107. private List<string> nameList = new List<string>();
  108. /// <summary>
  109. /// PointF集合
  110. /// </summary>
  111. private Dictionary<int, PointF[]> pointFDic = new Dictionary<int, PointF[]>();
  112. /// <summary>
  113. /// 需要删除的位置
  114. /// </summary>
  115. protected int delIndex = -1;
  116. protected double imgPxPerUnit;
  117. private int selectPicture = -1;
  118. private bool userAll = false;
  119. private List<AnalysisResult> resultList = new List<AnalysisResult>();
  120. private List<int> hasResultIndexList = new List<int>();
  121. private bool nodata = false;
  122. private bool isExportResults = false;
  123. private bool isExportReports = false;
  124. private bool isExportProjects = false;
  125. /// <summary>
  126. /// 是否脚本运行
  127. /// </summary>
  128. private Boolean initScriptValues = false;
  129. protected string argsKey;
  130. protected object argsValue;
  131. protected Dictionary<string, PorosityConfig> everyImgData = new Dictionary<string, PorosityConfig>();
  132. protected string ImgName;
  133. #endregion 属性
  134. #region 组件
  135. private GroupBox groupBox_operating;
  136. private GroupBox groupBox_img;
  137. protected ListView lstView_img;
  138. private ImageList imageList_img;
  139. private IContainer components;
  140. //private GroupBox groupBox_baseSetting;
  141. private ComboBox comboBox_rollingDirection;
  142. private Label label_lwRatioLimit;
  143. private Label label_rollingDirection;
  144. protected NumericUpDown numericUpDown_lwRatioLimit;
  145. //protected GroupBox groupBox_colorSetting;
  146. private Panel panel_colorGamut;
  147. private CustomControl.HistogramControl histogramControl_colorSetting;
  148. private Button button_colorAdjustmentBS;
  149. private Button button_colorAdjustmentGL;
  150. private Button button_colorAdjustmentRH;
  151. private NumericUpDown numericUpDown_colorAdjustmentBSD;
  152. private NumericUpDown numericUpDown_colorAdjustmentBSU;
  153. private Label label_colorAdjustmentBS;
  154. private NumericUpDown numericUpDown_colorAdjustmentGLD;
  155. private NumericUpDown numericUpDown_colorAdjustmentGLU;
  156. private Label label_colorAdjustmentGL;
  157. private NumericUpDown numericUpDown_colorAdjustmentRHD;
  158. private NumericUpDown numericUpDown_colorAdjustmentRHU;
  159. private Label label_colorAdjustmentRH;
  160. private RadioButton radioButton_checkedHLS;
  161. private RadioButton radioButton_checkedRGB;
  162. private GroupBox groupBox_review;
  163. private GroupBox groupBox_report;
  164. private Label label_resultPrecision;
  165. protected DomainUpDown domainUpDown_resultPrecision;
  166. private Button button_exportResults;
  167. private Button button_generateReport;
  168. private GroupBox groupBox6groupBox_analysisResult2;
  169. private ListView listView_analysisResult;
  170. private GroupBox groupBox_analysisResult1;
  171. private Button button_remove;
  172. private Button button_all;
  173. private CheckBox checkBox1;
  174. private CheckBox checkBox11;
  175. private CheckBox checkBox3_0;
  176. private CustomControl.HistogramControl histogramControl_binary;
  177. private CustomControl.DecimalScopeControl numberScopeControl_binary1;
  178. private CheckBox checkBox_showBinary;
  179. private Button button_autoThreshold;
  180. private Label label_colorGamut;
  181. private Button button_pickColor;
  182. private Label label_showBinaryColor;
  183. private Panel panel_showBinaryColor;
  184. private Panel panel_colorGamutPhase;
  185. private CheckBox checkBox_showColorGamutPhase;
  186. private ToolTip toolTip_InclusionsDetails;
  187. private ListView listView_analysisResult2;
  188. private Button button_setting;
  189. private CheckedListBox listBox_analysisResult;
  190. private CheckBox checkBox_generateReport_opensetting;
  191. private Button btn_saveresult;
  192. private int imgIndex = -1;
  193. private bool addView = true;
  194. /// <summary>
  195. /// 当前点击调色板
  196. /// </summary>
  197. private int currentPanel = 1;
  198. private Button button1;
  199. //二值化集成1
  200. private BinaryClass binaryClass;
  201. protected int menuId;
  202. protected string menuName;
  203. private BinaryControl bc;
  204. private Button button3;
  205. private ComboBox comboBox2;
  206. private Label label2;
  207. /// <summary>
  208. /// 参数下拉的集合
  209. /// </summary>
  210. private List<string> files = new List<string>();
  211. private viewSetting ViewSetting;
  212. private int offsetHalfW = 0;
  213. private Button button2;
  214. private int offsetHalfH = 0;
  215. protected PorosityModel porosityModel = new PorosityModel();
  216. protected PorosityModel.PorosityParameter thisParameters;
  217. private string dialogText;
  218. private Button button5;
  219. private Button button4;
  220. protected int thisParametersIndex = -1;
  221. #endregion 组件
  222. #endregion 属性
  223. #region 构造函数
  224. public PorosityStandardDialog()
  225. {
  226. //this.Icon = PdnInfo.AppIcon;
  227. InitializeComponent();
  228. }
  229. public PorosityStandardDialog(AppWorkspace appWorkspace, string dialogText, PdnMenuItem menuItem)
  230. {
  231. this.firstChoose = 0;
  232. this.appWorkspace = appWorkspace;
  233. this.Text = dialogText;
  234. this.Icon = PdnInfo.AppIcon;
  235. this.dialogText = dialogText;
  236. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  237. InitializeComponent();
  238. this.action = new Data.Action.Action901();
  239. InitializeCustomControl();
  240. InitializeLanguageText();
  241. Initialize();
  242. InitParameterList();
  243. getViewSetting();
  244. this.menuId = menuItem.MenuId;
  245. this.menuName = menuItem.Text;
  246. this.binaryClass = new BinaryClass(menuId);
  247. //二值化集成2
  248. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.binary.Text") }
  249. , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
  250. this.Shown += showImg;
  251. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  252. }
  253. private void showImg(object sender, EventArgs e)
  254. {
  255. lstView_img.Focus();
  256. if (this.imgIndex != -1)
  257. {
  258. //滚动到指定的行位置
  259. this.lstView_img.EnsureVisible(this.imgIndex);
  260. this.selectPicture = this.imgIndex;
  261. this.lstView_img.Items[imgIndex].Focused = true;
  262. this.lstView_img.Items[imgIndex].Selected = true;
  263. }
  264. //如果是脚本执行,将参数带入
  265. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  266. {
  267. this.initScriptValues = true;//ScriptAutomatic
  268. //Boolean initScriptValues = true;
  269. ////在这里反射出对应功能的参数类
  270. string className = InvariantData.path_Action + ".Action" + menuId;
  271. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  272. foreach (Args arg in param.Lists)
  273. {
  274. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  275. if (param1.value != null)
  276. arg.Value = param1.value;
  277. this.argsKey = arg.key;
  278. this.argsValue = arg.Value;
  279. getArgsValue();
  280. getValue(arg.key, arg.Value);
  281. }
  282. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  283. }
  284. else
  285. {//读取上次关闭窗口时保存的参数
  286. getLastData();
  287. }
  288. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  289. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  290. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  291. this.startScriptAutomaticAction();
  292. }
  293. /// <summary>
  294. /// 执行脚本自动化的步骤
  295. /// </summary>
  296. private void startScriptAutomaticAction()
  297. {
  298. this.button4.PerformClick();
  299. this.button5.PerformClick();
  300. if (isExportResults)//导出结果
  301. this.button_exportResults.PerformClick();
  302. if (isExportReports)//生成报告
  303. this.button_generateReport.PerformClick();
  304. if (isExportProjects)//导出项目
  305. this.button1.PerformClick();
  306. this.appWorkspace.ScriptAutomatic = false;
  307. this.Close();
  308. }
  309. #endregion 构造函数
  310. #region 初始化组件
  311. private void InitializeLanguageText()
  312. {
  313. this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
  314. this.button3.Text = PdnResources.GetString("Menu.ViewSetting.Text");
  315. this.label2.Text = PdnResources.GetString("Menu.view.text");
  316. this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  317. this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
  318. this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
  319. this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  320. this.comboBox_rollingDirection.Items.AddRange(new object[] {
  321. PdnResources.GetString("Menu.vertical.text"),
  322. PdnResources.GetString("Menu.Level.text")});
  323. this.label_lwRatioLimit.Text = PdnResources.GetString("Menu.lengthwidthratio.Text");
  324. this.label_rollingDirection.Text = PdnResources.GetString("Menu.Rollingdirection.text");
  325. this.checkBox_showColorGamutPhase.Text = PdnResources.GetString("Menu.Matchthecoloreffect.text");
  326. this.button_pickColor.Text = PdnResources.GetString("Menu.Pickcolor.text");
  327. this.label_colorGamut.Text = PdnResources.GetString("Menu.Colorinterval.text");
  328. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  329. this.button1.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
  330. this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  331. this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
  332. this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  333. this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
  334. this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  335. this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
  336. this.label_showBinaryColor.Text = PdnResources.GetString("Menu.BinaryColor.text");
  337. this.checkBox_showBinary.Text = PdnResources.GetString("Menu.Displaysthebinaryeffect.text");
  338. this.button_autoThreshold.Text = PdnResources.GetString("Menu.Automaticthreshold.text");
  339. }
  340. private void InitializeCustomControl()
  341. {
  342. //
  343. // bc
  344. //
  345. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  346. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  347. this.bc.BinaryChecked = false;
  348. this.bc.BinaryStyle = 1;
  349. this.bc.Location = new System.Drawing.Point(178, 72);
  350. this.bc.Name = "bc";
  351. this.bc.OriginChecked = false;
  352. this.bc.scope1End = 0D;
  353. this.bc.scope1Start = 0D;
  354. this.bc.scope2End = 0D;
  355. this.bc.scope2Start = 0D;
  356. this.bc.scope3End = 0D;
  357. this.bc.scope3Start = 0D;
  358. this.bc.Size = new System.Drawing.Size(360, 292);
  359. this.bc.TabIndex = 5;
  360. this.Controls.Add(this.bc);
  361. this.Controls.SetChildIndex(this.bc, 0);
  362. }
  363. private void InitializeComponent()
  364. {
  365. this.components = new System.ComponentModel.Container();
  366. this.groupBox_operating = new System.Windows.Forms.GroupBox();
  367. this.button5 = new System.Windows.Forms.Button();
  368. this.button4 = new System.Windows.Forms.Button();
  369. this.button2 = new System.Windows.Forms.Button();
  370. this.button3 = new System.Windows.Forms.Button();
  371. this.comboBox2 = new System.Windows.Forms.ComboBox();
  372. this.label2 = new System.Windows.Forms.Label();
  373. this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
  374. this.button_setting = new System.Windows.Forms.Button();
  375. this.btn_saveresult = new System.Windows.Forms.Button();
  376. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  377. this.groupBox_img = new System.Windows.Forms.GroupBox();
  378. this.lstView_img = new System.Windows.Forms.ListView();
  379. this.imageList_img = new System.Windows.Forms.ImageList(this.components);
  380. this.comboBox_rollingDirection = new System.Windows.Forms.ComboBox();
  381. this.label_lwRatioLimit = new System.Windows.Forms.Label();
  382. this.label_rollingDirection = new System.Windows.Forms.Label();
  383. this.numericUpDown_lwRatioLimit = new System.Windows.Forms.NumericUpDown();
  384. this.checkBox_showColorGamutPhase = new System.Windows.Forms.CheckBox();
  385. this.panel_colorGamutPhase = new System.Windows.Forms.Panel();
  386. this.button_pickColor = new System.Windows.Forms.Button();
  387. this.label_colorGamut = new System.Windows.Forms.Label();
  388. this.panel_colorGamut = new System.Windows.Forms.Panel();
  389. this.histogramControl_colorSetting = new PaintDotNet.CustomControl.HistogramControl();
  390. this.button_colorAdjustmentBS = new System.Windows.Forms.Button();
  391. this.button_colorAdjustmentGL = new System.Windows.Forms.Button();
  392. this.button_colorAdjustmentRH = new System.Windows.Forms.Button();
  393. this.numericUpDown_colorAdjustmentBSD = new System.Windows.Forms.NumericUpDown();
  394. this.numericUpDown_colorAdjustmentBSU = new System.Windows.Forms.NumericUpDown();
  395. this.label_colorAdjustmentBS = new System.Windows.Forms.Label();
  396. this.numericUpDown_colorAdjustmentGLD = new System.Windows.Forms.NumericUpDown();
  397. this.numericUpDown_colorAdjustmentGLU = new System.Windows.Forms.NumericUpDown();
  398. this.label_colorAdjustmentGL = new System.Windows.Forms.Label();
  399. this.numericUpDown_colorAdjustmentRHD = new System.Windows.Forms.NumericUpDown();
  400. this.numericUpDown_colorAdjustmentRHU = new System.Windows.Forms.NumericUpDown();
  401. this.label_colorAdjustmentRH = new System.Windows.Forms.Label();
  402. this.radioButton_checkedHLS = new System.Windows.Forms.RadioButton();
  403. this.radioButton_checkedRGB = new System.Windows.Forms.RadioButton();
  404. this.groupBox_review = new System.Windows.Forms.GroupBox();
  405. this.groupBox_report = new System.Windows.Forms.GroupBox();
  406. this.button1 = new System.Windows.Forms.Button();
  407. this.label_resultPrecision = new System.Windows.Forms.Label();
  408. this.domainUpDown_resultPrecision = new System.Windows.Forms.DomainUpDown();
  409. this.button_exportResults = new System.Windows.Forms.Button();
  410. this.button_generateReport = new System.Windows.Forms.Button();
  411. this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
  412. this.listView_analysisResult2 = new System.Windows.Forms.ListView();
  413. this.listView_analysisResult = new System.Windows.Forms.ListView();
  414. this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
  415. this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
  416. this.button_remove = new System.Windows.Forms.Button();
  417. this.button_all = new System.Windows.Forms.Button();
  418. this.panel_showBinaryColor = new System.Windows.Forms.Panel();
  419. this.label_showBinaryColor = new System.Windows.Forms.Label();
  420. this.histogramControl_binary = new PaintDotNet.CustomControl.HistogramControl();
  421. this.numberScopeControl_binary1 = new PaintDotNet.CustomControl.DecimalScopeControl();
  422. this.checkBox_showBinary = new System.Windows.Forms.CheckBox();
  423. this.button_autoThreshold = new System.Windows.Forms.Button();
  424. this.toolTip_InclusionsDetails = new System.Windows.Forms.ToolTip(this.components);
  425. this.groupBox_operating.SuspendLayout();
  426. this.groupBox_img.SuspendLayout();
  427. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_lwRatioLimit)).BeginInit();
  428. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentBSD)).BeginInit();
  429. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentBSU)).BeginInit();
  430. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentGLD)).BeginInit();
  431. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentGLU)).BeginInit();
  432. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentRHD)).BeginInit();
  433. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentRHU)).BeginInit();
  434. this.groupBox_report.SuspendLayout();
  435. this.groupBox6groupBox_analysisResult2.SuspendLayout();
  436. this.groupBox_analysisResult1.SuspendLayout();
  437. this.SuspendLayout();
  438. //
  439. // groupBox_operating
  440. //
  441. this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  442. | System.Windows.Forms.AnchorStyles.Right)));
  443. this.groupBox_operating.Controls.Add(this.button5);
  444. this.groupBox_operating.Controls.Add(this.button4);
  445. this.groupBox_operating.Controls.Add(this.button2);
  446. this.groupBox_operating.Controls.Add(this.button3);
  447. this.groupBox_operating.Controls.Add(this.comboBox2);
  448. this.groupBox_operating.Controls.Add(this.label2);
  449. this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
  450. this.groupBox_operating.Controls.Add(this.button_setting);
  451. this.groupBox_operating.Controls.Add(this.btn_saveresult);
  452. this.groupBox_operating.Location = new System.Drawing.Point(13, 12);
  453. this.groupBox_operating.Name = "groupBox_operating";
  454. this.groupBox_operating.Size = new System.Drawing.Size(1152, 53);
  455. this.groupBox_operating.TabIndex = 12;
  456. this.groupBox_operating.TabStop = false;
  457. //
  458. // button5
  459. //
  460. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  461. this.button5.Location = new System.Drawing.Point(910, 19);
  462. this.button5.Name = "button5";
  463. this.button5.Size = new System.Drawing.Size(75, 23);
  464. this.button5.TabIndex = 46;
  465. this.button5.Text = "保存全部";
  466. this.button5.UseVisualStyleBackColor = true;
  467. this.button5.Click += new System.EventHandler(this.button5_Click);
  468. //
  469. // button4
  470. //
  471. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  472. this.button4.Location = new System.Drawing.Point(829, 19);
  473. this.button4.Name = "button4";
  474. this.button4.Size = new System.Drawing.Size(75, 23);
  475. this.button4.TabIndex = 45;
  476. this.button4.Text = "应用全部";
  477. this.button4.UseVisualStyleBackColor = true;
  478. this.button4.Click += new System.EventHandler(this.button4_Click);
  479. //
  480. // button2
  481. //
  482. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  483. this.button2.Location = new System.Drawing.Point(727, 20);
  484. this.button2.Name = "button2";
  485. this.button2.Size = new System.Drawing.Size(96, 23);
  486. this.button2.TabIndex = 44;
  487. this.button2.Text = "添加视场";
  488. this.button2.UseVisualStyleBackColor = true;
  489. this.button2.Click += new System.EventHandler(this.button2_Click);
  490. //
  491. // button3
  492. //
  493. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  494. this.button3.Location = new System.Drawing.Point(991, 19);
  495. this.button3.Name = "button3";
  496. this.button3.Size = new System.Drawing.Size(75, 23);
  497. this.button3.TabIndex = 43;
  498. this.button3.UseVisualStyleBackColor = true;
  499. this.button3.Click += new System.EventHandler(this.button3_Click);
  500. //
  501. // comboBox2
  502. //
  503. this.comboBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  504. this.comboBox2.FormattingEnabled = true;
  505. this.comboBox2.Location = new System.Drawing.Point(550, 21);
  506. this.comboBox2.Name = "comboBox2";
  507. this.comboBox2.Size = new System.Drawing.Size(171, 20);
  508. this.comboBox2.TabIndex = 42;
  509. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  510. //
  511. // label2
  512. //
  513. this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  514. this.label2.AutoSize = true;
  515. this.label2.Location = new System.Drawing.Point(660, 25);
  516. this.label2.Name = "label2";
  517. this.label2.Size = new System.Drawing.Size(0, 12);
  518. this.label2.TabIndex = 41;
  519. //
  520. // checkBox_generateReport_opensetting
  521. //
  522. this.checkBox_generateReport_opensetting.AutoSize = true;
  523. this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  524. this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
  525. this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
  526. this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(15, 14);
  527. this.checkBox_generateReport_opensetting.TabIndex = 6;
  528. this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
  529. //
  530. // button_setting
  531. //
  532. this.button_setting.Location = new System.Drawing.Point(6, 20);
  533. this.button_setting.Name = "button_setting";
  534. this.button_setting.Size = new System.Drawing.Size(75, 23);
  535. this.button_setting.TabIndex = 4;
  536. this.button_setting.UseVisualStyleBackColor = true;
  537. this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
  538. //
  539. // btn_saveresult
  540. //
  541. this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  542. this.btn_saveresult.Location = new System.Drawing.Point(1072, 20);
  543. this.btn_saveresult.Name = "btn_saveresult";
  544. this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
  545. this.btn_saveresult.TabIndex = 2;
  546. this.btn_saveresult.UseVisualStyleBackColor = true;
  547. this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
  548. //
  549. // checkBox3_0
  550. //
  551. this.checkBox3_0.Location = new System.Drawing.Point(0, 0);
  552. this.checkBox3_0.Name = "checkBox3_0";
  553. this.checkBox3_0.Size = new System.Drawing.Size(104, 24);
  554. this.checkBox3_0.TabIndex = 0;
  555. //
  556. // groupBox_img
  557. //
  558. this.groupBox_img.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  559. | System.Windows.Forms.AnchorStyles.Left)));
  560. this.groupBox_img.Controls.Add(this.lstView_img);
  561. this.groupBox_img.Location = new System.Drawing.Point(13, 72);
  562. this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
  563. this.groupBox_img.Name = "groupBox_img";
  564. this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
  565. this.groupBox_img.Size = new System.Drawing.Size(158, 483);
  566. this.groupBox_img.TabIndex = 13;
  567. this.groupBox_img.TabStop = false;
  568. //
  569. // lstView_img
  570. //
  571. this.lstView_img.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  572. | System.Windows.Forms.AnchorStyles.Left)
  573. | System.Windows.Forms.AnchorStyles.Right)));
  574. this.lstView_img.HideSelection = false;
  575. this.lstView_img.LargeImageList = this.imageList_img;
  576. this.lstView_img.Location = new System.Drawing.Point(8, 26);
  577. this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
  578. this.lstView_img.MultiSelect = false;
  579. this.lstView_img.Name = "lstView_img";
  580. this.lstView_img.Size = new System.Drawing.Size(140, 449);
  581. this.lstView_img.TabIndex = 0;
  582. this.lstView_img.UseCompatibleStateImageBehavior = false;
  583. this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  584. this.lstView_img.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lstView_img_MouseUp);
  585. //
  586. // imageList_img
  587. //
  588. this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  589. this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
  590. this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
  591. //
  592. // comboBox_rollingDirection
  593. //
  594. this.comboBox_rollingDirection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  595. this.comboBox_rollingDirection.FormattingEnabled = true;
  596. this.comboBox_rollingDirection.Location = new System.Drawing.Point(87, 23);
  597. this.comboBox_rollingDirection.Name = "comboBox_rollingDirection";
  598. this.comboBox_rollingDirection.Size = new System.Drawing.Size(56, 20);
  599. this.comboBox_rollingDirection.TabIndex = 3;
  600. //
  601. // label_lwRatioLimit
  602. //
  603. this.label_lwRatioLimit.AutoSize = true;
  604. this.label_lwRatioLimit.Location = new System.Drawing.Point(192, 26);
  605. this.label_lwRatioLimit.Name = "label_lwRatioLimit";
  606. this.label_lwRatioLimit.Size = new System.Drawing.Size(65, 12);
  607. this.label_lwRatioLimit.TabIndex = 7;
  608. //
  609. // label_rollingDirection
  610. //
  611. this.label_rollingDirection.AutoSize = true;
  612. this.label_rollingDirection.Location = new System.Drawing.Point(10, 26);
  613. this.label_rollingDirection.Name = "label_rollingDirection";
  614. this.label_rollingDirection.Size = new System.Drawing.Size(53, 12);
  615. this.label_rollingDirection.TabIndex = 8;
  616. //
  617. // numericUpDown_lwRatioLimit
  618. //
  619. this.numericUpDown_lwRatioLimit.DecimalPlaces = 2;
  620. this.numericUpDown_lwRatioLimit.Location = new System.Drawing.Point(263, 24);
  621. this.numericUpDown_lwRatioLimit.Maximum = new decimal(new int[] {
  622. 10,
  623. 0,
  624. 0,
  625. 0});
  626. this.numericUpDown_lwRatioLimit.Minimum = new decimal(new int[] {
  627. 1,
  628. 0,
  629. 0,
  630. 0});
  631. this.numericUpDown_lwRatioLimit.Name = "numericUpDown_lwRatioLimit";
  632. this.numericUpDown_lwRatioLimit.Size = new System.Drawing.Size(56, 21);
  633. this.numericUpDown_lwRatioLimit.TabIndex = 5;
  634. this.numericUpDown_lwRatioLimit.Value = new decimal(new int[] {
  635. 3,
  636. 0,
  637. 0,
  638. 0});
  639. //
  640. // checkBox_showColorGamutPhase
  641. //
  642. this.checkBox_showColorGamutPhase.AutoSize = true;
  643. this.checkBox_showColorGamutPhase.Location = new System.Drawing.Point(225, 49);
  644. this.checkBox_showColorGamutPhase.Name = "checkBox_showColorGamutPhase";
  645. this.checkBox_showColorGamutPhase.Size = new System.Drawing.Size(96, 16);
  646. this.checkBox_showColorGamutPhase.TabIndex = 41;
  647. this.checkBox_showColorGamutPhase.UseVisualStyleBackColor = true;
  648. //
  649. // panel_colorGamutPhase
  650. //
  651. this.panel_colorGamutPhase.BackColor = System.Drawing.Color.Lime;
  652. this.panel_colorGamutPhase.Location = new System.Drawing.Point(325, 49);
  653. this.panel_colorGamutPhase.Name = "panel_colorGamutPhase";
  654. this.panel_colorGamutPhase.Size = new System.Drawing.Size(69, 17);
  655. this.panel_colorGamutPhase.TabIndex = 40;
  656. //
  657. // button_pickColor
  658. //
  659. this.button_pickColor.Location = new System.Drawing.Point(352, 20);
  660. this.button_pickColor.Name = "button_pickColor";
  661. this.button_pickColor.Size = new System.Drawing.Size(48, 23);
  662. this.button_pickColor.TabIndex = 36;
  663. this.button_pickColor.UseVisualStyleBackColor = true;
  664. //
  665. // label_colorGamut
  666. //
  667. this.label_colorGamut.AutoSize = true;
  668. this.label_colorGamut.Location = new System.Drawing.Point(5, 51);
  669. this.label_colorGamut.Name = "label_colorGamut";
  670. this.label_colorGamut.Size = new System.Drawing.Size(53, 12);
  671. this.label_colorGamut.TabIndex = 35;
  672. //
  673. // panel_colorGamut
  674. //
  675. this.panel_colorGamut.Location = new System.Drawing.Point(64, 47);
  676. this.panel_colorGamut.Name = "panel_colorGamut";
  677. this.panel_colorGamut.Size = new System.Drawing.Size(130, 17);
  678. this.panel_colorGamut.TabIndex = 34;
  679. //
  680. // histogramControl_colorSetting
  681. //
  682. this.histogramControl_colorSetting.Flag = 1;
  683. this.histogramControl_colorSetting.Location = new System.Drawing.Point(6, 21);
  684. this.histogramControl_colorSetting.Name = "histogramControl_colorSetting";
  685. this.histogramControl_colorSetting.Size = new System.Drawing.Size(188, 114);
  686. this.histogramControl_colorSetting.TabIndex = 0;
  687. //
  688. // button_colorAdjustmentBS
  689. //
  690. this.button_colorAdjustmentBS.Location = new System.Drawing.Point(134, 99);
  691. this.button_colorAdjustmentBS.Name = "button_colorAdjustmentBS";
  692. this.button_colorAdjustmentBS.Size = new System.Drawing.Size(34, 21);
  693. this.button_colorAdjustmentBS.TabIndex = 34;
  694. this.button_colorAdjustmentBS.Text = "B";
  695. this.button_colorAdjustmentBS.UseVisualStyleBackColor = true;
  696. //
  697. // button_colorAdjustmentGL
  698. //
  699. this.button_colorAdjustmentGL.Location = new System.Drawing.Point(134, 72);
  700. this.button_colorAdjustmentGL.Name = "button_colorAdjustmentGL";
  701. this.button_colorAdjustmentGL.Size = new System.Drawing.Size(34, 21);
  702. this.button_colorAdjustmentGL.TabIndex = 33;
  703. this.button_colorAdjustmentGL.Text = "G";
  704. this.button_colorAdjustmentGL.UseVisualStyleBackColor = true;
  705. //
  706. // button_colorAdjustmentRH
  707. //
  708. this.button_colorAdjustmentRH.BackColor = System.Drawing.SystemColors.Control;
  709. this.button_colorAdjustmentRH.Location = new System.Drawing.Point(134, 45);
  710. this.button_colorAdjustmentRH.Margin = new System.Windows.Forms.Padding(0);
  711. this.button_colorAdjustmentRH.Name = "button_colorAdjustmentRH";
  712. this.button_colorAdjustmentRH.Size = new System.Drawing.Size(34, 21);
  713. this.button_colorAdjustmentRH.TabIndex = 32;
  714. this.button_colorAdjustmentRH.Text = "R";
  715. this.button_colorAdjustmentRH.UseVisualStyleBackColor = true;
  716. //
  717. // numericUpDown_colorAdjustmentBSD
  718. //
  719. this.numericUpDown_colorAdjustmentBSD.Location = new System.Drawing.Point(82, 99);
  720. this.numericUpDown_colorAdjustmentBSD.Maximum = new decimal(new int[] {
  721. 255,
  722. 0,
  723. 0,
  724. 0});
  725. this.numericUpDown_colorAdjustmentBSD.Name = "numericUpDown_colorAdjustmentBSD";
  726. this.numericUpDown_colorAdjustmentBSD.Size = new System.Drawing.Size(40, 21);
  727. this.numericUpDown_colorAdjustmentBSD.TabIndex = 30;
  728. this.numericUpDown_colorAdjustmentBSD.Tag = "max";
  729. //
  730. // numericUpDown_colorAdjustmentBSU
  731. //
  732. this.numericUpDown_colorAdjustmentBSU.Location = new System.Drawing.Point(37, 99);
  733. this.numericUpDown_colorAdjustmentBSU.Maximum = new decimal(new int[] {
  734. 255,
  735. 0,
  736. 0,
  737. 0});
  738. this.numericUpDown_colorAdjustmentBSU.Name = "numericUpDown_colorAdjustmentBSU";
  739. this.numericUpDown_colorAdjustmentBSU.Size = new System.Drawing.Size(40, 21);
  740. this.numericUpDown_colorAdjustmentBSU.TabIndex = 29;
  741. this.numericUpDown_colorAdjustmentBSU.Tag = "min";
  742. //
  743. // label_colorAdjustmentBS
  744. //
  745. this.label_colorAdjustmentBS.AutoSize = true;
  746. this.label_colorAdjustmentBS.Location = new System.Drawing.Point(10, 103);
  747. this.label_colorAdjustmentBS.Name = "label_colorAdjustmentBS";
  748. this.label_colorAdjustmentBS.Size = new System.Drawing.Size(23, 12);
  749. this.label_colorAdjustmentBS.TabIndex = 31;
  750. this.label_colorAdjustmentBS.Text = "B:";
  751. //
  752. // numericUpDown_colorAdjustmentGLD
  753. //
  754. this.numericUpDown_colorAdjustmentGLD.Location = new System.Drawing.Point(82, 72);
  755. this.numericUpDown_colorAdjustmentGLD.Maximum = new decimal(new int[] {
  756. 255,
  757. 0,
  758. 0,
  759. 0});
  760. this.numericUpDown_colorAdjustmentGLD.Name = "numericUpDown_colorAdjustmentGLD";
  761. this.numericUpDown_colorAdjustmentGLD.Size = new System.Drawing.Size(40, 21);
  762. this.numericUpDown_colorAdjustmentGLD.TabIndex = 27;
  763. this.numericUpDown_colorAdjustmentGLD.Tag = "max";
  764. //
  765. // numericUpDown_colorAdjustmentGLU
  766. //
  767. this.numericUpDown_colorAdjustmentGLU.Location = new System.Drawing.Point(37, 72);
  768. this.numericUpDown_colorAdjustmentGLU.Maximum = new decimal(new int[] {
  769. 255,
  770. 0,
  771. 0,
  772. 0});
  773. this.numericUpDown_colorAdjustmentGLU.Name = "numericUpDown_colorAdjustmentGLU";
  774. this.numericUpDown_colorAdjustmentGLU.Size = new System.Drawing.Size(40, 21);
  775. this.numericUpDown_colorAdjustmentGLU.TabIndex = 26;
  776. this.numericUpDown_colorAdjustmentGLU.Tag = "min";
  777. //
  778. // label_colorAdjustmentGL
  779. //
  780. this.label_colorAdjustmentGL.AutoSize = true;
  781. this.label_colorAdjustmentGL.Location = new System.Drawing.Point(10, 76);
  782. this.label_colorAdjustmentGL.Name = "label_colorAdjustmentGL";
  783. this.label_colorAdjustmentGL.Size = new System.Drawing.Size(23, 12);
  784. this.label_colorAdjustmentGL.TabIndex = 28;
  785. this.label_colorAdjustmentGL.Text = "G:";
  786. //
  787. // numericUpDown_colorAdjustmentRHD
  788. //
  789. this.numericUpDown_colorAdjustmentRHD.Location = new System.Drawing.Point(82, 45);
  790. this.numericUpDown_colorAdjustmentRHD.Maximum = new decimal(new int[] {
  791. 255,
  792. 0,
  793. 0,
  794. 0});
  795. this.numericUpDown_colorAdjustmentRHD.Name = "numericUpDown_colorAdjustmentRHD";
  796. this.numericUpDown_colorAdjustmentRHD.Size = new System.Drawing.Size(40, 21);
  797. this.numericUpDown_colorAdjustmentRHD.TabIndex = 8;
  798. this.numericUpDown_colorAdjustmentRHD.Tag = "max";
  799. //
  800. // numericUpDown_colorAdjustmentRHU
  801. //
  802. this.numericUpDown_colorAdjustmentRHU.Location = new System.Drawing.Point(37, 45);
  803. this.numericUpDown_colorAdjustmentRHU.Maximum = new decimal(new int[] {
  804. 255,
  805. 0,
  806. 0,
  807. 0});
  808. this.numericUpDown_colorAdjustmentRHU.Name = "numericUpDown_colorAdjustmentRHU";
  809. this.numericUpDown_colorAdjustmentRHU.Size = new System.Drawing.Size(40, 21);
  810. this.numericUpDown_colorAdjustmentRHU.TabIndex = 7;
  811. this.numericUpDown_colorAdjustmentRHU.Tag = "min";
  812. //
  813. // label_colorAdjustmentRH
  814. //
  815. this.label_colorAdjustmentRH.AutoSize = true;
  816. this.label_colorAdjustmentRH.Location = new System.Drawing.Point(10, 49);
  817. this.label_colorAdjustmentRH.Name = "label_colorAdjustmentRH";
  818. this.label_colorAdjustmentRH.Size = new System.Drawing.Size(23, 12);
  819. this.label_colorAdjustmentRH.TabIndex = 25;
  820. this.label_colorAdjustmentRH.Text = "R:";
  821. //
  822. // radioButton_checkedHLS
  823. //
  824. this.radioButton_checkedHLS.AutoSize = true;
  825. this.radioButton_checkedHLS.Location = new System.Drawing.Point(66, 20);
  826. this.radioButton_checkedHLS.Name = "radioButton_checkedHLS";
  827. this.radioButton_checkedHLS.Size = new System.Drawing.Size(41, 16);
  828. this.radioButton_checkedHLS.TabIndex = 4;
  829. this.radioButton_checkedHLS.Text = "HLS";
  830. this.radioButton_checkedHLS.UseVisualStyleBackColor = true;
  831. this.radioButton_checkedHLS.Visible = false;
  832. //
  833. // radioButton_checkedRGB
  834. //
  835. this.radioButton_checkedRGB.AutoSize = true;
  836. this.radioButton_checkedRGB.Checked = true;
  837. this.radioButton_checkedRGB.Location = new System.Drawing.Point(7, 20);
  838. this.radioButton_checkedRGB.Name = "radioButton_checkedRGB";
  839. this.radioButton_checkedRGB.Size = new System.Drawing.Size(41, 16);
  840. this.radioButton_checkedRGB.TabIndex = 3;
  841. this.radioButton_checkedRGB.TabStop = true;
  842. this.radioButton_checkedRGB.Text = "RGB";
  843. this.radioButton_checkedRGB.UseVisualStyleBackColor = true;
  844. //
  845. // groupBox_review
  846. //
  847. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  848. | System.Windows.Forms.AnchorStyles.Left)
  849. | System.Windows.Forms.AnchorStyles.Right)));
  850. this.groupBox_review.Location = new System.Drawing.Point(540, 72);
  851. this.groupBox_review.Name = "groupBox_review";
  852. this.groupBox_review.Size = new System.Drawing.Size(626, 483);
  853. this.groupBox_review.TabIndex = 30;
  854. this.groupBox_review.TabStop = false;
  855. //
  856. // groupBox_report
  857. //
  858. this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  859. this.groupBox_report.Controls.Add(this.button1);
  860. this.groupBox_report.Controls.Add(this.label_resultPrecision);
  861. this.groupBox_report.Controls.Add(this.domainUpDown_resultPrecision);
  862. this.groupBox_report.Controls.Add(this.button_exportResults);
  863. this.groupBox_report.Controls.Add(this.button_generateReport);
  864. this.groupBox_report.Location = new System.Drawing.Point(1024, 561);
  865. this.groupBox_report.Name = "groupBox_report";
  866. this.groupBox_report.Size = new System.Drawing.Size(142, 188);
  867. this.groupBox_report.TabIndex = 33;
  868. this.groupBox_report.TabStop = false;
  869. //
  870. // button1
  871. //
  872. this.button1.Location = new System.Drawing.Point(29, 101);
  873. this.button1.Name = "button1";
  874. this.button1.Size = new System.Drawing.Size(75, 23);
  875. this.button1.TabIndex = 4;
  876. this.button1.UseVisualStyleBackColor = true;
  877. this.button1.Click += new System.EventHandler(this.button1_Click);
  878. //
  879. // label_resultPrecision
  880. //
  881. this.label_resultPrecision.AutoSize = true;
  882. this.label_resultPrecision.Location = new System.Drawing.Point(22, 147);
  883. this.label_resultPrecision.Name = "label_resultPrecision";
  884. this.label_resultPrecision.Size = new System.Drawing.Size(0, 12);
  885. this.label_resultPrecision.TabIndex = 3;
  886. //
  887. // domainUpDown_resultPrecision
  888. //
  889. this.domainUpDown_resultPrecision.Location = new System.Drawing.Point(63, 145);
  890. this.domainUpDown_resultPrecision.Name = "domainUpDown_resultPrecision";
  891. this.domainUpDown_resultPrecision.Size = new System.Drawing.Size(41, 21);
  892. this.domainUpDown_resultPrecision.TabIndex = 2;
  893. this.domainUpDown_resultPrecision.Text = "2";
  894. this.domainUpDown_resultPrecision.SelectedItemChanged += new System.EventHandler(this.domainUpDown_resultPrecision_SelectedItemChanged);
  895. //
  896. // button_exportResults
  897. //
  898. this.button_exportResults.Location = new System.Drawing.Point(29, 62);
  899. this.button_exportResults.Name = "button_exportResults";
  900. this.button_exportResults.Size = new System.Drawing.Size(75, 23);
  901. this.button_exportResults.TabIndex = 1;
  902. this.button_exportResults.UseVisualStyleBackColor = true;
  903. this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
  904. //
  905. // button_generateReport
  906. //
  907. this.button_generateReport.Location = new System.Drawing.Point(29, 24);
  908. this.button_generateReport.Name = "button_generateReport";
  909. this.button_generateReport.Size = new System.Drawing.Size(75, 23);
  910. this.button_generateReport.TabIndex = 0;
  911. this.button_generateReport.UseVisualStyleBackColor = true;
  912. this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
  913. //
  914. // groupBox6groupBox_analysisResult2
  915. //
  916. this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  917. | System.Windows.Forms.AnchorStyles.Right)));
  918. this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult2);
  919. this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult);
  920. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 561);
  921. this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
  922. this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(769, 188);
  923. this.groupBox6groupBox_analysisResult2.TabIndex = 32;
  924. this.groupBox6groupBox_analysisResult2.TabStop = false;
  925. //
  926. // listView_analysisResult2
  927. //
  928. this.listView_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  929. | System.Windows.Forms.AnchorStyles.Right)));
  930. this.listView_analysisResult2.FullRowSelect = true;
  931. this.listView_analysisResult2.GridLines = true;
  932. this.listView_analysisResult2.HideSelection = false;
  933. this.listView_analysisResult2.Location = new System.Drawing.Point(6, 114);
  934. this.listView_analysisResult2.MultiSelect = false;
  935. this.listView_analysisResult2.Name = "listView_analysisResult2";
  936. this.listView_analysisResult2.Size = new System.Drawing.Size(757, 63);
  937. this.listView_analysisResult2.TabIndex = 2;
  938. this.listView_analysisResult2.UseCompatibleStateImageBehavior = false;
  939. //
  940. // listView_analysisResult
  941. //
  942. this.listView_analysisResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  943. | System.Windows.Forms.AnchorStyles.Right)));
  944. this.listView_analysisResult.FullRowSelect = true;
  945. this.listView_analysisResult.GridLines = true;
  946. this.listView_analysisResult.HideSelection = false;
  947. this.listView_analysisResult.Location = new System.Drawing.Point(6, 20);
  948. this.listView_analysisResult.MultiSelect = false;
  949. this.listView_analysisResult.Name = "listView_analysisResult";
  950. this.listView_analysisResult.ShowItemToolTips = true;
  951. this.listView_analysisResult.Size = new System.Drawing.Size(757, 88);
  952. this.listView_analysisResult.TabIndex = 2;
  953. this.listView_analysisResult.UseCompatibleStateImageBehavior = false;
  954. //
  955. // groupBox_analysisResult1
  956. //
  957. this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  958. this.groupBox_analysisResult1.Controls.Add(this.listBox_analysisResult);
  959. this.groupBox_analysisResult1.Controls.Add(this.button_remove);
  960. this.groupBox_analysisResult1.Controls.Add(this.button_all);
  961. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 561);
  962. this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
  963. this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 188);
  964. this.groupBox_analysisResult1.TabIndex = 31;
  965. this.groupBox_analysisResult1.TabStop = false;
  966. //
  967. // listBox_analysisResult
  968. //
  969. this.listBox_analysisResult.CheckOnClick = true;
  970. this.listBox_analysisResult.FormattingEnabled = true;
  971. this.listBox_analysisResult.HorizontalScrollbar = true;
  972. this.listBox_analysisResult.Location = new System.Drawing.Point(6, 53);
  973. this.listBox_analysisResult.Name = "listBox_analysisResult";
  974. this.listBox_analysisResult.Size = new System.Drawing.Size(199, 132);
  975. this.listBox_analysisResult.TabIndex = 0;
  976. this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
  977. //
  978. // button_remove
  979. //
  980. this.button_remove.Location = new System.Drawing.Point(130, 24);
  981. this.button_remove.Name = "button_remove";
  982. this.button_remove.Size = new System.Drawing.Size(75, 23);
  983. this.button_remove.TabIndex = 8;
  984. this.button_remove.UseVisualStyleBackColor = true;
  985. this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
  986. //
  987. // button_all
  988. //
  989. this.button_all.Location = new System.Drawing.Point(14, 24);
  990. this.button_all.Name = "button_all";
  991. this.button_all.Size = new System.Drawing.Size(75, 23);
  992. this.button_all.TabIndex = 1;
  993. this.button_all.UseVisualStyleBackColor = true;
  994. this.button_all.Click += new System.EventHandler(this.button_all_Click);
  995. //
  996. // panel_showBinaryColor
  997. //
  998. this.panel_showBinaryColor.BackColor = System.Drawing.Color.Yellow;
  999. this.panel_showBinaryColor.Location = new System.Drawing.Point(325, 82);
  1000. this.panel_showBinaryColor.Name = "panel_showBinaryColor";
  1001. this.panel_showBinaryColor.Size = new System.Drawing.Size(69, 17);
  1002. this.panel_showBinaryColor.TabIndex = 38;
  1003. //
  1004. // label_showBinaryColor
  1005. //
  1006. this.label_showBinaryColor.AutoSize = true;
  1007. this.label_showBinaryColor.Location = new System.Drawing.Point(217, 84);
  1008. this.label_showBinaryColor.Name = "label_showBinaryColor";
  1009. this.label_showBinaryColor.Size = new System.Drawing.Size(77, 12);
  1010. this.label_showBinaryColor.TabIndex = 36;
  1011. //
  1012. // histogramControl_binary
  1013. //
  1014. this.histogramControl_binary.Flag = 1;
  1015. this.histogramControl_binary.Location = new System.Drawing.Point(8, 22);
  1016. this.histogramControl_binary.Name = "histogramControl_binary";
  1017. this.histogramControl_binary.Size = new System.Drawing.Size(186, 117);
  1018. this.histogramControl_binary.TabIndex = 16;
  1019. //
  1020. // numberScopeControl_binary1
  1021. //
  1022. this.numberScopeControl_binary1.DecimalPlaces = 0;
  1023. this.numberScopeControl_binary1.Location = new System.Drawing.Point(217, 23);
  1024. this.numberScopeControl_binary1.Maximum = 255D;
  1025. this.numberScopeControl_binary1.maxValue = 0D;
  1026. this.numberScopeControl_binary1.Minimum = 0D;
  1027. this.numberScopeControl_binary1.minValue = 0D;
  1028. this.numberScopeControl_binary1.Name = "numberScopeControl_binary1";
  1029. this.numberScopeControl_binary1.Size = new System.Drawing.Size(150, 22);
  1030. this.numberScopeControl_binary1.TabIndex = 15;
  1031. //
  1032. // checkBox_showBinary
  1033. //
  1034. this.checkBox_showBinary.AutoSize = true;
  1035. this.checkBox_showBinary.Checked = true;
  1036. this.checkBox_showBinary.CheckState = System.Windows.Forms.CheckState.Checked;
  1037. this.checkBox_showBinary.Location = new System.Drawing.Point(217, 116);
  1038. this.checkBox_showBinary.Name = "checkBox_showBinary";
  1039. this.checkBox_showBinary.Size = new System.Drawing.Size(96, 16);
  1040. this.checkBox_showBinary.TabIndex = 11;
  1041. this.checkBox_showBinary.UseVisualStyleBackColor = true;
  1042. //
  1043. // button_autoThreshold
  1044. //
  1045. this.button_autoThreshold.Location = new System.Drawing.Point(217, 51);
  1046. this.button_autoThreshold.Name = "button_autoThreshold";
  1047. this.button_autoThreshold.Size = new System.Drawing.Size(75, 22);
  1048. this.button_autoThreshold.TabIndex = 12;
  1049. this.button_autoThreshold.UseVisualStyleBackColor = true;
  1050. //
  1051. // PorosityStandardDialog
  1052. //
  1053. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  1054. this.ClientSize = new System.Drawing.Size(1177, 761);
  1055. this.Controls.Add(this.groupBox_report);
  1056. this.Controls.Add(this.groupBox6groupBox_analysisResult2);
  1057. this.Controls.Add(this.groupBox_analysisResult1);
  1058. this.Controls.Add(this.groupBox_review);
  1059. this.Controls.Add(this.groupBox_img);
  1060. this.Controls.Add(this.groupBox_operating);
  1061. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  1062. this.Name = "PorosityStandardDialog";
  1063. this.Controls.SetChildIndex(this.groupBox_operating, 0);
  1064. this.Controls.SetChildIndex(this.groupBox_img, 0);
  1065. this.Controls.SetChildIndex(this.groupBox_review, 0);
  1066. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  1067. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  1068. this.Controls.SetChildIndex(this.groupBox_report, 0);
  1069. this.groupBox_operating.ResumeLayout(false);
  1070. this.groupBox_operating.PerformLayout();
  1071. this.groupBox_img.ResumeLayout(false);
  1072. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_lwRatioLimit)).EndInit();
  1073. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentBSD)).EndInit();
  1074. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentBSU)).EndInit();
  1075. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentGLD)).EndInit();
  1076. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentGLU)).EndInit();
  1077. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentRHD)).EndInit();
  1078. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_colorAdjustmentRHU)).EndInit();
  1079. this.groupBox_report.ResumeLayout(false);
  1080. this.groupBox_report.PerformLayout();
  1081. this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
  1082. this.groupBox_analysisResult1.ResumeLayout(false);
  1083. this.ResumeLayout(false);
  1084. }
  1085. public void Initialize()
  1086. {
  1087. for (int i = 10; i >= 0; i--)
  1088. {
  1089. this.domainUpDown_resultPrecision.Items.Add(i.ToString());
  1090. }
  1091. this.domainUpDown_resultPrecision.SelectedIndex = 8;
  1092. this.documentItems = new Dictionary<int, DocumentItem>();
  1093. // 构造工作结构
  1094. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1095. {
  1096. Bitmap bitmap = this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreateAliasedBitmap();
  1097. List<PhaseModel> phaseModels = new List<PhaseModel>();
  1098. List<PhaseModel> originalPhaseModels = new List<PhaseModel>();
  1099. //二值化相关
  1100. PhaseModel analysisModel = this.appWorkspace.DocumentWorkspaces[i].AnalysisPhaseModel;
  1101. if (analysisModel == null)
  1102. {
  1103. PhaseModel modelBinary = new PhaseModel();
  1104. modelBinary.choise = true;
  1105. modelBinary.mat = null;
  1106. //modelBinary.color = panel_showBinaryColor.BackColor.ToArgb();//###
  1107. modelBinary.position = originalPhaseModels.Count + 1;
  1108. modelBinary.name = PdnResources.GetString("Menu.binary.Text");
  1109. modelBinary.color = 0;
  1110. phaseModels.Add(analysisModel);
  1111. originalPhaseModels.Add(modelBinary);
  1112. }
  1113. else
  1114. {
  1115. if (analysisModel.name == PdnResources.GetString("Menu.binary.Text"))
  1116. {
  1117. analysisModel.name = PdnResources.GetString("Menu.Multiphasebinary.Text");
  1118. }
  1119. phaseModels.Add(analysisModel);
  1120. originalPhaseModels = this.appWorkspace.DocumentWorkspaces[i].phaseModels.Where(m => m.choise == true).ToList();
  1121. }
  1122. this.documentItems.Add(i, new DocumentItem(bitmap, null, phaseModels, originalPhaseModels));
  1123. }
  1124. //初始化图片列表
  1125. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1126. {
  1127. this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1128. this.lstView_img.Items.Add("", i);
  1129. this.lstView_img.Items[i].ImageIndex = i;
  1130. this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1131. this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1132. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1133. {
  1134. this.imgIndex = i;
  1135. }
  1136. }
  1137. //
  1138. //初始化图像控件
  1139. //
  1140. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  1141. this.documentWorkspace.Cursor = Cursors.Default;
  1142. this.documentWorkspace.Dock = DockStyle.Fill;
  1143. this.documentWorkspace.HookMouseEvents();
  1144. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1145. this.documentWorkspace.Visible = true;
  1146. this.documentWorkspace.panel.Click += new EventHandler(this.documentWorkspace_panel_Click);
  1147. this.groupBox_review.Controls.Add(this.documentWorkspace);
  1148. //
  1149. //初始化操作按钮
  1150. //
  1151. this.commonControlButtons = new CommonControlButtons();
  1152. this.commonControlButtons.Dock = DockStyle.Top;
  1153. this.commonControlButtons.Height = 30;
  1154. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1155. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1156. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1157. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1158. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1159. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1160. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1161. groupBox_review.Controls.Add(this.commonControlButtons);
  1162. //this.binaryExtractionModel.ColorInterval = 1;
  1163. // 初始化报告列表
  1164. this.listView_analysisResult.View = View.Details;
  1165. this.listView_analysisResult2.View = View.Details;
  1166. this.listBox_analysisResult.DisplayMember = "Display";
  1167. this.listBox_analysisResult.ValueMember = "Value";
  1168. documentWorkspace.panel.MouseDown += Panel_Click;
  1169. }
  1170. #endregion 初始化组件
  1171. #region 事件
  1172. #region 公共按钮
  1173. private void zoomInButton_Click(object sender, EventArgs e)
  1174. {
  1175. this.documentWorkspace.ZoomIn();
  1176. }
  1177. private void zoomOutButton_Click(object sender, EventArgs e)
  1178. {
  1179. this.documentWorkspace.ZoomOut();
  1180. }
  1181. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1182. {
  1183. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1184. }
  1185. private void actualSizeButton_Click(object sender, EventArgs e)
  1186. {
  1187. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1188. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1189. }
  1190. private void pointerButton_Click(object sender, EventArgs e)
  1191. {
  1192. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  1193. }
  1194. private void mobileModeButton_Click(object sender, EventArgs e)
  1195. {
  1196. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1197. }
  1198. #endregion 公共按钮
  1199. private void button_setting_Click(object sender, EventArgs e)
  1200. {
  1201. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1202. if (recombinationRateSetDialog.hasModule)
  1203. {
  1204. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1205. recombinationRateSetDialog.ShowDialog();
  1206. }
  1207. else
  1208. {
  1209. recombinationRateSetDialog = null;
  1210. }
  1211. }
  1212. private void btn_saveresult_Click(object sender, EventArgs e)
  1213. {
  1214. if (this.lstView_img.FocusedItem == null || this.lstView_img.FocusedItem.Index == -1)
  1215. {
  1216. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  1217. return;
  1218. }
  1219. //二值化
  1220. if (!bcBinaryChecked())
  1221. {
  1222. if (!userAll)
  1223. {
  1224. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
  1225. }
  1226. return;
  1227. }
  1228. if (this.tempAnalysisResult == null)
  1229. {
  1230. if (!userAll)
  1231. {
  1232. MessageBox.Show(PdnResources.GetString("Menu.Nodatatosave.text"));
  1233. }
  1234. return;
  1235. }
  1236. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]))
  1237. {
  1238. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1239. if (dr == DialogResult.OK)
  1240. {
  1241. dict[this.lstView_img.FocusedItem.Text] = this.tempAnalysisResult.phaseModels;
  1242. analysisResults[this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]] = this.tempAnalysisResult;
  1243. buildListBox_analysisResult();
  1244. save_normal_data();
  1245. }
  1246. return;
  1247. }
  1248. if (dict.ContainsKey(this.lstView_img.FocusedItem.Text))
  1249. {
  1250. dict[this.lstView_img.FocusedItem.Text] = this.documentWorkspace.phaseModels;
  1251. }
  1252. else
  1253. {
  1254. dict.Add(this.lstView_img.FocusedItem.Text, this.documentWorkspace.phaseModels);
  1255. }
  1256. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index], this.tempAnalysisResult);
  1257. if (userAll)
  1258. {
  1259. if (hasResultIndexList.IndexOf(this.lstView_img.FocusedItem.Index) == -1)
  1260. {
  1261. resultList.Add(this.tempAnalysisResult);
  1262. hasResultIndexList.Add(this.lstView_img.FocusedItem.Index);
  1263. }
  1264. else
  1265. {
  1266. resultList[this.lstView_img.FocusedItem.Index] = this.tempAnalysisResult;
  1267. }
  1268. }
  1269. if (!nodata) {
  1270. buildListBox_analysisResult();
  1271. }
  1272. save_normal_data();
  1273. }
  1274. private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
  1275. {
  1276. if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
  1277. {
  1278. if (!string.IsNullOrEmpty(ImgName)) {
  1279. saveEveryImgData();
  1280. }
  1281. this.tempAnalysisResult = null;
  1282. this.documentWorkspace.Document = Document.FromImage(this.documentItems[this.lstView_img.FocusedItem.Index].bitmap);
  1283. this.documentWorkspace.Visible = true;
  1284. this.imgPxPerUnit = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1285. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1286. this.methodOfAssessment = getMethodOfAssessment();
  1287. MethodOfAssessment.activeMethod = this.methodOfAssessment;
  1288. SetAnalyzeModelFromXml(this.methodOfAssessment.resourcesName);
  1289. if (this.bcBinaryChecked())
  1290. {
  1291. this.documentWorkspace.activeTool = DrawToolType.InclusionNoEffect;
  1292. }
  1293. else
  1294. {
  1295. if (this.addView)
  1296. {
  1297. this.documentWorkspace.activeTool = DrawToolType.Pointer;
  1298. }
  1299. else
  1300. {
  1301. this.documentWorkspace.activeTool = DrawToolType.InclusionNoEffect;
  1302. }
  1303. }
  1304. this.originalPhaseModels = this.documentItems[this.lstView_img.FocusedItem.Index].originalPhaseModels;
  1305. clearAllView();
  1306. this.nameList.Clear();
  1307. this.rectangleF.Clear();
  1308. this.rectangleTypeList.Clear();
  1309. //二值化集成4
  1310. if (firstChoose == 0)
  1311. {
  1312. //获取所有外部保存的视场
  1313. InitViewData();
  1314. }
  1315. binaryClass.RefreshHistogramControl1Values();
  1316. if (selectPicture != -1)
  1317. {
  1318. this.binaryClass.saveMat(this.imageList_img.Images.Keys[selectPicture]);
  1319. }
  1320. selectPicture = this.lstView_img.FocusedItem.Index;
  1321. var gList = new GraphicsList();
  1322. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count != 0)
  1323. {
  1324. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  1325. {
  1326. gList.Add(s.Clone(this.documentWorkspace));
  1327. }
  1328. }
  1329. else
  1330. {
  1331. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.Count; i++)
  1332. {
  1333. var obj = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList[i].Clone(this.documentWorkspace);
  1334. gList.Add(obj);
  1335. }
  1336. }
  1337. this.documentWorkspace.GraphicsList = gList;
  1338. binaryClass.listView1_SelectedIndexChanged(this.bitmap, this.imageList_img.Images.Keys[selectPicture]);
  1339. getViewMethod();
  1340. bClassBinaryImplFinishAction(sender, e);
  1341. this.documentWorkspace.Refresh();
  1342. firstChoose += 1;
  1343. this.ImgName = this.lstView_img.FocusedItem.Name;
  1344. getEveryImgData();
  1345. }
  1346. else
  1347. {
  1348. this.documentWorkspace.Visible = false;
  1349. }
  1350. }
  1351. #region [二值化相关方法]
  1352. /// <summary>
  1353. /// 添加参数改变的监听
  1354. /// </summary>
  1355. /// <param name="sender"></param>
  1356. /// <param name="e"></param>
  1357. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1358. {
  1359. this.binaryClass.loadParams();
  1360. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  1361. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1362. this.startScriptAutomaticAction();
  1363. }
  1364. /// <summary>
  1365. /// 参数改变时,重新处理图像
  1366. /// </summary>
  1367. /// <param name="sender"></param>
  1368. /// <param name="e"></param>
  1369. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1370. {
  1371. this.originalPhaseModels = this.documentWorkspace.phaseModels.Where(m => m.choise == true).ToList();
  1372. if (!bcOriginChecked())
  1373. {
  1374. if (bcBinaryChecked())
  1375. {
  1376. clearAllView();
  1377. getAllView();
  1378. btn_statistics_Click();
  1379. list_add_data();
  1380. }
  1381. else
  1382. {
  1383. clearAllView();
  1384. }
  1385. }
  1386. else
  1387. {
  1388. clearAllView();
  1389. }
  1390. this.documentWorkspace.Refresh();
  1391. }
  1392. public bool bcBinaryChecked()
  1393. {
  1394. if (this.addView && !bc.BinaryChecked)
  1395. {
  1396. this.documentWorkspace.activeTool = DrawToolType.Pointer;
  1397. }
  1398. else
  1399. {
  1400. this.documentWorkspace.activeTool = DrawToolType.InclusionNoEffect;
  1401. }
  1402. return bc != null && bc.BinaryChecked;
  1403. }
  1404. private bool bcOriginChecked()
  1405. {
  1406. return bc != null && bc.OriginChecked;
  1407. }
  1408. /// <summary>
  1409. /// 显示原图/原图+二值图
  1410. /// </summary>
  1411. /// <param name="sender"></param>
  1412. /// <param name="e"></param>
  1413. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1414. {
  1415. if (!bcOriginChecked())
  1416. {
  1417. if (bcBinaryChecked())
  1418. this.documentWorkspace.PhaseModels[0].choise = true;
  1419. }
  1420. else
  1421. {
  1422. this.documentWorkspace.PhaseModels[0].choise = false;
  1423. }
  1424. this.originalPhaseModels = this.documentWorkspace.phaseModels.Where(m => m.choise == true).ToList();
  1425. if (!bcOriginChecked())
  1426. {
  1427. if (bcBinaryChecked())
  1428. {
  1429. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = true;
  1430. getAllView();
  1431. list_add_data();
  1432. }
  1433. else
  1434. {
  1435. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = false;
  1436. clearAllView();
  1437. }
  1438. }
  1439. else
  1440. {
  1441. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = false;
  1442. clearAllView();
  1443. }
  1444. this.documentWorkspace.Refresh();
  1445. }
  1446. #endregion [二值化相关方法]
  1447. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  1448. {
  1449. buildListView_analysisResult();
  1450. }
  1451. private void button_all_Click(object sender, EventArgs e)
  1452. {
  1453. for (int i = 0; i < this.listBox_analysisResult.Items.Count; i++)
  1454. {
  1455. this.listBox_analysisResult.SetItemChecked(i, true);
  1456. }
  1457. buildListView_analysisResult();
  1458. }
  1459. private void documentWorkspace_panel_Click(object sender, EventArgs e)
  1460. {
  1461. System.Windows.Forms.MouseEventArgs me = (System.Windows.Forms.MouseEventArgs)e;
  1462. if (me.Button == MouseButtons.Left)
  1463. {
  1464. }
  1465. else
  1466. {
  1467. System.Drawing.Point pointscroll = this.documentWorkspace.GetScalePoint(((System.Windows.Forms.MouseEventArgs)e).Location);
  1468. }
  1469. }
  1470. #endregion 事件
  1471. #region 内部方法
  1472. private void buildListBox_analysisResult()
  1473. {
  1474. this.listBox_analysisResult.Items.Clear();
  1475. foreach (var item in analysisResults.Keys)
  1476. {
  1477. this.listBox_analysisResult.Items.Add(new LocalListViewItem(item, item.GetFriendlyName()));
  1478. }
  1479. buildListView_analysisResult();
  1480. }
  1481. private List<ListViewItem> buildAnalysisResults(DocumentWorkspace workspace, AnalysisResult analysisResult)
  1482. {
  1483. List<ListViewItem> listViews = new List<ListViewItem>();
  1484. foreach (var fieldOfView in analysisResult.resultBody.Keys)
  1485. {
  1486. ListViewItem lvi = new ListViewItem();
  1487. lvi.Text = workspace.GetFriendlyName();
  1488. lvi.SubItems.Add(fieldOfView.name);
  1489. foreach (var item in analysisResult.resultBody[fieldOfView])
  1490. {
  1491. try
  1492. {
  1493. int num = 2;
  1494. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1495. {
  1496. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1497. }
  1498. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(item), num).ToString());
  1499. }
  1500. catch (Exception ex)
  1501. {
  1502. lvi.SubItems.Add(item);
  1503. }
  1504. }
  1505. listViews.Add(lvi);
  1506. }
  1507. return listViews;
  1508. }
  1509. private void buildListView_analysisResult()
  1510. {
  1511. List<AnalysisResult> conclusions = new List<AnalysisResult>();
  1512. this.listView_analysisResult.Columns.Clear();
  1513. this.listView_analysisResult.Items.Clear();
  1514. this.listView_analysisResult2.Columns.Clear();
  1515. this.listView_analysisResult2.Items.Clear();
  1516. if (analysisResults.Count == 0)
  1517. {
  1518. return;
  1519. }
  1520. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  1521. {
  1522. return;
  1523. }
  1524. this.listView_analysisResult.BeginUpdate();
  1525. // 构建头
  1526. foreach (var item in analysisResults.First().Value.getResultHead())
  1527. {
  1528. ColumnHeader header = new ColumnHeader();
  1529. header.Text = item;
  1530. header.Width = 150;
  1531. this.listView_analysisResult.Columns.Add(header);
  1532. }
  1533. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1534. {
  1535. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  1536. this.listView_analysisResult.Items.AddRange(buildAnalysisResults(workspace, analysisResults[workspace]).ToArray());
  1537. conclusions.Add(analysisResults[workspace]);
  1538. }
  1539. this.listView_analysisResult.EndUpdate();
  1540. if (this.listView_analysisResult.Items.Count > 0)
  1541. {
  1542. this.listView_analysisResult.Items[0].Selected = true;
  1543. }
  1544. // 构建头
  1545. foreach (var item in this.methodOfAssessment.getResultConclusionHead())
  1546. {
  1547. ColumnHeader header = new ColumnHeader();
  1548. header.Text = item;
  1549. header.Width = 150;
  1550. this.listView_analysisResult2.Columns.Add(header);
  1551. }
  1552. ListViewItem lvi = new ListViewItem();
  1553. List<string> strings = this.methodOfAssessment.buildResultConclusion(conclusions, porosityConfig);
  1554. //保留小数点
  1555. try
  1556. {
  1557. int num = 2;
  1558. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1559. {
  1560. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1561. }
  1562. lvi.Text = Math.Round(Convert.ToDecimal(strings[0]), num).ToString();
  1563. }
  1564. catch (Exception ex)
  1565. {
  1566. lvi.Text = strings[0];
  1567. }
  1568. for (int i = 1; i < strings.Count; i++)
  1569. {
  1570. try
  1571. {
  1572. int num = 2;
  1573. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1574. { num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1575. }
  1576. if (strings[i].Contains("±"))
  1577. {
  1578. strings[i] = strings[i].Replace("±", "");
  1579. lvi.SubItems.Add("±" + Math.Round(Convert.ToDecimal(strings[i]), num).ToString());
  1580. }
  1581. else
  1582. {
  1583. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(strings[i]), num).ToString());
  1584. }
  1585. }
  1586. catch (Exception ex)
  1587. {
  1588. lvi.SubItems.Add(strings[i]);
  1589. }
  1590. }
  1591. this.listView_analysisResult2.Items.Add(lvi);
  1592. this.listView_analysisResult2.EndUpdate();
  1593. }
  1594. private void button_generateReport_Click(object sender, EventArgs e)
  1595. {
  1596. if (this.listView_analysisResult.Items.Count == 0)
  1597. {
  1598. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1599. return;
  1600. }
  1601. if (this.checkBox_generateReport_opensetting.Checked)
  1602. {
  1603. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1604. if (recombinationRateSetDialog.hasModule)
  1605. {
  1606. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1607. recombinationRateSetDialog.ShowDialog();
  1608. }
  1609. else
  1610. {
  1611. recombinationRateSetDialog = null;
  1612. }
  1613. }
  1614. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1615. {
  1616. //获取word书签与excel单元格的关系,以字典方式存储
  1617. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1618. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1619. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1620. {
  1621. foreach (mic_module_infos info in mic_module_infos)
  1622. {
  1623. tagInfos.Add(info.tag_name, info.cell_position);
  1624. }
  1625. }
  1626. List<List<List<string>>> sheets = new List<List<List<string>>>();
  1627. sheets.Add(new List<List<string>>());
  1628. List<List<string>> contentList = new List<List<string>>();
  1629. List<string> contentHead = new List<string>();
  1630. contentList.Add(contentHead);
  1631. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  1632. {
  1633. contentHead.Add(c.Text);
  1634. }
  1635. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  1636. {
  1637. List<string> contentBody = new List<string>();
  1638. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  1639. {
  1640. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  1641. }
  1642. contentList.Add(contentBody);
  1643. }
  1644. contentList.Add(new List<string>());
  1645. contentHead = new List<string>();
  1646. contentList.Add(contentHead);
  1647. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  1648. {
  1649. contentHead.Add(c.Text);
  1650. }
  1651. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  1652. {
  1653. List<string> contentBody = new List<string>();
  1654. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  1655. {
  1656. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  1657. }
  1658. contentList.Add(contentBody);
  1659. }
  1660. sheets.Add(contentList);
  1661. sheets.Add(new List<List<string>>());
  1662. List<Bitmap> bitList = new List<Bitmap>();
  1663. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1664. {
  1665. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  1666. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1667. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  1668. originalBit.Tag = pantographRatio;
  1669. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1670. newBit.Tag = pantographRatio;
  1671. Graphics graphics = Graphics.FromImage(newBit);
  1672. foreach (var phase in dict[((LocalListViewItem)item).Display])
  1673. {
  1674. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  1675. graphics.DrawImage(processedBit, new PointF(0, 0));
  1676. }
  1677. bitList.Add(originalBit);
  1678. bitList.Add(newBit);
  1679. }
  1680. try
  1681. {
  1682. this.appWorkspace.CreateAnalysisReportInclusion(this.analyzeSettingModel, sheets, bitList, tagInfos);
  1683. }
  1684. catch (Exception ex)
  1685. {
  1686. MessageBox.Show(ex.Message);
  1687. }
  1688. }
  1689. else
  1690. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1691. }
  1692. private void button_exportResults_Click(object sender, EventArgs e)
  1693. {
  1694. if (this.listView_analysisResult.Items.Count == 0)
  1695. {
  1696. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1697. return;
  1698. }
  1699. try
  1700. {
  1701. SaveFileDialog exe = new SaveFileDialog();
  1702. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1703. exe.FilterIndex = 0;
  1704. exe.RestoreDirectory = true;
  1705. exe.Title = "Export Excel File";
  1706. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1707. exe.FileName = DateTime.Now.ToString("yyyyMMddHHmmss") + this.methodOfAssessment.fileName;
  1708. DialogResult dr = exe.ShowDialog();
  1709. if (dr != DialogResult.OK)
  1710. {
  1711. return;
  1712. }
  1713. DataTable dtb = new DataTable();
  1714. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  1715. {
  1716. dtb.Columns.Add(c.Text);
  1717. }
  1718. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  1719. {
  1720. DataRow dataRow = dtb.NewRow();
  1721. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  1722. {
  1723. dataRow[c] = this.listView_analysisResult.Items[r].SubItems[c].Text;
  1724. }
  1725. dtb.Rows.Add(dataRow);
  1726. }
  1727. DataTable dtb1 = new DataTable();
  1728. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  1729. {
  1730. dtb1.Columns.Add(c.Text);
  1731. }
  1732. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  1733. {
  1734. DataRow dataRow = dtb1.NewRow();
  1735. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  1736. {
  1737. dataRow[c] = this.listView_analysisResult2.Items[r].SubItems[c].Text;
  1738. }
  1739. dtb1.Rows.Add(dataRow);
  1740. }
  1741. List<DataTable> list = new List<DataTable>();
  1742. list.Add(dtb);
  1743. list.Add(dtb1);
  1744. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1745. }
  1746. catch (Exception ex)
  1747. {
  1748. MessageBox.Show(ex.Message);
  1749. }
  1750. }
  1751. /// <summary>
  1752. /// 初始化参数配置下拉
  1753. /// </summary>
  1754. public void InitParameterList(int index = 0)
  1755. {
  1756. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\");
  1757. files.Clear();
  1758. foreach (string fileName in fileNames)
  1759. {
  1760. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  1761. files.Add(name);
  1762. }
  1763. string nowModelName = Startup.instance.configModel.BinaryParameter.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  1764. this.binaryExtractionModel = XmlSerializeHelper.DESerializer<BinaryExtractionModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\Default.xml", FileMode.Open));/*" + this.comboBox1.SelectedItem.ToString() + "*///##############
  1765. }
  1766. #endregion 内部方法
  1767. #region 需继承方法
  1768. protected virtual void getAllView()
  1769. {
  1770. //throw new NotImplementedException();
  1771. }
  1772. protected virtual void SubclassInitialize()
  1773. {
  1774. //throw new NotImplementedException();
  1775. }
  1776. protected virtual MethodOfAssessment getMethodOfAssessment()
  1777. {
  1778. throw new NotImplementedException();
  1779. }
  1780. protected virtual void initColorSetting()
  1781. {
  1782. //throw new NotImplementedException();
  1783. }
  1784. protected virtual void initDisplaySetting()
  1785. {
  1786. //throw new NotImplementedException();
  1787. }
  1788. protected virtual void clearAllView()
  1789. {
  1790. //throw new NotImplementedException();
  1791. }
  1792. protected virtual void list_add_data()
  1793. {
  1794. //throw new NotImplementedException();
  1795. }
  1796. protected virtual void save_normal_data()
  1797. {
  1798. //throw new NotImplementedException();
  1799. }
  1800. protected virtual void toView()
  1801. {
  1802. //throw new NotImplementedException();
  1803. }
  1804. protected virtual void clearOneView()
  1805. {
  1806. }
  1807. protected virtual void changeOneViewColor()
  1808. {
  1809. }
  1810. protected virtual void getArgsValue()
  1811. {
  1812. }
  1813. protected virtual void setArgsValue()
  1814. {
  1815. }
  1816. protected virtual void getEveryImgData()
  1817. {
  1818. }
  1819. protected virtual void saveEveryImgData()
  1820. {
  1821. }
  1822. protected virtual void recalculate()
  1823. {
  1824. if (this.firstChoose != 0)
  1825. {
  1826. btn_statistics_Click();
  1827. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]))
  1828. {
  1829. analysisResults[this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]] = this.tempAnalysisResult;
  1830. }
  1831. else
  1832. {
  1833. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index], this.tempAnalysisResult);
  1834. }
  1835. buildListView_analysisResult();
  1836. }
  1837. }
  1838. #endregion 需继承方法
  1839. #region 内部类
  1840. internal class LocalListViewItem
  1841. {
  1842. public DocumentWorkspace Value { get; }
  1843. public string Display { get; }
  1844. public LocalListViewItem(DocumentWorkspace Value, string Display)
  1845. {
  1846. this.Value = Value;
  1847. this.Display = Display;
  1848. }
  1849. }
  1850. internal class DocumentItem
  1851. {
  1852. public Bitmap bitmap;
  1853. public GraphicsList graphicsList;
  1854. public List<PhaseModel> phaseModels;
  1855. public bool isErZhi = false;
  1856. public List<PhaseModel> originalPhaseModels;
  1857. public List<DrawObject> drawGraphicsList = new List<DrawObject>();
  1858. public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels, List<PhaseModel> originalPhaseModels)
  1859. {
  1860. this.bitmap = bitmap;
  1861. this.graphicsList = graphicsList;
  1862. this.phaseModels = phaseModels;
  1863. this.originalPhaseModels = originalPhaseModels;
  1864. }
  1865. }
  1866. #endregion 内部类
  1867. private void domainUpDown_resultPrecision_SelectedItemChanged(object sender, EventArgs e)
  1868. {
  1869. buildListView_analysisResult();
  1870. clearAllView();
  1871. getAllView();
  1872. list_add_data();
  1873. }
  1874. private void button_remove_Click(object sender, EventArgs e)
  1875. {
  1876. if (this.listBox_analysisResult.Items.Count == 0)
  1877. {
  1878. MessageBox.Show(PdnResources.GetString("Menu.Noresultsatmeasuring.text"));
  1879. return;
  1880. }
  1881. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeleteth.text") + "?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
  1882. {
  1883. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  1884. {
  1885. return;
  1886. }
  1887. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1888. {
  1889. this.analysisResults.Remove(((LocalListViewItem)item).Value);
  1890. }
  1891. buildListBox_analysisResult();
  1892. }
  1893. }
  1894. /// <summary>
  1895. /// 识别
  1896. /// </summary>
  1897. /// <param name="sender"></param>
  1898. /// <param name="e"></param>
  1899. private void btn_statistics_Click()
  1900. {
  1901. if (this.lstView_img.FocusedItem == null || !this.lstView_img.FocusedItem.Selected)
  1902. {
  1903. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1904. return;
  1905. }
  1906. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1907. {
  1908. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformabinaryoperationfirst.text"));
  1909. return;
  1910. }
  1911. Mat mat = this.documentWorkspace.PhaseModels[0].mat.Clone();
  1912. for (int i = 0; i < mat.Height; i++)
  1913. {
  1914. for (int j = 0; j < mat.Width; j++)
  1915. {
  1916. if (mat.At<int>(i, j) == 0)
  1917. {
  1918. mat.Set<Vec3b>(i, j, new Vec3b(255, 255, 255));
  1919. }
  1920. }
  1921. }
  1922. #region [获取参数]
  1923. string filePath = Application.StartupPath + "\\PorosityConfig\\6093Config.xml";
  1924. try
  1925. {
  1926. porosityConfig = XmlSerializeHelper.DESerializer<PorosityConfig>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1927. }
  1928. catch (Exception ex)
  1929. {
  1930. porosityConfig.diameterType = 1;
  1931. porosityConfig.distanceFactor = 1;
  1932. porosityConfig.maxDiameter = 1;
  1933. porosityConfig.maxPorosityNum = 1;
  1934. porosityConfig.maxPorosityPercent = 1;
  1935. porosityConfig.minDiameter = 1;
  1936. porosityConfig.roughSurface = 1;
  1937. porosityConfig.stressType = "D";
  1938. porosityConfig.diameter = false;
  1939. porosityConfig.minDistanceA = false;
  1940. porosityConfig.minDiameterU = false;
  1941. porosityConfig.surfaceRz = false;
  1942. if (!Directory.Exists(filePath))
  1943. {
  1944. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityConfig>(porosityConfig);
  1945. Directory.CreateDirectory(Application.StartupPath + "\\PorosityConfig\\");
  1946. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1947. }
  1948. }
  1949. #endregion [获取参数]
  1950. Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetCutSizeWithColorWhiteOrTransparentColor(false);
  1951. Mat oldMat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  1952. bool isOne = true;
  1953. if (this.documentWorkspace.GraphicsList.IsExsitView())
  1954. {
  1955. isOne = false;
  1956. }
  1957. for (int i = 0; i < this.originalPhaseModels.Count; i++)
  1958. {
  1959. PhaseModel pModel = this.originalPhaseModels[i];
  1960. if (pModel.mat == null)
  1961. {
  1962. pModel.mat = this.documentWorkspace.phaseModels[i].mat;
  1963. }
  1964. }
  1965. this.rectangleF.Clear();
  1966. this.rectangleTypeList.Clear();
  1967. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  1968. {
  1969. this.rectangleF.Add(this.documentWorkspace.GraphicsList[i].Rectangle);
  1970. this.rectangleTypeList.Add(this.documentWorkspace.GraphicsList[i].drawToolType);
  1971. }
  1972. //识别
  1973. this.tempAnalysisResult = this.methodOfAssessment.generateReport(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap), mat, oldMat, rectangleF, rectangleTypeList, this.originalPhaseModels, porosityConfig, isOne);
  1974. }
  1975. private void button1_Click(object sender, EventArgs e)
  1976. {
  1977. if (this.listView_analysisResult.Items.Count == 0)
  1978. {
  1979. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1980. return;
  1981. }
  1982. if (this.analyzeSettingModel == null)
  1983. {
  1984. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  1985. return;
  1986. }
  1987. int num = 2;
  1988. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1989. {
  1990. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1991. }
  1992. //获取项目工程内的文件夹路径
  1993. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.NonferrousMetal.Porosity.Text", this.analyzeSettingModel.savePath);
  1994. if (item != null)
  1995. {
  1996. //向文件夹内保存图片和报告
  1997. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1998. {
  1999. //获取word书签与excel单元格的关系,以字典方式存储
  2000. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2001. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2002. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2003. {
  2004. foreach (mic_module_infos info in mic_module_infos)
  2005. {
  2006. tagInfos.Add(info.tag_name, info.cell_position);
  2007. }
  2008. }
  2009. List<List<string>> contentList = new List<List<string>>();
  2010. List<string> contentHead = new List<string>();
  2011. contentList.Add(contentHead);
  2012. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  2013. {
  2014. contentHead.Add(c.Text);
  2015. }
  2016. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  2017. {
  2018. List<string> contentBody = new List<string>();
  2019. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  2020. {
  2021. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  2022. }
  2023. contentList.Add(contentBody);
  2024. }
  2025. contentList.Add(new List<string>());
  2026. contentHead = new List<string>();
  2027. contentList.Add(contentHead);
  2028. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  2029. {
  2030. contentHead.Add(c.Text);
  2031. }
  2032. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  2033. {
  2034. List<string> contentBody = new List<string>();
  2035. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  2036. {
  2037. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  2038. }
  2039. contentList.Add(contentBody);
  2040. }
  2041. List<List<string>> inclusionList = new List<List<string>>();
  2042. List<Bitmap> bitList = new List<Bitmap>();
  2043. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2044. foreach (var itemIt in this.listBox_analysisResult.CheckedItems)
  2045. {
  2046. List<List<string>> dataList = new List<List<string>>();
  2047. List<string> inclusionHead = new List<string>();
  2048. inclusionHead.Add(PdnResources.GetString("Menu.Pixellength.text"));
  2049. inclusionHead.Add(PdnResources.GetString("Menu.Pixelwidth.Text"));
  2050. inclusionHead.Add(PdnResources.GetString("Menu.hectuallength.Text"));
  2051. inclusionHead.Add(PdnResources.GetString("Menu.Theactualwidthofthe.Text"));
  2052. dataList.Add(inclusionHead);
  2053. DocumentWorkspace workspace = ((LocalListViewItem)itemIt).Value;
  2054. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  2055. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  2056. originalBit.Tag = pantographRatio;
  2057. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2058. newBit.Tag = pantographRatio;
  2059. Graphics graphics = Graphics.FromImage(newBit);
  2060. foreach (var phase in dict[((LocalListViewItem)itemIt).Display])
  2061. {
  2062. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  2063. graphics.DrawImage(processedBit, new PointF(0, 0));
  2064. }
  2065. bitList.Add(originalBit);
  2066. bitList.Add(newBit);
  2067. foreach (var inclusion in analysisResults[workspace].porositys)
  2068. {
  2069. List<string> inclusionBody = new List<string>();
  2070. inclusionBody.Add(Math.Round(inclusion.pixelLength, num) + "");
  2071. inclusionBody.Add(Math.Round(inclusion.pixelWidth, num) + "");
  2072. inclusionBody.Add(Math.Round(inclusion.physicalLength, num) + "");
  2073. inclusionBody.Add(Math.Round(inclusion.physicalWidth, num) + "");
  2074. dataList.Add(inclusionBody);
  2075. }
  2076. ExportProjectModel exportProjectModel = new ExportProjectModel();
  2077. exportProjectModel.dataList = dataList;
  2078. exportProjectModel.picName = ((LocalListViewItem)itemIt).Display;
  2079. exportProjectModel.tagName = PdnResources.GetString("Menu.pore.Text");
  2080. exportModel.Add(exportProjectModel);
  2081. }
  2082. try
  2083. {
  2084. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, contentList, exportModel, bitList, tagInfos, item.path, item.code);
  2085. }
  2086. catch (Exception ex)
  2087. {
  2088. MessageBox.Show(ex.Message);
  2089. }
  2090. }
  2091. else
  2092. {
  2093. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2094. return;
  2095. }
  2096. //保存项目信息到数据库
  2097. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2098. }
  2099. }
  2100. /// <summary>
  2101. /// 不可点击空白区域
  2102. /// </summary>
  2103. /// <param name="sender"></param>
  2104. /// <param name="e"></param>
  2105. private void lstView_img_MouseUp(object sender, MouseEventArgs e)
  2106. {
  2107. if (e.Button == MouseButtons.Left)
  2108. {
  2109. if (lstView_img.SelectedItems.Count > 0)
  2110. {
  2111. }
  2112. else if (lstView_img.SelectedItems.Count <= 0)//点击空白区
  2113. {
  2114. if (this.lstView_img.FocusedItem != null)
  2115. {
  2116. ListViewItem item = this.lstView_img.GetItemAt(e.X, e.Y);
  2117. if (item == null)
  2118. {
  2119. this.lstView_img.FocusedItem.Selected = true;
  2120. }
  2121. }
  2122. }
  2123. }
  2124. }
  2125. #region [跳转视场设置相关方法]
  2126. #region [初始方法]
  2127. private void getViewMethod()
  2128. {
  2129. var drawObjectList = new List<DrawObject>();
  2130. // 找出正方形视场
  2131. for (int i = this.documentWorkspace.GraphicsList.Count - 1; i >= 0; i--)
  2132. {
  2133. if (this.documentWorkspace.GraphicsList[i].objectType == DrawClass.View)
  2134. {
  2135. //this.rectangleF.Add(this.documentWorkspace.GraphicsList[i].Rectangle);
  2136. this.rectangleTypeList.Add(this.documentWorkspace.GraphicsList[i].drawToolType);
  2137. drawObjectList.Add(this.documentWorkspace.GraphicsList[i]);
  2138. this.nameList.Add(PdnResources.GetString("Menu.view.text") + $"{i + 1}");
  2139. }
  2140. }
  2141. drawObjectList.Reverse();
  2142. this.nameList.Reverse();
  2143. //this.rectangleF.Reverse();
  2144. this.rectangleTypeList.Reverse();
  2145. foreach (var s in drawObjectList)
  2146. {
  2147. s.Color = retrunColor(drawObjectList.IndexOf(s));
  2148. }
  2149. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList = drawObjectList;
  2150. this.documentWorkspace.panel.Paint += Panel_Paint;
  2151. }
  2152. private void InitViewData()
  2153. {
  2154. var list = mic_view_infos_BLL.FindAll();
  2155. if (list != null && list.Count > 0)
  2156. {
  2157. foreach (var s in list)
  2158. {
  2159. ViewListModel model = XmlSerializeHelper.DESerializer<ViewListModel>(s.view_xml);
  2160. foreach (var m in model.Views)
  2161. {
  2162. if (model.Views.Count == 1)
  2163. {
  2164. this.comboBox2.Items.Add($"{s.view_name}");
  2165. }
  2166. else
  2167. {
  2168. this.comboBox2.Items.Add($"{s.view_name}-{model.Views.IndexOf(m) + 1}");
  2169. }
  2170. this.modelList.Add(m);
  2171. }
  2172. }
  2173. }
  2174. }
  2175. #endregion
  2176. private void getViewSetting()
  2177. {
  2178. string filePath = Application.StartupPath + "\\PorosityConfig\\ViewConfig.xml";
  2179. try
  2180. {
  2181. ViewSetting = XmlSerializeHelper.DESerializer<viewSetting>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  2182. }
  2183. catch (Exception ex)
  2184. {
  2185. ViewSetting = new viewSetting();
  2186. ViewSetting.colorFirst = Color.Red.ToArgb();
  2187. ViewSetting.colorSecond = Color.Yellow.ToArgb();
  2188. ViewSetting.colorThird = Color.Green.ToArgb();
  2189. ViewSetting.colorFourth = Color.Blue.ToArgb();
  2190. ViewSetting.colorFifth = Color.MediumVioletRed.ToArgb();
  2191. ViewSetting.colorSixth = Color.Magenta.ToArgb();
  2192. ViewSetting.colorSeventh = Color.DarkViolet.ToArgb();
  2193. ViewSetting.colorEighth = Color.LightSkyBlue.ToArgb();
  2194. ViewSetting.colorNinth = Color.Cyan.ToArgb();
  2195. ViewSetting.colorTenth = Color.SeaGreen.ToArgb();
  2196. ViewSetting.colorEleventh = Color.DarkOrange.ToArgb();
  2197. ViewSetting.colorTwelfth = Color.Sienna.ToArgb();
  2198. if (!Directory.Exists(filePath))
  2199. {
  2200. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<viewSetting>(ViewSetting);
  2201. Directory.CreateDirectory(Application.StartupPath + "\\PorosityConfig\\");
  2202. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2203. }
  2204. }
  2205. }
  2206. private void button3_Click(object sender, EventArgs e)
  2207. {
  2208. //是否需要二值化
  2209. if (this.lstView_img.FocusedItem == null || !this.lstView_img.FocusedItem.Selected)
  2210. {
  2211. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  2212. return;
  2213. }
  2214. double pxPerUnit = this.imgPxPerUnit;
  2215. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList == null || this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count == 0)
  2216. {
  2217. MessageBox.Show(PdnResources.GetString("Menu.ewbeforesettingfieldofview.Text"));
  2218. return;
  2219. }
  2220. if (bcBinaryChecked())
  2221. {
  2222. MessageBox.Show("请取消二值化后再进行视场设置!");
  2223. return;
  2224. }
  2225. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2226. {
  2227. var g = s.Clone();
  2228. this.oldDrawList.Add(g);
  2229. }
  2230. new PorosityViewSetting(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList, this.nameList, -1, ViewSetting, this, pxPerUnit).ShowDialog();
  2231. }
  2232. /// <summary>
  2233. /// 清空视场
  2234. /// </summary>
  2235. public void clearView()
  2236. {
  2237. this.documentWorkspace.GraphicsList.DeleteAllView();
  2238. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList = new List<DrawObject>();
  2239. this.oldDrawList.Clear();
  2240. //this.pointFDic.Clear();
  2241. this.nameList.Clear();
  2242. this.bc.BinaryChecked = false;
  2243. //this.rectangleF.Clear();
  2244. this.rectangleTypeList.Clear();
  2245. clearAllView();
  2246. this.documentWorkspace.Refresh();
  2247. }
  2248. /// <summary>
  2249. /// 删除视场
  2250. /// </summary>
  2251. public void clearOneView(int id, int index)
  2252. {
  2253. this.documentWorkspace.GraphicsList.RemoveByIds(new List<int>() { id });
  2254. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.RemoveAt(index);
  2255. this.delIndex = index;
  2256. this.nameList.RemoveAt(index);
  2257. //this.rectangleF.RemoveAt(index);
  2258. this.rectangleTypeList.RemoveAt(index);
  2259. clearOneView();
  2260. //this.pointFDic.Clear();
  2261. //for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  2262. //{
  2263. // this.pointFDic.Add(i, this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[i].GetPoints().ToArray());
  2264. //}
  2265. this.documentWorkspace.Refresh();
  2266. }
  2267. /// <summary>
  2268. /// 视场颜色高亮
  2269. /// </summary>
  2270. public void colorHighlight(int index)
  2271. {
  2272. this.chooseGrIndex = index;
  2273. this.documentWorkspace.Refresh();
  2274. }
  2275. /// <summary>
  2276. /// 修改视场颜色
  2277. /// </summary>
  2278. public void changeThisColor(int index, int color)
  2279. {
  2280. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Color = Color.FromArgb(color);
  2281. this.delIndex = index;
  2282. changeOneViewColor();
  2283. this.documentWorkspace.Refresh();
  2284. }
  2285. /// <summary>
  2286. /// 修改视场
  2287. /// </summary>
  2288. public void editView()
  2289. {
  2290. this.oldDrawList.Clear();
  2291. this.documentWorkspace.Refresh();
  2292. }
  2293. /// <summary>
  2294. /// 没有保存 返回之前的颜色
  2295. /// </summary>
  2296. public void returnOldColor()
  2297. {
  2298. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2299. {
  2300. var graphics = this.oldDrawList.Where(m => m.ID == s.ID).FirstOrDefault();
  2301. if (graphics == null)
  2302. {
  2303. continue;
  2304. }
  2305. s.Color = graphics.Color;
  2306. }
  2307. this.oldDrawList.Clear();
  2308. this.documentWorkspace.Refresh();
  2309. }
  2310. /// <summary>
  2311. /// 修改中心点x坐标的事件
  2312. /// </summary>
  2313. /// <param name="sender"></param>
  2314. /// <param name="e"></param>
  2315. public void numericUpDown3_ValueChange(int id, int index, int newValue, int oldValue)
  2316. {
  2317. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2318. {
  2319. int deltaX = newValue - oldValue;
  2320. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Move(deltaX, 0);
  2321. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2322. //pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2323. this.documentWorkspace.Refresh();
  2324. }
  2325. }
  2326. /// <summary>
  2327. /// 修改中心点y坐标的事件
  2328. /// </summary>
  2329. /// <param name="sender"></param>
  2330. /// <param name="e"></param>
  2331. public void numericupdown4_valuechange(int id, int index, int newValue, int oldValue)
  2332. {
  2333. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2334. {
  2335. int deltay = newValue - oldValue;
  2336. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Move(0, deltay);
  2337. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2338. //pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2339. this.documentWorkspace.Refresh();
  2340. }
  2341. }
  2342. /// <summary>
  2343. ///
  2344. /// </summary>
  2345. /// <param name="sender"></param>
  2346. /// <param name="e"></param>
  2347. public DrawObject numericUpDown5_ValueChange(int id, int index, int value)
  2348. {
  2349. double pxPerUnit = this.imgPxPerUnit;
  2350. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2351. {
  2352. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2353. //if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType == DrawToolType.ViewTriangle)
  2354. //{
  2355. // this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].endPoint.Y = (float)(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].startPoint.Y + value / pxPerUnit);
  2356. // this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].MoveHandleTo(new System.Drawing.Point((int)this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].endPoint.X, (int)this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].endPoint.Y), 2);
  2357. // //this.pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2358. //}
  2359. //else
  2360. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType == DrawToolType.ViewSquare || this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType == DrawToolType.ViewCircle)
  2361. {
  2362. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2363. }
  2364. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2365. var obj = this.documentWorkspace.GraphicsList.GetById(id);
  2366. if (obj != null)
  2367. {
  2368. obj.Width= this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Width;
  2369. obj.Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Height;
  2370. obj.Normalize();
  2371. }
  2372. //this.rectangleF[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle;
  2373. this.documentWorkspace.Refresh();
  2374. return this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index];
  2375. }
  2376. return null;
  2377. }
  2378. /// <summary>
  2379. ///
  2380. /// </summary>
  2381. /// <param name="sender"></param>
  2382. /// <param name="e"></param>
  2383. public DrawObject numericUpDown6_ValueChange(int id, int index, int value)
  2384. {
  2385. double pxPerUnit = this.imgPxPerUnit;
  2386. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2387. {
  2388. var type = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType;
  2389. switch (type)
  2390. {
  2391. case DrawToolType.ViewOval:
  2392. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2393. break;
  2394. case DrawToolType.ViewCircle:
  2395. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = ((float)Math.Pow((value / Math.PI), 0.5)) * 2;
  2396. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width;
  2397. break;
  2398. case DrawToolType.ViewRectangle:
  2399. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2400. break;
  2401. case DrawToolType.ViewTriangle:
  2402. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2403. break;
  2404. case DrawToolType.ViewSquare:
  2405. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (float)(Math.Sqrt(value) / pxPerUnit);
  2406. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = (float)(Math.Sqrt(value) / pxPerUnit);
  2407. break;
  2408. case DrawToolType.ViewPolygon:
  2409. case DrawToolType.ViewTriangleEx:
  2410. case DrawToolType.ViewRectangleEx:
  2411. break;
  2412. }
  2413. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2414. var obj = this.documentWorkspace.GraphicsList.GetById(id);
  2415. if (obj != null)
  2416. {
  2417. obj.Width = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Width;
  2418. obj.Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Height;
  2419. obj.Normalize();
  2420. }
  2421. //this.rectangleF[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle;
  2422. this.documentWorkspace.Refresh();
  2423. return this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index];
  2424. }
  2425. return null;
  2426. }
  2427. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  2428. {
  2429. this.chooseIndex = this.comboBox2.SelectedIndex;
  2430. }
  2431. private void Panel_Click(object sender, MouseEventArgs e)
  2432. {
  2433. if (this.chooseIndex == -1)
  2434. {
  2435. return;
  2436. }
  2437. if (this.addView) {
  2438. return;
  2439. }
  2440. if (bcBinaryChecked())
  2441. {
  2442. MessageBox.Show("请取消二值化后再添加!");
  2443. return;
  2444. }
  2445. var name = this.comboBox2.SelectedItem.ToString();
  2446. try
  2447. {
  2448. var model = this.modelList[this.chooseIndex];
  2449. if (e.Button == MouseButtons.Left)
  2450. {
  2451. System.Drawing.Point loc = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  2452. DrawToolType type = (DrawToolType)Enum.Parse(typeof(DrawToolType), model.Type);
  2453. ViewBase line = null;
  2454. List<PointF> pointFList = new List<PointF>();
  2455. foreach (var s in model.Points)
  2456. {
  2457. if (model.Points.IndexOf(s) == 0)
  2458. {
  2459. pointFList.Add(new PointF(loc.X, loc.Y));
  2460. continue;
  2461. }
  2462. var xDifference = model.Points[0].X - s.X;
  2463. var yDifference = model.Points[0].Y - s.Y;
  2464. pointFList.Add(new PointF(loc.X - xDifference, loc.Y - yDifference));
  2465. }
  2466. switch (type)
  2467. {
  2468. case DrawToolType.ViewOval:
  2469. line = new ViewOval(pointFList);
  2470. break;
  2471. case DrawToolType.ViewCircle:
  2472. line = new ViewCircle(pointFList);
  2473. break;
  2474. case DrawToolType.ViewRectangle:
  2475. line = new ViewRectangle(pointFList);
  2476. break;
  2477. case DrawToolType.ViewTriangle:
  2478. line = new ViewTriangle(pointFList);
  2479. break;
  2480. case DrawToolType.ViewSquare:
  2481. line = new ViewSquare(pointFList);
  2482. break;
  2483. case DrawToolType.ViewPolygon:
  2484. case DrawToolType.ViewTriangleEx:
  2485. line = new ViewPolygon(pointFList);
  2486. break;
  2487. case DrawToolType.ViewRectangleEx:
  2488. line = new ViewRectangleEx(pointFList);
  2489. break;
  2490. }
  2491. if (line != null)
  2492. {
  2493. line.ISurfaceBox = documentWorkspace;
  2494. line.combineMode = (CombineMode)Enum.Parse(typeof(CombineMode), model.CombineMode);
  2495. line.Selected = true;
  2496. line.Color = retrunColor(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count);
  2497. //pointFDic.Add(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count, pointFList.ToArray());
  2498. this.oldDrawList.Add(line);
  2499. nameList.Add($"{name}-{nameList.Count()}");
  2500. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Insert(0, line);
  2501. documentWorkspace.AddGraphicsFromForm(line);
  2502. //this.rectangleF.Add(line.Rectangle);
  2503. this.rectangleTypeList.Add(line.drawToolType);
  2504. if (this.bcBinaryChecked())
  2505. {
  2506. clearAllView();
  2507. btn_statistics_Click();
  2508. getAllView();
  2509. list_add_data();
  2510. }
  2511. }
  2512. }
  2513. else
  2514. {
  2515. this.comboBox2.SelectedIndex = -1;
  2516. this.chooseIndex = -1;
  2517. }
  2518. }
  2519. catch (Exception ex)
  2520. {
  2521. }
  2522. }
  2523. private void Panel_Paint(object sender, PaintEventArgs e)
  2524. {
  2525. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2526. int wid = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Width : this.documentWorkspace.CompositionSurface.Width;
  2527. int hei = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Height : this.documentWorkspace.CompositionSurface.Height;
  2528. int width = (int)(wid * this.documentWorkspace.ScaleFactor.Ratio);
  2529. int height = (int)(hei * this.documentWorkspace.ScaleFactor.Ratio);
  2530. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
  2531. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
  2532. e.Graphics.TranslateTransform(x, y);
  2533. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2534. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2535. {
  2536. var jiacu = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s) == chooseGrIndex ? 10 : 5;
  2537. var pen = new Pen(s.Color, jiacu);
  2538. switch (s.drawToolType)
  2539. {
  2540. case DrawToolType.ViewOval:
  2541. case DrawToolType.ViewCircle:
  2542. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2543. {
  2544. e.Graphics.DrawClosedCurve(pen, this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].pointArrayList.ToArray());
  2545. }
  2546. break;
  2547. case DrawToolType.ViewSquare:
  2548. case DrawToolType.ViewRectangle:
  2549. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2550. {
  2551. var rectangle = this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].Rectangle;
  2552. e.Graphics.DrawRectangle(pen, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
  2553. }
  2554. break;
  2555. case DrawToolType.ViewRectangleEx:
  2556. case DrawToolType.ViewPolygon:
  2557. case DrawToolType.ViewTriangle:
  2558. case DrawToolType.ViewTriangleEx:
  2559. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2560. {
  2561. var pointF = this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].pointArrayList.ToArray();
  2562. if (pointF != null && pointF.Count() > 1)
  2563. {
  2564. e.Graphics.DrawPolygon(pen, pointF);
  2565. }
  2566. }
  2567. break;
  2568. }
  2569. }
  2570. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2571. e.Graphics.TranslateTransform(-x, -y);
  2572. }
  2573. private Color retrunColor(int index)
  2574. {
  2575. switch ((index + 1) % 12)
  2576. {
  2577. case 1:
  2578. return Color.FromArgb(ViewSetting.colorFirst);
  2579. case 2:
  2580. return Color.FromArgb(ViewSetting.colorSecond);
  2581. case 3:
  2582. return Color.FromArgb(ViewSetting.colorThird);
  2583. case 4:
  2584. return Color.FromArgb(ViewSetting.colorFourth);
  2585. case 5:
  2586. return Color.FromArgb(ViewSetting.colorFifth);
  2587. case 6:
  2588. return Color.FromArgb(ViewSetting.colorSixth);
  2589. case 7:
  2590. return Color.FromArgb(ViewSetting.colorSeventh);
  2591. case 8:
  2592. return Color.FromArgb(ViewSetting.colorEighth);
  2593. case 9:
  2594. return Color.FromArgb(ViewSetting.colorNinth);
  2595. case 10:
  2596. return Color.FromArgb(ViewSetting.colorTenth);
  2597. case 11:
  2598. return Color.FromArgb(ViewSetting.colorEleventh);
  2599. case 12:
  2600. return Color.FromArgb(ViewSetting.colorTwelfth);
  2601. }
  2602. return Color.FromArgb(ViewSetting.colorFirst);
  2603. }
  2604. #endregion [跳转视场设置相关方法]
  2605. private void button2_Click(object sender, EventArgs e)
  2606. {
  2607. if (bcBinaryChecked()) {
  2608. MessageBox.Show("请取消二值化后再拖动视场或者添加视场!");
  2609. return;
  2610. }
  2611. this.addView = !this.addView;
  2612. if (!this.addView)
  2613. {
  2614. this.button2.Text = "取消添加视场";
  2615. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  2616. }
  2617. else {
  2618. this.button2.Text = "添加视场";
  2619. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  2620. }
  2621. }
  2622. private void getLastData()
  2623. {
  2624. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterPorosityModel.xml";
  2625. var text = this.dialogText;
  2626. if (!System.IO.File.Exists(filePath))
  2627. {
  2628. porosityModel.PorosityParameters = new List<PorosityModel.PorosityParameter>();
  2629. string[] textList = new string[] { "PV6093", "VW50093", "VDGP202", "GBT37787" };
  2630. for (int i = 0; i < textList.Count(); i++)
  2631. {
  2632. var porosityParameters = new PorosityModel.PorosityParameter();
  2633. porosityParameters.hasUsed = false;
  2634. porosityParameters.name = textList[i];
  2635. porosityModel.PorosityParameters.Add(porosityParameters);
  2636. }
  2637. this.thisParametersIndex = textList.ToList().IndexOf(text);
  2638. this.thisParameters = porosityModel.PorosityParameters[this.thisParametersIndex];
  2639. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2640. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2641. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2642. }
  2643. else
  2644. {
  2645. porosityModel = XmlSerializeHelper.DESerializer<PorosityModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  2646. if (porosityModel.PorosityParameters == null)
  2647. {
  2648. porosityModel.PorosityParameters = new List<PorosityModel.PorosityParameter>();
  2649. }
  2650. thisParameters = porosityModel.PorosityParameters.Where(m => m.name.Equals(text)).FirstOrDefault();
  2651. if (thisParameters == null)
  2652. {
  2653. thisParameters = new PorosityModel.PorosityParameter();
  2654. thisParameters.hasUsed = false;
  2655. thisParameters.name = text;
  2656. porosityModel.PorosityParameters.Add(thisParameters);
  2657. this.thisParametersIndex = porosityModel.PorosityParameters.Count() - 1;
  2658. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2659. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2660. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2661. }
  2662. else
  2663. {
  2664. this.thisParametersIndex = porosityModel.PorosityParameters.IndexOf(thisParameters);
  2665. if (thisParameters.hasUsed)
  2666. {
  2667. checkBox_generateReport_opensetting.Checked = thisParameters.parameter1;
  2668. domainUpDown_resultPrecision.SelectedIndex = thisParameters.parameter2;
  2669. }
  2670. }
  2671. }
  2672. }
  2673. private void saveLastData(object sender, EventArgs e)
  2674. {
  2675. #region [开启脚本录制]
  2676. if (appWorkspace.startScriptRecording)
  2677. {
  2678. getScriptRecording();
  2679. }
  2680. #endregion
  2681. binaryClass.saveParams();
  2682. if (this.thisParametersIndex == -1)
  2683. {
  2684. return;
  2685. }
  2686. this.thisParameters.hasUsed = true;
  2687. thisParameters.parameter1 = checkBox_generateReport_opensetting.Checked;
  2688. thisParameters.parameter2 = domainUpDown_resultPrecision.SelectedIndex;
  2689. this.porosityModel.PorosityParameters[this.thisParametersIndex] = this.thisParameters;
  2690. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterPorosityModel.xml";
  2691. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2692. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2693. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2694. }
  2695. /// <summary>
  2696. /// 应用全部
  2697. /// </summary>
  2698. /// <param name="sender"></param>
  2699. /// <param name="e"></param>
  2700. private void button4_Click(object sender, EventArgs e)
  2701. {
  2702. if (this.lstView_img.FocusedItem == null)
  2703. {
  2704. return;
  2705. }
  2706. binaryClass.saveParams();
  2707. binaryClass.applyToAll(this.imageList_img.Images.Keys, this.imageList_img.Images.Keys[this.lstView_img.FocusedItem.Index]);
  2708. userAll = true;
  2709. resultList.Clear();
  2710. hasResultIndexList.Clear();
  2711. analysisResults.Clear();
  2712. //var data = new CurrentPageData();
  2713. var firstIndex = this.lstView_img.FocusedItem.Index;
  2714. //if (everyImgData.ContainsKey(this.lstView_img.FocusedItem.Index))
  2715. //{
  2716. // data = everyImgData[this.lstView_img.FocusedItem.Index];
  2717. //}
  2718. nodata = true;
  2719. for (int i = 0; i < lstView_img.Items.Count; i++)
  2720. {
  2721. this.lstView_img.Items[i].EnsureVisible();
  2722. this.lstView_img.Items[i].Focused = true;
  2723. this.lstView_img.Items[i].Selected = true;
  2724. this.btn_saveresult_Click(sender, e);
  2725. }
  2726. nodata = false;
  2727. }
  2728. /// <summary>
  2729. /// 保存全部
  2730. /// </summary>
  2731. /// <param name="sender"></param>
  2732. /// <param name="e"></param>
  2733. private void button5_Click(object sender, EventArgs e)
  2734. {
  2735. if (this.lstView_img.FocusedItem == null)
  2736. {
  2737. return;
  2738. }
  2739. if (!userAll) {
  2740. MessageBox.Show("请先点击应用全部");
  2741. return;
  2742. }
  2743. if (resultList.Count() == 0)
  2744. {
  2745. MessageBox.Show("无结果数据!");
  2746. return;
  2747. }
  2748. if (listBox_analysisResult.Items.Count > 0)
  2749. {
  2750. if (MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  2751. {
  2752. for (int i = 0; i < resultList.Count(); i++)
  2753. {
  2754. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[i]))
  2755. {
  2756. continue;
  2757. }
  2758. else
  2759. {
  2760. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[i], resultList[i]);
  2761. }
  2762. buildListBox_analysisResult();
  2763. }
  2764. return;
  2765. }
  2766. }
  2767. for (int i = 0; i < resultList.Count(); i++)
  2768. {
  2769. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[i]))
  2770. {
  2771. analysisResults[this.appWorkspace.DocumentWorkspaces[i]] = resultList[i];
  2772. }
  2773. else
  2774. {
  2775. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[i], resultList[i]);
  2776. }
  2777. buildListBox_analysisResult();
  2778. }
  2779. for (int i = 0; i < listBox_analysisResult.Items.Count; i++) {
  2780. listBox_analysisResult.SetItemChecked(i, true);
  2781. }
  2782. buildListView_analysisResult();
  2783. }
  2784. private void getValue(string key, object value)
  2785. {
  2786. switch (key)
  2787. {
  2788. case "OpenWhileExportReport":
  2789. checkBox_generateReport_opensetting.Checked = Convert.ToBoolean(value);
  2790. break;
  2791. case "CalculatorDecimalDigits":
  2792. domainUpDown_resultPrecision.SelectedIndex = (int)value;
  2793. break;
  2794. case "ExportResults":
  2795. isExportResults = Convert.ToBoolean(value);
  2796. break;
  2797. case "ExportReports":
  2798. isExportReports = Convert.ToBoolean(value);
  2799. break;
  2800. case "ExportProjects":
  2801. isExportProjects = Convert.ToBoolean(value);
  2802. break;
  2803. }
  2804. }
  2805. #region [脚本录制]
  2806. private void getScriptRecording()
  2807. {
  2808. string className = InvariantData.path_Action + ".Action" + menuId;
  2809. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  2810. List<Args> args = param.Lists;
  2811. foreach (var item in args)
  2812. {
  2813. item.value = setScriptRecording(item.key);
  2814. }
  2815. //找出子类相关参数 进行赋值
  2816. List<Args> oneIsNullList = args.Where(m => m.value == null).ToList();
  2817. foreach (var item in oneIsNullList)
  2818. {
  2819. this.argsKey = item.key;
  2820. this.setArgsValue();
  2821. item.value = this.argsValue;
  2822. }
  2823. //找出二值相关参数 进行赋值
  2824. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  2825. foreach (var item in isNullList)
  2826. {
  2827. item.value = binaryClass.setScriptRecording(item.key);
  2828. }
  2829. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  2830. }
  2831. private object setScriptRecording(string key)
  2832. {
  2833. object value = null;
  2834. switch (key)
  2835. {
  2836. case "OpenWhileExportReport":
  2837. value = checkBox_generateReport_opensetting.Checked;
  2838. break;
  2839. case "CalculatorDecimalDigits":
  2840. value = this.domainUpDown_resultPrecision.SelectedItem;
  2841. break;
  2842. case "ExportResults":
  2843. value = isExportResults;
  2844. break;
  2845. case "ExportReports":
  2846. value = isExportReports;
  2847. break;
  2848. case "ExportProjects":
  2849. value = isExportProjects;
  2850. break;
  2851. }
  2852. return value;
  2853. }
  2854. #endregion
  2855. }
  2856. }