MetallographicMethod3887Dialog.cs 165 KB

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