PorosityStandardDialog.cs 141 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223
  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 Mat imageMat;
  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(this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreatedAliasedMat().Clone(), 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.groupBox_review.Controls.Add(this.documentWorkspace);
  1147. //
  1148. //初始化操作按钮
  1149. //
  1150. this.commonControlButtons = new CommonControlButtons();
  1151. this.commonControlButtons.Dock = DockStyle.Top;
  1152. this.commonControlButtons.Height = 30;
  1153. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1154. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1155. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1156. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1157. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1158. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1159. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1160. groupBox_review.Controls.Add(this.commonControlButtons);
  1161. //this.binaryExtractionModel.ColorInterval = 1;
  1162. // 初始化报告列表
  1163. this.listView_analysisResult.View = View.Details;
  1164. this.listView_analysisResult2.View = View.Details;
  1165. this.listBox_analysisResult.DisplayMember = "Display";
  1166. this.listBox_analysisResult.ValueMember = "Value";
  1167. documentWorkspace.panel.MouseDown += Panel_Click;
  1168. }
  1169. #endregion 初始化组件
  1170. #region 事件
  1171. #region 公共按钮
  1172. private void zoomInButton_Click(object sender, EventArgs e)
  1173. {
  1174. this.documentWorkspace.ZoomIn();
  1175. }
  1176. private void zoomOutButton_Click(object sender, EventArgs e)
  1177. {
  1178. this.documentWorkspace.ZoomOut();
  1179. }
  1180. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1181. {
  1182. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1183. }
  1184. private void actualSizeButton_Click(object sender, EventArgs e)
  1185. {
  1186. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1187. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1188. }
  1189. private void pointerButton_Click(object sender, EventArgs e)
  1190. {
  1191. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  1192. }
  1193. private void mobileModeButton_Click(object sender, EventArgs e)
  1194. {
  1195. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1196. }
  1197. #endregion 公共按钮
  1198. private void button_setting_Click(object sender, EventArgs e)
  1199. {
  1200. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1201. if (recombinationRateSetDialog.hasModule)
  1202. {
  1203. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1204. recombinationRateSetDialog.ShowDialog();
  1205. }
  1206. else
  1207. {
  1208. recombinationRateSetDialog = null;
  1209. }
  1210. }
  1211. private void btn_saveresult_Click(object sender, EventArgs e)
  1212. {
  1213. if (this.lstView_img.FocusedItem == null || this.lstView_img.FocusedItem.Index == -1)
  1214. {
  1215. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  1216. return;
  1217. }
  1218. //二值化
  1219. if (!bcBinaryChecked())
  1220. {
  1221. if (!userAll)
  1222. {
  1223. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
  1224. }
  1225. return;
  1226. }
  1227. if (this.tempAnalysisResult == null)
  1228. {
  1229. if (!userAll)
  1230. {
  1231. MessageBox.Show(PdnResources.GetString("Menu.Nodatatosave.text"));
  1232. }
  1233. return;
  1234. }
  1235. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]))
  1236. {
  1237. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1238. if (dr == DialogResult.OK)
  1239. {
  1240. dict[this.lstView_img.FocusedItem.Text] = this.tempAnalysisResult.phaseModels;
  1241. analysisResults[this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]] = this.tempAnalysisResult;
  1242. buildListBox_analysisResult();
  1243. save_normal_data();
  1244. }
  1245. return;
  1246. }
  1247. if (dict.ContainsKey(this.lstView_img.FocusedItem.Text))
  1248. {
  1249. dict[this.lstView_img.FocusedItem.Text] = this.documentWorkspace.phaseModels;
  1250. }
  1251. else
  1252. {
  1253. dict.Add(this.lstView_img.FocusedItem.Text, this.documentWorkspace.phaseModels);
  1254. }
  1255. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index], this.tempAnalysisResult);
  1256. if (userAll)
  1257. {
  1258. if (hasResultIndexList.IndexOf(this.lstView_img.FocusedItem.Index) == -1)
  1259. {
  1260. resultList.Add(this.tempAnalysisResult);
  1261. hasResultIndexList.Add(this.lstView_img.FocusedItem.Index);
  1262. }
  1263. else
  1264. {
  1265. resultList[this.lstView_img.FocusedItem.Index] = this.tempAnalysisResult;
  1266. }
  1267. }
  1268. if (!nodata)
  1269. {
  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. {
  1280. saveEveryImgData();
  1281. }
  1282. this.tempAnalysisResult = null;
  1283. this.documentWorkspace.Document = Document.FromImageMat(this.documentItems[this.lstView_img.FocusedItem.Index].imageMat);
  1284. this.documentWorkspace.Visible = true;
  1285. this.imgPxPerUnit = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1286. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  1287. this.methodOfAssessment = getMethodOfAssessment();
  1288. MethodOfAssessment.activeMethod = this.methodOfAssessment;
  1289. SetAnalyzeModelFromXml(this.methodOfAssessment.resourcesName);
  1290. if (this.bcBinaryChecked())
  1291. {
  1292. this.documentWorkspace.ActiveTool = DrawToolType.InclusionNoEffect;
  1293. }
  1294. else
  1295. {
  1296. if (this.addView)
  1297. {
  1298. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1299. }
  1300. else
  1301. {
  1302. this.documentWorkspace.ActiveTool = DrawToolType.InclusionNoEffect;
  1303. }
  1304. }
  1305. this.originalPhaseModels = this.documentItems[this.lstView_img.FocusedItem.Index].originalPhaseModels;
  1306. clearAllView();
  1307. this.nameList.Clear();
  1308. this.rectangleF.Clear();
  1309. this.rectangleTypeList.Clear();
  1310. //二值化集成4
  1311. if (firstChoose == 0)
  1312. {
  1313. //获取所有外部保存的视场
  1314. InitViewData();
  1315. }
  1316. binaryClass.RefreshHistogramControl1Values();
  1317. if (selectPicture != -1)
  1318. {
  1319. this.binaryClass.saveMat(this.imageList_img.Images.Keys[selectPicture]);
  1320. }
  1321. selectPicture = this.lstView_img.FocusedItem.Index;
  1322. var gList = new GraphicsList();
  1323. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count != 0)
  1324. {
  1325. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  1326. {
  1327. gList.Add(s.Clone(this.documentWorkspace));
  1328. }
  1329. }
  1330. else
  1331. {
  1332. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.Count; i++)
  1333. {
  1334. var obj = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList[i].Clone(this.documentWorkspace);
  1335. gList.Add(obj);
  1336. }
  1337. }
  1338. var b = appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList == this.documentWorkspace.GraphicsList;
  1339. binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), this.imageList_img.Images.Keys[selectPicture]);
  1340. this.documentWorkspace.GraphicsList = gList;
  1341. getViewMethod();
  1342. bClassBinaryImplFinishAction(sender, e);
  1343. this.documentWorkspace.Refresh();
  1344. firstChoose += 1;
  1345. this.ImgName = this.lstView_img.FocusedItem.Name;
  1346. getEveryImgData();
  1347. }
  1348. else
  1349. {
  1350. this.documentWorkspace.Visible = false;
  1351. }
  1352. }
  1353. #region [二值化相关方法]
  1354. /// <summary>
  1355. /// 添加参数改变的监听
  1356. /// </summary>
  1357. /// <param name="sender"></param>
  1358. /// <param name="e"></param>
  1359. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1360. {
  1361. this.binaryClass.loadParams();
  1362. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  1363. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1364. this.startScriptAutomaticAction();
  1365. }
  1366. /// <summary>
  1367. /// 参数改变时,重新处理图像
  1368. /// </summary>
  1369. /// <param name="sender"></param>
  1370. /// <param name="e"></param>
  1371. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1372. {
  1373. this.originalPhaseModels = this.documentWorkspace.phaseModels.Where(m => m.choise == true).ToList();
  1374. if (!bcOriginChecked())
  1375. {
  1376. if (bcBinaryChecked())
  1377. {
  1378. clearAllView();
  1379. getAllView();
  1380. btn_statistics_Click();
  1381. list_add_data();
  1382. }
  1383. else
  1384. {
  1385. clearAllView();
  1386. }
  1387. }
  1388. else
  1389. {
  1390. clearAllView();
  1391. }
  1392. this.documentWorkspace.Refresh();
  1393. }
  1394. public bool bcBinaryChecked()
  1395. {
  1396. if (this.addView && !bc.BinaryChecked)
  1397. {
  1398. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1399. }
  1400. else
  1401. {
  1402. this.documentWorkspace.ActiveTool = DrawToolType.InclusionNoEffect;
  1403. }
  1404. return bc != null && bc.BinaryChecked;
  1405. }
  1406. private bool bcOriginChecked()
  1407. {
  1408. return bc != null && bc.OriginChecked;
  1409. }
  1410. /// <summary>
  1411. /// 显示原图/原图+二值图
  1412. /// </summary>
  1413. /// <param name="sender"></param>
  1414. /// <param name="e"></param>
  1415. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1416. {
  1417. if (!bcOriginChecked())
  1418. {
  1419. if (bcBinaryChecked())
  1420. this.documentWorkspace.PhaseModels[0].choise = true;
  1421. }
  1422. else
  1423. {
  1424. this.documentWorkspace.PhaseModels[0].choise = false;
  1425. }
  1426. this.originalPhaseModels = this.documentWorkspace.phaseModels.Where(m => m.choise == true).ToList();
  1427. if (!bcOriginChecked())
  1428. {
  1429. if (bcBinaryChecked())
  1430. {
  1431. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = true;
  1432. getAllView();
  1433. list_add_data();
  1434. }
  1435. else
  1436. {
  1437. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = false;
  1438. clearAllView();
  1439. }
  1440. }
  1441. else
  1442. {
  1443. this.documentItems[this.lstView_img.FocusedItem.Index].isErZhi = false;
  1444. clearAllView();
  1445. }
  1446. this.documentWorkspace.Refresh();
  1447. }
  1448. #endregion [二值化相关方法]
  1449. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  1450. {
  1451. buildListView_analysisResult();
  1452. }
  1453. private void button_all_Click(object sender, EventArgs e)
  1454. {
  1455. for (int i = 0; i < this.listBox_analysisResult.Items.Count; i++)
  1456. {
  1457. this.listBox_analysisResult.SetItemChecked(i, true);
  1458. }
  1459. buildListView_analysisResult();
  1460. }
  1461. #endregion 事件
  1462. #region 内部方法
  1463. private void buildListBox_analysisResult()
  1464. {
  1465. this.listBox_analysisResult.Items.Clear();
  1466. foreach (var item in analysisResults.Keys)
  1467. {
  1468. this.listBox_analysisResult.Items.Add(new LocalListViewItem(item, item.GetFriendlyName()));
  1469. }
  1470. buildListView_analysisResult();
  1471. }
  1472. private List<ListViewItem> buildAnalysisResults(DocumentWorkspace workspace, AnalysisResult analysisResult)
  1473. {
  1474. List<ListViewItem> listViews = new List<ListViewItem>();
  1475. foreach (var fieldOfView in analysisResult.resultBody.Keys)
  1476. {
  1477. ListViewItem lvi = new ListViewItem();
  1478. lvi.Text = workspace.GetFriendlyName();
  1479. lvi.SubItems.Add(fieldOfView.name);
  1480. foreach (var item in analysisResult.resultBody[fieldOfView])
  1481. {
  1482. try
  1483. {
  1484. int num = 2;
  1485. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1486. {
  1487. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1488. }
  1489. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(item), num).ToString());
  1490. }
  1491. catch (Exception ex)
  1492. {
  1493. lvi.SubItems.Add(item);
  1494. }
  1495. }
  1496. listViews.Add(lvi);
  1497. }
  1498. return listViews;
  1499. }
  1500. private void buildListView_analysisResult()
  1501. {
  1502. List<AnalysisResult> conclusions = new List<AnalysisResult>();
  1503. this.listView_analysisResult.Columns.Clear();
  1504. this.listView_analysisResult.Items.Clear();
  1505. this.listView_analysisResult2.Columns.Clear();
  1506. this.listView_analysisResult2.Items.Clear();
  1507. if (analysisResults.Count == 0)
  1508. {
  1509. return;
  1510. }
  1511. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  1512. {
  1513. return;
  1514. }
  1515. this.listView_analysisResult.BeginUpdate();
  1516. // 构建头
  1517. foreach (var item in analysisResults.First().Value.getResultHead())
  1518. {
  1519. ColumnHeader header = new ColumnHeader();
  1520. header.Text = item;
  1521. header.Width = 150;
  1522. this.listView_analysisResult.Columns.Add(header);
  1523. }
  1524. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1525. {
  1526. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  1527. this.listView_analysisResult.Items.AddRange(buildAnalysisResults(workspace, analysisResults[workspace]).ToArray());
  1528. conclusions.Add(analysisResults[workspace]);
  1529. }
  1530. this.listView_analysisResult.EndUpdate();
  1531. if (this.listView_analysisResult.Items.Count > 0)
  1532. {
  1533. this.listView_analysisResult.Items[0].Selected = true;
  1534. }
  1535. // 构建头
  1536. foreach (var item in this.methodOfAssessment.getResultConclusionHead())
  1537. {
  1538. ColumnHeader header = new ColumnHeader();
  1539. header.Text = item;
  1540. header.Width = 150;
  1541. this.listView_analysisResult2.Columns.Add(header);
  1542. }
  1543. ListViewItem lvi = new ListViewItem();
  1544. List<string> strings = this.methodOfAssessment.buildResultConclusion(conclusions, porosityConfig);
  1545. //保留小数点
  1546. try
  1547. {
  1548. int num = 2;
  1549. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1550. {
  1551. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1552. }
  1553. lvi.Text = Math.Round(Convert.ToDecimal(strings[0]), num).ToString();
  1554. }
  1555. catch (Exception ex)
  1556. {
  1557. lvi.Text = strings[0];
  1558. }
  1559. for (int i = 1; i < strings.Count; i++)
  1560. {
  1561. try
  1562. {
  1563. int num = 2;
  1564. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1565. {
  1566. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1567. }
  1568. if (strings[i].Contains("±"))
  1569. {
  1570. strings[i] = strings[i].Replace("±", "");
  1571. lvi.SubItems.Add("±" + Math.Round(Convert.ToDecimal(strings[i]), num).ToString());
  1572. }
  1573. else
  1574. {
  1575. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(strings[i]), num).ToString());
  1576. }
  1577. }
  1578. catch (Exception ex)
  1579. {
  1580. lvi.SubItems.Add(strings[i]);
  1581. }
  1582. }
  1583. this.listView_analysisResult2.Items.Add(lvi);
  1584. this.listView_analysisResult2.EndUpdate();
  1585. }
  1586. private void button_generateReport_Click(object sender, EventArgs e)
  1587. {
  1588. if (this.listView_analysisResult.Items.Count == 0)
  1589. {
  1590. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1591. return;
  1592. }
  1593. if (this.checkBox_generateReport_opensetting.Checked)
  1594. {
  1595. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1596. if (recombinationRateSetDialog.hasModule)
  1597. {
  1598. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1599. recombinationRateSetDialog.ShowDialog();
  1600. }
  1601. else
  1602. {
  1603. recombinationRateSetDialog = null;
  1604. }
  1605. }
  1606. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1607. {
  1608. //获取word书签与excel单元格的关系,以字典方式存储
  1609. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1610. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1611. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1612. {
  1613. foreach (mic_module_infos info in mic_module_infos)
  1614. {
  1615. tagInfos.Add(info.tag_name, info.cell_position);
  1616. }
  1617. }
  1618. List<List<List<string>>> sheets = new List<List<List<string>>>();
  1619. sheets.Add(new List<List<string>>());
  1620. List<List<string>> contentList = new List<List<string>>();
  1621. List<string> contentHead = new List<string>();
  1622. contentList.Add(contentHead);
  1623. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  1624. {
  1625. contentHead.Add(c.Text);
  1626. }
  1627. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  1628. {
  1629. List<string> contentBody = new List<string>();
  1630. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  1631. {
  1632. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  1633. }
  1634. contentList.Add(contentBody);
  1635. }
  1636. contentList.Add(new List<string>());
  1637. contentHead = new List<string>();
  1638. contentList.Add(contentHead);
  1639. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  1640. {
  1641. contentHead.Add(c.Text);
  1642. }
  1643. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  1644. {
  1645. List<string> contentBody = new List<string>();
  1646. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  1647. {
  1648. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  1649. }
  1650. contentList.Add(contentBody);
  1651. }
  1652. sheets.Add(contentList);
  1653. sheets.Add(new List<List<string>>());
  1654. List<Bitmap> bitList = new List<Bitmap>();
  1655. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1656. {
  1657. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  1658. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1659. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  1660. originalBit.Tag = pantographRatio;
  1661. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1662. newBit.Tag = pantographRatio;
  1663. Graphics graphics = Graphics.FromImage(newBit);
  1664. foreach (var phase in dict[((LocalListViewItem)item).Display])
  1665. {
  1666. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  1667. graphics.DrawImage(processedBit, new PointF(0, 0));
  1668. }
  1669. bitList.Add(originalBit);
  1670. bitList.Add(newBit);
  1671. }
  1672. try
  1673. {
  1674. this.appWorkspace.CreateAnalysisReportInclusion(this.analyzeSettingModel, sheets, bitList, tagInfos);
  1675. }
  1676. catch (Exception ex)
  1677. {
  1678. MessageBox.Show(ex.Message);
  1679. }
  1680. }
  1681. else
  1682. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1683. }
  1684. private void button_exportResults_Click(object sender, EventArgs e)
  1685. {
  1686. if (this.listView_analysisResult.Items.Count == 0)
  1687. {
  1688. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1689. return;
  1690. }
  1691. try
  1692. {
  1693. SaveFileDialog exe = new SaveFileDialog();
  1694. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1695. exe.FilterIndex = 0;
  1696. exe.RestoreDirectory = true;
  1697. exe.Title = "Export Excel File";
  1698. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1699. exe.FileName = DateTime.Now.ToString("yyyyMMddHHmmss") + this.methodOfAssessment.fileName;
  1700. DialogResult dr = exe.ShowDialog();
  1701. if (dr != DialogResult.OK)
  1702. {
  1703. return;
  1704. }
  1705. DataTable dtb = new DataTable();
  1706. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  1707. {
  1708. dtb.Columns.Add(c.Text);
  1709. }
  1710. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  1711. {
  1712. DataRow dataRow = dtb.NewRow();
  1713. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  1714. {
  1715. dataRow[c] = this.listView_analysisResult.Items[r].SubItems[c].Text;
  1716. }
  1717. dtb.Rows.Add(dataRow);
  1718. }
  1719. DataTable dtb1 = new DataTable();
  1720. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  1721. {
  1722. dtb1.Columns.Add(c.Text);
  1723. }
  1724. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  1725. {
  1726. DataRow dataRow = dtb1.NewRow();
  1727. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  1728. {
  1729. dataRow[c] = this.listView_analysisResult2.Items[r].SubItems[c].Text;
  1730. }
  1731. dtb1.Rows.Add(dataRow);
  1732. }
  1733. List<DataTable> list = new List<DataTable>();
  1734. list.Add(dtb);
  1735. list.Add(dtb1);
  1736. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1737. }
  1738. catch (Exception ex)
  1739. {
  1740. MessageBox.Show(ex.Message);
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 初始化参数配置下拉
  1745. /// </summary>
  1746. public void InitParameterList(int index = 0)
  1747. {
  1748. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\");
  1749. files.Clear();
  1750. foreach (string fileName in fileNames)
  1751. {
  1752. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  1753. files.Add(name);
  1754. }
  1755. string nowModelName = Startup.instance.configModel.BinaryParameter.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  1756. this.binaryExtractionModel = XmlSerializeHelper.DESerializer<BinaryExtractionModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\Default.xml", FileMode.Open));/*" + this.comboBox1.SelectedItem.ToString() + "*///##############
  1757. }
  1758. #endregion 内部方法
  1759. #region 需继承方法
  1760. protected virtual void getAllView()
  1761. {
  1762. //throw new NotImplementedException();
  1763. }
  1764. protected virtual void SubclassInitialize()
  1765. {
  1766. //throw new NotImplementedException();
  1767. }
  1768. protected virtual MethodOfAssessment getMethodOfAssessment()
  1769. {
  1770. throw new NotImplementedException();
  1771. }
  1772. protected virtual void initColorSetting()
  1773. {
  1774. //throw new NotImplementedException();
  1775. }
  1776. protected virtual void initDisplaySetting()
  1777. {
  1778. //throw new NotImplementedException();
  1779. }
  1780. protected virtual void clearAllView()
  1781. {
  1782. //throw new NotImplementedException();
  1783. }
  1784. protected virtual void list_add_data()
  1785. {
  1786. //throw new NotImplementedException();
  1787. }
  1788. protected virtual void save_normal_data()
  1789. {
  1790. //throw new NotImplementedException();
  1791. }
  1792. protected virtual void toView()
  1793. {
  1794. //throw new NotImplementedException();
  1795. }
  1796. protected virtual void clearOneView()
  1797. {
  1798. }
  1799. protected virtual void changeOneViewColor()
  1800. {
  1801. }
  1802. protected virtual void getArgsValue()
  1803. {
  1804. }
  1805. protected virtual void setArgsValue()
  1806. {
  1807. }
  1808. protected virtual void getEveryImgData()
  1809. {
  1810. }
  1811. protected virtual void saveEveryImgData()
  1812. {
  1813. }
  1814. protected virtual void recalculate()
  1815. {
  1816. if (this.firstChoose != 0)
  1817. {
  1818. btn_statistics_Click();
  1819. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]))
  1820. {
  1821. analysisResults[this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]] = this.tempAnalysisResult;
  1822. }
  1823. else
  1824. {
  1825. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index], this.tempAnalysisResult);
  1826. }
  1827. buildListView_analysisResult();
  1828. }
  1829. }
  1830. #endregion 需继承方法
  1831. #region 内部类
  1832. internal class LocalListViewItem
  1833. {
  1834. public DocumentWorkspace Value { get; }
  1835. public string Display { get; }
  1836. public LocalListViewItem(DocumentWorkspace Value, string Display)
  1837. {
  1838. this.Value = Value;
  1839. this.Display = Display;
  1840. }
  1841. }
  1842. internal class DocumentItem
  1843. {
  1844. public Mat imageMat;
  1845. public GraphicsList graphicsList;
  1846. public List<PhaseModel> phaseModels;
  1847. public bool isErZhi = false;
  1848. public List<PhaseModel> originalPhaseModels;
  1849. public List<DrawObject> drawGraphicsList = new List<DrawObject>();
  1850. public DocumentItem(Mat imageMat, GraphicsList graphicsList, List<PhaseModel> phaseModels, List<PhaseModel> originalPhaseModels)
  1851. {
  1852. this.imageMat = imageMat;
  1853. this.graphicsList = graphicsList;
  1854. this.phaseModels = phaseModels;
  1855. this.originalPhaseModels = originalPhaseModels;
  1856. }
  1857. }
  1858. #endregion 内部类
  1859. private void domainUpDown_resultPrecision_SelectedItemChanged(object sender, EventArgs e)
  1860. {
  1861. buildListView_analysisResult();
  1862. clearAllView();
  1863. getAllView();
  1864. list_add_data();
  1865. }
  1866. private void button_remove_Click(object sender, EventArgs e)
  1867. {
  1868. if (this.listBox_analysisResult.Items.Count == 0)
  1869. {
  1870. MessageBox.Show(PdnResources.GetString("Menu.Noresultsatmeasuring.text"));
  1871. return;
  1872. }
  1873. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeleteth.text") + "?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
  1874. {
  1875. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  1876. {
  1877. return;
  1878. }
  1879. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1880. {
  1881. this.analysisResults.Remove(((LocalListViewItem)item).Value);
  1882. }
  1883. buildListBox_analysisResult();
  1884. }
  1885. }
  1886. /// <summary>
  1887. /// 识别
  1888. /// </summary>
  1889. /// <param name="sender"></param>
  1890. /// <param name="e"></param>
  1891. private void btn_statistics_Click()
  1892. {
  1893. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  1894. int itemCount = 100;
  1895. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  1896. System.Threading.ThreadStart copyThreadProc =
  1897. delegate ()
  1898. {
  1899. if (this.lstView_img.FocusedItem == null || !this.lstView_img.FocusedItem.Selected)
  1900. {
  1901. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1902. return;
  1903. }
  1904. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1905. {
  1906. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformabinaryoperationfirst.text"));
  1907. return;
  1908. }
  1909. Mat mat = this.documentWorkspace.PhaseModels[0].mat.Clone();
  1910. for (int i = 0; i < mat.Height; i++)
  1911. {
  1912. for (int j = 0; j < mat.Width; j++)
  1913. {
  1914. if (mat.At<int>(i, j) == 0)
  1915. {
  1916. mat.Set<Vec3b>(i, j, new Vec3b(255, 255, 255));
  1917. }
  1918. }
  1919. }
  1920. #region [获取参数]
  1921. string filePath = Application.StartupPath + "\\PorosityConfig\\6093Config.xml";
  1922. try
  1923. {
  1924. porosityConfig = XmlSerializeHelper.DESerializer<PorosityConfig>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1925. }
  1926. catch (Exception ex)
  1927. {
  1928. porosityConfig.diameterType = 1;
  1929. porosityConfig.distanceFactor = 1;
  1930. porosityConfig.maxDiameter = 1;
  1931. porosityConfig.maxPorosityNum = 1;
  1932. porosityConfig.maxPorosityPercent = 1;
  1933. porosityConfig.minDiameter = 1;
  1934. porosityConfig.roughSurface = 1;
  1935. porosityConfig.stressType = "D";
  1936. porosityConfig.diameter = false;
  1937. porosityConfig.minDistanceA = false;
  1938. porosityConfig.minDiameterU = false;
  1939. porosityConfig.surfaceRz = false;
  1940. if (!Directory.Exists(filePath))
  1941. {
  1942. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityConfig>(porosityConfig);
  1943. Directory.CreateDirectory(Application.StartupPath + "\\PorosityConfig\\");
  1944. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1945. }
  1946. }
  1947. #endregion [获取参数]
  1948. Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetCutSizeWithColorWhiteOrTransparentColor(false);
  1949. Mat oldMat = PaintDotNet.Camera.Tools.ToMat(bitmap);
  1950. bool isOne = true;
  1951. if (this.documentWorkspace.GraphicsList.IsExsitView())
  1952. {
  1953. isOne = false;
  1954. }
  1955. for (int i = 0; i < this.originalPhaseModels.Count; i++)
  1956. {
  1957. PhaseModel pModel = this.originalPhaseModels[i];
  1958. if (pModel.mat == null)
  1959. {
  1960. pModel.mat = this.documentWorkspace.phaseModels[i].mat;
  1961. }
  1962. }
  1963. this.rectangleF.Clear();
  1964. this.rectangleTypeList.Clear();
  1965. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  1966. {
  1967. this.rectangleF.Add(this.documentWorkspace.GraphicsList[i].Rectangle);
  1968. this.rectangleTypeList.Add(this.documentWorkspace.GraphicsList[i].drawToolType);
  1969. }
  1970. //识别
  1971. this.tempAnalysisResult = this.methodOfAssessment.generateReport(this.imageMat.Clone(), mat, oldMat, rectangleF, rectangleTypeList, this.originalPhaseModels, porosityConfig, isOne);
  1972. progressEvents.EndOperation(OperationResult.Finished);
  1973. };
  1974. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  1975. }
  1976. private void button1_Click(object sender, EventArgs e)
  1977. {
  1978. if (this.listView_analysisResult.Items.Count == 0)
  1979. {
  1980. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1981. return;
  1982. }
  1983. if (this.analyzeSettingModel == null)
  1984. {
  1985. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  1986. return;
  1987. }
  1988. int num = 2;
  1989. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1990. {
  1991. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1992. }
  1993. //获取项目工程内的文件夹路径
  1994. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.NonferrousMetal.Porosity.Text", this.analyzeSettingModel.savePath);
  1995. if (item != null)
  1996. {
  1997. //向文件夹内保存图片和报告
  1998. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1999. {
  2000. //获取word书签与excel单元格的关系,以字典方式存储
  2001. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2002. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2003. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2004. {
  2005. foreach (mic_module_infos info in mic_module_infos)
  2006. {
  2007. tagInfos.Add(info.tag_name, info.cell_position);
  2008. }
  2009. }
  2010. List<List<string>> contentList = new List<List<string>>();
  2011. List<string> contentHead = new List<string>();
  2012. contentList.Add(contentHead);
  2013. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  2014. {
  2015. contentHead.Add(c.Text);
  2016. }
  2017. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  2018. {
  2019. List<string> contentBody = new List<string>();
  2020. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  2021. {
  2022. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  2023. }
  2024. contentList.Add(contentBody);
  2025. }
  2026. contentList.Add(new List<string>());
  2027. contentHead = new List<string>();
  2028. contentList.Add(contentHead);
  2029. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  2030. {
  2031. contentHead.Add(c.Text);
  2032. }
  2033. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  2034. {
  2035. List<string> contentBody = new List<string>();
  2036. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  2037. {
  2038. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  2039. }
  2040. contentList.Add(contentBody);
  2041. }
  2042. List<List<string>> inclusionList = new List<List<string>>();
  2043. List<Bitmap> bitList = new List<Bitmap>();
  2044. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2045. foreach (var itemIt in this.listBox_analysisResult.CheckedItems)
  2046. {
  2047. List<List<string>> dataList = new List<List<string>>();
  2048. List<string> inclusionHead = new List<string>();
  2049. inclusionHead.Add(PdnResources.GetString("Menu.Pixellength.text"));
  2050. inclusionHead.Add(PdnResources.GetString("Menu.Pixelwidth.Text"));
  2051. inclusionHead.Add(PdnResources.GetString("Menu.hectuallength.Text"));
  2052. inclusionHead.Add(PdnResources.GetString("Menu.Theactualwidthofthe.Text"));
  2053. dataList.Add(inclusionHead);
  2054. DocumentWorkspace workspace = ((LocalListViewItem)itemIt).Value;
  2055. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  2056. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  2057. originalBit.Tag = pantographRatio;
  2058. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2059. newBit.Tag = pantographRatio;
  2060. Graphics graphics = Graphics.FromImage(newBit);
  2061. foreach (var phase in dict[((LocalListViewItem)itemIt).Display])
  2062. {
  2063. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  2064. graphics.DrawImage(processedBit, new PointF(0, 0));
  2065. }
  2066. bitList.Add(originalBit);
  2067. bitList.Add(newBit);
  2068. foreach (var inclusion in analysisResults[workspace].porositys)
  2069. {
  2070. List<string> inclusionBody = new List<string>();
  2071. inclusionBody.Add(Math.Round(inclusion.pixelLength, num) + "");
  2072. inclusionBody.Add(Math.Round(inclusion.pixelWidth, num) + "");
  2073. inclusionBody.Add(Math.Round(inclusion.physicalLength, num) + "");
  2074. inclusionBody.Add(Math.Round(inclusion.physicalWidth, num) + "");
  2075. dataList.Add(inclusionBody);
  2076. }
  2077. ExportProjectModel exportProjectModel = new ExportProjectModel();
  2078. exportProjectModel.dataList = dataList;
  2079. exportProjectModel.picName = ((LocalListViewItem)itemIt).Display;
  2080. exportProjectModel.tagName = PdnResources.GetString("Menu.pore.Text");
  2081. exportModel.Add(exportProjectModel);
  2082. }
  2083. try
  2084. {
  2085. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, contentList, exportModel, bitList, tagInfos, item.path, item.code);
  2086. }
  2087. catch (Exception ex)
  2088. {
  2089. MessageBox.Show(ex.Message);
  2090. }
  2091. }
  2092. else
  2093. {
  2094. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2095. return;
  2096. }
  2097. //保存项目信息到数据库
  2098. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2099. }
  2100. }
  2101. /// <summary>
  2102. /// 不可点击空白区域
  2103. /// </summary>
  2104. /// <param name="sender"></param>
  2105. /// <param name="e"></param>
  2106. private void lstView_img_MouseUp(object sender, MouseEventArgs e)
  2107. {
  2108. if (e.Button == MouseButtons.Left)
  2109. {
  2110. if (lstView_img.SelectedItems.Count > 0)
  2111. {
  2112. }
  2113. else if (lstView_img.SelectedItems.Count <= 0)//点击空白区
  2114. {
  2115. if (this.lstView_img.FocusedItem != null)
  2116. {
  2117. ListViewItem item = this.lstView_img.GetItemAt(e.X, e.Y);
  2118. if (item == null)
  2119. {
  2120. this.lstView_img.FocusedItem.Selected = true;
  2121. }
  2122. }
  2123. }
  2124. }
  2125. }
  2126. #region [跳转视场设置相关方法]
  2127. #region [初始方法]
  2128. private void getViewMethod()
  2129. {
  2130. var drawObjectList = new List<DrawObject>();
  2131. // 找出正方形视场
  2132. for (int i = this.documentWorkspace.GraphicsList.Count - 1; i >= 0; i--)
  2133. {
  2134. if (this.documentWorkspace.GraphicsList[i].objectType == DrawClass.View)
  2135. {
  2136. //this.rectangleF.Add(this.documentWorkspace.GraphicsList[i].Rectangle);
  2137. this.rectangleTypeList.Add(this.documentWorkspace.GraphicsList[i].drawToolType);
  2138. drawObjectList.Add(this.documentWorkspace.GraphicsList[i]);
  2139. this.nameList.Add(PdnResources.GetString("Menu.view.text") + $"{i + 1}");
  2140. }
  2141. }
  2142. drawObjectList.Reverse();
  2143. this.nameList.Reverse();
  2144. //this.rectangleF.Reverse();
  2145. this.rectangleTypeList.Reverse();
  2146. foreach (var s in drawObjectList)
  2147. {
  2148. s.Color = retrunColor(drawObjectList.IndexOf(s));
  2149. }
  2150. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList = drawObjectList;
  2151. this.documentWorkspace.panel.Paint += Panel_Paint;
  2152. }
  2153. private void InitViewData()
  2154. {
  2155. var list = mic_view_infos_BLL.FindAll();
  2156. if (list != null && list.Count > 0)
  2157. {
  2158. foreach (var s in list)
  2159. {
  2160. ViewListModel model = XmlSerializeHelper.DESerializer<ViewListModel>(s.view_xml);
  2161. foreach (var m in model.Views)
  2162. {
  2163. if (model.Views.Count == 1)
  2164. {
  2165. this.comboBox2.Items.Add($"{s.view_name}");
  2166. }
  2167. else
  2168. {
  2169. this.comboBox2.Items.Add($"{s.view_name}-{model.Views.IndexOf(m) + 1}");
  2170. }
  2171. this.modelList.Add(m);
  2172. }
  2173. }
  2174. }
  2175. }
  2176. #endregion
  2177. private void getViewSetting()
  2178. {
  2179. string filePath = Application.StartupPath + "\\PorosityConfig\\ViewConfig.xml";
  2180. try
  2181. {
  2182. ViewSetting = XmlSerializeHelper.DESerializer<viewSetting>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  2183. }
  2184. catch (Exception ex)
  2185. {
  2186. ViewSetting = new viewSetting();
  2187. ViewSetting.colorFirst = Color.Red.ToArgb();
  2188. ViewSetting.colorSecond = Color.Yellow.ToArgb();
  2189. ViewSetting.colorThird = Color.Green.ToArgb();
  2190. ViewSetting.colorFourth = Color.Blue.ToArgb();
  2191. ViewSetting.colorFifth = Color.MediumVioletRed.ToArgb();
  2192. ViewSetting.colorSixth = Color.Magenta.ToArgb();
  2193. ViewSetting.colorSeventh = Color.DarkViolet.ToArgb();
  2194. ViewSetting.colorEighth = Color.LightSkyBlue.ToArgb();
  2195. ViewSetting.colorNinth = Color.Cyan.ToArgb();
  2196. ViewSetting.colorTenth = Color.SeaGreen.ToArgb();
  2197. ViewSetting.colorEleventh = Color.DarkOrange.ToArgb();
  2198. ViewSetting.colorTwelfth = Color.Sienna.ToArgb();
  2199. if (!Directory.Exists(filePath))
  2200. {
  2201. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<viewSetting>(ViewSetting);
  2202. Directory.CreateDirectory(Application.StartupPath + "\\PorosityConfig\\");
  2203. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2204. }
  2205. }
  2206. }
  2207. private void button3_Click(object sender, EventArgs e)
  2208. {
  2209. //是否需要二值化
  2210. if (this.lstView_img.FocusedItem == null || !this.lstView_img.FocusedItem.Selected)
  2211. {
  2212. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  2213. return;
  2214. }
  2215. double pxPerUnit = this.imgPxPerUnit;
  2216. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList == null || this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count == 0)
  2217. {
  2218. MessageBox.Show(PdnResources.GetString("Menu.ewbeforesettingfieldofview.Text"));
  2219. return;
  2220. }
  2221. if (bcBinaryChecked())
  2222. {
  2223. MessageBox.Show("请取消二值化后再进行视场设置!");
  2224. return;
  2225. }
  2226. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2227. {
  2228. var g = s.Clone();
  2229. this.oldDrawList.Add(g);
  2230. }
  2231. new PorosityViewSetting(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList, this.nameList, -1, ViewSetting, this, pxPerUnit).ShowDialog();
  2232. }
  2233. /// <summary>
  2234. /// 清空视场
  2235. /// </summary>
  2236. public void clearView()
  2237. {
  2238. this.documentWorkspace.GraphicsList.DeleteAllView();
  2239. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList = new List<DrawObject>();
  2240. this.oldDrawList.Clear();
  2241. //this.pointFDic.Clear();
  2242. this.nameList.Clear();
  2243. this.bc.BinaryChecked = false;
  2244. //this.rectangleF.Clear();
  2245. this.rectangleTypeList.Clear();
  2246. clearAllView();
  2247. this.documentWorkspace.Refresh();
  2248. }
  2249. /// <summary>
  2250. /// 删除视场
  2251. /// </summary>
  2252. public void clearOneView(int id, int index)
  2253. {
  2254. this.documentWorkspace.GraphicsList.RemoveByIds(new List<int>() { id });
  2255. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.RemoveAt(index);
  2256. this.delIndex = index;
  2257. this.nameList.RemoveAt(index);
  2258. //this.rectangleF.RemoveAt(index);
  2259. this.rectangleTypeList.RemoveAt(index);
  2260. clearOneView();
  2261. //this.pointFDic.Clear();
  2262. //for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  2263. //{
  2264. // this.pointFDic.Add(i, this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[i].GetPoints().ToArray());
  2265. //}
  2266. this.documentWorkspace.Refresh();
  2267. }
  2268. /// <summary>
  2269. /// 视场颜色高亮
  2270. /// </summary>
  2271. public void colorHighlight(int index)
  2272. {
  2273. this.chooseGrIndex = index;
  2274. this.documentWorkspace.Refresh();
  2275. }
  2276. /// <summary>
  2277. /// 修改视场颜色
  2278. /// </summary>
  2279. public void changeThisColor(int index, int color)
  2280. {
  2281. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Color = Color.FromArgb(color);
  2282. this.delIndex = index;
  2283. changeOneViewColor();
  2284. this.documentWorkspace.Refresh();
  2285. }
  2286. /// <summary>
  2287. /// 修改视场
  2288. /// </summary>
  2289. public void editView()
  2290. {
  2291. this.oldDrawList.Clear();
  2292. this.documentWorkspace.Refresh();
  2293. }
  2294. /// <summary>
  2295. /// 没有保存 返回之前的颜色
  2296. /// </summary>
  2297. public void returnOldColor()
  2298. {
  2299. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2300. {
  2301. var graphics = this.oldDrawList.Where(m => m.ID == s.ID).FirstOrDefault();
  2302. if (graphics == null)
  2303. {
  2304. continue;
  2305. }
  2306. s.Color = graphics.Color;
  2307. }
  2308. this.oldDrawList.Clear();
  2309. this.documentWorkspace.Refresh();
  2310. }
  2311. /// <summary>
  2312. /// 修改中心点x坐标的事件
  2313. /// </summary>
  2314. /// <param name="sender"></param>
  2315. /// <param name="e"></param>
  2316. public void numericUpDown3_ValueChange(int id, int index, int newValue, int oldValue)
  2317. {
  2318. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2319. {
  2320. int deltaX = newValue - oldValue;
  2321. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Move(deltaX, 0);
  2322. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2323. //pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2324. this.documentWorkspace.Refresh();
  2325. }
  2326. }
  2327. /// <summary>
  2328. /// 修改中心点y坐标的事件
  2329. /// </summary>
  2330. /// <param name="sender"></param>
  2331. /// <param name="e"></param>
  2332. public void numericupdown4_valuechange(int id, int index, int newValue, int oldValue)
  2333. {
  2334. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2335. {
  2336. int deltay = newValue - oldValue;
  2337. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Move(0, deltay);
  2338. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2339. //pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2340. this.documentWorkspace.Refresh();
  2341. }
  2342. }
  2343. /// <summary>
  2344. ///
  2345. /// </summary>
  2346. /// <param name="sender"></param>
  2347. /// <param name="e"></param>
  2348. public DrawObject numericUpDown5_ValueChange(int id, int index, int value)
  2349. {
  2350. double pxPerUnit = this.imgPxPerUnit;
  2351. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2352. {
  2353. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2354. //if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType == DrawToolType.ViewTriangle)
  2355. //{
  2356. // 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);
  2357. // 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);
  2358. // //this.pointFDic[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].GetPoints().ToArray();
  2359. //}
  2360. //else
  2361. 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)
  2362. {
  2363. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2364. }
  2365. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2366. var obj = this.documentWorkspace.GraphicsList.GetById(id);
  2367. if (obj != null)
  2368. {
  2369. obj.Width = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Width;
  2370. obj.Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Height;
  2371. obj.Normalize();
  2372. }
  2373. //this.rectangleF[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle;
  2374. this.documentWorkspace.Refresh();
  2375. return this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index];
  2376. }
  2377. return null;
  2378. }
  2379. /// <summary>
  2380. ///
  2381. /// </summary>
  2382. /// <param name="sender"></param>
  2383. /// <param name="e"></param>
  2384. public DrawObject numericUpDown6_ValueChange(int id, int index, int value)
  2385. {
  2386. double pxPerUnit = this.imgPxPerUnit;
  2387. if (this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index] != null && !this.appWorkspace.ActiveDocumentWorkspace.mouseStatus)
  2388. {
  2389. var type = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].drawToolType;
  2390. switch (type)
  2391. {
  2392. case DrawToolType.ViewOval:
  2393. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2394. break;
  2395. case DrawToolType.ViewCircle:
  2396. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = ((float)Math.Pow((value / Math.PI), 0.5)) * 2;
  2397. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width;
  2398. break;
  2399. case DrawToolType.ViewRectangle:
  2400. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2401. break;
  2402. case DrawToolType.ViewTriangle:
  2403. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (int)(double.Parse(value.ToString()) / pxPerUnit);
  2404. break;
  2405. case DrawToolType.ViewSquare:
  2406. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Height = (float)(Math.Sqrt(value) / pxPerUnit);
  2407. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Width = (float)(Math.Sqrt(value) / pxPerUnit);
  2408. break;
  2409. case DrawToolType.ViewPolygon:
  2410. case DrawToolType.ViewTriangleEx:
  2411. case DrawToolType.ViewRectangleEx:
  2412. break;
  2413. }
  2414. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Normalize();
  2415. var obj = this.documentWorkspace.GraphicsList.GetById(id);
  2416. if (obj != null)
  2417. {
  2418. obj.Width = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Width;
  2419. obj.Height = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle.Height;
  2420. obj.Normalize();
  2421. }
  2422. //this.rectangleF[index] = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index].Rectangle;
  2423. this.documentWorkspace.Refresh();
  2424. return this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[index];
  2425. }
  2426. return null;
  2427. }
  2428. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  2429. {
  2430. this.chooseIndex = this.comboBox2.SelectedIndex;
  2431. }
  2432. private void Panel_Click(object sender, MouseEventArgs e)
  2433. {
  2434. if (this.chooseIndex == -1)
  2435. {
  2436. return;
  2437. }
  2438. if (this.addView)
  2439. {
  2440. return;
  2441. }
  2442. if (bcBinaryChecked())
  2443. {
  2444. MessageBox.Show("请取消二值化后再添加!");
  2445. return;
  2446. }
  2447. var name = this.comboBox2.SelectedItem.ToString();
  2448. try
  2449. {
  2450. var model = this.modelList[this.chooseIndex];
  2451. if (e.Button == MouseButtons.Left)
  2452. {
  2453. System.Drawing.Point loc = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  2454. DrawToolType type = (DrawToolType)Enum.Parse(typeof(DrawToolType), model.Type);
  2455. ViewBase line = null;
  2456. List<PointF> pointFList = new List<PointF>();
  2457. foreach (var s in model.Points)
  2458. {
  2459. if (model.Points.IndexOf(s) == 0)
  2460. {
  2461. pointFList.Add(new PointF(loc.X, loc.Y));
  2462. continue;
  2463. }
  2464. var xDifference = model.Points[0].X - s.X;
  2465. var yDifference = model.Points[0].Y - s.Y;
  2466. pointFList.Add(new PointF(loc.X - xDifference, loc.Y - yDifference));
  2467. }
  2468. switch (type)
  2469. {
  2470. case DrawToolType.ViewOval:
  2471. line = new ViewOval(pointFList);
  2472. break;
  2473. case DrawToolType.ViewCircle:
  2474. line = new ViewCircle(pointFList);
  2475. break;
  2476. case DrawToolType.ViewRectangle:
  2477. line = new ViewRectangle(pointFList);
  2478. break;
  2479. case DrawToolType.ViewTriangle:
  2480. line = new ViewTriangle(pointFList);
  2481. break;
  2482. case DrawToolType.ViewSquare:
  2483. line = new ViewSquare(pointFList);
  2484. break;
  2485. case DrawToolType.ViewPolygon:
  2486. case DrawToolType.ViewTriangleEx:
  2487. line = new ViewPolygon(pointFList);
  2488. break;
  2489. case DrawToolType.ViewRectangleEx:
  2490. line = new ViewRectangleEx(pointFList);
  2491. break;
  2492. }
  2493. if (line != null)
  2494. {
  2495. line.ISurfaceBox = documentWorkspace;
  2496. line.combineMode = (CombineMode)Enum.Parse(typeof(CombineMode), model.CombineMode);
  2497. line.Selected = true;
  2498. line.Color = retrunColor(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count);
  2499. //pointFDic.Add(this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Count, pointFList.ToArray());
  2500. this.oldDrawList.Add(line);
  2501. nameList.Add($"{PdnResources.GetString("Menu.view.text") }{nameList.Count()}");
  2502. this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.Insert(0, line);
  2503. documentWorkspace.AddGraphicsFromForm(line);
  2504. //this.rectangleF.Add(line.Rectangle);
  2505. this.rectangleTypeList.Add(line.drawToolType);
  2506. if (this.bcBinaryChecked())
  2507. {
  2508. clearAllView();
  2509. btn_statistics_Click();
  2510. getAllView();
  2511. list_add_data();
  2512. }
  2513. }
  2514. }
  2515. else
  2516. {
  2517. this.comboBox2.SelectedIndex = -1;
  2518. this.chooseIndex = -1;
  2519. }
  2520. }
  2521. catch (Exception ex)
  2522. {
  2523. }
  2524. }
  2525. private void Panel_Paint(object sender, PaintEventArgs e)
  2526. {
  2527. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2528. int wid = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Width : this.documentWorkspace.CompositionSurface.Width;
  2529. int hei = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Height : this.documentWorkspace.CompositionSurface.Height;
  2530. int width = (int)(wid * this.documentWorkspace.ScaleFactor.Ratio);
  2531. int height = (int)(hei * this.documentWorkspace.ScaleFactor.Ratio);
  2532. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
  2533. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
  2534. e.Graphics.TranslateTransform(x, y);
  2535. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2536. foreach (var s in this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList)
  2537. {
  2538. var jiacu = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s) == chooseGrIndex ? 10 : 5;
  2539. var pen = new Pen(s.Color, jiacu);
  2540. switch (s.drawToolType)
  2541. {
  2542. case DrawToolType.ViewOval:
  2543. case DrawToolType.ViewCircle:
  2544. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2545. {
  2546. e.Graphics.DrawClosedCurve(pen, this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].pointArrayList.ToArray());
  2547. }
  2548. break;
  2549. case DrawToolType.ViewSquare:
  2550. case DrawToolType.ViewRectangle:
  2551. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2552. {
  2553. var rectangle = this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].Rectangle;
  2554. e.Graphics.DrawRectangle(pen, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
  2555. }
  2556. break;
  2557. case DrawToolType.ViewRectangleEx:
  2558. case DrawToolType.ViewPolygon:
  2559. case DrawToolType.ViewTriangle:
  2560. case DrawToolType.ViewTriangleEx:
  2561. if (this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)] != null)
  2562. {
  2563. var pointF = this.documentWorkspace.GraphicsList[this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList.IndexOf(s)].pointArrayList.ToArray();
  2564. if (pointF != null && pointF.Count() > 1)
  2565. {
  2566. e.Graphics.DrawPolygon(pen, pointF);
  2567. }
  2568. }
  2569. break;
  2570. }
  2571. }
  2572. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2573. e.Graphics.TranslateTransform(-x, -y);
  2574. }
  2575. private Color retrunColor(int index)
  2576. {
  2577. switch ((index + 1) % 12)
  2578. {
  2579. case 1:
  2580. return Color.FromArgb(ViewSetting.colorFirst);
  2581. case 2:
  2582. return Color.FromArgb(ViewSetting.colorSecond);
  2583. case 3:
  2584. return Color.FromArgb(ViewSetting.colorThird);
  2585. case 4:
  2586. return Color.FromArgb(ViewSetting.colorFourth);
  2587. case 5:
  2588. return Color.FromArgb(ViewSetting.colorFifth);
  2589. case 6:
  2590. return Color.FromArgb(ViewSetting.colorSixth);
  2591. case 7:
  2592. return Color.FromArgb(ViewSetting.colorSeventh);
  2593. case 8:
  2594. return Color.FromArgb(ViewSetting.colorEighth);
  2595. case 9:
  2596. return Color.FromArgb(ViewSetting.colorNinth);
  2597. case 10:
  2598. return Color.FromArgb(ViewSetting.colorTenth);
  2599. case 11:
  2600. return Color.FromArgb(ViewSetting.colorEleventh);
  2601. case 12:
  2602. return Color.FromArgb(ViewSetting.colorTwelfth);
  2603. }
  2604. return Color.FromArgb(ViewSetting.colorFirst);
  2605. }
  2606. #endregion [跳转视场设置相关方法]
  2607. private void button2_Click(object sender, EventArgs e)
  2608. {
  2609. if (bcBinaryChecked())
  2610. {
  2611. MessageBox.Show("请取消二值化后再拖动视场或者添加视场!");
  2612. return;
  2613. }
  2614. this.addView = !this.addView;
  2615. if (!this.addView)
  2616. {
  2617. this.button2.Text = "取消添加视场";
  2618. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  2619. }
  2620. else
  2621. {
  2622. this.button2.Text = "添加视场";
  2623. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  2624. }
  2625. }
  2626. private void getLastData()
  2627. {
  2628. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterPorosityModel.xml";
  2629. var text = this.dialogText;
  2630. if (!System.IO.File.Exists(filePath))
  2631. {
  2632. porosityModel.PorosityParameters = new List<PorosityModel.PorosityParameter>();
  2633. string[] textList = new string[] { "PV6093", "VW50093", "VDGP202", "GBT37787" };
  2634. for (int i = 0; i < textList.Count(); i++)
  2635. {
  2636. var porosityParameters = new PorosityModel.PorosityParameter();
  2637. porosityParameters.hasUsed = false;
  2638. porosityParameters.name = textList[i];
  2639. porosityModel.PorosityParameters.Add(porosityParameters);
  2640. }
  2641. this.thisParametersIndex = textList.ToList().IndexOf(text);
  2642. this.thisParameters = porosityModel.PorosityParameters[this.thisParametersIndex];
  2643. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2644. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2645. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2646. }
  2647. else
  2648. {
  2649. porosityModel = XmlSerializeHelper.DESerializer<PorosityModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  2650. if (porosityModel.PorosityParameters == null)
  2651. {
  2652. porosityModel.PorosityParameters = new List<PorosityModel.PorosityParameter>();
  2653. }
  2654. thisParameters = porosityModel.PorosityParameters.Where(m => m.name.Equals(text)).FirstOrDefault();
  2655. if (thisParameters == null)
  2656. {
  2657. thisParameters = new PorosityModel.PorosityParameter();
  2658. thisParameters.hasUsed = false;
  2659. thisParameters.name = text;
  2660. porosityModel.PorosityParameters.Add(thisParameters);
  2661. this.thisParametersIndex = porosityModel.PorosityParameters.Count() - 1;
  2662. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2663. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2664. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2665. }
  2666. else
  2667. {
  2668. this.thisParametersIndex = porosityModel.PorosityParameters.IndexOf(thisParameters);
  2669. if (thisParameters.hasUsed)
  2670. {
  2671. checkBox_generateReport_opensetting.Checked = thisParameters.parameter1;
  2672. domainUpDown_resultPrecision.SelectedIndex = thisParameters.parameter2;
  2673. }
  2674. }
  2675. }
  2676. }
  2677. private void saveLastData(object sender, EventArgs e)
  2678. {
  2679. #region [开启脚本录制]
  2680. if (appWorkspace.startScriptRecording)
  2681. {
  2682. getScriptRecording();
  2683. }
  2684. #endregion
  2685. binaryClass.saveParams();
  2686. if (this.thisParametersIndex == -1)
  2687. {
  2688. return;
  2689. }
  2690. this.thisParameters.hasUsed = true;
  2691. thisParameters.parameter1 = checkBox_generateReport_opensetting.Checked;
  2692. thisParameters.parameter2 = domainUpDown_resultPrecision.SelectedIndex;
  2693. this.porosityModel.PorosityParameters[this.thisParametersIndex] = this.thisParameters;
  2694. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterPorosityModel.xml";
  2695. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<PorosityModel>(porosityModel);
  2696. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  2697. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  2698. }
  2699. /// <summary>
  2700. /// 应用全部
  2701. /// </summary>
  2702. /// <param name="sender"></param>
  2703. /// <param name="e"></param>
  2704. private void button4_Click(object sender, EventArgs e)
  2705. {
  2706. if (this.lstView_img.FocusedItem == null)
  2707. {
  2708. return;
  2709. }
  2710. binaryClass.saveParams();
  2711. binaryClass.applyToAll(this.imageList_img.Images.Keys, this.imageList_img.Images.Keys[this.lstView_img.FocusedItem.Index]);
  2712. userAll = true;
  2713. resultList.Clear();
  2714. hasResultIndexList.Clear();
  2715. analysisResults.Clear();
  2716. //var data = new CurrentPageData();
  2717. var firstIndex = this.lstView_img.FocusedItem.Index;
  2718. //if (everyImgData.ContainsKey(this.lstView_img.FocusedItem.Index))
  2719. //{
  2720. // data = everyImgData[this.lstView_img.FocusedItem.Index];
  2721. //}
  2722. nodata = true;
  2723. for (int i = 0; i < lstView_img.Items.Count; i++)
  2724. {
  2725. this.lstView_img.Items[i].EnsureVisible();
  2726. this.lstView_img.Items[i].Focused = true;
  2727. this.lstView_img.Items[i].Selected = true;
  2728. this.btn_saveresult_Click(sender, e);
  2729. }
  2730. nodata = false;
  2731. }
  2732. /// <summary>
  2733. /// 保存全部
  2734. /// </summary>
  2735. /// <param name="sender"></param>
  2736. /// <param name="e"></param>
  2737. private void button5_Click(object sender, EventArgs e)
  2738. {
  2739. if (this.lstView_img.FocusedItem == null)
  2740. {
  2741. return;
  2742. }
  2743. if (!userAll)
  2744. {
  2745. MessageBox.Show("请先点击应用全部");
  2746. return;
  2747. }
  2748. if (resultList.Count() == 0)
  2749. {
  2750. MessageBox.Show("无结果数据!");
  2751. return;
  2752. }
  2753. if (listBox_analysisResult.Items.Count > 0)
  2754. {
  2755. if (MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  2756. {
  2757. for (int i = 0; i < resultList.Count(); i++)
  2758. {
  2759. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[i]))
  2760. {
  2761. continue;
  2762. }
  2763. else
  2764. {
  2765. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[i], resultList[i]);
  2766. }
  2767. buildListBox_analysisResult();
  2768. }
  2769. return;
  2770. }
  2771. }
  2772. for (int i = 0; i < resultList.Count(); i++)
  2773. {
  2774. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[i]))
  2775. {
  2776. analysisResults[this.appWorkspace.DocumentWorkspaces[i]] = resultList[i];
  2777. }
  2778. else
  2779. {
  2780. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[i], resultList[i]);
  2781. }
  2782. buildListBox_analysisResult();
  2783. }
  2784. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  2785. {
  2786. listBox_analysisResult.SetItemChecked(i, true);
  2787. }
  2788. buildListView_analysisResult();
  2789. }
  2790. private void getValue(string key, object value)
  2791. {
  2792. switch (key)
  2793. {
  2794. case "OpenWhileExportReport":
  2795. checkBox_generateReport_opensetting.Checked = Convert.ToBoolean(value);
  2796. break;
  2797. case "CalculatorDecimalDigits":
  2798. domainUpDown_resultPrecision.SelectedIndex = (int)value;
  2799. break;
  2800. case "ExportResults":
  2801. isExportResults = Convert.ToBoolean(value);
  2802. break;
  2803. case "ExportReports":
  2804. isExportReports = Convert.ToBoolean(value);
  2805. break;
  2806. case "ExportProjects":
  2807. isExportProjects = Convert.ToBoolean(value);
  2808. break;
  2809. }
  2810. }
  2811. #region [脚本录制]
  2812. private void getScriptRecording()
  2813. {
  2814. string className = InvariantData.path_Action + ".Action" + menuId;
  2815. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  2816. List<Args> args = param.Lists;
  2817. foreach (var item in args)
  2818. {
  2819. item.value = setScriptRecording(item.key);
  2820. }
  2821. //找出子类相关参数 进行赋值
  2822. List<Args> oneIsNullList = args.Where(m => m.value == null).ToList();
  2823. foreach (var item in oneIsNullList)
  2824. {
  2825. this.argsKey = item.key;
  2826. this.setArgsValue();
  2827. item.value = this.argsValue;
  2828. }
  2829. //找出二值相关参数 进行赋值
  2830. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  2831. foreach (var item in isNullList)
  2832. {
  2833. item.value = binaryClass.setScriptRecording(item.key);
  2834. }
  2835. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  2836. }
  2837. private object setScriptRecording(string key)
  2838. {
  2839. object value = null;
  2840. switch (key)
  2841. {
  2842. case "OpenWhileExportReport":
  2843. value = checkBox_generateReport_opensetting.Checked;
  2844. break;
  2845. case "CalculatorDecimalDigits":
  2846. value = this.domainUpDown_resultPrecision.SelectedItem;
  2847. break;
  2848. case "ExportResults":
  2849. value = isExportResults;
  2850. break;
  2851. case "ExportReports":
  2852. value = isExportReports;
  2853. break;
  2854. case "ExportProjects":
  2855. value = isExportProjects;
  2856. break;
  2857. }
  2858. return value;
  2859. }
  2860. #endregion
  2861. }
  2862. }