MetallographicMethod224Dialog.cs 165 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379
  1. using Metis.ParameterSet;
  2. using OpenCvSharp.Extensions;
  3. using PaintDotNet.Base;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.Base.Functionodel;
  6. using PaintDotNet.Base.SettingModel;
  7. using PaintDotNet.CustomControl;
  8. using PaintDotNet.Data.Param;
  9. using PaintDotNet.DbOpreate.DbBll;
  10. using PaintDotNet.DbOpreate.DbModel;
  11. using PaintDotNet.Instrument;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Data.Entity.Migrations.Infrastructure;
  17. using System.Diagnostics.Contracts;
  18. using System.Drawing;
  19. using System.Drawing.Drawing2D;
  20. using System.IO;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Threading.Tasks;
  24. using System.Windows.Forms;
  25. namespace PaintDotNet.DedicatedAnalysis.SteelDecarburization.GBT224_2019
  26. {
  27. /// <summary>
  28. /// 金相法
  29. /// </summary>
  30. internal class MetallographicMethod224Dialog : PdnBaseForm
  31. {
  32. #region 基础控件
  33. private Button button1;
  34. private CheckBox checkBox1;
  35. private Button button2;
  36. private GroupBox groupBox2;
  37. private ListView listView1;
  38. private GroupBox groupBox3;
  39. private GroupBox groupBox4;
  40. private Button button5;
  41. private Button button4;
  42. private Button button3;
  43. private GroupBox groupBox5;
  44. private TextBox textBox2;
  45. private TextBox textBox1;
  46. private Label label2;
  47. private Label label1;
  48. private GroupBox groupBox6;
  49. private Panel panel1;
  50. private Label label4;
  51. private Label label3;
  52. private Panel panel5;
  53. private Panel panel4;
  54. private Panel panel3;
  55. private Panel panel2;
  56. private GroupBox groupBox7;
  57. private CheckBox checkBox3;
  58. private CheckBox checkBox2;
  59. private GroupBox groupBox8;
  60. private DataGridView dataGridView1;
  61. private GroupBox groupBox9;
  62. private Button button6;
  63. private Button button7;
  64. private ListView listView2;
  65. private DataGridView dataGridView2;
  66. private Button button9;
  67. private Button button8;
  68. private NumericUpDown numericUpDown1;
  69. private Label label8;
  70. private Label label9;
  71. private Label label10;
  72. private ImageList imageList1;
  73. private IContainer components;
  74. private GroupBox groupBox1;
  75. private TrackBar trackBar1;
  76. private TrackBar trackBar2;
  77. private Button button10;
  78. #endregion
  79. /// <summary>
  80. /// 调色板
  81. /// </summary>
  82. PaintDotNet.ColorsForm colorsForm1;
  83. PaintDotNet.ColorsForm colorsForm2;
  84. PaintDotNet.ColorsForm colorsForm3;
  85. PaintDotNet.ColorsForm colorsForm4;
  86. PaintDotNet.ColorsForm colorsForm5;
  87. /// <summary>
  88. /// 主控件
  89. /// </summary>
  90. private AppWorkspace appWorkspace;
  91. /// <summary>
  92. /// 图像面板
  93. /// </summary>
  94. private DocumentWorkspaceWindow documentWorkspace;
  95. /// <summary>
  96. /// 公共按钮
  97. /// </summary>
  98. private CommonControlButtons commonControlButtons;
  99. /// <summary>
  100. /// 选中图片的bitmap
  101. /// </summary>
  102. private Bitmap bitmap;
  103. /// <summary>
  104. /// 0:添加 1:选择 2:删除
  105. /// </summary>
  106. private int operationK = -1;
  107. /// <summary>
  108. /// 被选择的线
  109. /// </summary>
  110. private int selected = -1;
  111. /// <summary>
  112. /// 起止点
  113. /// </summary>
  114. private System.Drawing.PointF startPoint, endPoint;
  115. /// <summary>
  116. /// 存储所有线的点集合
  117. /// </summary>
  118. private List<PointF[]> pointList = new List<PointF[]>();
  119. /// <summary>
  120. /// 测量点
  121. /// </summary>
  122. public List<RectangleF> rectangleFList = new List<RectangleF>();
  123. /// <summary>
  124. /// 存储当前线的点集合
  125. /// </summary>
  126. private PointF[] nowLine;
  127. /// <summary>
  128. /// 线的总数
  129. /// </summary>
  130. private int lineCount = 0;
  131. /// <summary>
  132. /// 计算结果的表格集合
  133. /// </summary>
  134. private List<DataTable> resultTableList = new List<DataTable>();
  135. /// <summary>
  136. /// 保存用于生成报告的图片
  137. /// </summary>
  138. private List<Bitmap> bitList;
  139. /// <summary>
  140. /// 储存点击保存结果后的所有原图与分析图
  141. /// </summary>
  142. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  143. /// <summary>
  144. /// 是否显示全部
  145. /// </summary>
  146. private bool showAll = false;
  147. /// <summary>
  148. /// 辅助计算偏移量-移动线两端的点
  149. /// </summary>
  150. private PointF lastPoint = new PointF(0, 0);
  151. /// <summary>
  152. /// 辅助计算偏移量-移动线中间的点
  153. /// </summary>
  154. private PointF tempPoint = new PointF(0, 0);
  155. /// <summary>
  156. /// 判断图形是否可移动
  157. /// </summary>
  158. private bool canMove = false;
  159. /// <summary>
  160. /// 移动线上的哪一个点
  161. /// </summary>
  162. private int movePointIndex = -1;
  163. /// <summary>
  164. /// 单位标尺
  165. /// </summary>
  166. private double unitLength = 1;
  167. private CheckBox checkBox6;
  168. private CheckBox checkBox5;
  169. private CheckBox checkBox4;
  170. /// <summary>
  171. /// 中间数据
  172. /// </summary>
  173. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  174. private int defaultIndex = -1;
  175. private int menuId;
  176. private string menuName;
  177. /// <summary>
  178. /// 是否脚本运行
  179. /// </summary>
  180. private Boolean initScriptValues = false;
  181. /// <summary>
  182. /// 保存窗口参数
  183. /// </summary>
  184. private GrainSizeAnalysisModel analysisModel;
  185. private const string ParamKey_Report = "report";//报告设置
  186. private const string ParamKey_LineLength = "lineLength";//线长
  187. private const string ParamKey_LineWidth = "lineWidth";//线宽
  188. private const string ParamKey_Baseline = "baseline";//基准线
  189. private const string ParamKey_Surface = "surface";//钢样表面
  190. private const string ParamKey_Whole = "whole";//完全
  191. private const string ParamKey_WholeColour = "wholeColour";//完全颜色
  192. private const string ParamKey_Valid = "valid";//有效
  193. private const string ParamKey_ValidColour = "validColour";//有效颜色
  194. private const string ParamKey_Part = "part";//部分
  195. private const string ParamKey_PartColour = "partColour";//部分颜色
  196. private const string ParamKey_WholeGauge = "wholeGauge";//完全测量
  197. private const string ParamKey_ValidGauge = "validGauge";//有效测量
  198. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  199. public MetallographicMethod224Dialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  200. {
  201. this.menuId = menuItem.MenuId;
  202. this.menuName = menuItem.Text;
  203. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  204. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  205. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  206. foreach (var item in this.analysisModel.ListParam)
  207. item.setValue();
  208. this.appWorkspace = appWorkspace;
  209. InitializeComponent();
  210. InitializeLanguageText();
  211. InitGridHeader();
  212. InitOtherTools();
  213. //如果是脚本执行,将参数带入
  214. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  215. {
  216. this.initScriptValues = true;//ScriptAutomatic
  217. //Boolean initScriptValues = true;
  218. ////在这里反射出对应功能的参数类
  219. string className = InvariantData.path_Action + ".Action" + menuId;
  220. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  221. foreach (Args arg in param.Lists)
  222. {
  223. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  224. if (param1.value != null)
  225. arg.Value = param1.value;
  226. getValue(arg.key, arg.Value);
  227. }
  228. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  229. }
  230. else
  231. {//读取上次关闭窗口时保存的参数
  232. GetListParamModel();
  233. }
  234. InitPicList();
  235. InitCommonButtonEvent();
  236. AddPictureBoxEvent();
  237. SetAnalyzeModelFromXml("Template.Manager.item3.MetallographicMethod224");
  238. }
  239. private void ShowImgEvent(object sender, EventArgs e)
  240. {
  241. listView1.Focus();
  242. if (this.defaultIndex != -1)
  243. {
  244. this.listView1.Items[defaultIndex].Focused = true;
  245. this.listView1.Items[defaultIndex].Selected = true;
  246. }
  247. }
  248. private void InitializeLanguageText()
  249. {
  250. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  251. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  252. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  253. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  254. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  255. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  256. this.groupBox4.Text = PdnResources.GetString("Menu.Measurementbaseline.text");
  257. this.button5.Text = PdnResources.GetString("Menu.Deletemeasurementline.text");
  258. this.button4.Text = PdnResources.GetString("Menu.Selectmeasurementline.text");
  259. this.button3.Text = PdnResources.GetString("Menu.Addmeasuringline.text");
  260. this.groupBox5.Text = PdnResources.GetString("Menu.Basicsettingsofmeasuringline.text");
  261. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  262. this.label1.Text = PdnResources.GetString("Menu.Linelength.text") + ":";
  263. this.groupBox6.Text = PdnResources.GetString("Menu.Colorsetting.text");
  264. this.checkBox6.Text = PdnResources.GetString("Menu.Partiallydecarburizedlayer.text") + ":";
  265. this.checkBox5.Text = PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text") + ":";
  266. this.checkBox4.Text = PdnResources.GetString("Menu.Completelydecarburizedlayer.text") + ":";
  267. this.label4.Text = PdnResources.GetString("Menu.Steelsamplesurface.text") + ":";
  268. this.label3.Text = PdnResources.GetString("Menu.Baseline.text") + ":";
  269. this.groupBox7.Text = PdnResources.GetString("Menu.Measurementlayerselection.text");
  270. this.checkBox3.Text = PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text");
  271. this.checkBox2.Text = PdnResources.GetString("Menu.Completelydecarburizedlayer.text");
  272. this.groupBox8.Text = PdnResources.GetString("Menu.datapresentation.text");
  273. this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");
  274. this.button10.Text = PdnResources.GetString("Menu.Exportproject.text");
  275. this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  276. this.button9.Text = PdnResources.GetString("Menu.Exportresults.text");
  277. this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  278. this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  279. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  280. this.Text = "GB/T 224-2019(" + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Metallographicmethod.text") + ")";
  281. }
  282. private void InitializeComponent()
  283. {
  284. this.components = new System.ComponentModel.Container();
  285. this.groupBox1 = new System.Windows.Forms.GroupBox();
  286. this.button2 = new System.Windows.Forms.Button();
  287. this.checkBox1 = new System.Windows.Forms.CheckBox();
  288. this.button1 = new System.Windows.Forms.Button();
  289. this.groupBox2 = new System.Windows.Forms.GroupBox();
  290. this.listView1 = new System.Windows.Forms.ListView();
  291. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  292. this.groupBox3 = new System.Windows.Forms.GroupBox();
  293. this.groupBox4 = new System.Windows.Forms.GroupBox();
  294. this.button5 = new System.Windows.Forms.Button();
  295. this.button4 = new System.Windows.Forms.Button();
  296. this.button3 = new System.Windows.Forms.Button();
  297. this.groupBox5 = new System.Windows.Forms.GroupBox();
  298. this.trackBar2 = new System.Windows.Forms.TrackBar();
  299. this.trackBar1 = new System.Windows.Forms.TrackBar();
  300. this.textBox2 = new System.Windows.Forms.TextBox();
  301. this.textBox1 = new System.Windows.Forms.TextBox();
  302. this.label2 = new System.Windows.Forms.Label();
  303. this.label1 = new System.Windows.Forms.Label();
  304. this.groupBox6 = new System.Windows.Forms.GroupBox();
  305. this.checkBox6 = new System.Windows.Forms.CheckBox();
  306. this.panel5 = new System.Windows.Forms.Panel();
  307. this.checkBox5 = new System.Windows.Forms.CheckBox();
  308. this.panel4 = new System.Windows.Forms.Panel();
  309. this.checkBox4 = new System.Windows.Forms.CheckBox();
  310. this.panel3 = new System.Windows.Forms.Panel();
  311. this.panel2 = new System.Windows.Forms.Panel();
  312. this.panel1 = new System.Windows.Forms.Panel();
  313. this.label4 = new System.Windows.Forms.Label();
  314. this.label3 = new System.Windows.Forms.Label();
  315. this.groupBox7 = new System.Windows.Forms.GroupBox();
  316. this.checkBox3 = new System.Windows.Forms.CheckBox();
  317. this.checkBox2 = new System.Windows.Forms.CheckBox();
  318. this.groupBox8 = new System.Windows.Forms.GroupBox();
  319. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  320. this.groupBox9 = new System.Windows.Forms.GroupBox();
  321. this.button10 = new System.Windows.Forms.Button();
  322. this.label10 = new System.Windows.Forms.Label();
  323. this.label9 = new System.Windows.Forms.Label();
  324. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  325. this.label8 = new System.Windows.Forms.Label();
  326. this.button9 = new System.Windows.Forms.Button();
  327. this.button8 = new System.Windows.Forms.Button();
  328. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  329. this.listView2 = new System.Windows.Forms.ListView();
  330. this.button7 = new System.Windows.Forms.Button();
  331. this.button6 = new System.Windows.Forms.Button();
  332. this.groupBox1.SuspendLayout();
  333. this.groupBox2.SuspendLayout();
  334. this.groupBox4.SuspendLayout();
  335. this.groupBox5.SuspendLayout();
  336. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
  337. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  338. this.groupBox6.SuspendLayout();
  339. this.groupBox7.SuspendLayout();
  340. this.groupBox8.SuspendLayout();
  341. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  342. this.groupBox9.SuspendLayout();
  343. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  344. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  345. this.SuspendLayout();
  346. //
  347. // groupBox1
  348. //
  349. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  350. | System.Windows.Forms.AnchorStyles.Right)));
  351. this.groupBox1.Controls.Add(this.button2);
  352. this.groupBox1.Controls.Add(this.checkBox1);
  353. this.groupBox1.Controls.Add(this.button1);
  354. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  355. this.groupBox1.Name = "groupBox1";
  356. this.groupBox1.Size = new System.Drawing.Size(1081, 50);
  357. this.groupBox1.TabIndex = 1;
  358. this.groupBox1.TabStop = false;
  359. //
  360. // button2
  361. //
  362. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  363. | System.Windows.Forms.AnchorStyles.Right)));
  364. this.button2.Location = new System.Drawing.Point(985, 14);
  365. this.button2.Name = "button2";
  366. this.button2.Size = new System.Drawing.Size(84, 30);
  367. this.button2.TabIndex = 2;
  368. this.button2.UseVisualStyleBackColor = true;
  369. this.button2.Click += new System.EventHandler(this.button2_Click);
  370. //
  371. // checkBox1
  372. //
  373. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  374. | System.Windows.Forms.AnchorStyles.Left)));
  375. this.checkBox1.AutoSize = true;
  376. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  377. this.checkBox1.Name = "checkBox1";
  378. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  379. this.checkBox1.TabIndex = 1;
  380. this.checkBox1.UseVisualStyleBackColor = true;
  381. //
  382. // button1
  383. //
  384. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  385. | System.Windows.Forms.AnchorStyles.Left)));
  386. this.button1.Location = new System.Drawing.Point(15, 14);
  387. this.button1.Name = "button1";
  388. this.button1.Size = new System.Drawing.Size(84, 30);
  389. this.button1.TabIndex = 0;
  390. this.button1.UseVisualStyleBackColor = true;
  391. this.button1.Click += new System.EventHandler(this.button1_Click);
  392. //
  393. // groupBox2
  394. //
  395. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  396. | System.Windows.Forms.AnchorStyles.Left)));
  397. this.groupBox2.Controls.Add(this.listView1);
  398. this.groupBox2.Location = new System.Drawing.Point(14, 60);
  399. this.groupBox2.Name = "groupBox2";
  400. this.groupBox2.Size = new System.Drawing.Size(135, 497);
  401. this.groupBox2.TabIndex = 2;
  402. this.groupBox2.TabStop = false;
  403. //
  404. // listView1
  405. //
  406. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  407. | System.Windows.Forms.AnchorStyles.Left)
  408. | System.Windows.Forms.AnchorStyles.Right)));
  409. this.listView1.HideSelection = false;
  410. this.listView1.LargeImageList = this.imageList1;
  411. this.listView1.Location = new System.Drawing.Point(5, 17);
  412. this.listView1.MultiSelect = false;
  413. this.listView1.Name = "listView1";
  414. this.listView1.Size = new System.Drawing.Size(124, 474);
  415. this.listView1.TabIndex = 0;
  416. this.listView1.UseCompatibleStateImageBehavior = false;
  417. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  418. //
  419. // imageList1
  420. //
  421. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  422. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  423. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  424. //
  425. // groupBox3
  426. //
  427. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  428. | System.Windows.Forms.AnchorStyles.Left)
  429. | System.Windows.Forms.AnchorStyles.Right)));
  430. this.groupBox3.Location = new System.Drawing.Point(515, 60);
  431. this.groupBox3.Name = "groupBox3";
  432. this.groupBox3.Size = new System.Drawing.Size(580, 496);
  433. this.groupBox3.TabIndex = 3;
  434. this.groupBox3.TabStop = false;
  435. //
  436. // groupBox4
  437. //
  438. this.groupBox4.Controls.Add(this.button5);
  439. this.groupBox4.Controls.Add(this.button4);
  440. this.groupBox4.Controls.Add(this.button3);
  441. this.groupBox4.Location = new System.Drawing.Point(156, 60);
  442. this.groupBox4.Name = "groupBox4";
  443. this.groupBox4.Size = new System.Drawing.Size(353, 58);
  444. this.groupBox4.TabIndex = 4;
  445. this.groupBox4.TabStop = false;
  446. //
  447. // button5
  448. //
  449. this.button5.Location = new System.Drawing.Point(203, 20);
  450. this.button5.Name = "button5";
  451. this.button5.Size = new System.Drawing.Size(75, 23);
  452. this.button5.TabIndex = 2;
  453. this.button5.UseVisualStyleBackColor = true;
  454. this.button5.Click += new System.EventHandler(this.button5_Click);
  455. //
  456. // button4
  457. //
  458. this.button4.Location = new System.Drawing.Point(109, 20);
  459. this.button4.Name = "button4";
  460. this.button4.Size = new System.Drawing.Size(75, 23);
  461. this.button4.TabIndex = 1;
  462. this.button4.UseVisualStyleBackColor = true;
  463. this.button4.Click += new System.EventHandler(this.button4_Click);
  464. //
  465. // button3
  466. //
  467. this.button3.Location = new System.Drawing.Point(16, 20);
  468. this.button3.Name = "button3";
  469. this.button3.Size = new System.Drawing.Size(75, 23);
  470. this.button3.TabIndex = 0;
  471. this.button3.UseVisualStyleBackColor = true;
  472. this.button3.Click += new System.EventHandler(this.button3_Click);
  473. //
  474. // groupBox5
  475. //
  476. this.groupBox5.Controls.Add(this.trackBar2);
  477. this.groupBox5.Controls.Add(this.trackBar1);
  478. this.groupBox5.Controls.Add(this.textBox2);
  479. this.groupBox5.Controls.Add(this.textBox1);
  480. this.groupBox5.Controls.Add(this.label2);
  481. this.groupBox5.Controls.Add(this.label1);
  482. this.groupBox5.Location = new System.Drawing.Point(156, 125);
  483. this.groupBox5.Name = "groupBox5";
  484. this.groupBox5.Size = new System.Drawing.Size(353, 71);
  485. this.groupBox5.TabIndex = 5;
  486. this.groupBox5.TabStop = false;
  487. //
  488. // trackBar2
  489. //
  490. this.trackBar2.Cursor = System.Windows.Forms.Cursors.Hand;
  491. this.trackBar2.Location = new System.Drawing.Point(219, 24);
  492. this.trackBar2.Maximum = 50;
  493. this.trackBar2.Minimum = 1;
  494. this.trackBar2.Name = "trackBar2";
  495. this.trackBar2.Size = new System.Drawing.Size(85, 45);
  496. this.trackBar2.TabIndex = 5;
  497. this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None;
  498. this.trackBar2.Value = 3;
  499. this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll);
  500. this.trackBar2.ValueChanged += new System.EventHandler(this.trackBar2_ValueChanged);
  501. //
  502. // trackBar1
  503. //
  504. this.trackBar1.Cursor = System.Windows.Forms.Cursors.Hand;
  505. this.trackBar1.Location = new System.Drawing.Point(42, 24);
  506. this.trackBar1.Maximum = 50;
  507. this.trackBar1.Minimum = 1;
  508. this.trackBar1.Name = "trackBar1";
  509. this.trackBar1.Size = new System.Drawing.Size(91, 45);
  510. this.trackBar1.TabIndex = 4;
  511. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  512. this.trackBar1.Value = 40;
  513. this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
  514. this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
  515. //
  516. // textBox2
  517. //
  518. this.textBox2.Location = new System.Drawing.Point(307, 24);
  519. this.textBox2.Name = "textBox2";
  520. this.textBox2.Size = new System.Drawing.Size(35, 21);
  521. this.textBox2.TabIndex = 3;
  522. this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
  523. this.textBox2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyUp);
  524. //
  525. // textBox1
  526. //
  527. this.textBox1.Location = new System.Drawing.Point(136, 24);
  528. this.textBox1.Name = "textBox1";
  529. this.textBox1.Size = new System.Drawing.Size(35, 21);
  530. this.textBox1.TabIndex = 2;
  531. this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
  532. this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp);
  533. //
  534. // label2
  535. //
  536. this.label2.AutoSize = true;
  537. this.label2.Location = new System.Drawing.Point(183, 28);
  538. this.label2.Name = "label2";
  539. this.label2.Size = new System.Drawing.Size(0, 12);
  540. this.label2.TabIndex = 1;
  541. //
  542. // label1
  543. //
  544. this.label1.AutoSize = true;
  545. this.label1.Location = new System.Drawing.Point(12, 28);
  546. this.label1.Name = "label1";
  547. this.label1.Size = new System.Drawing.Size(0, 12);
  548. this.label1.TabIndex = 0;
  549. //
  550. // groupBox6
  551. //
  552. this.groupBox6.Controls.Add(this.checkBox6);
  553. this.groupBox6.Controls.Add(this.panel5);
  554. this.groupBox6.Controls.Add(this.checkBox5);
  555. this.groupBox6.Controls.Add(this.panel4);
  556. this.groupBox6.Controls.Add(this.checkBox4);
  557. this.groupBox6.Controls.Add(this.panel3);
  558. this.groupBox6.Controls.Add(this.panel2);
  559. this.groupBox6.Controls.Add(this.panel1);
  560. this.groupBox6.Controls.Add(this.label4);
  561. this.groupBox6.Controls.Add(this.label3);
  562. this.groupBox6.Location = new System.Drawing.Point(156, 202);
  563. this.groupBox6.Name = "groupBox6";
  564. this.groupBox6.Size = new System.Drawing.Size(354, 95);
  565. this.groupBox6.TabIndex = 6;
  566. this.groupBox6.TabStop = false;
  567. //
  568. // checkBox6
  569. //
  570. this.checkBox6.AutoSize = true;
  571. this.checkBox6.Location = new System.Drawing.Point(157, 68);
  572. this.checkBox6.Name = "checkBox6";
  573. this.checkBox6.Size = new System.Drawing.Size(15, 14);
  574. this.checkBox6.TabIndex = 5;
  575. this.checkBox6.UseVisualStyleBackColor = true;
  576. this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
  577. //
  578. // panel5
  579. //
  580. this.panel5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  581. this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  582. this.panel5.Location = new System.Drawing.Point(259, 67);
  583. this.panel5.Name = "panel5";
  584. this.panel5.Size = new System.Drawing.Size(75, 18);
  585. this.panel5.TabIndex = 8;
  586. this.panel5.Click += new System.EventHandler(this.panel5_Click);
  587. //
  588. // checkBox5
  589. //
  590. this.checkBox5.AutoSize = true;
  591. this.checkBox5.Location = new System.Drawing.Point(157, 46);
  592. this.checkBox5.Name = "checkBox5";
  593. this.checkBox5.Size = new System.Drawing.Size(15, 14);
  594. this.checkBox5.TabIndex = 4;
  595. this.checkBox5.UseVisualStyleBackColor = true;
  596. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  597. //
  598. // panel4
  599. //
  600. this.panel4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  601. this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  602. this.panel4.Location = new System.Drawing.Point(259, 44);
  603. this.panel4.Name = "panel4";
  604. this.panel4.Size = new System.Drawing.Size(75, 18);
  605. this.panel4.TabIndex = 7;
  606. this.panel4.Click += new System.EventHandler(this.panel4_Click);
  607. //
  608. // checkBox4
  609. //
  610. this.checkBox4.AutoSize = true;
  611. this.checkBox4.Location = new System.Drawing.Point(157, 23);
  612. this.checkBox4.Name = "checkBox4";
  613. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  614. this.checkBox4.TabIndex = 3;
  615. this.checkBox4.UseVisualStyleBackColor = true;
  616. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  617. //
  618. // panel3
  619. //
  620. this.panel3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  621. this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  622. this.panel3.Location = new System.Drawing.Point(259, 21);
  623. this.panel3.Name = "panel3";
  624. this.panel3.Size = new System.Drawing.Size(75, 18);
  625. this.panel3.TabIndex = 6;
  626. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  627. //
  628. // panel2
  629. //
  630. this.panel2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  631. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  632. this.panel2.Location = new System.Drawing.Point(72, 44);
  633. this.panel2.Name = "panel2";
  634. this.panel2.Size = new System.Drawing.Size(75, 18);
  635. this.panel2.TabIndex = 6;
  636. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  637. //
  638. // panel1
  639. //
  640. this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  641. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  642. this.panel1.Location = new System.Drawing.Point(72, 21);
  643. this.panel1.Name = "panel1";
  644. this.panel1.Size = new System.Drawing.Size(75, 18);
  645. this.panel1.TabIndex = 5;
  646. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  647. //
  648. // label4
  649. //
  650. this.label4.AutoSize = true;
  651. this.label4.Location = new System.Drawing.Point(11, 47);
  652. this.label4.Name = "label4";
  653. this.label4.Size = new System.Drawing.Size(0, 12);
  654. this.label4.TabIndex = 1;
  655. //
  656. // label3
  657. //
  658. this.label3.AutoSize = true;
  659. this.label3.Location = new System.Drawing.Point(11, 25);
  660. this.label3.Name = "label3";
  661. this.label3.Size = new System.Drawing.Size(0, 12);
  662. this.label3.TabIndex = 0;
  663. //
  664. // groupBox7
  665. //
  666. this.groupBox7.Controls.Add(this.checkBox3);
  667. this.groupBox7.Controls.Add(this.checkBox2);
  668. this.groupBox7.Location = new System.Drawing.Point(156, 303);
  669. this.groupBox7.Name = "groupBox7";
  670. this.groupBox7.Size = new System.Drawing.Size(353, 58);
  671. this.groupBox7.TabIndex = 7;
  672. this.groupBox7.TabStop = false;
  673. //
  674. // checkBox3
  675. //
  676. this.checkBox3.AutoSize = true;
  677. this.checkBox3.Checked = true;
  678. this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked;
  679. this.checkBox3.Location = new System.Drawing.Point(142, 25);
  680. this.checkBox3.Name = "checkBox3";
  681. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  682. this.checkBox3.TabIndex = 1;
  683. this.checkBox3.UseVisualStyleBackColor = true;
  684. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  685. //
  686. // checkBox2
  687. //
  688. this.checkBox2.AutoSize = true;
  689. this.checkBox2.Checked = true;
  690. this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
  691. this.checkBox2.Location = new System.Drawing.Point(26, 25);
  692. this.checkBox2.Name = "checkBox2";
  693. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  694. this.checkBox2.TabIndex = 0;
  695. this.checkBox2.UseVisualStyleBackColor = true;
  696. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  697. //
  698. // groupBox8
  699. //
  700. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  701. | System.Windows.Forms.AnchorStyles.Left)));
  702. this.groupBox8.Controls.Add(this.dataGridView1);
  703. this.groupBox8.Location = new System.Drawing.Point(155, 367);
  704. this.groupBox8.Name = "groupBox8";
  705. this.groupBox8.Size = new System.Drawing.Size(353, 189);
  706. this.groupBox8.TabIndex = 8;
  707. this.groupBox8.TabStop = false;
  708. //
  709. // dataGridView1
  710. //
  711. this.dataGridView1.AllowUserToAddRows = false;
  712. this.dataGridView1.AllowUserToDeleteRows = false;
  713. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  714. | System.Windows.Forms.AnchorStyles.Left)
  715. | System.Windows.Forms.AnchorStyles.Right)));
  716. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  717. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  718. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  719. this.dataGridView1.Location = new System.Drawing.Point(7, 21);
  720. this.dataGridView1.MultiSelect = false;
  721. this.dataGridView1.Name = "dataGridView1";
  722. this.dataGridView1.RowHeadersVisible = false;
  723. this.dataGridView1.RowTemplate.Height = 23;
  724. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  725. this.dataGridView1.Size = new System.Drawing.Size(340, 162);
  726. this.dataGridView1.TabIndex = 0;
  727. //
  728. // groupBox9
  729. //
  730. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  731. | System.Windows.Forms.AnchorStyles.Right)));
  732. this.groupBox9.Controls.Add(this.button10);
  733. this.groupBox9.Controls.Add(this.label10);
  734. this.groupBox9.Controls.Add(this.label9);
  735. this.groupBox9.Controls.Add(this.numericUpDown1);
  736. this.groupBox9.Controls.Add(this.label8);
  737. this.groupBox9.Controls.Add(this.button9);
  738. this.groupBox9.Controls.Add(this.button8);
  739. this.groupBox9.Controls.Add(this.dataGridView2);
  740. this.groupBox9.Controls.Add(this.listView2);
  741. this.groupBox9.Controls.Add(this.button7);
  742. this.groupBox9.Controls.Add(this.button6);
  743. this.groupBox9.Location = new System.Drawing.Point(14, 562);
  744. this.groupBox9.Name = "groupBox9";
  745. this.groupBox9.Size = new System.Drawing.Size(1081, 204);
  746. this.groupBox9.TabIndex = 9;
  747. this.groupBox9.TabStop = false;
  748. //
  749. // button10
  750. //
  751. this.button10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  752. this.button10.Location = new System.Drawing.Point(941, 103);
  753. this.button10.Name = "button10";
  754. this.button10.Size = new System.Drawing.Size(128, 26);
  755. this.button10.TabIndex = 10;
  756. this.button10.UseVisualStyleBackColor = true;
  757. this.button10.Click += new System.EventHandler(this.button10_Click);
  758. //
  759. // label10
  760. //
  761. this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  762. this.label10.AutoSize = true;
  763. this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
  764. this.label10.Location = new System.Drawing.Point(927, 9);
  765. this.label10.Name = "label10";
  766. this.label10.Size = new System.Drawing.Size(11, 192);
  767. this.label10.TabIndex = 9;
  768. this.label10.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  769. //
  770. // label9
  771. //
  772. this.label9.AutoSize = true;
  773. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  774. this.label9.Location = new System.Drawing.Point(210, 9);
  775. this.label9.Name = "label9";
  776. this.label9.Size = new System.Drawing.Size(11, 192);
  777. this.label9.TabIndex = 8;
  778. this.label9.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  779. //
  780. // numericUpDown1
  781. //
  782. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  783. this.numericUpDown1.Location = new System.Drawing.Point(993, 162);
  784. this.numericUpDown1.Maximum = new decimal(new int[] {
  785. 10,
  786. 0,
  787. 0,
  788. 0});
  789. this.numericUpDown1.Name = "numericUpDown1";
  790. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  791. this.numericUpDown1.TabIndex = 7;
  792. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  793. //
  794. // label8
  795. //
  796. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  797. this.label8.AutoSize = true;
  798. this.label8.Location = new System.Drawing.Point(957, 167);
  799. this.label8.Name = "label8";
  800. this.label8.Size = new System.Drawing.Size(0, 12);
  801. this.label8.TabIndex = 6;
  802. //
  803. // button9
  804. //
  805. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  806. this.button9.Location = new System.Drawing.Point(941, 68);
  807. this.button9.Name = "button9";
  808. this.button9.Size = new System.Drawing.Size(128, 26);
  809. this.button9.TabIndex = 5;
  810. this.button9.UseVisualStyleBackColor = true;
  811. this.button9.Click += new System.EventHandler(this.button9_Click);
  812. //
  813. // button8
  814. //
  815. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  816. this.button8.Location = new System.Drawing.Point(941, 34);
  817. this.button8.Name = "button8";
  818. this.button8.Size = new System.Drawing.Size(128, 26);
  819. this.button8.TabIndex = 4;
  820. this.button8.UseVisualStyleBackColor = true;
  821. this.button8.Click += new System.EventHandler(this.button8_Click);
  822. //
  823. // dataGridView2
  824. //
  825. this.dataGridView2.AllowUserToAddRows = false;
  826. this.dataGridView2.AllowUserToDeleteRows = false;
  827. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  828. | System.Windows.Forms.AnchorStyles.Left)
  829. | System.Windows.Forms.AnchorStyles.Right)));
  830. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  831. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  832. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  833. this.dataGridView2.Location = new System.Drawing.Point(228, 20);
  834. this.dataGridView2.MultiSelect = false;
  835. this.dataGridView2.Name = "dataGridView2";
  836. this.dataGridView2.RowHeadersVisible = false;
  837. this.dataGridView2.RowTemplate.Height = 23;
  838. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  839. this.dataGridView2.Size = new System.Drawing.Size(693, 176);
  840. this.dataGridView2.TabIndex = 3;
  841. //
  842. // listView2
  843. //
  844. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  845. | System.Windows.Forms.AnchorStyles.Left)));
  846. this.listView2.HideSelection = false;
  847. this.listView2.Location = new System.Drawing.Point(16, 56);
  848. this.listView2.Name = "listView2";
  849. this.listView2.Size = new System.Drawing.Size(181, 140);
  850. this.listView2.TabIndex = 2;
  851. this.listView2.UseCompatibleStateImageBehavior = false;
  852. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  853. //
  854. // button7
  855. //
  856. this.button7.Location = new System.Drawing.Point(145, 20);
  857. this.button7.Name = "button7";
  858. this.button7.Size = new System.Drawing.Size(52, 26);
  859. this.button7.TabIndex = 1;
  860. this.button7.UseVisualStyleBackColor = true;
  861. this.button7.Click += new System.EventHandler(this.button7_Click);
  862. //
  863. // button6
  864. //
  865. this.button6.Location = new System.Drawing.Point(16, 20);
  866. this.button6.Name = "button6";
  867. this.button6.Size = new System.Drawing.Size(93, 26);
  868. this.button6.TabIndex = 0;
  869. this.button6.UseVisualStyleBackColor = true;
  870. this.button6.Click += new System.EventHandler(this.button6_Click);
  871. //
  872. // MetallographicMethod224Dialog
  873. //
  874. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  875. this.ClientSize = new System.Drawing.Size(1107, 771);
  876. this.Controls.Add(this.groupBox9);
  877. this.Controls.Add(this.groupBox8);
  878. this.Controls.Add(this.groupBox7);
  879. this.Controls.Add(this.groupBox6);
  880. this.Controls.Add(this.groupBox5);
  881. this.Controls.Add(this.groupBox4);
  882. this.Controls.Add(this.groupBox3);
  883. this.Controls.Add(this.groupBox2);
  884. this.Controls.Add(this.groupBox1);
  885. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  886. this.Name = "MetallographicMethod224Dialog";
  887. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MetallographicMethod224Dialog_FormClosing);
  888. this.Controls.SetChildIndex(this.groupBox1, 0);
  889. this.Controls.SetChildIndex(this.groupBox2, 0);
  890. this.Controls.SetChildIndex(this.groupBox3, 0);
  891. this.Controls.SetChildIndex(this.groupBox4, 0);
  892. this.Controls.SetChildIndex(this.groupBox5, 0);
  893. this.Controls.SetChildIndex(this.groupBox6, 0);
  894. this.Controls.SetChildIndex(this.groupBox7, 0);
  895. this.Controls.SetChildIndex(this.groupBox8, 0);
  896. this.Controls.SetChildIndex(this.groupBox9, 0);
  897. this.groupBox1.ResumeLayout(false);
  898. this.groupBox1.PerformLayout();
  899. this.groupBox2.ResumeLayout(false);
  900. this.groupBox4.ResumeLayout(false);
  901. this.groupBox5.ResumeLayout(false);
  902. this.groupBox5.PerformLayout();
  903. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
  904. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  905. this.groupBox6.ResumeLayout(false);
  906. this.groupBox6.PerformLayout();
  907. this.groupBox7.ResumeLayout(false);
  908. this.groupBox7.PerformLayout();
  909. this.groupBox8.ResumeLayout(false);
  910. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  911. this.groupBox9.ResumeLayout(false);
  912. this.groupBox9.PerformLayout();
  913. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  914. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  915. this.ResumeLayout(false);
  916. }
  917. /// <summary>
  918. /// 初始化其他控件
  919. /// </summary>
  920. private void InitOtherTools()
  921. {
  922. //
  923. //初始化图像控件
  924. //
  925. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  926. this.documentWorkspace.Dock = DockStyle.Fill;
  927. this.documentWorkspace.HookMouseEvents();
  928. this.documentWorkspace.AuxiliaryLineEnabled = false;
  929. this.documentWorkspace.Visible = false;
  930. this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.NullTool;
  931. this.groupBox3.Controls.Add(documentWorkspace);
  932. //
  933. //初始化操作按钮
  934. //
  935. this.commonControlButtons = new CommonControlButtons();
  936. this.commonControlButtons.Dock = DockStyle.Top;
  937. this.commonControlButtons.Height = 30;
  938. this.commonControlButtons.HideZoomToWindowAndActualSize();
  939. this.commonControlButtons.Visible = false;
  940. this.groupBox3.Controls.Add(commonControlButtons);
  941. //
  942. //调色板
  943. //
  944. this.colorsForm1 = new ColorsForm();
  945. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  946. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  947. this.colorsForm2 = new ColorsForm();
  948. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  949. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  950. this.colorsForm3 = new ColorsForm();
  951. this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
  952. this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  953. this.colorsForm4 = new ColorsForm();
  954. this.colorsForm4.StartPosition = FormStartPosition.CenterScreen;
  955. this.colorsForm4.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  956. this.colorsForm5 = new ColorsForm();
  957. this.colorsForm5.StartPosition = FormStartPosition.CenterScreen;
  958. this.colorsForm5.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  959. //
  960. //颜色panel给定初始值
  961. //
  962. this.panel1.BackColor = Color.Red;
  963. this.panel2.BackColor = Color.Blue;
  964. this.panel3.BackColor = Color.Green;
  965. this.panel4.BackColor = Color.Pink;
  966. this.panel5.BackColor = Color.Yellow;
  967. //
  968. //滚动条与输入框值匹配
  969. //
  970. this.textBox1.Text = "" + this.trackBar1.Value;
  971. this.textBox2.Text = "" + this.trackBar2.Value;
  972. //
  973. //按钮绑定事件
  974. //
  975. this.button3.LostFocus += new System.EventHandler(this.button3_LostFocus);
  976. ////
  977. ////获取系统标尺-微米
  978. ////
  979. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  980. }
  981. /// <summary>
  982. /// 初始化图片列表数据
  983. /// </summary>
  984. public void InitPicList()
  985. {
  986. //初始化图片列表
  987. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  988. {
  989. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  990. this.listView1.Items.Add("", i);
  991. this.listView1.Items[i].ImageIndex = i;
  992. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  993. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  994. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  995. {
  996. defaultIndex = i;
  997. }
  998. }
  999. this.Shown += ShowImgEvent;
  1000. }
  1001. /// <summary>
  1002. /// 初始化表头
  1003. /// </summary>
  1004. private void InitGridHeader()
  1005. {
  1006. //
  1007. //数据展示表
  1008. //
  1009. this.dataGridView1.ColumnHeadersHeight = 50;
  1010. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1011. h1.Width = 72;
  1012. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1013. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1014. h2.Width = 66;
  1015. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1016. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1017. h3.Width = 66;
  1018. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1019. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1020. h4.Width = 66;
  1021. DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();
  1022. h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1023. h5.Width = 66;
  1024. this.dataGridView1.Columns.Add(h1);
  1025. this.dataGridView1.Columns.Add(h2);
  1026. this.dataGridView1.Columns.Add(h3);
  1027. this.dataGridView1.Columns.Add(h4);
  1028. this.dataGridView1.Columns.Add(h5);
  1029. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1030. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.packet.text")));
  1031. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Completelydecarburizedlayer.text")));
  1032. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")));
  1033. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")));
  1034. helper.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Totaldecarburizationlayer.text")));
  1035. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1036. this.dataGridView1.Columns[0].ReadOnly = true;
  1037. this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1038. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1039. this.dataGridView1.Columns[1].ReadOnly = true;
  1040. this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1041. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1042. this.dataGridView1.Columns[2].ReadOnly = true;
  1043. this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1044. this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1045. this.dataGridView1.Columns[3].ReadOnly = true;
  1046. this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1047. this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1048. this.dataGridView1.Columns[4].ReadOnly = true;
  1049. this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1050. this.dataGridView1.AllowUserToResizeRows = false;
  1051. this.dataGridView1.AllowUserToResizeColumns = false;
  1052. //
  1053. //分析结果表
  1054. //
  1055. this.dataGridView2.ColumnHeadersHeight = 30;
  1056. DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();
  1057. h6.Width = 115;
  1058. DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();
  1059. //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1060. h7.Width = 115;
  1061. DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();
  1062. //h8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1063. h8.Width = 115;
  1064. DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();
  1065. //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1066. h9.Width = 115;
  1067. DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn();
  1068. //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1069. h10.Width = 115;
  1070. DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
  1071. //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1072. h11.Width = 115;
  1073. this.dataGridView2.Columns.Add(h6);
  1074. this.dataGridView2.Columns.Add(h7);
  1075. this.dataGridView2.Columns.Add(h8);
  1076. this.dataGridView2.Columns.Add(h9);
  1077. this.dataGridView2.Columns.Add(h10);
  1078. this.dataGridView2.Columns.Add(h11);
  1079. DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  1080. helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1081. helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.packet.text")));
  1082. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Completelydecarburizedlayer.text")));
  1083. helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")));
  1084. helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")));
  1085. helper2.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, PdnResources.GetString("Menu.Totaldecarburizationlayer.text")));
  1086. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1087. this.dataGridView2.Columns[0].ReadOnly = true;
  1088. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1089. this.dataGridView2.Columns[1].ReadOnly = true;
  1090. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1091. this.dataGridView2.Columns[2].ReadOnly = true;
  1092. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1093. this.dataGridView2.Columns[3].ReadOnly = true;
  1094. this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1095. this.dataGridView2.Columns[4].ReadOnly = true;
  1096. this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  1097. this.dataGridView2.Columns[5].ReadOnly = true;
  1098. this.dataGridView2.AllowUserToResizeRows = false;
  1099. this.dataGridView2.AllowUserToResizeColumns = false;
  1100. //
  1101. //左下表
  1102. //
  1103. this.listView2.View = View.Details;
  1104. ColumnHeader header0 = new ColumnHeader();
  1105. header0.Text = PdnResources.GetString("Menu.Resultlist.Text");
  1106. header0.Width = 175;
  1107. this.listView2.Columns.Add(header0);
  1108. }
  1109. /// <summary>
  1110. /// 初始化画布按键功能
  1111. /// </summary>
  1112. private void InitCommonButtonEvent()
  1113. {
  1114. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1115. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1116. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1117. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1118. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1119. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1120. }
  1121. private void zoomInButton_Click(object sender, EventArgs e)
  1122. {
  1123. this.documentWorkspace.ZoomIn();
  1124. }
  1125. private void zoomOutButton_Click(object sender, EventArgs e)
  1126. {
  1127. this.documentWorkspace.ZoomOut();
  1128. }
  1129. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1130. {
  1131. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1132. }
  1133. private void actualSizeButton_Click(object sender, EventArgs e)
  1134. {
  1135. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1136. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1137. }
  1138. private void pointerButton_Click(object sender, EventArgs e)
  1139. {
  1140. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1141. }
  1142. private void mobileModeButton_Click(object sender, EventArgs e)
  1143. {
  1144. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1145. }
  1146. /// <summary>
  1147. /// 添加画布绑定事件
  1148. /// </summary>
  1149. private void AddPictureBoxEvent()
  1150. {
  1151. this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.BoxMouseDownHandler);
  1152. this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.BoxMouseMoveHandler);
  1153. this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.BoxMouseUpHandler);
  1154. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);
  1155. }
  1156. /// <summary>
  1157. /// 调色板回调函数
  1158. /// </summary>
  1159. /// <param name="sender"></param>
  1160. /// <param name="ce"></param>
  1161. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1162. {
  1163. }
  1164. /// <summary>
  1165. /// 添加内容单元格
  1166. /// </summary>
  1167. /// <param name="text"></param>
  1168. /// <param name="tag"></param>
  1169. /// <returns></returns>
  1170. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  1171. {
  1172. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1173. textboxcell.Value = text;
  1174. textboxcell.Tag = tag;
  1175. return textboxcell;
  1176. }
  1177. /// <summary>
  1178. /// 设置按钮
  1179. /// </summary>
  1180. /// <param name="sender"></param>
  1181. /// <param name="e"></param>
  1182. private void button1_Click(object sender, EventArgs e)
  1183. {
  1184. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.MetallographicMethod224");
  1185. if (metallographicMethodSetDialog.hasModule)
  1186. {
  1187. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1188. metallographicMethodSetDialog.ShowDialog();
  1189. }
  1190. else
  1191. {
  1192. metallographicMethodSetDialog = null;
  1193. }
  1194. }
  1195. /// <summary>
  1196. /// 保存结果按钮
  1197. /// </summary>
  1198. /// <param name="sender"></param>
  1199. /// <param name="e"></param>
  1200. private void button2_Click(object sender, EventArgs e)
  1201. {
  1202. if (this.listView1.SelectedItems.Count > 0)
  1203. {
  1204. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1205. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1206. bool replace = false;
  1207. int rowIndex = 0;
  1208. if (this.dataGridView1.Rows.Count > 0)
  1209. {
  1210. if (this.listView2.Items.Count > 0)
  1211. {
  1212. foreach (ListViewItem item in this.listView2.Items)
  1213. {
  1214. if (item.Name.Equals(tag))
  1215. {
  1216. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1217. if(dr == DialogResult.OK)
  1218. {
  1219. replace = true;
  1220. }
  1221. else
  1222. {
  1223. return;
  1224. }
  1225. break;
  1226. }
  1227. }
  1228. }
  1229. //有重名需要替换
  1230. if (replace)
  1231. {
  1232. for(int i = 0; i < this.resultTableList.Count; i++)
  1233. {
  1234. if (this.resultTableList[i].TableName.Equals(tag))
  1235. {
  1236. rowIndex = i;
  1237. this.resultTableList.Remove(this.resultTableList[i]);
  1238. if (this.pointList.Count > 0)
  1239. {
  1240. double avg1 = 0;
  1241. double avg2 = 0;
  1242. double avg3 = 0;
  1243. double avg4 = 0;
  1244. DataTable dt = new DataTable(tag);
  1245. dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1246. dt.Columns.Add(PdnResources.GetString("Menu.packet.text"));
  1247. dt.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  1248. dt.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  1249. dt.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  1250. dt.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  1251. for (int j = 0; j < this.pointList.Count; j++)
  1252. {
  1253. PointF[] pf = pointList[j];
  1254. DataRow dataRow = dt.NewRow();
  1255. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1256. dataRow[PdnResources.GetString("Menu.packet.text")] = "L" + (j + 1);
  1257. if (pf[2] == PointF.Empty)
  1258. dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = 0;
  1259. else
  1260. {
  1261. double dis1 = BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength;
  1262. dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = dis1;
  1263. avg1 += dis1;
  1264. }
  1265. if (pf[3] == PointF.Empty)
  1266. dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = 0;
  1267. else
  1268. {
  1269. double dis2 = BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength;
  1270. dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = dis2;
  1271. avg2 += dis2;
  1272. }
  1273. if (pf[2] == PointF.Empty)
  1274. dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = 0;
  1275. else
  1276. {
  1277. double dis3 = BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength;
  1278. dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = dis3;
  1279. avg3 += dis3;
  1280. }
  1281. double dis4 = BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength;
  1282. dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = dis4;
  1283. avg4 += dis4;
  1284. dt.Rows.Add(dataRow);
  1285. }
  1286. DataRow avgRow = dt.NewRow();
  1287. avgRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1288. avgRow[PdnResources.GetString("Menu.packet.text")] = PdnResources.GetString("Menu.Image.Average.Text");
  1289. avgRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = avg1 / lineCount;
  1290. avgRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = avg2 / lineCount;
  1291. avgRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = avg3 / lineCount;
  1292. avgRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = avg4 / lineCount;
  1293. dt.Rows.Add(avgRow);
  1294. resultTableList.Insert(rowIndex, dt);
  1295. }
  1296. }
  1297. }
  1298. }
  1299. //新增
  1300. else
  1301. {
  1302. ListViewItem listViewItem = new ListViewItem();
  1303. listViewItem.Name = tag;
  1304. listViewItem.SubItems[0].Text = imgName;
  1305. this.listView2.Items.Add(listViewItem);
  1306. this.listView2.SelectedItems.Clear();
  1307. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1308. if (this.pointList.Count > 0)
  1309. {
  1310. //重新计算平均值
  1311. double avg1 = 0;
  1312. double avg2 = 0;
  1313. double avg3 = 0;
  1314. double avg4 = 0;
  1315. DataTable dt = new DataTable(tag);
  1316. dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1317. dt.Columns.Add(PdnResources.GetString("Menu.packet.text"));
  1318. dt.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  1319. dt.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  1320. dt.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  1321. dt.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  1322. for (int i = 0; i < this.pointList.Count; i++)
  1323. {
  1324. PointF[] pf = pointList[i];
  1325. DataRow dataRow = dt.NewRow();
  1326. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1327. dataRow[PdnResources.GetString("Menu.packet.text")] = "L" + (i + 1);
  1328. if (pf[2] == PointF.Empty)
  1329. dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = 0;
  1330. else
  1331. {
  1332. double dis1 = BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength;
  1333. dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = dis1;
  1334. avg1 += dis1;
  1335. }
  1336. if (pf[3] == PointF.Empty)
  1337. dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = 0;
  1338. else
  1339. {
  1340. double dis2 = BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength;
  1341. dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = dis2;
  1342. avg2 += dis2;
  1343. }
  1344. if (pf[2] == PointF.Empty)
  1345. dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = 0;
  1346. else
  1347. {
  1348. double dis3 = BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength;
  1349. dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = dis3;
  1350. avg3 += dis3;
  1351. }
  1352. double dis4 = BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength;
  1353. dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = dis4;
  1354. avg4 += dis4;
  1355. dt.Rows.Add(dataRow);
  1356. }
  1357. DataRow avgRow = dt.NewRow();
  1358. avgRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1359. avgRow[PdnResources.GetString("Menu.packet.text")] = PdnResources.GetString("Menu.Image.Average.Text");
  1360. avgRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = avg1 / lineCount;
  1361. avgRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = avg2 / lineCount;
  1362. avgRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = avg3 / lineCount;
  1363. avgRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = avg4 / lineCount;
  1364. dt.Rows.Add(avgRow);
  1365. resultTableList.Add(dt);
  1366. }
  1367. }
  1368. RefreshDataGridView2();
  1369. //保存处理后的图片
  1370. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1371. List<Bitmap> tempBit = new List<Bitmap>();
  1372. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1373. originalBit.Tag = pantographRatio;
  1374. tempBit.Add(originalBit);
  1375. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1376. Graphics graphics = Graphics.FromImage(newBit);
  1377. if (this.documentWorkspace.phaseModels != null && this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null)
  1378. {
  1379. Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.phaseModels[0].mat);
  1380. graphics.DrawImage(processedBit, new PointF(0, 0));
  1381. }
  1382. Draw(graphics);
  1383. newBit.Tag = pantographRatio;
  1384. tempBit.Add(newBit);
  1385. if (bitDic.ContainsKey(tag))
  1386. bitDic[tag] = tempBit;
  1387. else
  1388. bitDic.Add(tag, tempBit);
  1389. //拼接中间数据
  1390. List<List<string>> dataList = new List<List<string>>();
  1391. List<string> columnName = new List<string>();
  1392. columnName.Add(PdnResources.GetString("Menu.packet.text"));
  1393. columnName.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  1394. columnName.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  1395. columnName.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  1396. columnName.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  1397. dataList.Add(columnName);
  1398. if (this.pointList.Count > 0)
  1399. {
  1400. for (int i = 0; i < this.pointList.Count; i++)
  1401. {
  1402. PointF[] pf = pointList[i];
  1403. List<string> strList = new List<string>();
  1404. strList.Add("L" + (i + 1));
  1405. if (pf[2] == PointF.Empty)
  1406. strList.Add("0");
  1407. else
  1408. strList.Add((BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength).ToString());
  1409. if (pf[3] == PointF.Empty)
  1410. strList.Add("0");
  1411. else
  1412. strList.Add((BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength).ToString());
  1413. if (pf[2] == PointF.Empty)
  1414. strList.Add("0");
  1415. else
  1416. strList.Add((BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength).ToString());
  1417. strList.Add((BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength).ToString());
  1418. dataList.Add(strList);
  1419. }
  1420. }
  1421. bool isExist = false;//是否已存在进行替换
  1422. int modelIndex = -1;//要替换的下标
  1423. for (int j = 0; j < tempDataModel.Count; j++)
  1424. {
  1425. if (tempDataModel[j].tagName.Equals(tag))
  1426. {
  1427. isExist = true;
  1428. modelIndex = j;
  1429. break;
  1430. }
  1431. }
  1432. if (isExist && modelIndex > -1)
  1433. tempDataModel[modelIndex].dataList = dataList;
  1434. else
  1435. {
  1436. ExportProjectModel newModel = new ExportProjectModel();
  1437. newModel.tagName = tag;
  1438. newModel.picName = imgName;
  1439. newModel.dataList = dataList;
  1440. tempDataModel.Add(newModel);
  1441. }
  1442. }
  1443. else
  1444. {
  1445. MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawthemeasuringlinefirst.text"));
  1446. }
  1447. }
  1448. else
  1449. {
  1450. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1451. }
  1452. }
  1453. /// <summary>
  1454. /// 刷新分析结果表
  1455. /// </summary>
  1456. private void RefreshDataGridView2()
  1457. {
  1458. this.dataGridView2.Rows.Clear();
  1459. if (this.showAll)
  1460. {
  1461. if (this.resultTableList.Count > 0)
  1462. {
  1463. foreach (DataTable dt in resultTableList)
  1464. {
  1465. for(int i = 0; i < dt.Rows.Count; i++)
  1466. {
  1467. DataGridViewRow row = new DataGridViewRow();
  1468. row.Height = 30;
  1469. row.Cells.Add(CreateTextBoxCell(dt.Rows[i][0].ToString(), ""));
  1470. row.Cells.Add(CreateTextBoxCell(dt.Rows[i][1].ToString(), ""));
  1471. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][2].ToString()) ? "0" :
  1472. dt.Rows[i][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1473. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][3].ToString()) ? "0" :
  1474. dt.Rows[i][3].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1475. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][4].ToString()) ? "0" :
  1476. dt.Rows[i][4].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1477. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][5].ToString()) ? "0" :
  1478. dt.Rows[i][5].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1479. this.dataGridView2.Rows.Add(row);
  1480. }
  1481. }
  1482. }
  1483. }
  1484. else
  1485. {
  1486. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1487. {
  1488. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1489. {
  1490. string tableName = this.listView2.SelectedItems[i].Name;
  1491. foreach (DataTable dt in resultTableList)
  1492. {
  1493. if (dt.TableName.Equals(tableName))
  1494. {
  1495. for (int j = 0; j < dt.Rows.Count; j++)
  1496. {
  1497. DataGridViewRow row = new DataGridViewRow();
  1498. row.Height = 30;
  1499. row.Cells.Add(CreateTextBoxCell(dt.Rows[j][0].ToString(), ""));
  1500. row.Cells.Add(CreateTextBoxCell(dt.Rows[j][1].ToString(), ""));
  1501. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][2].ToString()) ? "0" :
  1502. dt.Rows[j][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1503. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][3].ToString()) ? "0" :
  1504. dt.Rows[j][3].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1505. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][4].ToString()) ? "0" :
  1506. dt.Rows[j][4].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1507. row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][5].ToString()) ? "0" :
  1508. dt.Rows[j][5].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1509. this.dataGridView2.Rows.Add(row);
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. }
  1516. }
  1517. /// <summary>
  1518. /// 添加测量线按钮
  1519. /// </summary>
  1520. /// <param name="sender"></param>
  1521. /// <param name="e"></param>
  1522. private void button3_Click(object sender, EventArgs e)
  1523. {
  1524. operationK = 0;
  1525. selected = -1;
  1526. this.documentWorkspace.Refresh();
  1527. }
  1528. /// <summary>
  1529. /// 选择测量线按钮
  1530. /// </summary>
  1531. /// <param name="sender"></param>
  1532. /// <param name="e"></param>
  1533. private void button4_Click(object sender, EventArgs e)
  1534. {
  1535. operationK = 1;
  1536. }
  1537. /// <summary>
  1538. /// 删除测量线按钮
  1539. /// </summary>
  1540. /// <param name="sender"></param>
  1541. /// <param name="e"></param>
  1542. private void button5_Click(object sender, EventArgs e)
  1543. {
  1544. if (selected > -1)
  1545. {
  1546. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1547. if (dr == DialogResult.OK)
  1548. {
  1549. this.pointList.Remove(this.pointList[selected]);
  1550. this.rectangleFList.Remove(this.rectangleFList[selected]);
  1551. selected = -1;
  1552. lineCount--;
  1553. RefreshDataGridView1();
  1554. this.documentWorkspace.Refresh();
  1555. }
  1556. }
  1557. else
  1558. MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text"));
  1559. }
  1560. /// <summary>
  1561. /// 按键DELETE删除测量线
  1562. /// </summary>
  1563. /// <param name="sender"></param>
  1564. /// <param name="e"></param>
  1565. protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  1566. {
  1567. if (keyData == Keys.Delete)
  1568. {
  1569. if (selected > -1)
  1570. {
  1571. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1572. if (dr == DialogResult.OK)
  1573. {
  1574. this.pointList.Remove(this.pointList[selected]);
  1575. this.rectangleFList.Remove(this.rectangleFList[selected]);
  1576. selected = -1;
  1577. lineCount--;
  1578. RefreshDataGridView1();
  1579. this.documentWorkspace.Refresh();
  1580. }
  1581. }
  1582. else
  1583. MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text"));
  1584. }
  1585. return true;
  1586. //return base.ProcessCmdKey(ref msg, keyData);
  1587. }
  1588. /// <summary>
  1589. /// 全部显示按钮
  1590. /// </summary>
  1591. /// <param name="sender"></param>
  1592. /// <param name="e"></param>
  1593. private void button6_Click(object sender, EventArgs e)
  1594. {
  1595. if(this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1596. {
  1597. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1598. this.showAll = true;
  1599. RefreshDataGridView2();
  1600. }
  1601. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1602. {
  1603. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1604. this.showAll = false;
  1605. RefreshDataGridView2();
  1606. }
  1607. }
  1608. /// <summary>
  1609. /// 删除按钮
  1610. /// </summary>
  1611. /// <param name="sender"></param>
  1612. /// <param name="e"></param>
  1613. private void button7_Click(object sender, EventArgs e)
  1614. {
  1615. if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1616. {
  1617. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1618. if (dr == DialogResult.OK)
  1619. {
  1620. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1621. {
  1622. string tableName = this.listView2.SelectedItems[i].Name;
  1623. foreach (DataTable dt in resultTableList)
  1624. {
  1625. if (dt.TableName.Equals(tableName))
  1626. {
  1627. resultTableList.Remove(dt);
  1628. break;
  1629. }
  1630. }
  1631. if (bitDic.ContainsKey(tableName))
  1632. bitDic.Remove(tableName);
  1633. foreach (ExportProjectModel model in this.tempDataModel)
  1634. {
  1635. if (model.tagName.Equals(tableName))
  1636. {
  1637. this.tempDataModel.Remove(model);
  1638. break;
  1639. }
  1640. }
  1641. }
  1642. foreach (ListViewItem item in this.listView2.Items)
  1643. {
  1644. if (item.Selected)
  1645. this.listView2.Items.Remove(item);
  1646. }
  1647. RefreshDataGridView2();
  1648. }
  1649. }
  1650. }
  1651. /// <summary>
  1652. /// 生成报告按钮
  1653. /// </summary>
  1654. /// <param name="sender"></param>
  1655. /// <param name="e"></param>
  1656. private void button8_Click(object sender, EventArgs e)
  1657. {
  1658. if (this.checkBox1.Checked)
  1659. this.button1.PerformClick();
  1660. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1661. {
  1662. //获取word书签与excel单元格的关系,以字典方式存储
  1663. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1664. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1665. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1666. {
  1667. foreach (mic_module_infos info in mic_module_infos)
  1668. {
  1669. tagInfos.Add(info.tag_name, info.cell_position);
  1670. }
  1671. }
  1672. //分析结果
  1673. List<List<string>> analysisContent = new List<List<string>>();
  1674. List<string> contentHead = new List<string>();
  1675. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  1676. contentHead.Add(PdnResources.GetString("Menu.packet.text"));
  1677. contentHead.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  1678. contentHead.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  1679. contentHead.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  1680. contentHead.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  1681. analysisContent.Add(contentHead);
  1682. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1683. {
  1684. List<string> content = new List<string>();
  1685. content.Add(item.Cells[0].Value.ToString());
  1686. content.Add(item.Cells[1].Value.ToString());
  1687. content.Add(item.Cells[2].Value.ToString());
  1688. content.Add(item.Cells[3].Value.ToString());
  1689. content.Add(item.Cells[4].Value.ToString());
  1690. content.Add(item.Cells[5].Value.ToString());
  1691. analysisContent.Add(content);
  1692. }
  1693. //图片
  1694. bitList = new List<Bitmap>();
  1695. if (this.showAll)
  1696. {
  1697. foreach(KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1698. {
  1699. bitList.Add(kv.Value[0]);
  1700. bitList.Add(kv.Value[1]);
  1701. }
  1702. }
  1703. else
  1704. {
  1705. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1706. {
  1707. foreach (ListViewItem item in this.listView2.SelectedItems)
  1708. {
  1709. if (bitDic.ContainsKey(item.Name))
  1710. {
  1711. bitList.Add(bitDic[item.Name][0]);
  1712. bitList.Add(bitDic[item.Name][1]);
  1713. }
  1714. }
  1715. }
  1716. }
  1717. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1718. }
  1719. else
  1720. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1721. }
  1722. /// <summary>
  1723. /// 导出结果按钮
  1724. /// </summary>
  1725. /// <param name="sender"></param>
  1726. /// <param name="e"></param>
  1727. private void button9_Click(object sender, EventArgs e)
  1728. {
  1729. if (this.listView2.Items.Count > 0)
  1730. {
  1731. SaveFileDialog exe = new SaveFileDialog();
  1732. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1733. exe.FilterIndex = 0;
  1734. exe.RestoreDirectory = true;
  1735. exe.Title = "Export Excel File";
  1736. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1737. exe.FileName = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Metallographicmethod.text")+"GBT224" + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1738. DialogResult dr = exe.ShowDialog();
  1739. if (dr != DialogResult.OK)
  1740. return;
  1741. DataTable dtb = new DataTable();
  1742. dtb.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1743. dtb.Columns.Add(PdnResources.GetString("Menu.packet.text"));
  1744. dtb.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  1745. dtb.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  1746. dtb.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  1747. dtb.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  1748. for(int i = 0; i < this.dataGridView2.Rows.Count; i++)
  1749. {
  1750. DataRow dataRow = dtb.NewRow();
  1751. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView2.Rows[i].Cells[0].Value;
  1752. dataRow[PdnResources.GetString("Menu.packet.text")] = this.dataGridView2.Rows[i].Cells[1].Value;
  1753. dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = this.dataGridView2.Rows[i].Cells[2].Value;
  1754. dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = this.dataGridView2.Rows[i].Cells[3].Value;
  1755. dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = this.dataGridView2.Rows[i].Cells[4].Value;
  1756. dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = this.dataGridView2.Rows[i].Cells[5].Value;
  1757. dtb.Rows.Add(dataRow);
  1758. }
  1759. List<DataTable> list = new List<DataTable>();
  1760. list.Add(dtb);
  1761. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1762. }
  1763. else
  1764. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  1765. }
  1766. /// <summary>
  1767. /// 图像索引切换选中事件
  1768. /// </summary>
  1769. /// <param name="sender"></param>
  1770. /// <param name="e"></param>
  1771. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1772. {
  1773. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1774. {
  1775. unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1776. this.documentWorkspace.phaseModels.Clear();
  1777. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1778. Document document = Document.FromImage(bitmap);
  1779. this.documentWorkspace.Document = document;
  1780. this.documentWorkspace.Visible = true;
  1781. //this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
  1782. if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count == 0)
  1783. {
  1784. this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels;
  1785. }
  1786. else
  1787. {
  1788. this.documentWorkspace.phaseModels.Add(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].AnalysisPhaseModel);
  1789. }
  1790. //this.documentWorkspace.PhaseModels[0].choise = true;
  1791. this.commonControlButtons.Visible = true;
  1792. pointList = new List<PointF[]>();
  1793. rectangleFList = new List<RectangleF>();
  1794. lineCount = 0;
  1795. this.dataGridView1.Rows.Clear();
  1796. }
  1797. }
  1798. /// <summary>
  1799. /// 添加测量线按钮失去焦点
  1800. /// </summary>
  1801. /// <param name="sender"></param>
  1802. /// <param name="e"></param>
  1803. private void button3_LostFocus(object sender, EventArgs e)
  1804. {
  1805. operationK = -1;
  1806. selected = -1;
  1807. this.documentWorkspace.Refresh();
  1808. }
  1809. /// <summary>
  1810. /// 限制只可以输入0-9数字以及退格键
  1811. /// </summary>
  1812. /// <param name="sender"></param>
  1813. /// <param name="e"></param>
  1814. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  1815. {
  1816. if (e.KeyChar != '\b')//这是允许输入退格键 
  1817.             {
  1818. int len = this.textBox1.Text.Length;
  1819. if (len < 1 && e.KeyChar == '0')
  1820. {
  1821. e.Handled = true;
  1822. }
  1823. else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字 
  1824.                 {
  1825. e.Handled = true;
  1826. }
  1827. }
  1828. }
  1829. /// <summary>
  1830. /// 对输入值做限制
  1831. /// </summary>
  1832. /// <param name="sender"></param>
  1833. /// <param name="e"></param>
  1834. private void textBox1_KeyUp(object sender, KeyEventArgs e)
  1835. {
  1836. if (string.IsNullOrEmpty(this.textBox1.Text))
  1837. this.textBox1.Text = "1";
  1838. if (Convert.ToInt32(this.textBox1.Text) > 50)
  1839. this.textBox1.Text = "50";
  1840. this.trackBar1.Value = Convert.ToInt32(this.textBox1.Text);
  1841. }
  1842. /// <summary>
  1843. /// 限制只可以输入0-9数字以及退格键
  1844. /// </summary>
  1845. /// <param name="sender"></param>
  1846. /// <param name="e"></param>
  1847. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  1848. {
  1849. if (e.KeyChar != '\b')//这是允许输入退格键 
  1850.             {
  1851. int len = this.textBox1.Text.Length;
  1852. if (len < 1 && e.KeyChar == '0')
  1853. {
  1854. e.Handled = true;
  1855. }
  1856. else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字 
  1857.                 {
  1858. e.Handled = true;
  1859. }
  1860. }
  1861. }
  1862. /// <summary>
  1863. /// 对输入值做限制
  1864. /// </summary>
  1865. /// <param name="sender"></param>
  1866. /// <param name="e"></param>
  1867. private void textBox2_KeyUp(object sender, KeyEventArgs e)
  1868. {
  1869. if (string.IsNullOrEmpty(this.textBox2.Text))
  1870. this.textBox2.Text = "1";
  1871. if (Convert.ToInt32(this.textBox2.Text) > 50)
  1872. this.textBox2.Text = "50";
  1873. this.trackBar2.Value = Convert.ToInt32(this.textBox2.Text);
  1874. }
  1875. /// <summary>
  1876. /// 基准线panel被点击
  1877. /// </summary>
  1878. /// <param name="sender"></param>
  1879. /// <param name="e"></param>
  1880. private void panel1_Click(object sender, EventArgs e)
  1881. {
  1882. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  1883. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  1884. this.colorsForm1.ShowDialog();
  1885. }
  1886. private void colorsForm1Changed(object sender, EventArgs e)
  1887. {
  1888. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  1889. this.colorsForm1.Close();
  1890. this.documentWorkspace.Refresh();
  1891. }
  1892. /// <summary>
  1893. /// 钢样表面panel被点击
  1894. /// </summary>
  1895. /// <param name="sender"></param>
  1896. /// <param name="e"></param>
  1897. private void panel2_Click(object sender, EventArgs e)
  1898. {
  1899. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  1900. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed));
  1901. this.colorsForm2.ShowDialog();
  1902. }
  1903. private void colorsForm2Changed(object sender, EventArgs e)
  1904. {
  1905. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  1906. this.colorsForm2.Close();
  1907. this.documentWorkspace.Refresh();
  1908. }
  1909. /// <summary>
  1910. /// 完全脱碳层panel被点击
  1911. /// </summary>
  1912. /// <param name="sender"></param>
  1913. /// <param name="e"></param>
  1914. private void panel3_Click(object sender, EventArgs e)
  1915. {
  1916. this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel3.BackColor);
  1917. this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.colorsForm3Changed));
  1918. this.colorsForm3.ShowDialog();
  1919. }
  1920. private void colorsForm3Changed(object sender, EventArgs e)
  1921. {
  1922. this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
  1923. this.colorsForm3.Close();
  1924. this.documentWorkspace.Refresh();
  1925. }
  1926. /// <summary>
  1927. /// 有效脱碳层panel被点击
  1928. /// </summary>
  1929. /// <param name="sender"></param>
  1930. /// <param name="e"></param>
  1931. private void panel4_Click(object sender, EventArgs e)
  1932. {
  1933. this.colorsForm4.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
  1934. this.colorsForm4.setSaveBtn_Click(new System.EventHandler(this.colorsForm4Changed));
  1935. this.colorsForm4.ShowDialog();
  1936. }
  1937. private void colorsForm4Changed(object sender, EventArgs e)
  1938. {
  1939. this.panel4.BackColor = this.colorsForm4.UserPrimaryColor.ToColor();
  1940. this.colorsForm4.Close();
  1941. this.documentWorkspace.Refresh();
  1942. }
  1943. /// <summary>
  1944. /// 部分脱碳层panel被点击
  1945. /// </summary>
  1946. /// <param name="sender"></param>
  1947. /// <param name="e"></param>
  1948. private void panel5_Click(object sender, EventArgs e)
  1949. {
  1950. this.colorsForm5.UserPrimaryColor = ColorBgra.FromColor(this.panel5.BackColor);
  1951. this.colorsForm5.setSaveBtn_Click(new System.EventHandler(this.colorsForm5Changed));
  1952. this.colorsForm5.ShowDialog();
  1953. }
  1954. private void colorsForm5Changed(object sender, EventArgs e)
  1955. {
  1956. this.panel5.BackColor = this.colorsForm5.UserPrimaryColor.ToColor();
  1957. this.colorsForm5.Close();
  1958. this.documentWorkspace.Refresh();
  1959. }
  1960. /// <summary>
  1961. /// 线长滚动条滚动事件
  1962. /// </summary>
  1963. /// <param name="sender"></param>
  1964. /// <param name="e"></param>
  1965. private void trackBar1_Scroll(object sender, EventArgs e)
  1966. {
  1967. this.textBox1.Text = "" + this.trackBar1.Value;
  1968. }
  1969. private void trackBar1_ValueChanged(object sender, EventArgs e)
  1970. {
  1971. if (this.documentWorkspace != null)
  1972. {
  1973. this.documentWorkspace.Refresh();
  1974. }
  1975. }
  1976. /// <summary>
  1977. /// 线宽滚动条滚动事件
  1978. /// </summary>
  1979. /// <param name="sender"></param>
  1980. /// <param name="e"></param>
  1981. private void trackBar2_Scroll(object sender, EventArgs e)
  1982. {
  1983. this.textBox2.Text = "" + this.trackBar2.Value;
  1984. }
  1985. private void trackBar2_ValueChanged(object sender, EventArgs e)
  1986. {
  1987. if (this.documentWorkspace != null)
  1988. {
  1989. this.documentWorkspace.Refresh();
  1990. }
  1991. }
  1992. /// <summary>
  1993. /// 完全脱碳层选择框选中事件
  1994. /// </summary>
  1995. /// <param name="sender"></param>
  1996. /// <param name="e"></param>
  1997. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1998. {
  1999. if(this.pointList.Count > 0)
  2000. {
  2001. if (this.checkBox2.Checked && this.checkBox3.Checked)
  2002. {
  2003. foreach(PointF[] pf in pointList)
  2004. {
  2005. pf[2] = new PointF((pf[0].X + pf[3].X) / 2f, (pf[0].Y + pf[3].Y) / 2f);
  2006. }
  2007. }
  2008. if (this.checkBox2.Checked && !this.checkBox3.Checked)
  2009. {
  2010. foreach (PointF[] pf in pointList)
  2011. {
  2012. pf[2] = new PointF((pf[0].X + pf[1].X) / 2f, (pf[0].Y + pf[1].Y) / 2f);
  2013. }
  2014. }
  2015. if (!this.checkBox2.Checked)
  2016. {
  2017. foreach (PointF[] pf in pointList)
  2018. {
  2019. pf[2] = PointF.Empty;
  2020. }
  2021. }
  2022. RefreshDataGridView1();
  2023. this.documentWorkspace.Refresh();
  2024. }
  2025. }
  2026. /// <summary>
  2027. /// 有效脱碳层选择框选中事件
  2028. /// </summary>
  2029. /// <param name="sender"></param>
  2030. /// <param name="e"></param>
  2031. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  2032. {
  2033. if (this.pointList.Count > 0)
  2034. {
  2035. if (this.checkBox3.Checked && this.checkBox2.Checked)
  2036. {
  2037. foreach (PointF[] pf in pointList)
  2038. {
  2039. pf[3] = new PointF((pf[2].X + pf[1].X) / 2f, (pf[2].Y + pf[1].Y) / 2f);
  2040. }
  2041. }
  2042. if (this.checkBox3.Checked && !this.checkBox2.Checked)
  2043. {
  2044. foreach (PointF[] pf in pointList)
  2045. {
  2046. pf[3] = new PointF((pf[0].X + pf[1].X) / 2f, (pf[0].Y + pf[1].Y) / 2f);
  2047. }
  2048. }
  2049. if (!this.checkBox3.Checked)
  2050. {
  2051. foreach (PointF[] pf in pointList)
  2052. {
  2053. pf[3] = PointF.Empty;
  2054. }
  2055. }
  2056. RefreshDataGridView1();
  2057. this.documentWorkspace.Refresh();
  2058. }
  2059. }
  2060. /// <summary>
  2061. /// 小数数字框值改变
  2062. /// </summary>
  2063. /// <param name="sender"></param>
  2064. /// <param name="e"></param>
  2065. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  2066. {
  2067. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  2068. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  2069. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  2070. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  2071. RefreshDataGridView1();
  2072. RefreshDataGridView2();
  2073. if (this.documentWorkspace != null)
  2074. {
  2075. this.documentWorkspace.Refresh();
  2076. }
  2077. }
  2078. /// <summary>
  2079. /// 鼠标按下
  2080. /// </summary>
  2081. /// <param name="sender"></param>
  2082. /// <param name="e"></param>
  2083. private void BoxMouseDownHandler(object sender, MouseEventArgs e)
  2084. {
  2085. if (operationK >= 0 && e.Button == MouseButtons.Left)
  2086. {
  2087. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  2088. if (operationK == 0)
  2089. {
  2090. startPoint = endPoint = downPoint;
  2091. nowLine = new PointF[4];
  2092. nowLine[0] = startPoint;
  2093. nowLine[1] = endPoint;
  2094. pointList.Add(nowLine);
  2095. }
  2096. else if (operationK == 1)
  2097. {
  2098. lastPoint.X = downPoint.X;
  2099. lastPoint.Y = downPoint.Y;
  2100. tempPoint.X = downPoint.X;
  2101. tempPoint.Y = downPoint.Y;
  2102. for (int i = rectangleFList.Count - 1; i >= 0; i--)
  2103. {
  2104. if (rectangleFList[i].Contains(downPoint))
  2105. {
  2106. selected = i;
  2107. canMove = true;
  2108. }
  2109. }
  2110. if(selected > -1 && pointList!=null && pointList.Count>0)
  2111. {
  2112. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  2113. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  2114. if (new RectangleF(pointList[selected][0].X - tempLess, pointList[selected][0].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  2115. movePointIndex = 0;
  2116. else if (new RectangleF(pointList[selected][1].X - tempLess, pointList[selected][1].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  2117. movePointIndex = 1;
  2118. else if (pointList[selected][2] != PointF.Empty && new RectangleF(pointList[selected][2].X - tempLess, pointList[selected][2].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  2119. movePointIndex = 2;
  2120. else if (pointList[selected][3] != PointF.Empty && new RectangleF(pointList[selected][3].X - tempLess, pointList[selected][3].Y - tempLess, tempPlus, tempPlus).Contains(downPoint))
  2121. movePointIndex = 3;
  2122. else
  2123. movePointIndex = -1;
  2124. this.documentWorkspace.Refresh();
  2125. }
  2126. if (canMove)
  2127. return;
  2128. selected = -1;
  2129. }
  2130. }
  2131. }
  2132. /// <summary>
  2133. /// 鼠标移动
  2134. /// </summary>
  2135. /// <param name="sender"></param>
  2136. /// <param name="e"></param>
  2137. private void BoxMouseMoveHandler(object sender, MouseEventArgs e)
  2138. {
  2139. this.documentWorkspace.panel.Cursor = Cursors.Default;
  2140. if (operationK >= 0 && e.Button == MouseButtons.Left)
  2141. {
  2142. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  2143. if (operationK == 0)
  2144. {
  2145. this.endPoint = movePoint;
  2146. pointList[lineCount][1] = endPoint;
  2147. }
  2148. else if (operationK == 1 && selected > -1 && canMove)
  2149. {
  2150. float dx = movePoint.X - lastPoint.X;
  2151. float dy = movePoint.Y - lastPoint.Y;
  2152. float dxTemp = movePoint.X - tempPoint.X;
  2153. float dyTemp = movePoint.Y - tempPoint.Y;
  2154. lastPoint.X = movePoint.X;
  2155. lastPoint.Y = movePoint.Y;
  2156. if (movePointIndex == -1)
  2157. {
  2158. RectangleF rectangleF = new RectangleF();
  2159. rectangleF = rectangleFList[selected];
  2160. if (rectangleF.Contains(movePoint))
  2161. this.documentWorkspace.panel.Cursor = Cursors.SizeAll;
  2162. rectangleF.X += dx;
  2163. rectangleF.Y += dy;
  2164. rectangleFList[selected] = rectangleF;
  2165. for (int i = 0; i < pointList[selected].Count(); i++)
  2166. {
  2167. if (pointList[selected][i] == PointF.Empty)
  2168. continue;
  2169. pointList[selected][i].X += dx;
  2170. pointList[selected][i].Y += dy;
  2171. }
  2172. }
  2173. else if (movePointIndex == 0)
  2174. {
  2175. pointList[selected][0].X += dx;
  2176. pointList[selected][0].Y += dy;
  2177. if (checkBox2.Checked && checkBox3.Checked)
  2178. {
  2179. pointList[selected][2] = new PointF((2 * pointList[selected][0].X + pointList[selected][1].X) / 3f,
  2180. (2 * pointList[selected][0].Y + pointList[selected][1].Y) / 3f);
  2181. pointList[selected][3] = new PointF((pointList[selected][0].X + 2 * pointList[selected][1].X) / 3f,
  2182. (pointList[selected][0].Y + 2 * pointList[selected][1].Y) / 3f);
  2183. }
  2184. else if (checkBox2.Checked && !checkBox3.Checked)
  2185. {
  2186. pointList[selected][2] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f,
  2187. (pointList[selected][0].Y + pointList[selected][1].Y) / 2f);
  2188. pointList[selected][3] = PointF.Empty;
  2189. }
  2190. else if (!checkBox2.Checked && checkBox3.Checked)
  2191. {
  2192. pointList[selected][3] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f,
  2193. (pointList[selected][0].Y + pointList[selected][1].Y) / 2f);
  2194. pointList[selected][2] = PointF.Empty;
  2195. }
  2196. else
  2197. {
  2198. pointList[selected][2] = PointF.Empty;
  2199. pointList[selected][3] = PointF.Empty;
  2200. }
  2201. rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]);
  2202. }
  2203. else if (movePointIndex == 1)
  2204. {
  2205. pointList[selected][1].X += dx;
  2206. pointList[selected][1].Y += dy;
  2207. if (checkBox2.Checked && checkBox3.Checked)
  2208. {
  2209. pointList[selected][2] = new PointF((2 * pointList[selected][0].X + pointList[selected][1].X) / 3f,
  2210. (2 * pointList[selected][0].Y + pointList[selected][1].Y) / 3f);
  2211. pointList[selected][3] = new PointF((pointList[selected][0].X + 2 * pointList[selected][1].X) / 3f,
  2212. (pointList[selected][0].Y + 2 * pointList[selected][1].Y) / 3f);
  2213. }
  2214. else if (checkBox2.Checked && !checkBox3.Checked)
  2215. {
  2216. pointList[selected][2] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f,
  2217. (pointList[selected][0].Y + pointList[selected][1].Y) / 2f);
  2218. pointList[selected][3] = PointF.Empty;
  2219. }
  2220. else if (!checkBox2.Checked && checkBox3.Checked)
  2221. {
  2222. pointList[selected][3] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f,
  2223. (pointList[selected][0].Y + pointList[selected][1].Y) / 2f);
  2224. pointList[selected][2] = PointF.Empty;
  2225. }
  2226. else
  2227. {
  2228. pointList[selected][2] = PointF.Empty;
  2229. pointList[selected][3] = PointF.Empty;
  2230. }
  2231. rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]);
  2232. }
  2233. else if (movePointIndex == 2)
  2234. {
  2235. //测量线是一条垂线
  2236. if (pointList[selected][0].X == pointList[selected][1].X)
  2237. {
  2238. pointList[selected][2].Y += dy;
  2239. if (pointList[selected][3] == PointF.Empty)
  2240. pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][2].Y);
  2241. else
  2242. pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][3].Y, pointList[selected][2].Y);
  2243. }
  2244. //测量线是一条平行线
  2245. else if (pointList[selected][0].Y == pointList[selected][1].Y)
  2246. {
  2247. pointList[selected][2].X += dx;
  2248. if (pointList[selected][3] == PointF.Empty)
  2249. pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][2].X);
  2250. else
  2251. pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][3].X, pointList[selected][2].X);
  2252. }
  2253. //其他情况
  2254. else
  2255. {
  2256. float k = (pointList[selected][1].Y - pointList[selected][0].Y) / (pointList[selected][1].X - pointList[selected][0].X);
  2257. float b = pointList[selected][0].Y - k * pointList[selected][0].X;
  2258. if (Math.Abs(dxTemp) >= Math.Abs(dyTemp))
  2259. {
  2260. pointList[selected][2].X += dx;
  2261. if (pointList[selected][3] == PointF.Empty)
  2262. pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][2].X);
  2263. else
  2264. pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][3].X, pointList[selected][2].X);
  2265. pointList[selected][2].Y = k * pointList[selected][2].X + b;
  2266. }
  2267. else
  2268. {
  2269. pointList[selected][2].Y += dy;
  2270. if (pointList[selected][3] == PointF.Empty)
  2271. pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][2].Y);
  2272. else
  2273. pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][3].Y, pointList[selected][2].Y);
  2274. pointList[selected][2].X = (pointList[selected][2].Y - b) / k;
  2275. }
  2276. }
  2277. }
  2278. else if (movePointIndex == 3)
  2279. {
  2280. //测量线是一条垂线
  2281. if (pointList[selected][0].X == pointList[selected][1].X)
  2282. {
  2283. pointList[selected][3].Y += dy;
  2284. if (pointList[selected][2] == PointF.Empty)
  2285. pointList[selected][3].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][3].Y);
  2286. else
  2287. pointList[selected][3].Y = FormatCoordinate(pointList[selected][2].Y, pointList[selected][1].Y, pointList[selected][3].Y);
  2288. }
  2289. //测量线是一条平行线
  2290. else if (pointList[selected][0].Y == pointList[selected][1].Y)
  2291. {
  2292. pointList[selected][3].X += dx;
  2293. if (pointList[selected][2] == PointF.Empty)
  2294. pointList[selected][3].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][3].X);
  2295. else
  2296. pointList[selected][3].X = FormatCoordinate(pointList[selected][2].X, pointList[selected][1].X, pointList[selected][3].X);
  2297. }
  2298. //其他情况
  2299. else
  2300. {
  2301. float k = (pointList[selected][1].Y - pointList[selected][0].Y) / (pointList[selected][1].X - pointList[selected][0].X);
  2302. float b = pointList[selected][0].Y - k * pointList[selected][0].X;
  2303. if (Math.Abs(dxTemp) >= Math.Abs(dyTemp))
  2304. {
  2305. pointList[selected][3].X += dx;
  2306. if (pointList[selected][2] == PointF.Empty)
  2307. pointList[selected][3].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][3].X);
  2308. else
  2309. pointList[selected][3].X = FormatCoordinate(pointList[selected][2].X, pointList[selected][1].X, pointList[selected][3].X);
  2310. pointList[selected][3].Y = k * pointList[selected][3].X + b;
  2311. }
  2312. else
  2313. {
  2314. pointList[selected][3].Y += dy;
  2315. if (pointList[selected][2] == PointF.Empty)
  2316. pointList[selected][3].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][3].Y);
  2317. else
  2318. pointList[selected][3].Y = FormatCoordinate(pointList[selected][2].Y, pointList[selected][1].Y, pointList[selected][3].Y);
  2319. pointList[selected][3].X = (pointList[selected][3].Y - b) / k;
  2320. }
  2321. }
  2322. }
  2323. }
  2324. this.documentWorkspace.Refresh();
  2325. }
  2326. }
  2327. /// <summary>
  2328. /// 鼠标抬起
  2329. /// </summary>
  2330. /// <param name="sender"></param>
  2331. /// <param name="e"></param>
  2332. private void BoxMouseUpHandler(object sender, MouseEventArgs e)
  2333. {
  2334. if(e.Button == MouseButtons.Left)
  2335. {
  2336. if (operationK == 0)
  2337. {
  2338. if (startPoint != null && endPoint != null && startPoint != endPoint)
  2339. {
  2340. if (checkBox2.Checked && checkBox3.Checked)
  2341. {
  2342. pointList[lineCount][2] = new PointF((2 * startPoint.X + endPoint.X) / 3f, (2 * startPoint.Y + endPoint.Y) / 3f);
  2343. pointList[lineCount][3] = new PointF((startPoint.X + 2 * endPoint.X) / 3f, (startPoint.Y + 2 * endPoint.Y) / 3f);
  2344. }
  2345. else if (checkBox2.Checked && !checkBox3.Checked)
  2346. {
  2347. pointList[lineCount][2] = new PointF((startPoint.X + endPoint.X) / 2f, (startPoint.Y + endPoint.Y) / 2f);
  2348. }
  2349. else if (!checkBox2.Checked && checkBox3.Checked)
  2350. {
  2351. pointList[lineCount][3] = new PointF((startPoint.X + endPoint.X) / 2f, (startPoint.Y + endPoint.Y) / 2f);
  2352. }
  2353. RectangleF rectangleF = CalcOtherRectangle(pointList[lineCount][0], pointList[lineCount][1]);
  2354. rectangleFList.Add(rectangleF);
  2355. lineCount++;
  2356. AddContentToDataGridView();
  2357. }
  2358. else
  2359. {
  2360. pointList.RemoveAt(pointList.Count - 1);
  2361. }
  2362. this.documentWorkspace.Refresh();
  2363. }
  2364. else if (operationK == 1)
  2365. {
  2366. canMove = false;
  2367. movePointIndex = -1;
  2368. RefreshDataGridView1();
  2369. }
  2370. }
  2371. }
  2372. /// <summary>
  2373. /// 绘制事件
  2374. /// </summary>
  2375. /// <param name="sender"></param>
  2376. /// <param name="e"></param>
  2377. private void BoxPaintHandler(object sender, PaintEventArgs e)
  2378. {
  2379. if (this.documentWorkspace.CompositionSurface != null)
  2380. {
  2381. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2382. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  2383. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  2384. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  2385. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  2386. e.Graphics.TranslateTransform(x, y);
  2387. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2388. Draw(e.Graphics);
  2389. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2390. e.Graphics.TranslateTransform(-x, -y);
  2391. }
  2392. }
  2393. // <summary>
  2394. /// 存储字号与颜色字典
  2395. /// </summary>
  2396. public Dictionary<string, Color> colourFont = new Dictionary<string, Color>() { {"20", Color.Black }};
  2397. /// <summary>
  2398. /// 绘制
  2399. /// </summary>
  2400. private void Draw(Graphics graphics)
  2401. {
  2402. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  2403. Pen standardPen = new Pen(this.panel1.BackColor, this.trackBar2.Value);//基准线画笔
  2404. Pen surfacePen = new Pen(this.panel2.BackColor, this.trackBar2.Value);//钢样表面画笔
  2405. Pen completePen = new Pen(this.panel3.BackColor, this.trackBar2.Value);//完全脱碳层画笔
  2406. Pen validPen = new Pen(this.panel4.BackColor, this.trackBar2.Value);//有效脱碳层画笔
  2407. Pen partPen = new Pen(this.panel5.BackColor, this.trackBar2.Value);//部分脱碳层画笔
  2408. Pen borderPen = new Pen(Color.Black);//填充点外圈
  2409. SolidBrush insideBrush = new SolidBrush(Color.White);//填充点内圈
  2410. Pen rectPen = new Pen(Color.Black);
  2411. rectPen.DashStyle = DashStyle.Custom;
  2412. float[] dashArray = { 2.0f,3.0f };
  2413. rectPen.DashPattern = dashArray;
  2414. if (pointList.Count > 0)
  2415. {
  2416. foreach (PointF[] pointFs in pointList)
  2417. {
  2418. PointF[] pf = pointFs;
  2419. if (pointFs.Count() > 1 && pointFs[0] != pointFs[1])
  2420. {
  2421. float lineLength = this.trackBar1.Value / 2f;
  2422. double angle = Math.Round(BasicCalculationHelper.AngleText(pointFs[0], pointFs[1], new PointF(pointFs[0].X + lineLength, pointFs[0].Y)), 10);
  2423. //判断第二个点相对于第一个点的象限
  2424. int x2 = (int)(pointFs[1].X - pointFs[0].X);
  2425. if (x2 == 0)
  2426. x2 = 1;
  2427. int y2 = (int)(pointFs[1].Y - pointFs[0].Y);
  2428. if (y2 == 0)
  2429. y2 = 1;
  2430. int i2 = 0;
  2431. if (x2 > 0 && y2 > 0) //第4象限
  2432. {
  2433. i2 = 4;
  2434. }
  2435. else if (x2 > 0 && y2 < 0) //第1象限
  2436. {
  2437. i2 = 1;
  2438. }
  2439. else if (x2 < 0 && y2 < 0) //第2象限
  2440. {
  2441. i2 = 2;
  2442. }
  2443. else if (x2 < 0 && y2 > 0) //第3象限
  2444. {
  2445. i2 = 3;
  2446. }
  2447. double sAngle1;
  2448. double eAngle1;
  2449. double sAngle2;
  2450. double eAngle2;
  2451. if (i2 == 1 || i2 == 2)
  2452. {
  2453. sAngle1 = 360 - angle;
  2454. eAngle1 = 180 - angle;
  2455. sAngle2 = 270 - angle;
  2456. eAngle2 = 90 - angle;
  2457. }
  2458. else
  2459. {
  2460. sAngle1 = angle;
  2461. eAngle1 = 180 + angle;
  2462. sAngle2 = 270 + angle;
  2463. eAngle2 = 90 + angle;
  2464. }
  2465. graphics.DrawLine(standardPen, pointFs[0], pointFs[1]);
  2466. if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2))
  2467. {
  2468. PointF assistPoint1 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], sAngle2);
  2469. PointF assistPoint2 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], eAngle2);
  2470. PointF assistPoint3 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], sAngle2);
  2471. PointF assistPoint4 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], eAngle2);
  2472. graphics.DrawLine(surfacePen, assistPoint1, assistPoint2);
  2473. graphics.DrawLine(partPen, assistPoint3, assistPoint4);
  2474. //PointF[] pf = pointFs;
  2475. if (this.checkBox2.Checked)
  2476. {
  2477. if (i2 == 1 || i2 == 2)
  2478. {
  2479. if (this.checkBox6.Checked)
  2480. {
  2481. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint4.X, assistPoint4.Y - 10);
  2482. }
  2483. }
  2484. else
  2485. {
  2486. if (this.checkBox6.Checked)
  2487. {
  2488. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint3.X, assistPoint3.Y - 10);
  2489. }
  2490. }
  2491. }
  2492. }
  2493. if (pointFs[2] != PointF.Empty && checkBox2.Checked)
  2494. {
  2495. if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2))
  2496. {
  2497. PointF assistPoint5 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[2].X + lineLength), pointFs[2].Y), pointFs[2], sAngle2);
  2498. PointF assistPoint6 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[2].X + lineLength), pointFs[2].Y), pointFs[2], eAngle2);
  2499. graphics.DrawLine(completePen, assistPoint5, assistPoint6);
  2500. //PointF[] pf = pointFs;
  2501. if (i2 == 1 || i2 == 2)
  2502. {
  2503. if (this.checkBox4.Checked)
  2504. {
  2505. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value))*unitLength + "", "").Value.ToString()).ToString("F"+ this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint6.X, assistPoint6.Y - 10);
  2506. }
  2507. }
  2508. else
  2509. {
  2510. if (this.checkBox4.Checked)
  2511. {
  2512. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint5.X, assistPoint5.Y - 10);
  2513. }
  2514. }
  2515. }
  2516. }
  2517. if (pointFs[3] != PointF.Empty && checkBox3.Checked)
  2518. {
  2519. if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2))
  2520. {
  2521. PointF assistPoint7 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[3].X + lineLength), pointFs[3].Y), pointFs[3], sAngle2);
  2522. PointF assistPoint8 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[3].X + lineLength), pointFs[3].Y), pointFs[3], eAngle2);
  2523. graphics.DrawLine(validPen, assistPoint7, assistPoint8);
  2524. //PointF[] pf = pointFs;
  2525. if (i2 == 1 || i2 == 2)
  2526. {
  2527. if (this.checkBox5.Checked)
  2528. {
  2529. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F"+ this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint8.X, assistPoint8.Y - 10);
  2530. }
  2531. }
  2532. else
  2533. {
  2534. if (this.checkBox5.Checked)
  2535. {
  2536. graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint7.X, assistPoint7.Y - 10);
  2537. }
  2538. }
  2539. }
  2540. }
  2541. }
  2542. }
  2543. if (selected > -1)
  2544. {
  2545. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio<1 ? 1/ this.documentWorkspace.ScaleFactor.Ratio : 1));
  2546. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1));
  2547. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][0].X - tempLess), (int)(pointList[selected][0].Y - tempLess), tempPlus, tempPlus));
  2548. graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][0].X - tempLess, pointList[selected][0].Y - tempLess, tempPlus, tempPlus));
  2549. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][1].X - tempLess), (int)(pointList[selected][1].Y - tempLess), tempPlus, tempPlus));
  2550. graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][1].X - tempLess, pointList[selected][1].Y - tempLess, tempPlus, tempPlus));
  2551. if (pointList[selected][2] != PointF.Empty && checkBox2.Checked)
  2552. {
  2553. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][2].X - tempLess), (int)(pointList[selected][2].Y - tempLess), tempPlus, tempPlus));
  2554. graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][2].X - tempLess, pointList[selected][2].Y - tempLess, tempPlus, tempPlus));
  2555. }
  2556. if (pointList[selected][3] != PointF.Empty && checkBox3.Checked)
  2557. {
  2558. graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][3].X - tempLess), (int)(pointList[selected][3].Y - tempLess), tempPlus, tempPlus));
  2559. graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][3].X - tempLess, pointList[selected][3].Y - tempLess, tempPlus, tempPlus));
  2560. }
  2561. graphics.DrawRectangle(rectPen, rectangleFList[selected].X, rectangleFList[selected].Y, rectangleFList[selected].Width, rectangleFList[selected].Height);
  2562. }
  2563. }
  2564. standardPen.Dispose();
  2565. surfacePen.Dispose();
  2566. completePen.Dispose();
  2567. validPen.Dispose();
  2568. partPen.Dispose();
  2569. borderPen.Dispose();
  2570. insideBrush.Dispose();
  2571. rectPen.Dispose();
  2572. }
  2573. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  2574. {
  2575. if (this.documentWorkspace != null)
  2576. {
  2577. this.documentWorkspace.Refresh();
  2578. }
  2579. }
  2580. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  2581. {
  2582. if (this.documentWorkspace != null)
  2583. {
  2584. this.documentWorkspace.Refresh();
  2585. }
  2586. }
  2587. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  2588. {
  2589. if (this.documentWorkspace != null)
  2590. {
  2591. this.documentWorkspace.Refresh();
  2592. }
  2593. }
  2594. /// <summary>
  2595. /// 计算外接矩形
  2596. /// </summary>
  2597. private RectangleF CalcOtherRectangle(PointF p1, PointF p2)
  2598. {
  2599. RectangleF rectangleF = new RectangleF();
  2600. if (p1.X > p2.X)
  2601. rectangleF.X = p2.X;
  2602. else
  2603. rectangleF.X = p1.X;
  2604. if (p1.Y > p2.Y)
  2605. rectangleF.Y = p2.Y;
  2606. else
  2607. rectangleF.Y = p1.Y;
  2608. rectangleF.Width = Math.Abs(p2.X - p1.X);
  2609. rectangleF.Height = Math.Abs(p2.Y - p1.Y);
  2610. int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  2611. int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5;
  2612. return new RectangleF(rectangleF.X - tempLess, rectangleF.Y - tempLess, rectangleF.Width + tempPlus, rectangleF.Height + tempPlus);
  2613. }
  2614. /// <summary>
  2615. /// 计算指定索引列的平均值
  2616. /// </summary>
  2617. /// <param name="ColumnIndex"></param>
  2618. /// <returns></returns>
  2619. private double CalculateAverage(int ColumnIndex)
  2620. {
  2621. double sum = 0;
  2622. double avg = 0;
  2623. if (this.dataGridView1.Rows.Count > 0)
  2624. {
  2625. for (int i = 0; i < lineCount; i++)
  2626. {
  2627. try
  2628. {
  2629. double cellValue = double.Parse(this.dataGridView1.Rows[i].Cells[ColumnIndex].Value.ToString());
  2630. sum += cellValue;
  2631. }
  2632. catch (Exception e)
  2633. {
  2634. continue;
  2635. }
  2636. }
  2637. avg = sum / lineCount;
  2638. }
  2639. return avg;
  2640. }
  2641. /// <summary>
  2642. /// 分析结果列表选择切换
  2643. /// </summary>
  2644. /// <param name="sender"></param>
  2645. /// <param name="e"></param>
  2646. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  2647. {
  2648. if (this.showAll)
  2649. return;
  2650. RefreshDataGridView2();
  2651. }
  2652. /// <summary>
  2653. /// 向数据展示表插入数据
  2654. /// </summary>
  2655. private void AddContentToDataGridView()
  2656. {
  2657. PointF[] pf = pointList[lineCount - 1];
  2658. DataGridViewRow row = new DataGridViewRow();
  2659. row.Height = 37;
  2660. row.Cells.Add(CreateTextBoxCell("L" + (lineCount), ""));
  2661. //完全脱碳层
  2662. if (pf[2] == PointF.Empty)
  2663. row.Cells.Add(CreateTextBoxCell("0", ""));
  2664. else
  2665. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2666. //有效脱碳层
  2667. if (pf[3] == PointF.Empty)
  2668. row.Cells.Add(CreateTextBoxCell("0", ""));
  2669. else
  2670. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2671. //部分脱碳层
  2672. if (pf[2] == PointF.Empty)
  2673. row.Cells.Add(CreateTextBoxCell("0", ""));
  2674. else
  2675. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2676. //总脱碳层
  2677. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2678. if (this.dataGridView1.Rows.Count == 0)
  2679. {
  2680. this.dataGridView1.Rows.Add(row);
  2681. DataGridViewRow rowAvg = new DataGridViewRow();
  2682. rowAvg.Height = 36;
  2683. rowAvg.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Image.Average.Text"), ""));
  2684. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2685. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2686. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2687. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2688. this.dataGridView1.Rows.Add(rowAvg);
  2689. }
  2690. else
  2691. {
  2692. this.dataGridView1.Rows.Insert(lineCount - 1, row);
  2693. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[1].Value = Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value));
  2694. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[2].Value = Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value));
  2695. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[3].Value = Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value));
  2696. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[4].Value = Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value));
  2697. }
  2698. this.dataGridView1.ClearSelection();
  2699. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 2].Selected = true;
  2700. }
  2701. /// <summary>
  2702. /// 刷新数据展示表
  2703. /// </summary>
  2704. private void RefreshDataGridView1()
  2705. {
  2706. int selectedRowIndex = -1;
  2707. if (this.dataGridView1.Rows.Count > 0)
  2708. selectedRowIndex = this.dataGridView1.SelectedRows[0].Index;
  2709. this.dataGridView1.Rows.Clear();
  2710. for(int i = 0; i < pointList.Count; i++)
  2711. {
  2712. PointF[] pf = pointList[i];
  2713. DataGridViewRow row = new DataGridViewRow();
  2714. row.Height = 37;
  2715. row.Cells.Add(CreateTextBoxCell("L" + (i + 1), ""));
  2716. //完全脱碳层
  2717. if (pf[2] == PointF.Empty)
  2718. row.Cells.Add(CreateTextBoxCell("0", ""));
  2719. else
  2720. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2721. //有效脱碳层
  2722. if (pf[3] == PointF.Empty)
  2723. row.Cells.Add(CreateTextBoxCell("0", ""));
  2724. else
  2725. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2726. //部分脱碳层
  2727. if (pf[2] == PointF.Empty)
  2728. row.Cells.Add(CreateTextBoxCell("0", ""));
  2729. else
  2730. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2731. //总脱碳层
  2732. row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", ""));
  2733. this.dataGridView1.Rows.Add(row);
  2734. }
  2735. if (this.dataGridView1.Rows.Count > 0)
  2736. {
  2737. DataGridViewRow rowAvg = new DataGridViewRow();
  2738. rowAvg.Height = 36;
  2739. rowAvg.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Image.Average.Text"), ""));
  2740. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2741. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2742. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2743. rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  2744. this.dataGridView1.Rows.Add(rowAvg);
  2745. }
  2746. this.dataGridView1.ClearSelection();
  2747. if (selectedRowIndex > this.dataGridView1.Rows.Count - 1)
  2748. selectedRowIndex = this.dataGridView1.Rows.Count - 1;
  2749. if (selectedRowIndex < 0)
  2750. selectedRowIndex = 0;
  2751. if (this.dataGridView1.Rows.Count > 0)
  2752. this.dataGridView1.Rows[selectedRowIndex].Selected = true;
  2753. }
  2754. /// <summary>
  2755. /// 格式化坐标点
  2756. /// </summary>
  2757. /// <param name="coordinateA">参考点1</param>
  2758. /// <param name="coordinateB">参考点2</param>
  2759. /// <param name="basicCoordinate">需比对的点</param>
  2760. /// <returns></returns>
  2761. private float FormatCoordinate(float coordinateA, float coordinateB, float basicCoordinate)
  2762. {
  2763. float coordinate = basicCoordinate;
  2764. float[] pointArr = new float[] { coordinateA, coordinateB };
  2765. if (coordinate > pointArr.Max() - 3)
  2766. coordinate = pointArr.Max() - 3;
  2767. if (coordinate < pointArr.Min() + 3)
  2768. coordinate = pointArr.Min() + 3;
  2769. return coordinate;
  2770. }
  2771. /// <summary>
  2772. /// 导出项目按钮
  2773. /// </summary>
  2774. /// <param name="sender"></param>
  2775. /// <param name="e"></param>
  2776. private void button10_Click(object sender, EventArgs e)
  2777. {
  2778. try
  2779. {
  2780. if (this.analyzeSettingModel == null)
  2781. {
  2782. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2783. return;
  2784. }
  2785. //获取项目工程内的文件夹路径
  2786. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.SteelDecarburization.Text", this.analyzeSettingModel.savePath);
  2787. if(item != null)
  2788. {
  2789. //向文件夹内保存图片和报告
  2790. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2791. {
  2792. //获取word书签与excel单元格的关系,以字典方式存储
  2793. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2794. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2795. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2796. {
  2797. foreach (mic_module_infos info in mic_module_infos)
  2798. {
  2799. tagInfos.Add(info.tag_name, info.cell_position);
  2800. }
  2801. }
  2802. //分析结果
  2803. List<List<string>> analysisContent = new List<List<string>>();
  2804. List<string> contentHead = new List<string>();
  2805. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  2806. contentHead.Add(PdnResources.GetString("Menu.packet.text"));
  2807. contentHead.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text"));
  2808. contentHead.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"));
  2809. contentHead.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"));
  2810. contentHead.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text"));
  2811. analysisContent.Add(contentHead);
  2812. foreach (DataGridViewRow rowItem in this.dataGridView2.Rows)
  2813. {
  2814. List<string> content = new List<string>();
  2815. content.Add(rowItem.Cells[0].Value.ToString());
  2816. content.Add(rowItem.Cells[1].Value.ToString());
  2817. content.Add(rowItem.Cells[2].Value.ToString());
  2818. content.Add(rowItem.Cells[3].Value.ToString());
  2819. content.Add(rowItem.Cells[4].Value.ToString());
  2820. content.Add(rowItem.Cells[5].Value.ToString());
  2821. analysisContent.Add(content);
  2822. }
  2823. //图片
  2824. bitList = new List<Bitmap>();
  2825. if (this.showAll)
  2826. {
  2827. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  2828. {
  2829. bitList.Add(kv.Value[0]);
  2830. bitList.Add(kv.Value[1]);
  2831. }
  2832. }
  2833. else
  2834. {
  2835. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2836. {
  2837. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2838. {
  2839. if (bitDic.ContainsKey(rowItem.Name))
  2840. {
  2841. bitList.Add(bitDic[rowItem.Name][0]);
  2842. bitList.Add(bitDic[rowItem.Name][1]);
  2843. }
  2844. }
  2845. }
  2846. }
  2847. //中间数据
  2848. if (!this.showAll)
  2849. {
  2850. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2851. {
  2852. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2853. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2854. {
  2855. foreach (ExportProjectModel model in this.tempDataModel)
  2856. {
  2857. if (model.tagName.Equals(rowItem.Name))
  2858. {
  2859. ExportProjectModel tempModel = new ExportProjectModel();
  2860. tempModel.tagName = model.tagName;
  2861. tempModel.picName = model.picName;
  2862. tempModel.dataList = model.dataList;
  2863. exportModel.Add(tempModel);
  2864. break;
  2865. }
  2866. }
  2867. }
  2868. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
  2869. }
  2870. }
  2871. else
  2872. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
  2873. }
  2874. else
  2875. {
  2876. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2877. return;
  2878. }
  2879. //保存项目信息到数据库
  2880. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2881. }
  2882. }
  2883. catch (Exception)
  2884. {
  2885. }
  2886. }
  2887. #region 参数保存及提取
  2888. /// <summary>
  2889. /// 保存参数的key,value和type
  2890. /// </summary>
  2891. /// <param name="param_key"></param>
  2892. /// <param name="param_value"></param>
  2893. /// <param name="param_type"></param>
  2894. private void saveParamValue(string param_key, string param_value, int param_type)
  2895. {
  2896. bool foundItem = false;
  2897. foreach (var item in this.analysisModel.ListParam)
  2898. {
  2899. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  2900. {
  2901. item.param_value = param_value;
  2902. item.setValue();
  2903. foundItem = true;
  2904. break;
  2905. }
  2906. }
  2907. if (!foundItem)
  2908. {
  2909. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  2910. analysisItem.menuId = this.menuId;
  2911. analysisItem.param_key = param_key;
  2912. analysisItem.param_type = param_type;
  2913. analysisItem.param_value = param_value;
  2914. analysisItem.setValue();
  2915. this.analysisModel.ListParam.Add(analysisItem);
  2916. }
  2917. }
  2918. /// <summary>
  2919. /// 保存界面中的参数到model
  2920. /// </summary>
  2921. private void saveDialogParamValues()
  2922. {
  2923. saveParamValue(ParamKey_Report, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置
  2924. saveParamValue(ParamKey_LineLength, trackBar1 != null ? trackBar1.Value.ToString() : "40", (int)Base.Dtryt.Interger);//线长
  2925. saveParamValue(ParamKey_LineWidth, trackBar2 != null ? trackBar2.Value.ToString() : "3", (int)Base.Dtryt.Interger);//线宽
  2926. saveParamValue(ParamKey_Baseline, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//基准线颜色
  2927. saveParamValue(ParamKey_Surface, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//钢样表面颜色
  2928. saveParamValue(ParamKey_Whole, checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//完全
  2929. saveParamValue(ParamKey_WholeColour, panel3.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//完全颜色
  2930. saveParamValue(ParamKey_Valid, checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//有效
  2931. saveParamValue(ParamKey_ValidColour, panel4.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//有效颜色
  2932. saveParamValue(ParamKey_Part, checkBox6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//部分
  2933. saveParamValue(ParamKey_PartColour, panel5.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//部分颜色
  2934. saveParamValue(ParamKey_WholeGauge, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//完全测量
  2935. saveParamValue(ParamKey_ValidGauge, checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//有效测量
  2936. saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
  2937. }
  2938. /// <summary>
  2939. /// 获取保存的参数
  2940. /// </summary>
  2941. private void GetListParamModel()
  2942. {
  2943. if (this.analysisModel != null)
  2944. {
  2945. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  2946. {
  2947. switch (this.analysisModel.ListParam[i].param_key)
  2948. {
  2949. case ParamKey_Report:
  2950. checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2951. break;
  2952. case ParamKey_LineLength:
  2953. trackBar1.Value = (int)this.analysisModel.ListParam[i].value;
  2954. textBox1.Text = "" + trackBar1.Value;
  2955. break;
  2956. case ParamKey_LineWidth:
  2957. trackBar2.Value = (int)this.analysisModel.ListParam[i].value;
  2958. textBox2.Text = "" + trackBar2.Value;
  2959. break;
  2960. case ParamKey_Baseline:
  2961. panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  2962. break;
  2963. case ParamKey_Surface:
  2964. panel2.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  2965. break;
  2966. case ParamKey_Whole:
  2967. checkBox4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2968. break;
  2969. case ParamKey_WholeColour:
  2970. panel3.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  2971. break;
  2972. case ParamKey_Valid:
  2973. checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2974. break;
  2975. case ParamKey_ValidColour:
  2976. panel4.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  2977. break;
  2978. case ParamKey_Part:
  2979. checkBox6.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2980. break;
  2981. case ParamKey_PartColour:
  2982. panel5.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  2983. break;
  2984. case ParamKey_WholeGauge:
  2985. checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2986. break;
  2987. case ParamKey_ValidGauge:
  2988. checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  2989. break;
  2990. case ParamKey_DecimalPlace:
  2991. numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
  2992. break;
  2993. }
  2994. }
  2995. }
  2996. }
  2997. private void MetallographicMethod224Dialog_FormClosing(object sender, FormClosingEventArgs e)
  2998. {
  2999. #region [开启脚本录制]
  3000. if (appWorkspace.startScriptRecording)
  3001. {
  3002. getScriptRecording();
  3003. }
  3004. #endregion
  3005. this.saveDialogParamValues();
  3006. //xml保存路径
  3007. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  3008. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  3009. foreach (var analysisItem in this.analysisModel.ListParam)
  3010. {
  3011. bool foundItem = false;
  3012. foreach (var item in analysisModelXml.ListParam)
  3013. {
  3014. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  3015. {
  3016. item.param_value = analysisItem.param_value;
  3017. foundItem = true;
  3018. break;
  3019. }
  3020. }
  3021. if (!foundItem)
  3022. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  3023. }
  3024. //按路径和名称保存xml文件
  3025. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  3026. //保存xml
  3027. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  3028. }
  3029. #endregion
  3030. #region [脚本相关]
  3031. private void getValue(string key, object value) {
  3032. switch (key)
  3033. {
  3034. case "parameter1":
  3035. trackBar1.Value = Convert.ToInt32(value);
  3036. textBox1.Text = value.ToString();
  3037. break;
  3038. case "parameter2":
  3039. trackBar2.Value = Convert.ToInt32(value);
  3040. textBox2.Text = value.ToString();
  3041. break;
  3042. case "parameter3":
  3043. panel1.BackColor = Color.FromArgb((int)value);
  3044. break;
  3045. case "parameter4":
  3046. checkBox4.Checked = Convert.ToBoolean(value);
  3047. break;
  3048. case "parameter5":
  3049. panel3.BackColor = Color.FromArgb((int)value);
  3050. break;
  3051. case "parameter6":
  3052. panel2.BackColor = Color.FromArgb((int)value);
  3053. break;
  3054. case "parameter7":
  3055. checkBox5.Checked = Convert.ToBoolean(value);
  3056. break;
  3057. case "parameter8":
  3058. panel4.BackColor = Color.FromArgb((int)value);
  3059. break;
  3060. case "parameter9":
  3061. checkBox6.Checked = Convert.ToBoolean(value);
  3062. break;
  3063. case "parameter10":
  3064. panel5.BackColor = Color.FromArgb((int)value);
  3065. break;
  3066. case "parameter11":
  3067. checkBox2.Checked = Convert.ToBoolean(value);
  3068. break;
  3069. case "parameter12":
  3070. checkBox3.Checked = Convert.ToBoolean(value);
  3071. break;
  3072. case "OpenWhileExportReport":
  3073. checkBox1.Checked = Convert.ToBoolean(value);
  3074. break;
  3075. case "CalculatorDecimalDigits":
  3076. numericUpDown1.Value = Convert.ToDecimal(value);
  3077. break;
  3078. }
  3079. }
  3080. #endregion
  3081. #region [脚本录制]
  3082. private void getScriptRecording()
  3083. {
  3084. string className = InvariantData.path_Action + ".Action" + menuId;
  3085. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3086. List<Args> args = param.Lists;
  3087. foreach (var item in args)
  3088. {
  3089. item.value = setScriptRecording(item.key);
  3090. }
  3091. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3092. }
  3093. private object setScriptRecording(string key)
  3094. {
  3095. object value = null;
  3096. switch (key)
  3097. {
  3098. case "parameter1":
  3099. value = trackBar1.Value;
  3100. break;
  3101. case "parameter2":
  3102. value = trackBar2.Value;
  3103. break;
  3104. case "parameter3":
  3105. value = panel1.BackColor.ToArgb();
  3106. break;
  3107. case "parameter4":
  3108. value = checkBox4.Checked;
  3109. break;
  3110. case "parameter5":
  3111. value = panel3.BackColor.ToArgb();
  3112. break;
  3113. case "parameter6":
  3114. value = panel2.BackColor.ToArgb();
  3115. break;
  3116. case "parameter7":
  3117. value = checkBox5.Checked;
  3118. break;
  3119. case "parameter8":
  3120. value = panel4.BackColor.ToArgb();
  3121. break;
  3122. case "parameter9":
  3123. value = checkBox6.Checked;
  3124. break;
  3125. case "parameter10":
  3126. value = panel5.BackColor.ToArgb();
  3127. break;
  3128. case "parameter11":
  3129. value = checkBox2.Checked;
  3130. break;
  3131. case "parameter12":
  3132. value = checkBox3.Checked;
  3133. break;
  3134. case "OpenWhileExportReport":
  3135. value = checkBox1.Checked;
  3136. break;
  3137. case "CalculatorDecimalDigits":
  3138. value = numericUpDown1.Value;
  3139. break;
  3140. }
  3141. return value;
  3142. }
  3143. #endregion
  3144. }
  3145. }