QualityOfEdgeDialog.cs 168 KB

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