RuleAddForm.cs 78 KB

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