ArbitrationLawGuideDialog.cs 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. using PaintDotNet.Base.SettingModel;
  2. using PaintDotNet.Base.CommTool;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Data.Entity.Core.Metadata.Edm;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using System.Runtime.InteropServices;
  16. using PaintDotNet.DedicatedAnalysis.GrainSize;
  17. namespace PaintDotNet.DedicatedAnalysis
  18. {
  19. /// <summary>
  20. /// 晶粒度(仲裁法)辅助线设置
  21. /// </summary>
  22. public partial class ArbitrationLawGuideDialog : Form
  23. {
  24. #region 控件
  25. private GroupBox groupBox2;
  26. private GroupBox groupBox3;
  27. private Button button1;
  28. private Button button2;
  29. private Label label3;
  30. private Label label2;
  31. private Panel panel1;
  32. private Panel panel2;
  33. private GroupBox groupBox1;
  34. private NumericUpDown numericUpDown2;
  35. private GroupBox groupBox4;
  36. private Button button5;
  37. private Button button4;
  38. private Button button3;
  39. private Label label7;
  40. private TextBox textBox1;
  41. private ComboBox comboBox1;
  42. private DataGridView dataGridView1;
  43. #endregion
  44. /// <summary>
  45. /// 字体列表
  46. /// </summary>
  47. ArrayList fontsItems = new ArrayList();
  48. /// <summary>
  49. /// 超出尺寸
  50. /// </summary>
  51. private bool exceed;
  52. /// <summary>
  53. /// 调色板
  54. /// </summary>
  55. PaintDotNet.ColorsForm colorsForm;
  56. /// <summary>
  57. /// 操作区分(0 :添加 1 :编辑)
  58. /// </summary>
  59. private int operation = -1;
  60. /// <summary>
  61. /// 临时数据
  62. /// </summary>
  63. private List<ArrayList> arrayLists = new List<ArrayList>();
  64. /// <summary>
  65. /// 跳转画面 0:截点法 1:面积法
  66. /// </summary>
  67. private int picture;
  68. /// <summary>
  69. /// 直径
  70. /// </summary>
  71. public int diameter;
  72. /// <summary>
  73. /// 边距
  74. /// </summary>
  75. public int margin;
  76. /// <summary>
  77. /// 长度(垂线)
  78. /// </summary>
  79. public int vLineLength;
  80. /// <summary>
  81. /// 长度(水平线)
  82. /// </summary>
  83. public int hLineLength;
  84. /// <summary>
  85. /// 左上到右下斜线长度
  86. /// </summary>
  87. public int TopleftLineLength;
  88. /// <summary>
  89. /// 左下到右上斜线长度
  90. /// </summary>
  91. public int ToprightLineLength;
  92. /// <summary>
  93. /// 垂线到圆距离
  94. /// </summary>
  95. public int VLineToCDistance;
  96. /// <summary>
  97. /// 水平线到圆距离
  98. /// </summary>
  99. public int HLineToCDistance;
  100. /// <summary>
  101. /// 线宽
  102. /// </summary>
  103. public int lineWidth;
  104. /// %
  105. /// </summary>
  106. public decimal percentage;
  107. private Label label24;
  108. private NumericUpDown numericUpDown5;
  109. private Label label6;
  110. private NumericUpDown numericUpDown4;
  111. private Label label5;
  112. private NumericUpDown numericUpDown3;
  113. private Label label4;
  114. private NumericUpDown numericUpDown1;
  115. private Label label1;
  116. private DataGridViewTextBoxColumn GuideName;
  117. private int width;
  118. private int height;
  119. private ToolTip toolTip1;
  120. private IContainer components;
  121. /// <summary>
  122. /// 排列顺序
  123. /// </summary>
  124. private int index = 0;
  125. public ArbitrationLawGuideDialog(int width, int height)
  126. {
  127. this.width = width;
  128. this.height = height;
  129. InitializeComponent();
  130. InitializeLanguageText();
  131. InitializeButtonBackgroudImage();
  132. InitializeToolTip();
  133. InitializeData();
  134. //调色板
  135. this.colorsForm = new ColorsForm();
  136. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  137. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  138. }
  139. private void InitializeToolTip()
  140. {
  141. this.toolTip1 = new ToolTip();
  142. this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Addto.text"));
  143. this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Edit.Text"));
  144. this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Delete.Text"));
  145. this.toolTip1.ShowAlways = true;
  146. }
  147. private void InitializeButtonBackgroudImage()
  148. {
  149. this.button3.FlatStyle = FlatStyle.Flat;
  150. this.button3.FlatAppearance.BorderSize = 0;
  151. this.button3.BackgroundImageLayout = ImageLayout.Center;
  152. this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
  153. this.button4.FlatStyle = FlatStyle.Flat;
  154. this.button4.FlatAppearance.BorderSize = 0;
  155. this.button4.BackgroundImageLayout = ImageLayout.Center;
  156. this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
  157. this.button5.FlatStyle = FlatStyle.Flat;
  158. this.button5.FlatAppearance.BorderSize = 0;
  159. this.button5.BackgroundImageLayout = ImageLayout.Center;
  160. this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
  161. }
  162. private void RefreshGridIntersections()
  163. {
  164. float hGridSpacingDraw;
  165. float vGridSpacingDraw;
  166. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
  167. {
  168. float space = 1;
  169. //避免不必要的提示网格尺寸已超出图像
  170. if (this.numericUpDown5.Value > 0)
  171. space = (float)this.numericUpDown5.Value;
  172. hGridSpacingDraw = (float)(this.height - 2 * Convert.ToInt32(space)) / (Convert.ToInt32(this.numericUpDown1.Value) - 1);
  173. vGridSpacingDraw = (float)(this.width - 2 * Convert.ToInt32(space)) / ( Convert.ToInt32(this.numericUpDown3.Value) - 1);
  174. }
  175. else
  176. {
  177. hGridSpacingDraw = Convert.ToInt32(this.numericUpDown4.Value);
  178. vGridSpacingDraw = Convert.ToInt32(this.numericUpDown4.Value);
  179. }
  180. exceed = false;
  181. ArrayList xs = new ArrayList();
  182. ArrayList ys = new ArrayList();
  183. if ( Convert.ToInt32(this.numericUpDown1.Value) > 0)
  184. {
  185. if ( Convert.ToInt32(this.numericUpDown1.Value) % 2 == 0)
  186. {
  187. float Spacing = hGridSpacingDraw / 2;
  188. for (int i = 0; i < Convert.ToInt32(this.numericUpDown1.Value) / 2; i++)
  189. {
  190. if ((float)this.height / 2 - Spacing >= 0
  191. && (float)this.height / 2 + Spacing <= this.height)
  192. {
  193. ys.Add((float)this.height / 2 - Spacing);
  194. ys.Add((float)this.height / 2 + Spacing);
  195. }
  196. else
  197. exceed = true;
  198. Spacing += hGridSpacingDraw;
  199. }
  200. }
  201. else
  202. {
  203. if ( Convert.ToInt32(this.numericUpDown1.Value) == 1)
  204. ys.Add((float)this.height / 2);
  205. else
  206. {
  207. float Spacing = hGridSpacingDraw;
  208. for (int i = 0; i < ( Convert.ToInt32(this.numericUpDown1.Value) - 1) / 2; i++)
  209. {
  210. if (i == 0)
  211. ys.Add((float)this.height / 2);
  212. if ((float)this.height / 2 - Spacing >= 0
  213. && (float)this.height / 2 + Spacing <= this.height)
  214. {
  215. ys.Add((float)this.height / 2 - Spacing);
  216. ys.Add((float)this.height / 2 + Spacing);
  217. }
  218. else
  219. exceed = true;
  220. Spacing += hGridSpacingDraw;
  221. }
  222. }
  223. }
  224. }
  225. if ( Convert.ToInt32(this.numericUpDown3.Value) > 0)
  226. {
  227. if ( Convert.ToInt32(this.numericUpDown3.Value) % 2 == 0)
  228. {
  229. float Spacing = vGridSpacingDraw / 2;
  230. for (int i = 0; i < Convert.ToInt32(this.numericUpDown3.Value) / 2; i++)
  231. {
  232. if ((float)this.width / 2 - Spacing >= 0
  233. && (float)this.width / 2 + Spacing <= this.width)
  234. {
  235. xs.Add((float)this.width / 2 - Spacing);
  236. xs.Add((float)this.width / 2 + Spacing);
  237. }
  238. else
  239. exceed = true;
  240. Spacing += vGridSpacingDraw;
  241. }
  242. }
  243. else
  244. {
  245. if ( Convert.ToInt32(this.numericUpDown3.Value) == 1)
  246. xs.Add((float)this.width / 2);
  247. else
  248. {
  249. float Spacing = vGridSpacingDraw;
  250. for (int i = 0; i < ( Convert.ToInt32(this.numericUpDown3.Value) - 1) / 2; i++)
  251. {
  252. if (i == 0)
  253. xs.Add((float)this.width / 2);
  254. if ((float)this.width / 2 + Spacing <= this.width
  255. && (float)this.width / 2 - Spacing >= 0)
  256. {
  257. xs.Add((float)this.width / 2 - Spacing);
  258. xs.Add((float)this.width / 2 + Spacing);
  259. }
  260. else
  261. exceed = true;
  262. Spacing += vGridSpacingDraw;
  263. }
  264. }
  265. }
  266. }
  267. if(exceed)
  268. MessageBox.Show(PdnResources.GetString("Menu.Thegridsizehasexceededtheimage.text")+"!");
  269. }
  270. #region 初始化
  271. private void InitializeLanguageText()
  272. {
  273. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  274. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  275. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  276. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.AuxiliaryLine.Text");
  277. this.label6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Gridmargin.text") + ":";
  278. this.label5.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Gridspacing.text") + ":";
  279. this.label4.Text = PdnResources.GetString("Menu.Numberofvertical.text") + ":";
  280. this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thelevelofthenumber.text") + ":";
  281. this.label3.Text = PdnResources.GetString("Menu.Gridlinewidth.text") + ":";
  282. this.comboBox1.Items.AddRange(new object[] {
  283. PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text"),
  284. PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text")});
  285. this.label7.Text = PdnResources.GetString("Menu.name.text") + ":";
  286. this.label2.Text = PdnResources.GetString("Menu.Gridcolor.text") + ":";
  287. this.label24.Text = PdnResources.GetString("Menu.Type.text") + ":";
  288. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  289. this.groupBox4.Text = PdnResources.GetString("Menu.Preview.text");
  290. this.Text = PdnResources.GetString("Menu.Auxiliarylinestylesettings.text");
  291. }
  292. private void InitializeComponent()
  293. {
  294. this.components = new System.ComponentModel.Container();
  295. this.groupBox1 = new System.Windows.Forms.GroupBox();
  296. this.button2 = new System.Windows.Forms.Button();
  297. this.button1 = new System.Windows.Forms.Button();
  298. this.groupBox2 = new System.Windows.Forms.GroupBox();
  299. this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
  300. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  301. this.label6 = new System.Windows.Forms.Label();
  302. this.label5 = new System.Windows.Forms.Label();
  303. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  304. this.label4 = new System.Windows.Forms.Label();
  305. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  306. this.label1 = new System.Windows.Forms.Label();
  307. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  308. this.label3 = new System.Windows.Forms.Label();
  309. this.comboBox1 = new System.Windows.Forms.ComboBox();
  310. this.textBox1 = new System.Windows.Forms.TextBox();
  311. this.panel2 = new System.Windows.Forms.Panel();
  312. this.label7 = new System.Windows.Forms.Label();
  313. this.label2 = new System.Windows.Forms.Label();
  314. this.label24 = new System.Windows.Forms.Label();
  315. this.groupBox3 = new System.Windows.Forms.GroupBox();
  316. this.panel1 = new System.Windows.Forms.Panel();
  317. this.groupBox4 = new System.Windows.Forms.GroupBox();
  318. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  319. this.GuideName = new System.Windows.Forms.DataGridViewTextBoxColumn();
  320. this.button5 = new System.Windows.Forms.Button();
  321. this.button4 = new System.Windows.Forms.Button();
  322. this.button3 = new System.Windows.Forms.Button();
  323. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  324. this.groupBox1.SuspendLayout();
  325. this.groupBox2.SuspendLayout();
  326. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
  327. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  328. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  329. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  330. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  331. this.groupBox3.SuspendLayout();
  332. this.groupBox4.SuspendLayout();
  333. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  334. this.SuspendLayout();
  335. //
  336. // groupBox1
  337. //
  338. this.groupBox1.Controls.Add(this.button2);
  339. this.groupBox1.Controls.Add(this.button1);
  340. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  341. this.groupBox1.Name = "groupBox1";
  342. this.groupBox1.Size = new System.Drawing.Size(500, 54);
  343. this.groupBox1.TabIndex = 0;
  344. this.groupBox1.TabStop = false;
  345. //
  346. // button2
  347. //
  348. this.button2.Location = new System.Drawing.Point(414, 16);
  349. this.button2.Name = "button2";
  350. this.button2.Size = new System.Drawing.Size(70, 28);
  351. this.button2.TabIndex = 1;
  352. this.button2.UseVisualStyleBackColor = true;
  353. this.button2.Click += new System.EventHandler(this.button2_Click);
  354. //
  355. // button1
  356. //
  357. this.button1.Location = new System.Drawing.Point(325, 16);
  358. this.button1.Name = "button1";
  359. this.button1.Size = new System.Drawing.Size(70, 28);
  360. this.button1.TabIndex = 0;
  361. this.button1.UseVisualStyleBackColor = true;
  362. this.button1.Click += new System.EventHandler(this.button1_Click);
  363. //
  364. // groupBox2
  365. //
  366. this.groupBox2.Controls.Add(this.numericUpDown5);
  367. this.groupBox2.Controls.Add(this.numericUpDown4);
  368. this.groupBox2.Controls.Add(this.label6);
  369. this.groupBox2.Controls.Add(this.label5);
  370. this.groupBox2.Controls.Add(this.numericUpDown3);
  371. this.groupBox2.Controls.Add(this.label4);
  372. this.groupBox2.Controls.Add(this.numericUpDown1);
  373. this.groupBox2.Controls.Add(this.label1);
  374. this.groupBox2.Controls.Add(this.numericUpDown2);
  375. this.groupBox2.Controls.Add(this.label3);
  376. this.groupBox2.Controls.Add(this.comboBox1);
  377. this.groupBox2.Controls.Add(this.textBox1);
  378. this.groupBox2.Controls.Add(this.panel2);
  379. this.groupBox2.Controls.Add(this.label7);
  380. this.groupBox2.Controls.Add(this.label2);
  381. this.groupBox2.Controls.Add(this.label24);
  382. this.groupBox2.Location = new System.Drawing.Point(193, 72);
  383. this.groupBox2.Name = "groupBox2";
  384. this.groupBox2.Size = new System.Drawing.Size(319, 177);
  385. this.groupBox2.TabIndex = 1;
  386. this.groupBox2.TabStop = false;
  387. //
  388. // numericUpDown5
  389. //
  390. this.numericUpDown5.Location = new System.Drawing.Point(90, 116);
  391. this.numericUpDown5.Maximum = new decimal(new int[] {
  392. 10000,
  393. 0,
  394. 0,
  395. 0});
  396. this.numericUpDown5.Name = "numericUpDown5";
  397. this.numericUpDown5.Size = new System.Drawing.Size(67, 21);
  398. this.numericUpDown5.TabIndex = 37;
  399. this.numericUpDown5.Value = new decimal(new int[] {
  400. 1,
  401. 0,
  402. 0,
  403. 0});
  404. this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
  405. //
  406. // numericUpDown4
  407. //
  408. this.numericUpDown4.Location = new System.Drawing.Point(90, 116);
  409. this.numericUpDown4.Maximum = new decimal(new int[] {
  410. 10000,
  411. 0,
  412. 0,
  413. 0});
  414. this.numericUpDown4.Name = "numericUpDown4";
  415. this.numericUpDown4.Size = new System.Drawing.Size(67, 21);
  416. this.numericUpDown4.TabIndex = 35;
  417. this.numericUpDown4.Value = new decimal(new int[] {
  418. 1,
  419. 0,
  420. 0,
  421. 0});
  422. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  423. //
  424. // label6
  425. //
  426. this.label6.AutoSize = true;
  427. this.label6.Location = new System.Drawing.Point(19, 120);
  428. this.label6.Name = "label6";
  429. this.label6.Size = new System.Drawing.Size(0, 12);
  430. this.label6.TabIndex = 36;
  431. //
  432. // label5
  433. //
  434. this.label5.AutoSize = true;
  435. this.label5.Location = new System.Drawing.Point(19, 120);
  436. this.label5.Name = "label5";
  437. this.label5.Size = new System.Drawing.Size(0, 12);
  438. this.label5.TabIndex = 34;
  439. //
  440. // numericUpDown3
  441. //
  442. this.numericUpDown3.Location = new System.Drawing.Point(229, 85);
  443. this.numericUpDown3.Maximum = new decimal(new int[] {
  444. 10000,
  445. 0,
  446. 0,
  447. 0});
  448. this.numericUpDown3.Name = "numericUpDown3";
  449. this.numericUpDown3.Size = new System.Drawing.Size(67, 21);
  450. this.numericUpDown3.TabIndex = 33;
  451. this.numericUpDown3.Value = new decimal(new int[] {
  452. 1,
  453. 0,
  454. 0,
  455. 0});
  456. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  457. //
  458. // label4
  459. //
  460. this.label4.AutoSize = true;
  461. this.label4.Location = new System.Drawing.Point(158, 88);
  462. this.label4.Name = "label4";
  463. this.label4.Size = new System.Drawing.Size(0, 12);
  464. this.label4.TabIndex = 32;
  465. //
  466. // numericUpDown1
  467. //
  468. this.numericUpDown1.Location = new System.Drawing.Point(90, 85);
  469. this.numericUpDown1.Maximum = new decimal(new int[] {
  470. 10000,
  471. 0,
  472. 0,
  473. 0});
  474. this.numericUpDown1.Name = "numericUpDown1";
  475. this.numericUpDown1.Size = new System.Drawing.Size(67, 21);
  476. this.numericUpDown1.TabIndex = 31;
  477. this.numericUpDown1.Value = new decimal(new int[] {
  478. 1,
  479. 0,
  480. 0,
  481. 0});
  482. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  483. //
  484. // label1
  485. //
  486. this.label1.AutoSize = true;
  487. this.label1.Location = new System.Drawing.Point(19, 88);
  488. this.label1.Name = "label1";
  489. this.label1.Size = new System.Drawing.Size(0, 12);
  490. this.label1.TabIndex = 30;
  491. //
  492. // numericUpDown2
  493. //
  494. this.numericUpDown2.Location = new System.Drawing.Point(90, 146);
  495. this.numericUpDown2.Maximum = new decimal(new int[] {
  496. 10000,
  497. 0,
  498. 0,
  499. 0});
  500. this.numericUpDown2.Name = "numericUpDown2";
  501. this.numericUpDown2.Size = new System.Drawing.Size(67, 21);
  502. this.numericUpDown2.TabIndex = 14;
  503. this.numericUpDown2.Value = new decimal(new int[] {
  504. 1,
  505. 0,
  506. 0,
  507. 0});
  508. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  509. //
  510. // label3
  511. //
  512. this.label3.AutoSize = true;
  513. this.label3.Location = new System.Drawing.Point(19, 150);
  514. this.label3.Name = "label3";
  515. this.label3.Size = new System.Drawing.Size(0, 12);
  516. this.label3.TabIndex = 2;
  517. //
  518. // comboBox1
  519. //
  520. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  521. this.comboBox1.FormattingEnabled = true;
  522. this.comboBox1.Location = new System.Drawing.Point(55, 49);
  523. this.comboBox1.Name = "comboBox1";
  524. this.comboBox1.Size = new System.Drawing.Size(241, 20);
  525. this.comboBox1.TabIndex = 20;
  526. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged_1);
  527. //
  528. // textBox1
  529. //
  530. this.textBox1.Location = new System.Drawing.Point(55, 17);
  531. this.textBox1.Name = "textBox1";
  532. this.textBox1.Size = new System.Drawing.Size(241, 21);
  533. this.textBox1.TabIndex = 19;
  534. //
  535. // panel2
  536. //
  537. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  538. this.panel2.Location = new System.Drawing.Point(229, 116);
  539. this.panel2.Name = "panel2";
  540. this.panel2.Size = new System.Drawing.Size(67, 21);
  541. this.panel2.TabIndex = 12;
  542. this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
  543. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  544. //
  545. // label7
  546. //
  547. this.label7.AutoSize = true;
  548. this.label7.Location = new System.Drawing.Point(19, 23);
  549. this.label7.Name = "label7";
  550. this.label7.Size = new System.Drawing.Size(0, 12);
  551. this.label7.TabIndex = 18;
  552. //
  553. // label2
  554. //
  555. this.label2.AutoSize = true;
  556. this.label2.Location = new System.Drawing.Point(160, 120);
  557. this.label2.Name = "label2";
  558. this.label2.Size = new System.Drawing.Size(0, 12);
  559. this.label2.TabIndex = 1;
  560. //
  561. // label24
  562. //
  563. this.label24.AutoSize = true;
  564. this.label24.Location = new System.Drawing.Point(19, 52);
  565. this.label24.Name = "label24";
  566. this.label24.Size = new System.Drawing.Size(0, 12);
  567. this.label24.TabIndex = 29;
  568. //
  569. // groupBox3
  570. //
  571. this.groupBox3.Controls.Add(this.panel1);
  572. this.groupBox3.Location = new System.Drawing.Point(193, 255);
  573. this.groupBox3.Name = "groupBox3";
  574. this.groupBox3.Size = new System.Drawing.Size(319, 213);
  575. this.groupBox3.TabIndex = 1;
  576. this.groupBox3.TabStop = false;
  577. //
  578. // panel1
  579. //
  580. this.panel1.Location = new System.Drawing.Point(6, 17);
  581. this.panel1.Name = "panel1";
  582. this.panel1.Size = new System.Drawing.Size(307, 190);
  583. this.panel1.TabIndex = 0;
  584. this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
  585. //
  586. // groupBox4
  587. //
  588. this.groupBox4.Controls.Add(this.dataGridView1);
  589. this.groupBox4.Controls.Add(this.button5);
  590. this.groupBox4.Controls.Add(this.button4);
  591. this.groupBox4.Controls.Add(this.button3);
  592. this.groupBox4.Location = new System.Drawing.Point(12, 72);
  593. this.groupBox4.Name = "groupBox4";
  594. this.groupBox4.Size = new System.Drawing.Size(175, 396);
  595. this.groupBox4.TabIndex = 2;
  596. this.groupBox4.TabStop = false;
  597. //
  598. // dataGridView1
  599. //
  600. this.dataGridView1.AllowUserToAddRows = false;
  601. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  602. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
  603. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  604. this.dataGridView1.ColumnHeadersVisible = false;
  605. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  606. this.GuideName});
  607. this.dataGridView1.Location = new System.Drawing.Point(6, 53);
  608. this.dataGridView1.MultiSelect = false;
  609. this.dataGridView1.Name = "dataGridView1";
  610. this.dataGridView1.RowHeadersVisible = false;
  611. this.dataGridView1.RowTemplate.Height = 23;
  612. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  613. this.dataGridView1.Size = new System.Drawing.Size(162, 337);
  614. this.dataGridView1.TabIndex = 4;
  615. this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
  616. //
  617. // GuideName
  618. //
  619. this.GuideName.HeaderText = "";
  620. this.GuideName.Name = "GuideName";
  621. //
  622. // button5
  623. //
  624. this.button5.Location = new System.Drawing.Point(138, 18);
  625. this.button5.Name = "button5";
  626. this.button5.Size = new System.Drawing.Size(30, 25);
  627. this.button5.TabIndex = 3;
  628. this.button5.UseVisualStyleBackColor = true;
  629. this.button5.Click += new System.EventHandler(this.button5_Click);
  630. //
  631. // button4
  632. //
  633. this.button4.Location = new System.Drawing.Point(104, 18);
  634. this.button4.Name = "button4";
  635. this.button4.Size = new System.Drawing.Size(30, 25);
  636. this.button4.TabIndex = 2;
  637. this.button4.UseVisualStyleBackColor = true;
  638. this.button4.Click += new System.EventHandler(this.button4_Click);
  639. //
  640. // button3
  641. //
  642. this.button3.Location = new System.Drawing.Point(70, 18);
  643. this.button3.Name = "button3";
  644. this.button3.Size = new System.Drawing.Size(30, 25);
  645. this.button3.TabIndex = 1;
  646. this.button3.UseVisualStyleBackColor = true;
  647. this.button3.Click += new System.EventHandler(this.button3_Click);
  648. //
  649. // ArbitrationLawGuideDialog
  650. //
  651. this.ClientSize = new System.Drawing.Size(521, 473);
  652. this.Controls.Add(this.groupBox4);
  653. this.Controls.Add(this.groupBox3);
  654. this.Controls.Add(this.groupBox2);
  655. this.Controls.Add(this.groupBox1);
  656. this.MaximizeBox = false;
  657. this.MaximumSize = new System.Drawing.Size(537, 512);
  658. this.MinimizeBox = false;
  659. this.MinimumSize = new System.Drawing.Size(537, 512);
  660. this.Name = "ArbitrationLawGuideDialog";
  661. this.ShowInTaskbar = false;
  662. this.groupBox1.ResumeLayout(false);
  663. this.groupBox2.ResumeLayout(false);
  664. this.groupBox2.PerformLayout();
  665. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
  666. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  667. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  668. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  669. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  670. this.groupBox3.ResumeLayout(false);
  671. this.groupBox4.ResumeLayout(false);
  672. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  673. this.ResumeLayout(false);
  674. }
  675. #endregion
  676. /// <summary>
  677. /// 初始化数据
  678. /// </summary>
  679. private void InitializeData()
  680. {
  681. this.comboBox1.SelectedIndex = 0;
  682. this.groupBox2.Enabled = false;
  683. this.dataGridView1.ReadOnly = true;
  684. GrainSizeArbitrationLawModel grainSizeArbitrationLawModel = XmlSerializeHelper.DESerializer<GrainSizeArbitrationLawModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml", FileMode.Open));
  685. if (grainSizeArbitrationLawModel.GridStyleList != null)
  686. {
  687. foreach (var GridStyle in grainSizeArbitrationLawModel.GridStyleList)
  688. {
  689. index++;
  690. DataGridViewRow row = new DataGridViewRow();
  691. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  692. {
  693. row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  694. }
  695. row.Cells[0].Value = GridStyle.gridName;
  696. this.dataGridView1.Rows.Add(row);
  697. ArrayList arrayList = new ArrayList();
  698. arrayList.Add(GridStyle.gridName);
  699. arrayList.Add(GridStyle.hNumber);
  700. arrayList.Add(GridStyle.vNumber);
  701. arrayList.Add(GridStyle.gridWidth);
  702. arrayList.Add(GridStyle.gridSpacing);
  703. arrayList.Add(GridStyle.gridColor);
  704. arrayList.Add(GridStyle.wholePicture);
  705. arrayList.Add(GridStyle.blank);
  706. this.arrayLists.Add(arrayList);
  707. }
  708. }
  709. }
  710. /// <summary>
  711. /// 保存到配置文件
  712. /// </summary>
  713. private void SaveXmlFile()
  714. {
  715. GrainSizeArbitrationLawModel grainSizeArbitrationLawModel = new GrainSizeArbitrationLawModel();
  716. grainSizeArbitrationLawModel.GridStyleList = new List<GrainSizeArbitrationLawModel.GridStyle>();
  717. if(this.arrayLists.Count == 0)
  718. {
  719. //以下保存xml文件信息
  720. string stageModelXml = XmlSerializeHelper.XmlSerialize<GrainSizeArbitrationLawModel>(grainSizeArbitrationLawModel);
  721. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml";
  722. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  723. }
  724. foreach (ArrayList arrayList1 in this.arrayLists)
  725. {
  726. GrainSizeArbitrationLawModel.GridStyle gridStyle = new GrainSizeArbitrationLawModel.GridStyle();
  727. gridStyle.gridName = arrayList1[0].ToString();
  728. gridStyle.hNumber = Convert.ToInt32(arrayList1[1]);
  729. gridStyle.vNumber = Convert.ToInt32(arrayList1[2]);
  730. gridStyle.gridWidth = Convert.ToInt32(arrayList1[3]);
  731. gridStyle.gridSpacing = Convert.ToInt32(arrayList1[4]);
  732. gridStyle.gridColor = Convert.ToInt32(arrayList1[5]);
  733. gridStyle.wholePicture = Convert.ToBoolean(arrayList1[6]);
  734. gridStyle.blank = Convert.ToInt32(arrayList1[7]);
  735. grainSizeArbitrationLawModel.GridStyleList.Add(gridStyle);
  736. //以下保存xml文件信息
  737. string stageModelXml = XmlSerializeHelper.XmlSerialize<GrainSizeArbitrationLawModel>(grainSizeArbitrationLawModel);
  738. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeArbitrationLawModel.xml";
  739. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  740. }
  741. }
  742. /// <summary>
  743. /// 页面关闭
  744. /// </summary>
  745. /// <param name="sender"></param>
  746. /// <param name="e"></param>
  747. private void button1_Click(object sender, EventArgs e)
  748. {
  749. this.Close();
  750. }
  751. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  752. {
  753. }
  754. private void panel2_Click(object sender, EventArgs e)
  755. {
  756. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  757. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  758. this.colorsForm.ShowDialog();
  759. }
  760. private void panel2Changed(object sender, EventArgs e)
  761. {
  762. this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  763. this.colorsForm.Close();
  764. }
  765. private void InitGroupbox2()
  766. {
  767. this.textBox1.Clear();
  768. this.comboBox1.SelectedIndex = 0;
  769. this.numericUpDown1.Value = 0;
  770. this.numericUpDown2.Value = 0;
  771. this.numericUpDown3.Value = 0;
  772. this.numericUpDown4.Value = 0;
  773. this.numericUpDown5.Value = 0;
  774. }
  775. /// <summary>
  776. /// 返回维护的辅助线
  777. /// </summary>
  778. private void ReturnGrainSize()
  779. {
  780. ArrayList arrayList = new ArrayList();
  781. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  782. {
  783. arrayList.Add(this.dataGridView1.Rows[i].Cells[0].Value);
  784. }
  785. GrainSizeArbitrationLawDialog grainSizeArbitrationLawDialog = (GrainSizeArbitrationLawDialog)this.Owner;
  786. grainSizeArbitrationLawDialog.comboboxChange = false;
  787. grainSizeArbitrationLawDialog.InitComboboxValue(arrayList);
  788. }
  789. /// <summary>
  790. /// 保存按钮
  791. /// </summary>
  792. /// <param name="sender"></param>
  793. /// <param name="e"></param>
  794. private void button2_Click(object sender, EventArgs e)
  795. {
  796. // 添加
  797. if (this.operation == 0)
  798. {
  799. if (string.IsNullOrEmpty(this.textBox1.Text))
  800. {
  801. MessageBox.Show(PdnResources.GetString("Menu.namecannotbeEmpty.text")+"!");
  802. }
  803. else
  804. {
  805. bool next = true;
  806. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  807. {
  808. if (this.dataGridView1.Rows[r].Cells[0].Value.Equals(this.textBox1.Text))
  809. {
  810. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  811. next = false;
  812. break;
  813. }
  814. }
  815. if (next)
  816. {
  817. ArrayList arrayList = new ArrayList();
  818. arrayList.Add(this.textBox1.Text);
  819. arrayList.Add(Convert.ToInt32(this.numericUpDown1.Value));
  820. arrayList.Add(Convert.ToInt32(this.numericUpDown3.Value));
  821. arrayList.Add(Convert.ToInt32(this.numericUpDown2.Value));
  822. arrayList.Add(Convert.ToInt32(this.numericUpDown4.Value));
  823. arrayList.Add(Convert.ToInt32(this.panel2.BackColor.ToArgb()));
  824. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
  825. arrayList.Add(true);
  826. else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
  827. arrayList.Add(false);
  828. arrayList.Add(Convert.ToInt32(numericUpDown5.Value));
  829. this.arrayLists.Add(arrayList);
  830. DataGridViewRow row = new DataGridViewRow();
  831. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  832. {
  833. row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  834. }
  835. row.Cells[0].Value = this.textBox1.Text;
  836. this.dataGridView1.Rows.Add(row);
  837. SaveXmlFile();
  838. MessageBox.Show(PdnResources.GetString("Menu.Addsuccessfully.text")+"!");
  839. operation = -1;
  840. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Selected = true;
  841. }
  842. }
  843. }
  844. // 编辑
  845. else if (this.operation == 1)
  846. {
  847. if (string.IsNullOrEmpty(this.textBox1.Text))
  848. {
  849. MessageBox.Show(PdnResources.GetString("Menu.namecannotbeEmpty.text")+"!");
  850. }
  851. else
  852. {
  853. bool next = true;
  854. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  855. {
  856. if (this.dataGridView1.Rows[r].Cells[0].Value.Equals(this.textBox1.Text) && this.dataGridView1.SelectedRows[0].Index != r)
  857. {
  858. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  859. next = false;
  860. break;
  861. }
  862. }
  863. if (next)
  864. {
  865. int updIndex = 0;
  866. foreach (var arrayList1 in this.arrayLists)
  867. {
  868. if (arrayList1[0].ToString().Equals(this.dataGridView1.SelectedRows[0].Cells[0].Value))
  869. {
  870. updIndex = Convert.ToInt32(arrayList1[arrayList1.Count - 1]);
  871. this.arrayLists.Remove(arrayList1);
  872. break;
  873. }
  874. }
  875. ArrayList arrayList = new ArrayList();
  876. arrayList.Add(this.textBox1.Text);
  877. arrayList.Add(Convert.ToInt32(this.numericUpDown1.Value));
  878. arrayList.Add(Convert.ToInt32(this.numericUpDown3.Value));
  879. arrayList.Add(Convert.ToInt32(this.numericUpDown2.Value));
  880. arrayList.Add(Convert.ToInt32(this.numericUpDown4.Value));
  881. arrayList.Add(Convert.ToInt32(this.panel2.BackColor.ToArgb()));
  882. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
  883. arrayList.Add(true);
  884. else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
  885. arrayList.Add(false);
  886. arrayList.Add(Convert.ToInt32(numericUpDown5.Value));
  887. this.arrayLists.Add(arrayList);
  888. this.dataGridView1.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
  889. SaveXmlFile();
  890. MessageBox.Show(PdnResources.GetString("Menu.Editsuccessfully.text")+"!");
  891. operation = -1;
  892. this.groupBox2.Enabled = false;
  893. }
  894. }
  895. }
  896. ReturnGrainSize();
  897. }
  898. /// <summary>
  899. /// 辅助线样式预览
  900. /// </summary>
  901. /// <param name="sender"></param>
  902. /// <param name="e"></param>
  903. private void panel1_Paint(object sender, PaintEventArgs e)
  904. {
  905. Draw(e.Graphics);
  906. }
  907. /// <summary>
  908. /// 辅助线样式预览是(面积法)
  909. /// </summary>
  910. private void Draw(Graphics g)
  911. {
  912. Pen linePen = new Pen(this.panel2.BackColor,Convert.ToInt32(this.numericUpDown2.Value));
  913. float hGridSpacingDraw;
  914. float vGridSpacingDraw;
  915. float blankDraw;
  916. bool wholePicture;
  917. int hNumber = Convert.ToInt32(this.numericUpDown1.Value) + 1;
  918. int vNumber = Convert.ToInt32(this.numericUpDown3.Value) + 1;
  919. float minX = this.panel1.Width / 2 - (vNumber - 1) * 10;
  920. float maxX = this.panel1.Width / 2 + (vNumber - 1) * 10;
  921. float minY = this.panel1.Height / 2 - (hNumber - 1) * 10;
  922. float maxY = this.panel1.Height / 2 + (hNumber - 1) * 10;
  923. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
  924. wholePicture = true;
  925. else
  926. wholePicture = false;
  927. if (wholePicture)
  928. {
  929. hGridSpacingDraw = (float)this.panel1.Height / Convert.ToInt32(this.numericUpDown1.Value);
  930. vGridSpacingDraw = (float)this.panel1.Width / Convert.ToInt32(this.numericUpDown3.Value);
  931. blankDraw = 0;
  932. }
  933. else
  934. {
  935. blankDraw = 0;
  936. hGridSpacingDraw = 20;
  937. vGridSpacingDraw = 20;
  938. }
  939. if (hNumber > 0)
  940. {
  941. if (hNumber % 2 == 0)
  942. {
  943. float Spacing = hGridSpacingDraw / 2;
  944. for (int i = 0; i < (float)hNumber / 2; i++)
  945. {
  946. if (wholePicture)
  947. {
  948. if ((float)this.panel1.Height / 2 - Spacing >= blankDraw)
  949. {
  950. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 - Spacing)
  951. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 - Spacing));
  952. }
  953. if ((float)this.panel1.Height / 2 + Spacing <= this.panel1.Height - blankDraw)
  954. {
  955. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 + Spacing)
  956. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 + Spacing));
  957. }
  958. }
  959. else
  960. {
  961. if ((float)this.panel1.Height / 2 - Spacing >= 0)
  962. {
  963. g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 - Spacing)
  964. , new PointF(maxX, (float)this.panel1.Height / 2 - Spacing));
  965. }
  966. if ((float)this.panel1.Height / 2 + Spacing <= this.panel1.Height)
  967. {
  968. g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 + Spacing)
  969. , new PointF(maxX, (float)this.panel1.Height / 2 + Spacing));
  970. }
  971. }
  972. Spacing += hGridSpacingDraw;
  973. }
  974. }
  975. else
  976. {
  977. if ((float)this.panel1.Width > 2 * blankDraw)
  978. {
  979. if (hNumber == 1)
  980. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2)
  981. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2));
  982. else
  983. {
  984. float Spacing = hGridSpacingDraw;
  985. for (int i = 0; i < (hNumber - 1) / 2; i++)
  986. {
  987. if (wholePicture)
  988. {
  989. if (i == 0)
  990. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2)
  991. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2));
  992. if (this.panel1.Height / 2 - Spacing >= blankDraw)
  993. {
  994. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 - Spacing)
  995. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 - Spacing));
  996. }
  997. if (this.panel1.Height / 2 + Spacing <= this.panel1.Height - blankDraw)
  998. {
  999. g.DrawLine(linePen, new PointF(blankDraw, (float)this.panel1.Height / 2 + Spacing)
  1000. , new PointF((float)(this.panel1.Width - blankDraw), (float)this.panel1.Height / 2 + Spacing));
  1001. }
  1002. }
  1003. else
  1004. {
  1005. if (i == 0)
  1006. g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2)
  1007. , new PointF(maxX, (float)this.panel1.Height / 2));
  1008. if (this.panel1.Height / 2 - Spacing >= 0)
  1009. {
  1010. g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 - Spacing)
  1011. , new PointF(maxX, (float)this.panel1.Height / 2 - Spacing));
  1012. }
  1013. if (this.panel1.Height / 2 + Spacing <= this.panel1.Height)
  1014. {
  1015. g.DrawLine(linePen, new PointF(minX, (float)this.panel1.Height / 2 + Spacing)
  1016. , new PointF(maxX, (float)this.panel1.Height / 2 + Spacing));
  1017. }
  1018. }
  1019. Spacing += hGridSpacingDraw;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }
  1025. if (vNumber > 0)
  1026. {
  1027. if (vNumber % 2 == 0)
  1028. {
  1029. float Spacing = vGridSpacingDraw / 2;
  1030. for (int i = 0; i < (float)vNumber / 2; i++)
  1031. {
  1032. if (wholePicture)
  1033. {
  1034. if ((float)this.panel1.Width / 2 - Spacing >= 0
  1035. && (float)this.panel1.Width / 2 - Spacing >= blankDraw)
  1036. {
  1037. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, blankDraw)
  1038. , new PointF((float)this.panel1.Width / 2 - Spacing, (float)(this.panel1.Height - blankDraw)));
  1039. }
  1040. if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width
  1041. && (float)this.panel1.Width / 2 + Spacing <= this.panel1.Width - blankDraw)
  1042. {
  1043. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, blankDraw)
  1044. , new PointF((float)this.panel1.Width / 2 + Spacing, (float)(this.panel1.Height - blankDraw)));
  1045. }
  1046. }
  1047. else
  1048. {
  1049. if ((float)this.panel1.Width / 2 - Spacing >= 0)
  1050. {
  1051. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, minY)
  1052. , new PointF((float)this.panel1.Width / 2 - Spacing, maxY));
  1053. }
  1054. if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width)
  1055. {
  1056. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, minY)
  1057. , new PointF((float)this.panel1.Width / 2 + Spacing, maxY));
  1058. }
  1059. }
  1060. Spacing += vGridSpacingDraw;
  1061. }
  1062. }
  1063. else
  1064. {
  1065. if (this.panel1.Height > 2 * blankDraw)
  1066. {
  1067. if (vNumber == 1)
  1068. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, blankDraw)
  1069. , new PointF((float)this.panel1.Width / 2, (float)(this.panel1.Height - blankDraw)));
  1070. else
  1071. {
  1072. float Spacing = vGridSpacingDraw;
  1073. for (int i = 0; i < (vNumber - 1) / 2; i++)
  1074. {
  1075. if (wholePicture)
  1076. {
  1077. if (i == 0)
  1078. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, blankDraw)
  1079. , new PointF((float)this.panel1.Width / 2, (float)(this.panel1.Height - blankDraw)));
  1080. if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width
  1081. && this.panel1.Width / 2 + Spacing <= this.panel1.Width - blankDraw)
  1082. {
  1083. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, blankDraw)
  1084. , new PointF((float)this.panel1.Width / 2 + Spacing, (float)(this.panel1.Height - blankDraw)));
  1085. }
  1086. if ((float)this.panel1.Width / 2 - Spacing >= 0 && (float)this.panel1.Width / 2 - Spacing >= blankDraw)
  1087. {
  1088. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, blankDraw)
  1089. , new PointF((float)this.panel1.Width / 2 - Spacing, (float)(this.panel1.Height - blankDraw)));
  1090. }
  1091. }
  1092. else
  1093. {
  1094. if (i == 0)
  1095. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2, minY)
  1096. , new PointF((float)this.panel1.Width / 2, maxY));
  1097. if ((float)this.panel1.Width / 2 + Spacing <= this.panel1.Width)
  1098. {
  1099. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 + Spacing, minY)
  1100. , new PointF((float)this.panel1.Width / 2 + Spacing, maxY));
  1101. }
  1102. if ((float)this.panel1.Width / 2 - Spacing >= 0)
  1103. {
  1104. g.DrawLine(linePen, new PointF((float)this.panel1.Width / 2 - Spacing, minY)
  1105. , new PointF((float)this.panel1.Width / 2 - Spacing, maxY));
  1106. }
  1107. }
  1108. Spacing += vGridSpacingDraw;
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. }
  1115. /// <summary>
  1116. /// 线颜色改变
  1117. /// </summary>
  1118. /// <param name="sender"></param>
  1119. /// <param name="e"></param>
  1120. private void panel2_BackColorChanged(object sender, EventArgs e)
  1121. {
  1122. this.panel1.Refresh();
  1123. }
  1124. /// <summary>
  1125. /// 切换辅助线类型
  1126. /// </summary>
  1127. /// <param name="sender"></param>
  1128. /// <param name="e"></param>
  1129. private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
  1130. {
  1131. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text").Equals(this.comboBox1.SelectedItem))
  1132. {
  1133. this.label6.Visible = true;
  1134. this.numericUpDown5.Visible = true;
  1135. this.label5.Visible = false;
  1136. this.numericUpDown4.Visible = false;
  1137. }
  1138. else if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text").Equals(this.comboBox1.SelectedItem))
  1139. {
  1140. this.label6.Visible = false;
  1141. this.numericUpDown5.Visible = false;
  1142. this.label5.Visible = true;
  1143. this.numericUpDown4.Visible = true;
  1144. }
  1145. this.panel1.Refresh();
  1146. }
  1147. /// <summary>
  1148. /// 添加辅助线
  1149. /// </summary>
  1150. /// <param name="sender"></param>
  1151. /// <param name="e"></param>
  1152. private void button3_Click(object sender, EventArgs e)
  1153. {
  1154. // 添加
  1155. this.textBox1.Focus();
  1156. this.dataGridView1.ClearSelection();
  1157. operation = 0;
  1158. this.groupBox2.Enabled = true;
  1159. InitGroupbox2();
  1160. }
  1161. /// <summary>
  1162. /// 编辑辅助线
  1163. /// </summary>
  1164. /// <param name="sender"></param>
  1165. /// <param name="e"></param>
  1166. private void button4_Click(object sender, EventArgs e)
  1167. {
  1168. if(this.dataGridView1.Rows.Count > 0)
  1169. {
  1170. if(this.dataGridView1.SelectedRows.Count > 0)
  1171. {
  1172. // 编辑
  1173. operation = 1;
  1174. this.groupBox2.Enabled = true;
  1175. }
  1176. else
  1177. {
  1178. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylinetoedit.text")+"!");
  1179. }
  1180. }
  1181. else
  1182. {
  1183. MessageBox.Show(PdnResources.GetString("Menu.Pleaseaddauxiliarylines.text")+"!");
  1184. }
  1185. }
  1186. /// <summary>
  1187. /// 切换辅助线
  1188. /// </summary>
  1189. /// <param name="sender"></param>
  1190. /// <param name="e"></param>
  1191. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  1192. {
  1193. this.groupBox2.Enabled = false;
  1194. if (this.dataGridView1.SelectedRows.Count > 0)
  1195. {
  1196. ArrayList arrayList1 = new ArrayList();
  1197. foreach (var arrayList in this.arrayLists)
  1198. {
  1199. if (this.dataGridView1.SelectedRows[0].Cells[0].Value.Equals(arrayList[0]))
  1200. arrayList1 = arrayList;
  1201. }
  1202. this.textBox1.Text = arrayList1[0].ToString();
  1203. if (Convert.ToBoolean(arrayList1[6]))
  1204. this.comboBox1.SelectedItem = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thefullgrid.text");
  1205. else
  1206. this.comboBox1.SelectedItem = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Non-fullimagegrid.text");
  1207. this.numericUpDown1.Value = Convert.ToInt32(arrayList1[1]);
  1208. this.numericUpDown3.Value = Convert.ToInt32(arrayList1[2]);
  1209. this.numericUpDown2.Value = Convert.ToInt32(arrayList1[3]);
  1210. this.numericUpDown4.Value = Convert.ToInt32(arrayList1[4]);
  1211. this.numericUpDown5.Value = Convert.ToInt32(arrayList1[7]);
  1212. this.panel2.BackColor = Color.FromArgb(Convert.ToInt32(arrayList1[5]));
  1213. this.panel1.Refresh();
  1214. }
  1215. }
  1216. /// <summary>
  1217. /// 删除辅助线
  1218. /// </summary>
  1219. /// <param name="sender"></param>
  1220. /// <param name="e"></param>
  1221. private void button5_Click(object sender, EventArgs e)
  1222. {
  1223. if(this.dataGridView1.SelectedRows.Count > 0)
  1224. {
  1225. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletetheauxiliaryline?.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1226. if (dr == DialogResult.OK)
  1227. {
  1228. foreach (var arrayList in this.arrayLists)
  1229. {
  1230. if (this.dataGridView1.SelectedRows[0].Cells[0].Value.Equals(arrayList[0]))
  1231. {
  1232. this.arrayLists.Remove(arrayList);
  1233. break;
  1234. }
  1235. }
  1236. SaveXmlFile();
  1237. this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]);
  1238. if (this.dataGridView1.Rows.Count == 0)
  1239. InitGroupbox2();
  1240. ReturnGrainSize();
  1241. }
  1242. this.panel1.Refresh();
  1243. }
  1244. else
  1245. {
  1246. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylinetodelete.text")+"!");
  1247. }
  1248. }
  1249. /// <summary>
  1250. /// 间距
  1251. /// </summary>
  1252. /// <param name="sender"></param>
  1253. /// <param name="e"></param>
  1254. private void numericUpDown21_ValueChanged(object sender, EventArgs e)
  1255. {
  1256. this.panel1.Refresh();
  1257. }
  1258. /// <summary>
  1259. /// 线条数
  1260. /// </summary>
  1261. /// <param name="sender"></param>
  1262. /// <param name="e"></param>
  1263. private void numericUpDown20_ValueChanged(object sender, EventArgs e)
  1264. {
  1265. this.panel1.Refresh();
  1266. }
  1267. /// <summary>
  1268. /// 间距
  1269. /// </summary>
  1270. /// <param name="sender"></param>
  1271. /// <param name="e"></param>
  1272. private void numericUpDown17_ValueChanged(object sender, EventArgs e)
  1273. {
  1274. this.panel1.Refresh();
  1275. }
  1276. /// <summary>
  1277. /// 线条数
  1278. /// </summary>
  1279. /// <param name="sender"></param>
  1280. /// <param name="e"></param>
  1281. private void numericUpDown19_ValueChanged(object sender, EventArgs e)
  1282. {
  1283. this.panel1.Refresh();
  1284. }
  1285. int hOldValue;
  1286. int vOldValue;
  1287. int sOldValue;
  1288. int bOldValue;
  1289. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1290. {
  1291. RefreshGridIntersections();
  1292. if (this.exceed)
  1293. this.numericUpDown1.Value = this.hOldValue;
  1294. this.hOldValue = Convert.ToInt32(this.numericUpDown1.Value);
  1295. this.panel1.Refresh();
  1296. }
  1297. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  1298. {
  1299. RefreshGridIntersections();
  1300. if (this.exceed)
  1301. this.numericUpDown3.Value = this.vOldValue;
  1302. this.vOldValue = Convert.ToInt32(this.numericUpDown3.Value);
  1303. this.panel1.Refresh();
  1304. }
  1305. private void numericUpDown5_ValueChanged(object sender, EventArgs e)
  1306. {
  1307. RefreshGridIntersections();
  1308. if (this.exceed)
  1309. this.numericUpDown5.Value = this.bOldValue;
  1310. this.bOldValue = Convert.ToInt32(this.numericUpDown5.Value);
  1311. this.panel1.Refresh();
  1312. }
  1313. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  1314. {
  1315. RefreshGridIntersections();
  1316. if (this.exceed)
  1317. this.numericUpDown4.Value = this.sOldValue;
  1318. this.sOldValue = Convert.ToInt32(this.numericUpDown4.Value);
  1319. this.panel1.Refresh();
  1320. }
  1321. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  1322. {
  1323. this.panel1.Refresh();
  1324. }
  1325. }
  1326. }