MetallographicMethodDialog.cs 157 KB

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