MetallographicMethod3887Dialog.cs 165 KB

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