RuleAddForm.cs 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
  1. using OpenCvSharp;
  2. using PaintDotNet.Adjust.BaseImage;
  3. using PaintDotNet.Base.CommTool;
  4. using PaintDotNet.Base.SettingModel;
  5. using PaintDotNet.CustomControl;
  6. using PaintDotNet.DbOpreate.DbBll;
  7. using PaintDotNet.DbOpreate.DbModel;
  8. using PaintDotNet.ImageCollect;
  9. using System;
  10. using System.Drawing;
  11. using System.Drawing.Drawing2D;
  12. using System.IO;
  13. using System.Windows.Forms;
  14. namespace PaintDotNet.Measuring
  15. {
  16. /// <summary>
  17. /// 标尺编辑/删除界面
  18. /// </summary>
  19. internal class RuleAddForm : PdnBaseForm
  20. {
  21. /// <summary>
  22. /// 公共按钮
  23. /// </summary>
  24. private CommonControlButtons commonControlButtons;
  25. /// <summary>
  26. /// 在各种弹窗中使用
  27. /// </summary>
  28. private DocumentWorkspaceWindow documentWorkspace;
  29. /// <summary>
  30. /// 步骤
  31. /// </summary>
  32. private byte step = 1;
  33. /// <summary>
  34. /// 方向
  35. /// </summary>
  36. private byte direction = 0;
  37. /// <summary>
  38. /// 标尺图片
  39. /// </summary>
  40. private Bitmap bitmap;
  41. /// <summary>
  42. /// 起止点
  43. /// </summary>
  44. private System.Drawing.Point startPoint, endPoint;
  45. /// <summary>
  46. /// x、y轴数值
  47. /// </summary>
  48. private int x, y;
  49. /// <summary>
  50. /// 绘制标尺的线宽
  51. /// </summary>
  52. private int width;
  53. /// <summary>
  54. /// 字体
  55. /// </summary>
  56. private Font font;
  57. /// <summary>
  58. /// 笔刷
  59. /// </summary>
  60. private Brush brush = new SolidBrush(Color.Red);
  61. /// <summary>
  62. /// 标尺xml文件,编辑标尺时使用
  63. /// </summary>
  64. public RulerFileModel ruleFileModel;
  65. /// <summary>
  66. /// 标尺数据,编辑标尺时使用
  67. /// </summary>
  68. public mic_rulers ruleModel;
  69. /// <summary>
  70. /// 1新增 2编辑
  71. /// </summary>
  72. public int status;
  73. /// <summary>
  74. /// 调色板
  75. /// </summary>
  76. PaintDotNet.ColorsForm colorsForm1;
  77. // Create the outline for our custom end cap.
  78. GraphicsPath hPath = new GraphicsPath();
  79. // Construct the hook-shaped end cap.
  80. CustomLineCap HookCap;
  81. public AppWorkspace appWorkspace;
  82. #region 像素跟踪
  83. private Mat mat, ImageROI, bmat = new Mat();
  84. /// <summary>
  85. /// rgb像素点
  86. /// </summary>
  87. private Vec3b bgr;
  88. /// <summary>
  89. /// hls像素点
  90. /// </summary>
  91. private double h, s, v;
  92. /// <summary>
  93. /// 缩放倍数
  94. /// </summary>
  95. private int scale;
  96. /// <summary>
  97. /// 中间十字和圆的颜色
  98. /// 根据左侧的panel的被选中的背景色变化
  99. /// </summary>
  100. private Color color = Color.Red;
  101. /// <summary>
  102. /// 按下标记
  103. /// </summary>
  104. private bool pressFlag;
  105. #endregion
  106. #region 控件
  107. private System.Windows.Forms.GroupBox groupBox1;
  108. private System.Windows.Forms.Button button1;
  109. private System.Windows.Forms.Button button3;
  110. private System.Windows.Forms.Button button2;
  111. private System.Windows.Forms.GroupBox groupBox2;
  112. private System.Windows.Forms.Button button4;
  113. private System.Windows.Forms.Button button5;
  114. private System.Windows.Forms.Button button6;
  115. private System.Windows.Forms.Button button9;
  116. private System.Windows.Forms.Button button8;
  117. private System.Windows.Forms.Button button7;
  118. private System.Windows.Forms.Panel panel1;
  119. private System.Windows.Forms.Label label7;
  120. private System.Windows.Forms.Label label1;
  121. private System.Windows.Forms.NumericUpDown numericUpDown1;
  122. private System.Windows.Forms.ColorDialog colorDialog1;
  123. private System.Windows.Forms.GroupBox groupBox3;
  124. private System.Windows.Forms.GroupBox groupBox4;
  125. private System.Windows.Forms.TextBox textBox1;
  126. private System.Windows.Forms.TextBox textBox6;
  127. private System.Windows.Forms.TextBox textBox5;
  128. private System.Windows.Forms.TextBox textBox4;
  129. private System.Windows.Forms.TextBox textBox2;
  130. private System.Windows.Forms.GroupBox groupBox5;
  131. private System.Windows.Forms.TextBox textBox12;
  132. private System.Windows.Forms.TextBox textBox11;
  133. private System.Windows.Forms.TextBox textBox10;
  134. private System.Windows.Forms.TextBox textBox9;
  135. private System.Windows.Forms.TextBox textBox8;
  136. private System.Windows.Forms.TextBox textBox7;
  137. private System.Windows.Forms.Panel panel2;
  138. private CustomControl.LinearColorPickerControl linearColorPickerControl1;
  139. private PictureBox pictureBox1;
  140. private Label label6;
  141. private Label label5;
  142. private Label label4;
  143. private Label label3;
  144. private Label label2;
  145. private Label label8;
  146. private Label label9;
  147. private TrackBar trackBar1;
  148. private NumericUpDown numericUpDown2;
  149. private Label label10;
  150. private Label label11;
  151. private Label label17;
  152. private Label label16;
  153. private Label label15;
  154. private Label label14;
  155. private Label label13;
  156. private Label label12;
  157. private Label label23;
  158. private Label label22;
  159. private Label label21;
  160. private Label label20;
  161. private Label label19;
  162. private Label label18;
  163. private NumericUpDown numericUpDown3;
  164. private Label label24;
  165. private System.Windows.Forms.ComboBox comboBox1;
  166. #endregion
  167. #region Windows Form Designer generated code
  168. private void InitializeLanguageText()
  169. {
  170. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  171. this.button6.Text = PdnResources.GetString("Menu.Previous.text");
  172. this.button5.Text = PdnResources.GetString("Menu.Nextstep.text");
  173. this.button3.Text = PdnResources.GetString("Menu.thirdstep.text");
  174. this.button2.Text = PdnResources.GetString("Menu.Secondstep.text");
  175. this.button1.Text = PdnResources.GetString("Menu.firststep.text");
  176. this.groupBox2.Text = PdnResources.GetString("Menu.Selectimagefrom.text");
  177. this.label1.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  178. this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
  179. this.button9.Text = PdnResources.GetString("Menu.Anydirection.text");
  180. this.button8.Text = PdnResources.GetString("Menu.Verticaldirection.text");
  181. this.button7.Text = PdnResources.GetString("Menu.horizontaldirection.text");
  182. this.button4.Text = PdnResources.GetString("Menu.Openimage.text");
  183. this.groupBox3.Text = PdnResources.GetString("Menu.Rulerimage.text");
  184. this.groupBox4.Text = PdnResources.GetString("Menu.params.text");
  185. this.label17.Text = PdnResources.GetString("Menu.Pixellength.text") + ":";
  186. this.label16.Text = PdnResources.GetString("Menu.Physicallength.text") + ":";
  187. this.label15.Text = PdnResources.GetString("Menu.Resolution.text") + ":";
  188. this.label14.Text = PdnResources.GetString("Menu.unit.text") + ":";
  189. this.label13.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text") + ":";
  190. this.label12.Text = PdnResources.GetString("Menu.name.text") + ":";
  191. this.groupBox5.Text = PdnResources.GetString("Menu.Expand.text");
  192. this.label23.Text = PdnResources.GetString("Menu.microscope.text") + ":";
  193. this.label22.Text = PdnResources.GetString("Menu.Objectlens.text") + ":";
  194. this.label21.Text = PdnResources.GetString("Menu.thecamera.text") + ":";
  195. this.label20.Text = PdnResources.GetString("Menu.oculars.text") + ":";
  196. this.label19.Text = PdnResources.GetString("Menu.interface.text") + ":";
  197. this.label18.Text = PdnResources.GetString("Menu.magnificationchanger.text") + ":";
  198. this.label9.Text = PdnResources.GetString("Menu.Times.text");
  199. this.label24.Text = PdnResources.GetString("Menu.Fontsize.text");
  200. }
  201. /// <summary>
  202. /// Required method for Designer support - do not modify
  203. /// the contents of this method with the code editor.
  204. /// </summary>
  205. private void InitializeComponent()
  206. {
  207. this.groupBox1 = new System.Windows.Forms.GroupBox();
  208. this.button6 = new System.Windows.Forms.Button();
  209. this.button5 = new System.Windows.Forms.Button();
  210. this.button3 = new System.Windows.Forms.Button();
  211. this.button2 = new System.Windows.Forms.Button();
  212. this.button1 = new System.Windows.Forms.Button();
  213. this.groupBox2 = new System.Windows.Forms.GroupBox();
  214. this.label24 = new System.Windows.Forms.Label();
  215. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  216. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  217. this.label1 = new System.Windows.Forms.Label();
  218. this.panel1 = new System.Windows.Forms.Panel();
  219. this.label7 = new System.Windows.Forms.Label();
  220. this.button9 = new System.Windows.Forms.Button();
  221. this.button8 = new System.Windows.Forms.Button();
  222. this.button7 = new System.Windows.Forms.Button();
  223. this.button4 = new System.Windows.Forms.Button();
  224. this.colorDialog1 = new System.Windows.Forms.ColorDialog();
  225. this.groupBox3 = new System.Windows.Forms.GroupBox();
  226. this.groupBox4 = new System.Windows.Forms.GroupBox();
  227. this.label17 = new System.Windows.Forms.Label();
  228. this.label16 = new System.Windows.Forms.Label();
  229. this.label15 = new System.Windows.Forms.Label();
  230. this.label14 = new System.Windows.Forms.Label();
  231. this.label13 = new System.Windows.Forms.Label();
  232. this.label12 = new System.Windows.Forms.Label();
  233. this.comboBox1 = new System.Windows.Forms.ComboBox();
  234. this.textBox6 = new System.Windows.Forms.TextBox();
  235. this.textBox5 = new System.Windows.Forms.TextBox();
  236. this.textBox4 = new System.Windows.Forms.TextBox();
  237. this.textBox2 = new System.Windows.Forms.TextBox();
  238. this.textBox1 = new System.Windows.Forms.TextBox();
  239. this.groupBox5 = new System.Windows.Forms.GroupBox();
  240. this.label23 = new System.Windows.Forms.Label();
  241. this.label22 = new System.Windows.Forms.Label();
  242. this.label21 = new System.Windows.Forms.Label();
  243. this.label20 = new System.Windows.Forms.Label();
  244. this.label19 = new System.Windows.Forms.Label();
  245. this.label18 = new System.Windows.Forms.Label();
  246. this.textBox12 = new System.Windows.Forms.TextBox();
  247. this.textBox11 = new System.Windows.Forms.TextBox();
  248. this.textBox10 = new System.Windows.Forms.TextBox();
  249. this.textBox9 = new System.Windows.Forms.TextBox();
  250. this.textBox8 = new System.Windows.Forms.TextBox();
  251. this.textBox7 = new System.Windows.Forms.TextBox();
  252. this.panel2 = new System.Windows.Forms.Panel();
  253. this.label10 = new System.Windows.Forms.Label();
  254. this.label11 = new System.Windows.Forms.Label();
  255. this.label9 = new System.Windows.Forms.Label();
  256. this.trackBar1 = new System.Windows.Forms.TrackBar();
  257. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  258. this.label6 = new System.Windows.Forms.Label();
  259. this.label5 = new System.Windows.Forms.Label();
  260. this.label4 = new System.Windows.Forms.Label();
  261. this.label3 = new System.Windows.Forms.Label();
  262. this.label2 = new System.Windows.Forms.Label();
  263. this.label8 = new System.Windows.Forms.Label();
  264. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  265. this.linearColorPickerControl1 = new PaintDotNet.CustomControl.LinearColorPickerControl();
  266. this.groupBox1.SuspendLayout();
  267. this.groupBox2.SuspendLayout();
  268. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  269. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  270. this.groupBox4.SuspendLayout();
  271. this.groupBox5.SuspendLayout();
  272. this.panel2.SuspendLayout();
  273. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  274. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  275. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  276. this.SuspendLayout();
  277. //
  278. // groupBox1
  279. //
  280. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  281. | System.Windows.Forms.AnchorStyles.Left)));
  282. this.groupBox1.Controls.Add(this.button6);
  283. this.groupBox1.Controls.Add(this.button5);
  284. this.groupBox1.Controls.Add(this.button3);
  285. this.groupBox1.Controls.Add(this.button2);
  286. this.groupBox1.Controls.Add(this.button1);
  287. this.groupBox1.Location = new System.Drawing.Point(13, 13);
  288. this.groupBox1.Name = "groupBox1";
  289. this.groupBox1.Size = new System.Drawing.Size(115, 445);
  290. this.groupBox1.TabIndex = 1;
  291. this.groupBox1.TabStop = false;
  292. //
  293. // button6
  294. //
  295. this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  296. | System.Windows.Forms.AnchorStyles.Right)));
  297. this.button6.Location = new System.Drawing.Point(20, 383);
  298. this.button6.Name = "button6";
  299. this.button6.Size = new System.Drawing.Size(75, 23);
  300. this.button6.TabIndex = 4;
  301. this.button6.Text = "上一步";
  302. this.button6.UseVisualStyleBackColor = true;
  303. this.button6.Click += new System.EventHandler(this.button6_Click);
  304. //
  305. // button5
  306. //
  307. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  308. | System.Windows.Forms.AnchorStyles.Right)));
  309. this.button5.Location = new System.Drawing.Point(20, 412);
  310. this.button5.Name = "button5";
  311. this.button5.Size = new System.Drawing.Size(75, 23);
  312. this.button5.TabIndex = 3;
  313. this.button5.Text = "下一步";
  314. this.button5.UseVisualStyleBackColor = true;
  315. this.button5.Click += new System.EventHandler(this.button5_Click);
  316. //
  317. // button3
  318. //
  319. this.button3.Location = new System.Drawing.Point(20, 89);
  320. this.button3.Name = "button3";
  321. this.button3.Size = new System.Drawing.Size(75, 23);
  322. this.button3.TabIndex = 2;
  323. this.button3.Text = "第三步";
  324. this.button3.UseVisualStyleBackColor = true;
  325. this.button3.Click += new System.EventHandler(this.button3_Click);
  326. //
  327. // button2
  328. //
  329. this.button2.Location = new System.Drawing.Point(20, 59);
  330. this.button2.Name = "button2";
  331. this.button2.Size = new System.Drawing.Size(75, 23);
  332. this.button2.TabIndex = 1;
  333. this.button2.Text = "第二步";
  334. this.button2.UseVisualStyleBackColor = true;
  335. this.button2.Click += new System.EventHandler(this.button2_Click);
  336. //
  337. // button1
  338. //
  339. this.button1.Location = new System.Drawing.Point(20, 29);
  340. this.button1.Name = "button1";
  341. this.button1.Size = new System.Drawing.Size(75, 23);
  342. this.button1.TabIndex = 0;
  343. this.button1.Text = "第一步";
  344. this.button1.UseVisualStyleBackColor = true;
  345. this.button1.Click += new System.EventHandler(this.button1_Click);
  346. //
  347. // groupBox2
  348. //
  349. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  350. | System.Windows.Forms.AnchorStyles.Right)));
  351. this.groupBox2.Controls.Add(this.label24);
  352. this.groupBox2.Controls.Add(this.numericUpDown1);
  353. this.groupBox2.Controls.Add(this.numericUpDown3);
  354. this.groupBox2.Controls.Add(this.label1);
  355. this.groupBox2.Controls.Add(this.panel1);
  356. this.groupBox2.Controls.Add(this.label7);
  357. this.groupBox2.Controls.Add(this.button9);
  358. this.groupBox2.Controls.Add(this.button8);
  359. this.groupBox2.Controls.Add(this.button7);
  360. this.groupBox2.Controls.Add(this.button4);
  361. this.groupBox2.Location = new System.Drawing.Point(134, 13);
  362. this.groupBox2.Name = "groupBox2";
  363. this.groupBox2.Size = new System.Drawing.Size(779, 52);
  364. this.groupBox2.TabIndex = 2;
  365. this.groupBox2.TabStop = false;
  366. this.groupBox2.Text = "从...选择图像";
  367. //
  368. // label24
  369. //
  370. this.label24.AutoSize = true;
  371. this.label24.Location = new System.Drawing.Point(278, 26);
  372. this.label24.Name = "label24";
  373. this.label24.Size = new System.Drawing.Size(41, 12);
  374. this.label24.TabIndex = 16;
  375. this.label24.Text = "字号:";
  376. //
  377. // numericUpDown1
  378. //
  379. this.numericUpDown1.Location = new System.Drawing.Point(181, 22);
  380. this.numericUpDown1.Maximum = new decimal(new int[] {
  381. 99999,
  382. 0,
  383. 0,
  384. 0});
  385. this.numericUpDown1.Minimum = new decimal(new int[] {
  386. 1,
  387. 0,
  388. 0,
  389. 0});
  390. this.numericUpDown1.Name = "numericUpDown1";
  391. this.numericUpDown1.Size = new System.Drawing.Size(72, 21);
  392. this.numericUpDown1.TabIndex = 15;
  393. this.numericUpDown1.Value = new decimal(new int[] {
  394. 3,
  395. 0,
  396. 0,
  397. 0});
  398. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  399. //
  400. // numericUpDown3
  401. //
  402. this.numericUpDown3.Location = new System.Drawing.Point(323, 22);
  403. this.numericUpDown3.Maximum = new decimal(new int[] {
  404. 49000,
  405. 0,
  406. 0,
  407. 0});
  408. this.numericUpDown3.Minimum = new decimal(new int[] {
  409. 1,
  410. 0,
  411. 0,
  412. 0});
  413. this.numericUpDown3.Name = "numericUpDown3";
  414. this.numericUpDown3.Size = new System.Drawing.Size(72, 21);
  415. this.numericUpDown3.TabIndex = 17;
  416. this.numericUpDown3.Value = new decimal(new int[] {
  417. 12,
  418. 0,
  419. 0,
  420. 0});
  421. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  422. //
  423. // label1
  424. //
  425. this.label1.AutoSize = true;
  426. this.label1.Location = new System.Drawing.Point(136, 26);
  427. this.label1.Name = "label1";
  428. this.label1.Size = new System.Drawing.Size(41, 12);
  429. this.label1.TabIndex = 4;
  430. this.label1.Text = "线宽:";
  431. //
  432. // panel1
  433. //
  434. this.panel1.BackColor = System.Drawing.Color.Red;
  435. this.panel1.Location = new System.Drawing.Point(55, 22);
  436. this.panel1.Name = "panel1";
  437. this.panel1.Size = new System.Drawing.Size(72, 21);
  438. this.panel1.TabIndex = 14;
  439. this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
  440. //
  441. // label7
  442. //
  443. this.label7.AutoSize = true;
  444. this.label7.Location = new System.Drawing.Point(13, 26);
  445. this.label7.Name = "label7";
  446. this.label7.Size = new System.Drawing.Size(41, 12);
  447. this.label7.TabIndex = 13;
  448. this.label7.Text = "颜色:";
  449. //
  450. // button9
  451. //
  452. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  453. this.button9.Location = new System.Drawing.Point(617, 21);
  454. this.button9.Name = "button9";
  455. this.button9.Size = new System.Drawing.Size(75, 23);
  456. this.button9.TabIndex = 3;
  457. this.button9.Text = "任意方向";
  458. this.button9.UseVisualStyleBackColor = true;
  459. this.button9.Click += new System.EventHandler(this.button9_Click);
  460. //
  461. // button8
  462. //
  463. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  464. this.button8.Location = new System.Drawing.Point(535, 21);
  465. this.button8.Name = "button8";
  466. this.button8.Size = new System.Drawing.Size(75, 23);
  467. this.button8.TabIndex = 2;
  468. this.button8.Text = "垂直方向";
  469. this.button8.UseVisualStyleBackColor = true;
  470. this.button8.Click += new System.EventHandler(this.button8_Click);
  471. //
  472. // button7
  473. //
  474. this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  475. this.button7.Location = new System.Drawing.Point(453, 21);
  476. this.button7.Name = "button7";
  477. this.button7.Size = new System.Drawing.Size(75, 23);
  478. this.button7.TabIndex = 1;
  479. this.button7.Text = "水平方向";
  480. this.button7.UseVisualStyleBackColor = true;
  481. this.button7.Click += new System.EventHandler(this.button7_Click);
  482. //
  483. // button4
  484. //
  485. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  486. | System.Windows.Forms.AnchorStyles.Right)));
  487. this.button4.Location = new System.Drawing.Point(698, 21);
  488. this.button4.Name = "button4";
  489. this.button4.Size = new System.Drawing.Size(75, 23);
  490. this.button4.TabIndex = 0;
  491. this.button4.Text = "保存标尺";
  492. this.button4.UseVisualStyleBackColor = true;
  493. this.button4.Click += new System.EventHandler(this.button4_Click);
  494. //
  495. // groupBox3
  496. //
  497. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  498. | System.Windows.Forms.AnchorStyles.Left)
  499. | System.Windows.Forms.AnchorStyles.Right)));
  500. this.groupBox3.Location = new System.Drawing.Point(135, 72);
  501. this.groupBox3.Name = "groupBox3";
  502. this.groupBox3.Size = new System.Drawing.Size(585, 386);
  503. this.groupBox3.TabIndex = 3;
  504. this.groupBox3.TabStop = false;
  505. this.groupBox3.Text = "标尺图像";
  506. //
  507. // groupBox4
  508. //
  509. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  510. this.groupBox4.Controls.Add(this.label17);
  511. this.groupBox4.Controls.Add(this.label16);
  512. this.groupBox4.Controls.Add(this.label15);
  513. this.groupBox4.Controls.Add(this.label14);
  514. this.groupBox4.Controls.Add(this.label13);
  515. this.groupBox4.Controls.Add(this.label12);
  516. this.groupBox4.Controls.Add(this.comboBox1);
  517. this.groupBox4.Controls.Add(this.textBox6);
  518. this.groupBox4.Controls.Add(this.textBox5);
  519. this.groupBox4.Controls.Add(this.textBox4);
  520. this.groupBox4.Controls.Add(this.textBox2);
  521. this.groupBox4.Controls.Add(this.textBox1);
  522. this.groupBox4.Location = new System.Drawing.Point(726, 72);
  523. this.groupBox4.Name = "groupBox4";
  524. this.groupBox4.Size = new System.Drawing.Size(187, 189);
  525. this.groupBox4.TabIndex = 4;
  526. this.groupBox4.TabStop = false;
  527. this.groupBox4.Visible = false;
  528. //
  529. // label17
  530. //
  531. this.label17.AutoSize = true;
  532. this.label17.Location = new System.Drawing.Point(9, 164);
  533. this.label17.Name = "label17";
  534. this.label17.Size = new System.Drawing.Size(0, 12);
  535. this.label17.TabIndex = 13;
  536. //
  537. // label16
  538. //
  539. this.label16.AutoSize = true;
  540. this.label16.Location = new System.Drawing.Point(9, 136);
  541. this.label16.Name = "label16";
  542. this.label16.Size = new System.Drawing.Size(0, 12);
  543. this.label16.TabIndex = 12;
  544. //
  545. // label15
  546. //
  547. this.label15.AutoSize = true;
  548. this.label15.Location = new System.Drawing.Point(9, 108);
  549. this.label15.Name = "label15";
  550. this.label15.Size = new System.Drawing.Size(0, 12);
  551. this.label15.TabIndex = 11;
  552. //
  553. // label14
  554. //
  555. this.label14.AutoSize = true;
  556. this.label14.Location = new System.Drawing.Point(9, 80);
  557. this.label14.Name = "label14";
  558. this.label14.Size = new System.Drawing.Size(0, 12);
  559. this.label14.TabIndex = 10;
  560. //
  561. // label13
  562. //
  563. this.label13.AutoSize = true;
  564. this.label13.Location = new System.Drawing.Point(9, 52);
  565. this.label13.Name = "label13";
  566. this.label13.Size = new System.Drawing.Size(0, 12);
  567. this.label13.TabIndex = 9;
  568. //
  569. // label12
  570. //
  571. this.label12.AutoSize = true;
  572. this.label12.Location = new System.Drawing.Point(9, 24);
  573. this.label12.Name = "label12";
  574. this.label12.Size = new System.Drawing.Size(0, 12);
  575. this.label12.TabIndex = 8;
  576. //
  577. // comboBox1
  578. //
  579. this.comboBox1.FormattingEnabled = true;
  580. this.comboBox1.Location = new System.Drawing.Point(75, 76);
  581. this.comboBox1.Name = "comboBox1";
  582. this.comboBox1.Size = new System.Drawing.Size(106, 20);
  583. this.comboBox1.TabIndex = 7;
  584. //
  585. // textBox6
  586. //
  587. this.textBox6.Location = new System.Drawing.Point(75, 160);
  588. this.textBox6.Name = "textBox6";
  589. this.textBox6.Size = new System.Drawing.Size(106, 21);
  590. this.textBox6.TabIndex = 6;
  591. //
  592. // textBox5
  593. //
  594. this.textBox5.Location = new System.Drawing.Point(75, 132);
  595. this.textBox5.Name = "textBox5";
  596. this.textBox5.Size = new System.Drawing.Size(106, 21);
  597. this.textBox5.TabIndex = 5;
  598. //
  599. // textBox4
  600. //
  601. this.textBox4.Location = new System.Drawing.Point(75, 104);
  602. this.textBox4.Name = "textBox4";
  603. this.textBox4.Size = new System.Drawing.Size(106, 21);
  604. this.textBox4.TabIndex = 4;
  605. //
  606. // textBox2
  607. //
  608. this.textBox2.Location = new System.Drawing.Point(76, 48);
  609. this.textBox2.Name = "textBox2";
  610. this.textBox2.Size = new System.Drawing.Size(106, 21);
  611. this.textBox2.TabIndex = 2;
  612. //
  613. // textBox1
  614. //
  615. this.textBox1.Location = new System.Drawing.Point(75, 20);
  616. this.textBox1.Name = "textBox1";
  617. this.textBox1.Size = new System.Drawing.Size(106, 21);
  618. this.textBox1.TabIndex = 1;
  619. //
  620. // groupBox5
  621. //
  622. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  623. this.groupBox5.Controls.Add(this.label23);
  624. this.groupBox5.Controls.Add(this.label22);
  625. this.groupBox5.Controls.Add(this.label21);
  626. this.groupBox5.Controls.Add(this.label20);
  627. this.groupBox5.Controls.Add(this.label19);
  628. this.groupBox5.Controls.Add(this.label18);
  629. this.groupBox5.Controls.Add(this.textBox12);
  630. this.groupBox5.Controls.Add(this.textBox11);
  631. this.groupBox5.Controls.Add(this.textBox10);
  632. this.groupBox5.Controls.Add(this.textBox9);
  633. this.groupBox5.Controls.Add(this.textBox8);
  634. this.groupBox5.Controls.Add(this.textBox7);
  635. this.groupBox5.Location = new System.Drawing.Point(726, 267);
  636. this.groupBox5.Name = "groupBox5";
  637. this.groupBox5.Size = new System.Drawing.Size(187, 191);
  638. this.groupBox5.TabIndex = 5;
  639. this.groupBox5.TabStop = false;
  640. this.groupBox5.Visible = false;
  641. //
  642. // label23
  643. //
  644. this.label23.AutoSize = true;
  645. this.label23.Location = new System.Drawing.Point(9, 165);
  646. this.label23.Name = "label23";
  647. this.label23.Size = new System.Drawing.Size(0, 12);
  648. this.label23.TabIndex = 11;
  649. //
  650. // label22
  651. //
  652. this.label22.AutoSize = true;
  653. this.label22.Location = new System.Drawing.Point(9, 137);
  654. this.label22.Name = "label22";
  655. this.label22.Size = new System.Drawing.Size(0, 12);
  656. this.label22.TabIndex = 10;
  657. //
  658. // label21
  659. //
  660. this.label21.AutoSize = true;
  661. this.label21.Location = new System.Drawing.Point(9, 109);
  662. this.label21.Name = "label21";
  663. this.label21.Size = new System.Drawing.Size(0, 12);
  664. this.label21.TabIndex = 9;
  665. //
  666. // label20
  667. //
  668. this.label20.AutoSize = true;
  669. this.label20.Location = new System.Drawing.Point(9, 81);
  670. this.label20.Name = "label20";
  671. this.label20.Size = new System.Drawing.Size(0, 12);
  672. this.label20.TabIndex = 8;
  673. //
  674. // label19
  675. //
  676. this.label19.AutoSize = true;
  677. this.label19.Location = new System.Drawing.Point(9, 53);
  678. this.label19.Name = "label19";
  679. this.label19.Size = new System.Drawing.Size(0, 12);
  680. this.label19.TabIndex = 7;
  681. //
  682. // label18
  683. //
  684. this.label18.AutoSize = true;
  685. this.label18.Location = new System.Drawing.Point(9, 25);
  686. this.label18.Name = "label18";
  687. this.label18.Size = new System.Drawing.Size(0, 12);
  688. this.label18.TabIndex = 6;
  689. //
  690. // textBox12
  691. //
  692. this.textBox12.Location = new System.Drawing.Point(75, 161);
  693. this.textBox12.Name = "textBox12";
  694. this.textBox12.Size = new System.Drawing.Size(106, 21);
  695. this.textBox12.TabIndex = 5;
  696. //
  697. // textBox11
  698. //
  699. this.textBox11.Location = new System.Drawing.Point(75, 133);
  700. this.textBox11.Name = "textBox11";
  701. this.textBox11.Size = new System.Drawing.Size(106, 21);
  702. this.textBox11.TabIndex = 4;
  703. //
  704. // textBox10
  705. //
  706. this.textBox10.Location = new System.Drawing.Point(75, 105);
  707. this.textBox10.Name = "textBox10";
  708. this.textBox10.Size = new System.Drawing.Size(106, 21);
  709. this.textBox10.TabIndex = 3;
  710. //
  711. // textBox9
  712. //
  713. this.textBox9.Location = new System.Drawing.Point(75, 77);
  714. this.textBox9.Name = "textBox9";
  715. this.textBox9.Size = new System.Drawing.Size(106, 21);
  716. this.textBox9.TabIndex = 2;
  717. //
  718. // textBox8
  719. //
  720. this.textBox8.Location = new System.Drawing.Point(75, 49);
  721. this.textBox8.Name = "textBox8";
  722. this.textBox8.Size = new System.Drawing.Size(106, 21);
  723. this.textBox8.TabIndex = 1;
  724. //
  725. // textBox7
  726. //
  727. this.textBox7.Location = new System.Drawing.Point(75, 21);
  728. this.textBox7.Name = "textBox7";
  729. this.textBox7.Size = new System.Drawing.Size(106, 21);
  730. this.textBox7.TabIndex = 0;
  731. //
  732. // panel2
  733. //
  734. this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  735. | System.Windows.Forms.AnchorStyles.Right)));
  736. this.panel2.BackColor = System.Drawing.SystemColors.Control;
  737. this.panel2.Controls.Add(this.label10);
  738. this.panel2.Controls.Add(this.label11);
  739. this.panel2.Controls.Add(this.label9);
  740. this.panel2.Controls.Add(this.trackBar1);
  741. this.panel2.Controls.Add(this.numericUpDown2);
  742. this.panel2.Controls.Add(this.label6);
  743. this.panel2.Controls.Add(this.label5);
  744. this.panel2.Controls.Add(this.label4);
  745. this.panel2.Controls.Add(this.label3);
  746. this.panel2.Controls.Add(this.label2);
  747. this.panel2.Controls.Add(this.label8);
  748. this.panel2.Controls.Add(this.pictureBox1);
  749. this.panel2.Controls.Add(this.linearColorPickerControl1);
  750. this.panel2.Location = new System.Drawing.Point(726, 79);
  751. this.panel2.Name = "panel2";
  752. this.panel2.Size = new System.Drawing.Size(187, 379);
  753. this.panel2.TabIndex = 0;
  754. this.panel2.Visible = false;
  755. //
  756. // label10
  757. //
  758. this.label10.AutoSize = true;
  759. this.label10.BackColor = System.Drawing.Color.Transparent;
  760. this.label10.Location = new System.Drawing.Point(6, 22);
  761. this.label10.Name = "label10";
  762. this.label10.Size = new System.Drawing.Size(17, 12);
  763. this.label10.TabIndex = 30;
  764. this.label10.Text = "Y=";
  765. //
  766. // label11
  767. //
  768. this.label11.AutoSize = true;
  769. this.label11.BackColor = System.Drawing.Color.Transparent;
  770. this.label11.Location = new System.Drawing.Point(6, 6);
  771. this.label11.Name = "label11";
  772. this.label11.Size = new System.Drawing.Size(17, 12);
  773. this.label11.TabIndex = 29;
  774. this.label11.Text = "X=";
  775. //
  776. // label9
  777. //
  778. this.label9.AutoSize = true;
  779. this.label9.Location = new System.Drawing.Point(47, 113);
  780. this.label9.Name = "label9";
  781. this.label9.Size = new System.Drawing.Size(0, 12);
  782. this.label9.TabIndex = 28;
  783. //
  784. // trackBar1
  785. //
  786. this.trackBar1.Location = new System.Drawing.Point(70, 109);
  787. this.trackBar1.Minimum = 1;
  788. this.trackBar1.Name = "trackBar1";
  789. this.trackBar1.Size = new System.Drawing.Size(91, 45);
  790. this.trackBar1.TabIndex = 27;
  791. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  792. this.trackBar1.Value = 1;
  793. this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
  794. //
  795. // numericUpDown2
  796. //
  797. this.numericUpDown2.Location = new System.Drawing.Point(6, 109);
  798. this.numericUpDown2.Maximum = new decimal(new int[] {
  799. 10,
  800. 0,
  801. 0,
  802. 0});
  803. this.numericUpDown2.Minimum = new decimal(new int[] {
  804. 1,
  805. 0,
  806. 0,
  807. 0});
  808. this.numericUpDown2.Name = "numericUpDown2";
  809. this.numericUpDown2.Size = new System.Drawing.Size(37, 21);
  810. this.numericUpDown2.TabIndex = 26;
  811. this.numericUpDown2.Value = new decimal(new int[] {
  812. 1,
  813. 0,
  814. 0,
  815. 0});
  816. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  817. //
  818. // label6
  819. //
  820. this.label6.AutoSize = true;
  821. this.label6.Location = new System.Drawing.Point(126, 90);
  822. this.label6.Name = "label6";
  823. this.label6.Size = new System.Drawing.Size(11, 12);
  824. this.label6.TabIndex = 25;
  825. this.label6.Text = "V";
  826. //
  827. // label5
  828. //
  829. this.label5.AutoSize = true;
  830. this.label5.Location = new System.Drawing.Point(126, 74);
  831. this.label5.Name = "label5";
  832. this.label5.Size = new System.Drawing.Size(11, 12);
  833. this.label5.TabIndex = 24;
  834. this.label5.Text = "S";
  835. //
  836. // label4
  837. //
  838. this.label4.AutoSize = true;
  839. this.label4.Location = new System.Drawing.Point(126, 58);
  840. this.label4.Name = "label4";
  841. this.label4.Size = new System.Drawing.Size(11, 12);
  842. this.label4.TabIndex = 23;
  843. this.label4.Text = "H";
  844. //
  845. // label3
  846. //
  847. this.label3.AutoSize = true;
  848. this.label3.Location = new System.Drawing.Point(126, 36);
  849. this.label3.Name = "label3";
  850. this.label3.Size = new System.Drawing.Size(11, 12);
  851. this.label3.TabIndex = 22;
  852. this.label3.Text = "B";
  853. //
  854. // label2
  855. //
  856. this.label2.AutoSize = true;
  857. this.label2.Location = new System.Drawing.Point(126, 20);
  858. this.label2.Name = "label2";
  859. this.label2.Size = new System.Drawing.Size(11, 12);
  860. this.label2.TabIndex = 21;
  861. this.label2.Text = "G";
  862. //
  863. // label8
  864. //
  865. this.label8.AutoSize = true;
  866. this.label8.Location = new System.Drawing.Point(126, 4);
  867. this.label8.Name = "label8";
  868. this.label8.Size = new System.Drawing.Size(35, 12);
  869. this.label8.TabIndex = 20;
  870. this.label8.Text = "R=255";
  871. //
  872. // pictureBox1
  873. //
  874. this.pictureBox1.Location = new System.Drawing.Point(3, 3);
  875. this.pictureBox1.Name = "pictureBox1";
  876. this.pictureBox1.Size = new System.Drawing.Size(100, 100);
  877. this.pictureBox1.TabIndex = 19;
  878. this.pictureBox1.TabStop = false;
  879. this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
  880. //
  881. // linearColorPickerControl1
  882. //
  883. this.linearColorPickerControl1.Count = 1;
  884. this.linearColorPickerControl1.CustomGradient = new System.Drawing.Color[] {
  885. System.Drawing.Color.White,
  886. System.Drawing.Color.Yellow,
  887. System.Drawing.Color.Red,
  888. System.Drawing.Color.Green,
  889. System.Drawing.Color.Blue,
  890. System.Drawing.Color.Black};
  891. this.linearColorPickerControl1.DrawFarNub = true;
  892. this.linearColorPickerControl1.DrawNearNub = true;
  893. this.linearColorPickerControl1.Location = new System.Drawing.Point(106, 3);
  894. this.linearColorPickerControl1.MaxColor = System.Drawing.Color.White;
  895. this.linearColorPickerControl1.MinColor = System.Drawing.Color.Black;
  896. this.linearColorPickerControl1.Name = "linearColorPickerControl1";
  897. this.linearColorPickerControl1.Orientation = System.Windows.Forms.Orientation.Vertical;
  898. this.linearColorPickerControl1.Size = new System.Drawing.Size(14, 100);
  899. this.linearColorPickerControl1.TabIndex = 18;
  900. this.linearColorPickerControl1.TabStop = false;
  901. this.linearColorPickerControl1.Value = 153;
  902. this.linearColorPickerControl1.ValueChanged += new PaintDotNet.IndexEventHandler(this.linearColorPickerControl1_ValueChanged);
  903. //
  904. // RuleAddForm
  905. //
  906. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  907. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  908. this.ClientSize = new System.Drawing.Size(922, 467);
  909. this.Controls.Add(this.panel2);
  910. this.Controls.Add(this.groupBox5);
  911. this.Controls.Add(this.groupBox4);
  912. this.Controls.Add(this.groupBox3);
  913. this.Controls.Add(this.groupBox2);
  914. this.Controls.Add(this.groupBox1);
  915. this.Name = "RuleAddForm";
  916. this.Text = "新建标尺";
  917. this.Controls.SetChildIndex(this.groupBox1, 0);
  918. this.Controls.SetChildIndex(this.groupBox2, 0);
  919. this.Controls.SetChildIndex(this.groupBox3, 0);
  920. this.Controls.SetChildIndex(this.groupBox4, 0);
  921. this.Controls.SetChildIndex(this.groupBox5, 0);
  922. this.Controls.SetChildIndex(this.panel2, 0);
  923. this.groupBox1.ResumeLayout(false);
  924. this.groupBox2.ResumeLayout(false);
  925. this.groupBox2.PerformLayout();
  926. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  927. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  928. this.groupBox4.ResumeLayout(false);
  929. this.groupBox4.PerformLayout();
  930. this.groupBox5.ResumeLayout(false);
  931. this.groupBox5.PerformLayout();
  932. this.panel2.ResumeLayout(false);
  933. this.panel2.PerformLayout();
  934. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  935. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  936. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  937. this.ResumeLayout(false);
  938. }
  939. #endregion
  940. //<summary>
  941. //初始化其他控件
  942. //</summary>
  943. private void InitOtherTools()
  944. {
  945. //
  946. //调色板
  947. //
  948. this.colorsForm1 = new ColorsForm();
  949. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  950. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  951. //
  952. //字号
  953. //
  954. font = new Font("常规", (int)this.numericUpDown3.Value);
  955. }
  956. private void colorsForm1Changed(object sender, EventArgs e)
  957. {
  958. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  959. this.colorsForm1.Close();
  960. }
  961. /// <summary>
  962. /// 像素跟踪的颜色控件
  963. /// </summary>
  964. /// <param name="sender"></param>
  965. /// <param name="ce"></param>
  966. private void linearColorPickerControl1_ValueChanged(object sender, IndexEventArgs ce)
  967. {
  968. this.color = this.linearColorPickerControl1.ValueToColor(this.linearColorPickerControl1.Value);
  969. this.pictureBox1.Refresh();
  970. }
  971. /// <summary>
  972. /// 构造函数
  973. /// </summary>
  974. /// <param name="status">1新增 2编辑</param>
  975. public RuleAddForm(int status, AppWorkspace appWorkspace)
  976. {
  977. this.status = status;
  978. this.appWorkspace = appWorkspace;
  979. InitializeComponent();
  980. InitializeLanguageText();
  981. InitOtherTools();
  982. this.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Newruler.text");
  983. //
  984. //初始化图像控件
  985. //
  986. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  987. this.documentWorkspace.Dock = DockStyle.Fill;
  988. this.documentWorkspace.HookMouseEvents();
  989. this.documentWorkspace.pixelTrackingEnabled = false;
  990. //this.documentWorkspace.SurfaceBox.RemoveMouseEvent();
  991. this.documentWorkspace.AuxiliaryLineEnabled = true;
  992. this.documentWorkspace.Visible = false;
  993. this.groupBox3.Controls.Add(documentWorkspace);
  994. //
  995. //初始化操作按钮
  996. //
  997. this.commonControlButtons = new CommonControlButtons();
  998. this.commonControlButtons.Dock = DockStyle.Top;
  999. this.commonControlButtons.Height = 30;
  1000. this.groupBox3.Controls.Add(commonControlButtons);
  1001. this.groupBox3.Width = this.groupBox3.Width + this.groupBox4.Width + 6;
  1002. InitializeUI();
  1003. this.comboBox1.Text = PdnResources.GetString("Menu.easeselectmeasurementunit.Text");
  1004. this.comboBox1.DataSource = new BindingSource(InvariantData.ruleUnitsDictionary, null);
  1005. this.comboBox1.DisplayMember = "Value";
  1006. this.comboBox1.ValueMember = "Key";
  1007. this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
  1008. this.comboBox1.SelectedIndex = 4;
  1009. InitializeHint();
  1010. this.width = (int)this.numericUpDown1.Value;
  1011. this.textBox4.ReadOnly = true;
  1012. InitCommonButtonEvent();
  1013. //自定义线形的线帽,已达到标尺垂线的效果
  1014. hPath.AddLine(new PointF(-6, 0), new PointF(6, 0));
  1015. HookCap = new CustomLineCap(null, hPath);
  1016. HookCap.SetStrokeCaps(LineCap.Flat, LineCap.Flat);
  1017. HookCap.WidthScale = 0.5f;
  1018. }
  1019. private void InitCommonButtonEvent()
  1020. {
  1021. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1022. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1023. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1024. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1025. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1026. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1027. }
  1028. private void zoomInButton_Click(object sender, EventArgs e)
  1029. {
  1030. this.documentWorkspace.ZoomIn();
  1031. }
  1032. private void zoomOutButton_Click(object sender, EventArgs e)
  1033. {
  1034. this.documentWorkspace.ZoomOut();
  1035. }
  1036. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1037. {
  1038. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1039. }
  1040. private void actualSizeButton_Click(object sender, EventArgs e)
  1041. {
  1042. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1043. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1044. }
  1045. private void pointerButton_Click(object sender, EventArgs e)
  1046. {
  1047. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1048. }
  1049. private void mobileModeButton_Click(object sender, EventArgs e)
  1050. {
  1051. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1052. }
  1053. /// <summary>
  1054. /// 编辑时初始化数据
  1055. /// </summary>
  1056. public void InitializeEditData()
  1057. {
  1058. //打开图片
  1059. if(ruleFileModel!=null && ruleFileModel.picBase64!=null)
  1060. {
  1061. //string base64Img = "data:image/png;base64," + ruleFileModel.picBase64;
  1062. bitmap = DrawRulerHelper.Base64StringToImage(ruleFileModel.picBase64);
  1063. Document document = Document.FromImage(bitmap);
  1064. documentWorkspace.Document = document;
  1065. this.documentWorkspace.Visible = true;
  1066. startPoint = new System.Drawing.Point(ruleFileModel.startPointX, ruleFileModel.startPointY);
  1067. endPoint = new System.Drawing.Point(ruleFileModel.endPointX, ruleFileModel.endPointY);
  1068. this.panel1.BackColor = Color.FromArgb(ruleFileModel.lineColor);
  1069. this.brush = new SolidBrush(this.panel1.BackColor);
  1070. this.numericUpDown1.Value = ruleFileModel.lineWidth;
  1071. this.numericUpDown3.Value = Math.Max(1, ruleFileModel.textSize);
  1072. AddPictureBoxEvent();
  1073. }
  1074. if(ruleModel != null)
  1075. {
  1076. this.textBox2.Text = ruleModel.gain_multiple.ToString();
  1077. this.textBox12.Text = ruleModel.microscope;
  1078. this.textBox11.Text = ruleModel.objective_lens;
  1079. this.textBox5.Text = ruleModel.physical_length.ToString();
  1080. this.textBox6.Text = ruleModel.pixel_length.ToString();
  1081. this.textBox10.Text = ruleModel.ruler_camera;
  1082. this.textBox8.Text = ruleModel.ruler_connector;
  1083. this.textBox9.Text = ruleModel.ruler_eyepiece;
  1084. this.textBox1.Text = ruleModel.ruler_name;
  1085. this.comboBox1.SelectedValue = ruleModel.ruler_units;
  1086. this.textBox7.Text = ruleModel.ruler_zoom;
  1087. this.textBox4.Text = ruleModel.ruler_width + "×" + ruleModel.ruler_height;
  1088. }
  1089. }
  1090. private void MouseDownHandler(object sender, MouseEventArgs e)
  1091. {
  1092. if (documentWorkspace != null)
  1093. {
  1094. //if (documentWorkspace.Tool != null)
  1095. // documentWorkspace.Tool.PerformMouseDown(e);
  1096. }
  1097. }
  1098. private void MouseMoveHandler(object sender, MouseEventArgs e)
  1099. {
  1100. if (documentWorkspace != null)
  1101. {
  1102. //if (documentWorkspace.Tool != null)
  1103. // documentWorkspace.Tool.PerformMouseMove(e);
  1104. }
  1105. }
  1106. private void MouseUpHandler(object sender, MouseEventArgs e)
  1107. {
  1108. if (documentWorkspace != null)
  1109. {
  1110. //if (documentWorkspace.Tool != null)
  1111. // documentWorkspace.Tool.PerformMouseUp(e);
  1112. }
  1113. }
  1114. /// <summary>
  1115. /// 打开图片/保存标尺
  1116. /// 公用按钮
  1117. /// </summary>
  1118. /// <param name="sender"></param>
  1119. /// <param name="e"></param>
  1120. private void button4_Click(object sender, EventArgs e)
  1121. {
  1122. //保存标尺
  1123. if (step == 3)
  1124. {
  1125. if (this.textBox1.Text.Equals(""))
  1126. {
  1127. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
  1128. return;
  1129. }
  1130. if (this.textBox2.Text.Equals(""))
  1131. {
  1132. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthemagnification.text"));
  1133. return;
  1134. }
  1135. if (this.textBox5.Text.Equals(""))
  1136. {
  1137. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthephysicallength.text"));
  1138. return;
  1139. }
  1140. if (startPoint == endPoint)
  1141. {
  1142. MessageBox.Show(PdnResources.GetString("Menu.asereturntothesecondsteptodrawther.Text")+"!");
  1143. return;
  1144. }
  1145. if (this.status == 1)
  1146. {
  1147. try
  1148. {
  1149. //判断标尺是否存在
  1150. for (int i = 0; i < Startup.instance.mic_rulersAll.Count; i++)
  1151. {
  1152. if (Startup.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox1.Text))
  1153. {
  1154. MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
  1155. return;
  1156. }
  1157. }
  1158. //组织数据,保存到数据库
  1159. mic_rulers rule = new mic_rulers();
  1160. rule.gain_multiple = decimal.Parse(this.textBox2.Text);
  1161. if (rule.gain_multiple<1)
  1162. {
  1163. MessageBox.Show("放大倍数错误,请检查!");
  1164. return;
  1165. }
  1166. rule.microscope = this.textBox12.Text;
  1167. rule.objective_lens = this.textBox11.Text;
  1168. rule.physical_length = decimal.Parse(this.textBox5.Text);
  1169. rule.pixel_length = float.Parse(this.textBox6.Text);
  1170. rule.ruler_camera = this.textBox10.Text;
  1171. rule.ruler_connector = this.textBox8.Text;
  1172. rule.ruler_eyepiece = this.textBox9.Text;
  1173. rule.ruler_height = this.bitmap.Height;
  1174. rule.ruler_name = this.textBox1.Text;
  1175. rule.ruler_units = (int)this.comboBox1.SelectedValue;
  1176. rule.ruler_width = this.bitmap.Width;
  1177. rule.ruler_zoom = this.textBox7.Text;
  1178. rule.ruler_type = 1;
  1179. mic_rulers_BLL.Add(rule);
  1180. Startup.instance.mic_rulersAll.Add(rule);
  1181. //生成xml文件
  1182. ruleFileModel = new RulerFileModel();
  1183. ruleFileModel.startPointX = startPoint.X;
  1184. ruleFileModel.startPointY = startPoint.Y;
  1185. ruleFileModel.endPointX = endPoint.X;
  1186. ruleFileModel.endPointY = endPoint.Y;
  1187. ruleFileModel.lineColor = this.panel1.BackColor.ToArgb();
  1188. ruleFileModel.lineWidth = width;
  1189. ruleFileModel.textSize = this.numericUpDown3.Value;
  1190. ruleFileModel.picBase64 = DrawRulerHelper.ImgToBase64String(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
  1191. //保存xml文件
  1192. string userInfoXml = XmlSerializeHelper.XmlSerialize<RulerFileModel>(ruleFileModel);
  1193. string folderPath = Application.StartupPath + "\\RuleFile\\";
  1194. if (!Directory.Exists(folderPath)) Directory.CreateDirectory(folderPath);
  1195. string filePath = rule.id + ".xml";
  1196. FileOperationHelper.WriteStringToFile(userInfoXml, folderPath + filePath, FileMode.Create);
  1197. this.Close();
  1198. }
  1199. catch (Exception)
  1200. {
  1201. System.Console.WriteLine(e.ToString());
  1202. MessageBox.Show(PdnResources.GetString("Menu.Rulerinformationsavingfaile.Text"));
  1203. }
  1204. }
  1205. else if(this.status == 2)
  1206. {
  1207. try
  1208. {
  1209. //判断标尺是否存在
  1210. for (int i = 0; i < Startup.instance.mic_rulersAll.Count; i++)
  1211. {
  1212. if (Startup.instance.mic_rulersAll[i].id == ruleModel.id)
  1213. continue;
  1214. if (Startup.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox1.Text))
  1215. {
  1216. MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
  1217. return;
  1218. }
  1219. }
  1220. //组织数据,保存到数据库
  1221. ruleModel.gain_multiple = decimal.Parse(this.textBox2.Text);
  1222. if (ruleModel.gain_multiple < 1)
  1223. {
  1224. MessageBox.Show("放大倍数错误,请检查!");
  1225. return;
  1226. }
  1227. ruleModel.microscope = this.textBox12.Text;
  1228. ruleModel.objective_lens = this.textBox11.Text;
  1229. ruleModel.physical_length = decimal.Parse(this.textBox5.Text);
  1230. ruleModel.pixel_length = float.Parse(this.textBox6.Text);
  1231. ruleModel.ruler_camera = this.textBox10.Text;
  1232. ruleModel.ruler_connector = this.textBox8.Text;
  1233. ruleModel.ruler_eyepiece = this.textBox9.Text;
  1234. ruleModel.ruler_height = this.bitmap.Height;
  1235. ruleModel.ruler_name = this.textBox1.Text;
  1236. ruleModel.ruler_units = (int)this.comboBox1.SelectedValue;
  1237. ruleModel.ruler_width = this.bitmap.Width;
  1238. ruleModel.ruler_zoom = this.textBox7.Text;
  1239. ruleModel.ruler_type = 1;
  1240. mic_rulers_BLL.Update(ruleModel);
  1241. //生成xml文件
  1242. ruleFileModel = new RulerFileModel();
  1243. ruleFileModel.startPointX = startPoint.X;
  1244. ruleFileModel.startPointY = startPoint.Y;
  1245. ruleFileModel.endPointX = endPoint.X;
  1246. ruleFileModel.endPointY = endPoint.Y;
  1247. ruleFileModel.lineColor = this.panel1.BackColor.ToArgb();
  1248. ruleFileModel.lineWidth = width;
  1249. ruleFileModel.textSize = this.numericUpDown3.Value;
  1250. ruleFileModel.picBase64 = DrawRulerHelper.ImgToBase64String(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
  1251. //保存xml文件
  1252. string userInfoXml = XmlSerializeHelper.XmlSerialize<RulerFileModel>(ruleFileModel);
  1253. string filePath = Application.StartupPath + "\\RuleFile\\" + ruleModel.id + ".xml";
  1254. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create);
  1255. this.Close();
  1256. this.appWorkspace.RefreshActiveRuler();
  1257. }
  1258. catch (Exception)
  1259. {
  1260. System.Console.WriteLine(e.ToString());
  1261. MessageBox.Show(PdnResources.GetString("Menu.Rulerinformationsavingfaile.Text"));
  1262. }
  1263. }
  1264. //刷新标尺列表
  1265. this.appWorkspace.RefueshRuleList();
  1266. //刷新预览窗口
  1267. if (CameraPreviewDialog.cameraPreviewDialog != null)
  1268. CameraPreviewDialog.cameraPreviewDialog.BindingRule();
  1269. }
  1270. else
  1271. {
  1272. OpenFileDialog dialog = new OpenFileDialog();
  1273. dialog.Filter = "图像文件(*.gif;*.jpg;*.jpeg;*.png)|*.gif;*.jpg;*.jpeg;*.png";
  1274. dialog.ShowDialog();
  1275. if (dialog.FileName != String.Empty)
  1276. {
  1277. try
  1278. {
  1279. bitmap = new Bitmap(dialog.FileName);
  1280. Document document = Document.FromImage(bitmap);
  1281. documentWorkspace.Document = document;
  1282. this.documentWorkspace.Visible = true;
  1283. this.textBox4.Text = bitmap.Width + "×" + bitmap.Height;
  1284. this.mat = null;
  1285. this.startPoint = System.Drawing.Point.Empty;
  1286. this.endPoint = System.Drawing.Point.Empty;
  1287. RemoveDocEvent();
  1288. AddPictureBoxEvent();
  1289. }
  1290. catch(Exception)
  1291. {
  1292. MessageBox.Show("打开图像失败, 请确认");
  1293. }
  1294. }
  1295. }
  1296. }
  1297. /// <summary>
  1298. /// 下一步
  1299. /// </summary>
  1300. /// <param name="sender"></param>
  1301. /// <param name="e"></param>
  1302. private void button5_Click(object sender, EventArgs e)
  1303. {
  1304. if (step == 1) {
  1305. if (bitmap == null)
  1306. {
  1307. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectrulerimage.Text")+"!");
  1308. return;
  1309. }
  1310. }
  1311. if (!this.panel2.Visible && !this.groupBox4.Visible)
  1312. {
  1313. this.groupBox3.Width = this.groupBox3.Width - this.groupBox4.Width - 3;
  1314. }
  1315. step++;
  1316. InitializeUI();
  1317. }
  1318. /// <summary>
  1319. /// 上一步
  1320. /// </summary>
  1321. /// <param name="sender"></param>
  1322. /// <param name="e"></param>
  1323. private void button6_Click(object sender, EventArgs e)
  1324. {
  1325. step--;
  1326. if (step == 1)
  1327. {
  1328. if (this.panel2.Visible || this.groupBox4.Visible)
  1329. {
  1330. this.groupBox3.Width = this.groupBox3.Width + this.groupBox4.Width + 3;
  1331. }
  1332. this.panel2.Visible = false;
  1333. this.groupBox4.Visible = false;
  1334. this.groupBox5.Visible = false;
  1335. }
  1336. InitializeUI();
  1337. }
  1338. /// <summary>
  1339. /// 初始化UI
  1340. /// </summary>
  1341. private void InitializeUI() {
  1342. if (step == 1) {
  1343. this.label1.Visible = false;
  1344. this.panel1.Visible = false;
  1345. this.label7.Visible = false;
  1346. this.label24.Visible = false;
  1347. this.numericUpDown1.Visible = false;
  1348. this.numericUpDown3.Visible = false;
  1349. this.button7.Visible = false;
  1350. this.button8.Visible = false;
  1351. this.button9.Visible = false;
  1352. this.button5.Enabled = true;
  1353. this.button6.Enabled = false;
  1354. this.button4.Visible = true;
  1355. this.button4.Text = PdnResources.GetString("Menu.Openimage.text");
  1356. this.button1.BackColor = Color.Black;
  1357. this.button1.ForeColor = Color.White;
  1358. this.button2.BackColor = Color.White;
  1359. this.button2.ForeColor = Color.Black;
  1360. this.button3.BackColor = Color.White;
  1361. this.button3.ForeColor = Color.Black;
  1362. }
  1363. if (step == 2) {
  1364. this.label1.Visible = true;
  1365. this.panel1.Visible = true;
  1366. this.label7.Visible = true;
  1367. this.label24.Visible = true;
  1368. this.numericUpDown1.Visible = true;
  1369. this.numericUpDown3.Visible = true;
  1370. this.button7.Visible = true;
  1371. this.button8.Visible = true;
  1372. this.button9.Visible = true;
  1373. this.button6.Enabled = true;
  1374. this.button5.Enabled = true;
  1375. this.panel2.Visible = true;
  1376. this.groupBox4.Visible = false;
  1377. this.groupBox5.Visible = false;
  1378. this.button4.Visible = false;
  1379. this.button4.Text = PdnResources.GetString("Menu.Openimage.text");
  1380. this.button2.BackColor = Color.Black;
  1381. this.button2.ForeColor = Color.White;
  1382. this.button1.BackColor = Color.White;
  1383. this.button1.ForeColor = Color.Black;
  1384. this.button3.BackColor = Color.White;
  1385. this.button3.ForeColor = Color.Black;
  1386. }
  1387. if (step == 3) {
  1388. this.label1.Visible = false;
  1389. this.panel1.Visible = false;
  1390. this.label7.Visible = false;
  1391. this.label24.Visible = false;
  1392. this.numericUpDown1.Visible = false;
  1393. this.numericUpDown3.Visible = false;
  1394. this.button7.Visible = false;
  1395. this.button8.Visible = false;
  1396. this.button9.Visible = false;
  1397. this.button6.Enabled = true;
  1398. this.button5.Enabled = false;
  1399. this.button4.Visible = true;
  1400. this.button4.Text = PdnResources.GetString("Menu.Savetheruler.text");
  1401. this.panel2.Visible = false;
  1402. this.groupBox4.Visible = true;
  1403. this.groupBox5.Visible = true;
  1404. this.button3.BackColor = Color.Black;
  1405. this.button3.ForeColor = Color.White;
  1406. this.button1.BackColor = Color.White;
  1407. this.button1.ForeColor = Color.Black;
  1408. this.button2.BackColor = Color.White;
  1409. this.button2.ForeColor = Color.Black;
  1410. }
  1411. }
  1412. /// <summary>
  1413. /// 初始化hint提示信息
  1414. /// </summary>
  1415. private void InitializeHint()
  1416. {
  1417. SystemLayer.SafeNativeMethods.SetCueText(this.textBox1, PdnResources.GetString("Menu.Pleaseenterarulername.text"));
  1418. SystemLayer.SafeNativeMethods.SetCueText(this.textBox2, PdnResources.GetString("Menu.Pleaseenterthemagnification.text"));
  1419. SystemLayer.SafeNativeMethods.SetCueText(this.textBox4, PdnResources.GetString("Menu.Pleaseinputimageresolution.Text"));
  1420. SystemLayer.SafeNativeMethods.SetCueText(this.textBox5, PdnResources.GetString("Menu.Pleaseenterthephysicallength.text"));
  1421. SystemLayer.SafeNativeMethods.SetCueText(this.textBox6, PdnResources.GetString("Menu.Pixellength.text"));
  1422. SystemLayer.SafeNativeMethods.SetCueText(this.textBox7, PdnResources.GetString("Menu.Pleaseentetionchanger.text"));
  1423. SystemLayer.SafeNativeMethods.SetCueText(this.textBox8, PdnResources.GetString("Menu.Pleaseentertheinterface.text"));
  1424. SystemLayer.SafeNativeMethods.SetCueText(this.textBox9, PdnResources.GetString("Menu.Pleaseentertheeyepiece.text"));
  1425. SystemLayer.SafeNativeMethods.SetCueText(this.textBox10, PdnResources.GetString("Menu.Pleaseenterthecamera.text"));
  1426. SystemLayer.SafeNativeMethods.SetCueText(this.textBox11, PdnResources.GetString("Menu.Pleaseenterobjectlens.text"));
  1427. SystemLayer.SafeNativeMethods.SetCueText(this.textBox12, PdnResources.GetString("Menu.Pleaseenterthemicroscope.text"));
  1428. }
  1429. /// <summary>
  1430. /// 第一步
  1431. /// </summary>
  1432. /// <param name="sender"></param>
  1433. /// <param name="e"></param>
  1434. private void button1_Click(object sender, EventArgs e)
  1435. {
  1436. if (this.panel2.Visible || this.groupBox4.Visible)
  1437. {
  1438. this.groupBox3.Width = this.groupBox3.Width + this.groupBox4.Width + 3;
  1439. }
  1440. this.panel2.Visible = false;
  1441. this.groupBox4.Visible = false;
  1442. this.groupBox5.Visible = false;
  1443. step = 1;
  1444. InitializeUI();
  1445. }
  1446. /// <summary>
  1447. /// 第二步
  1448. /// </summary>
  1449. /// <param name="sender"></param>
  1450. /// <param name="e"></param>
  1451. private void button2_Click(object sender, EventArgs e)
  1452. {
  1453. if (bitmap==null) {
  1454. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectrulerimage.Text")+"!");
  1455. return;
  1456. }
  1457. if (!this.panel2.Visible && !this.groupBox4.Visible)
  1458. {
  1459. this.groupBox3.Width = this.groupBox3.Width - this.groupBox4.Width - 3;
  1460. }
  1461. this.panel2.Visible = true;
  1462. this.groupBox4.Visible = false;
  1463. this.groupBox5.Visible = false;
  1464. this.button4.Text = PdnResources.GetString("Menu.Openimage.text");
  1465. step = 2;
  1466. InitializeUI();
  1467. }
  1468. /// <summary>
  1469. /// 第三步
  1470. /// </summary>
  1471. /// <param name="sender"></param>
  1472. /// <param name="e"></param>
  1473. private void button3_Click(object sender, EventArgs e)
  1474. {
  1475. if (bitmap == null)
  1476. {
  1477. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectrulerimage.Text")+"!");
  1478. return;
  1479. }
  1480. if (!this.panel2.Visible && !this.groupBox4.Visible)
  1481. {
  1482. this.groupBox3.Width = this.groupBox3.Width - this.groupBox4.Width - 3;
  1483. }
  1484. this.panel2.Visible = false;
  1485. this.groupBox4.Visible = true;
  1486. this.groupBox5.Visible = true;
  1487. step = 3;
  1488. InitializeUI();
  1489. }
  1490. /// <summary>
  1491. /// 颜色选择
  1492. /// </summary>
  1493. /// <param name="sender"></param>
  1494. /// <param name="e"></param>
  1495. private void panel1_MouseDown(object sender, MouseEventArgs e)
  1496. {
  1497. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  1498. this.colorsForm1.ShowDialog();
  1499. }
  1500. /// <summary>
  1501. /// 水平方向
  1502. /// </summary>
  1503. /// <param name="sender"></param>
  1504. /// <param name="e"></param>
  1505. private void button7_Click(object sender, EventArgs e)
  1506. {
  1507. direction = 1;
  1508. RemoveDocEvent();
  1509. AddPictureBoxEvent();
  1510. }
  1511. /// <summary>
  1512. /// 垂直方向
  1513. /// </summary>
  1514. /// <param name="sender"></param>
  1515. /// <param name="e"></param>
  1516. private void button8_Click(object sender, EventArgs e)
  1517. {
  1518. direction = 2;
  1519. RemoveDocEvent();
  1520. AddPictureBoxEvent();
  1521. }
  1522. /// <summary>
  1523. /// 任意方向
  1524. /// </summary>
  1525. /// <param name="sender"></param>
  1526. /// <param name="e"></param>
  1527. private void button9_Click(object sender, EventArgs e)
  1528. {
  1529. direction = 3;
  1530. RemoveDocEvent();
  1531. AddPictureBoxEvent();
  1532. }
  1533. /// <summary>
  1534. /// 添加事件
  1535. /// </summary>
  1536. private void AddPictureBoxEvent()
  1537. {
  1538. this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.BoxMouseDownHandler);
  1539. this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.BoxMouseMoveHandler);
  1540. this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.BoxMouseUpHandler);
  1541. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);
  1542. }
  1543. /// <summary>
  1544. /// 绘制事件
  1545. /// </summary>
  1546. /// <param name="sender"></param>
  1547. /// <param name="e"></param>
  1548. private void BoxPaintHandler(object sender, PaintEventArgs e)
  1549. {
  1550. if (startPoint!=null && endPoint!=null)
  1551. {
  1552. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1553. int width1 = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1554. int height1 = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1555. int x = (rc.Width < width1) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width1) / 2;
  1556. int y = (rc.Height < height1) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height1) / 2;
  1557. double length = BasicCalculationHelper.GetDistance(startPoint, endPoint, 2);
  1558. e.Graphics.TranslateTransform(x, y);
  1559. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1560. Pen linePen = new Pen(this.panel1.BackColor);
  1561. brush = new SolidBrush(this.panel1.BackColor);
  1562. linePen.Width = width;
  1563. linePen.CustomStartCap = HookCap;
  1564. linePen.CustomEndCap = HookCap;
  1565. e.Graphics.DrawLine(linePen, startPoint, endPoint);
  1566. linePen.Dispose();
  1567. //参考下,然后绘制带角度的文字https://www.jianshu.com/p/404ed85887e6
  1568. if (length > 0)
  1569. {
  1570. //计算需要旋转的角度
  1571. double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new System.Drawing.Point(startPoint.X, endPoint.Y));
  1572. //原始旋转矩阵
  1573. Matrix mtxSave = e.Graphics.Transform;
  1574. Matrix matrix = e.Graphics.Transform;
  1575. matrix.RotateAt((float)angle, new PointF(startPoint.X, startPoint.Y));
  1576. e.Graphics.Transform = matrix;
  1577. e.Graphics.DrawString(length + "px", font, brush, startPoint.X, startPoint.Y);
  1578. //还原为原始旋转矩阵
  1579. e.Graphics.Transform = mtxSave;
  1580. this.textBox6.Text = length.ToString();//将像素长度传递至第三步
  1581. }
  1582. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1583. e.Graphics.TranslateTransform(-x, -y);
  1584. }
  1585. }
  1586. private void BoxMouseUpHandler(object sender, MouseEventArgs e)
  1587. {
  1588. this.pressFlag = false;
  1589. if (e.Button == MouseButtons.Left)
  1590. direction = 0;
  1591. }
  1592. private void BoxMouseMoveHandler(object sender, MouseEventArgs e)
  1593. {
  1594. if (this.bitmap != null)
  1595. {
  1596. this.SetImageAndData(this.documentWorkspace.CalcPixelPoint(e.Location));
  1597. }
  1598. if (this.pressFlag && direction > 0 && e.Button == MouseButtons.Left) {
  1599. System.Drawing.Point point = e.Location;
  1600. if (direction == 1)
  1601. {
  1602. point.Y = y;
  1603. }
  1604. else if (direction == 2)
  1605. {
  1606. point.X = x;
  1607. }
  1608. this.endPoint = this.documentWorkspace.GetScalePoint(point);
  1609. this.documentWorkspace.Refresh();
  1610. }
  1611. }
  1612. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  1613. {
  1614. if (mat != null)
  1615. {
  1616. scale = (int)this.numericUpDown2.Value;
  1617. this.trackBar1.Value = scale;
  1618. }
  1619. }
  1620. private void trackBar1_ValueChanged(object sender, EventArgs e)
  1621. {
  1622. if (mat != null)
  1623. {
  1624. scale = this.trackBar1.Value;
  1625. this.numericUpDown2.Value = this.trackBar1.Value;
  1626. }
  1627. }
  1628. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  1629. {
  1630. font = new Font("常规", (int)this.numericUpDown3.Value);
  1631. this.documentWorkspace.Refresh();
  1632. }
  1633. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  1634. {
  1635. e.Graphics.DrawLine(new Pen(color), 0, 50, 100, 50);
  1636. e.Graphics.DrawLine(new Pen(color), 50, 0, 50, 100);
  1637. e.Graphics.DrawEllipse(new Pen(color), new Rectangle(25, 25, 50, 50));
  1638. }
  1639. private void BoxMouseDownHandler(object sender, MouseEventArgs e)
  1640. {
  1641. this.pressFlag = true;
  1642. if (direction > 0 && e.Button == MouseButtons.Left) {
  1643. x = e.Location.X;
  1644. y = e.Location.Y;
  1645. startPoint = endPoint = this.documentWorkspace.GetScalePoint(e.Location);
  1646. }
  1647. }
  1648. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1649. {
  1650. this.width = (int)this.numericUpDown1.Value;
  1651. this.documentWorkspace.Refresh();
  1652. }
  1653. private void RemoveDocEvent()
  1654. {
  1655. this.documentWorkspace.DocumentMouseUp -= new MouseEventHandler(this.MouseUpHandler);
  1656. this.documentWorkspace.DocumentMouseMove -= new MouseEventHandler(this.MouseMoveHandler);
  1657. this.documentWorkspace.DocumentMouseDown -= new MouseEventHandler(this.MouseDownHandler);
  1658. }
  1659. /// <summary>
  1660. /// 设置像素跟踪
  1661. /// </summary>
  1662. /// <param name="point"></param>
  1663. public void SetImageAndData(System.Drawing.Point point)
  1664. {
  1665. if (this.documentWorkspace != null)
  1666. {
  1667. if (this.documentWorkspace.CompositionSurface != null)
  1668. {
  1669. scale = int.Parse(this.numericUpDown2.Value.ToString());
  1670. if (mat == null)
  1671. {
  1672. mat = this.documentWorkspace.CompositionSurface.CreatedAliasedMat().Clone();
  1673. Cv2.Resize(mat, bmat, new OpenCvSharp.Size(mat.Width * scale, mat.Height * scale));
  1674. Mat temp = new Mat(new OpenCvSharp.Size(bmat.Width + 100, bmat.Height + 100), bmat.Type());
  1675. Cv2.CopyMakeBorder(bmat, temp, 50, 50, 50, 50, BorderTypes.Constant, Scalar.All(255));
  1676. bmat = temp;
  1677. }
  1678. if (point.Y < 0) point.Y = 0;
  1679. if (point.X < 0) point.X = 0;
  1680. this.label11.Text = "X=" + point.X.ToString();
  1681. this.label10.Text = "Y=" + point.Y.ToString();
  1682. if (point.X< mat.Width && point.Y < mat.Height)
  1683. {
  1684. bgr = mat.At<Vec3b>(point.Y, point.X);
  1685. this.label8.Text = "R=" + bgr[2];
  1686. this.label2.Text = "G=" + bgr[1];
  1687. this.label3.Text = "B=" + bgr[0];
  1688. BaseTools.RgbToHsv(bgr, out h, out s, out v);
  1689. this.label4.Text = "H=" + (int)(h / 2);
  1690. this.label5.Text = "S=" + (int)(s * 255);
  1691. this.label6.Text = "V=" + (int)(v * 255);
  1692. //设置源图像ROI
  1693. Rect roi = new Rect(point.X, point.Y, 100, 100);//首先要用个rect确定我们的兴趣区域在哪
  1694. ImageROI = new Mat(bmat, roi);
  1695. //按缩放比例截取小图像
  1696. Rect roi1 = new Rect((100 - 100 / scale) / 2, (100 - 100 / scale) / 2, 100 / scale, 100 / scale);
  1697. ImageROI = new Mat(ImageROI, roi1);
  1698. //按固定宽高放大图像
  1699. Cv2.Resize(ImageROI, ImageROI, new OpenCvSharp.Size(100, 100));
  1700. this.pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(ImageROI);
  1701. }
  1702. }
  1703. }
  1704. }
  1705. }
  1706. }