MetallographicMethod224Dialog.cs 165 KB

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