QualityOfEdgeDialog.cs 168 KB

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