PointDataDialog.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using PaintDotNet.DbOpreate.DbBll;
  2. using PaintDotNet.DbOpreate.DbModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace PaintDotNet.Setting
  13. {
  14. /// <summary>
  15. /// 新增/编辑点距
  16. /// </summary>
  17. public partial class PointDataDialog : PdnBaseForm
  18. {
  19. private string pointId = string.Empty;
  20. private ListView fatherListView;
  21. private int listIndex = 0;
  22. public PointDataDialog(string id, ListView listView,int index = 0)
  23. {
  24. StartPosition = FormStartPosition.CenterScreen;
  25. InitializeComponent();
  26. InitializeLanguageText();
  27. #region [展示控件]
  28. pointId = id;
  29. fatherListView = listView;
  30. listIndex = index;
  31. if (!string.IsNullOrEmpty(pointId))
  32. {
  33. var point = mic_screen_rules_BLL.FindDefault(Convert.ToInt32(pointId));
  34. if (point == null)
  35. {
  36. MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
  37. }
  38. textBox1.MaxLength = 10;
  39. textBox2.MaxLength = 10;
  40. textBox3.MaxLength = 10;
  41. textBox4.MaxLength = 10;
  42. textBox5.MaxLength = 10;
  43. textBox1.Text = point.size;
  44. textBox4.Text = point.point_pitch;
  45. textBox5.Text = point.screen_width;
  46. string[] ls = point.max_resolution.Split('×');
  47. textBox2.Text = ls[0];
  48. textBox3.Text = ls[1];
  49. }
  50. #endregion
  51. }
  52. #region [控件相关]
  53. private TextBox textBox1;
  54. private Label label13;
  55. private TextBox textBox2;
  56. private Label label1;
  57. private Label label2;
  58. private TextBox textBox3;
  59. private Label label3;
  60. private TextBox textBox4;
  61. private Label label4;
  62. private TextBox textBox5;
  63. private Label label5;
  64. private Label label6;
  65. private Label label7;
  66. private Button button1;
  67. private Button button2;
  68. private void InitializeLanguageText()
  69. {
  70. label13.Text = PdnResources.GetString("Menu.sizeed.text") + ":";
  71. label1.Text = PdnResources.GetString("Menu.Set.Generalsettings.Maximumresolution.text") + ":";
  72. label3.Text = PdnResources.GetString("Menu.Set.Generalsettings.dotspacing.text") + ":";
  73. label5.Text = PdnResources.GetString("Menu.Set.Generalsettings.Screenwidth.text") + ":";
  74. label6.Text = PdnResources.GetString("Menu.Mm.text");
  75. label7.Text = PdnResources.GetString("Menu.Mm.text");
  76. button1.Text = PdnResources.GetString("Menu.ensure.text");
  77. button2.Text = PdnResources.GetString("Menu.cancel.text");
  78. }
  79. private void InitializeComponent()
  80. {
  81. this.textBox1 = new System.Windows.Forms.TextBox();
  82. this.label13 = new System.Windows.Forms.Label();
  83. this.textBox2 = new System.Windows.Forms.TextBox();
  84. this.label1 = new System.Windows.Forms.Label();
  85. this.label2 = new System.Windows.Forms.Label();
  86. this.textBox3 = new System.Windows.Forms.TextBox();
  87. this.label3 = new System.Windows.Forms.Label();
  88. this.textBox4 = new System.Windows.Forms.TextBox();
  89. this.label4 = new System.Windows.Forms.Label();
  90. this.textBox5 = new System.Windows.Forms.TextBox();
  91. this.label5 = new System.Windows.Forms.Label();
  92. this.label6 = new System.Windows.Forms.Label();
  93. this.label7 = new System.Windows.Forms.Label();
  94. this.button1 = new System.Windows.Forms.Button();
  95. this.button2 = new System.Windows.Forms.Button();
  96. this.SuspendLayout();
  97. //
  98. // textBox1
  99. //
  100. this.textBox1.Location = new System.Drawing.Point(111, 23);
  101. this.textBox1.Name = "textBox1";
  102. this.textBox1.Size = new System.Drawing.Size(172, 21);
  103. this.textBox1.TabIndex = 4;
  104. //
  105. // label13
  106. //
  107. this.label13.AutoSize = true;
  108. this.label13.Location = new System.Drawing.Point(47, 26);
  109. this.label13.Name = "label13";
  110. this.label13.Size = new System.Drawing.Size(41, 12);
  111. this.label13.TabIndex = 3;
  112. this.label13.Text = "尺寸:";
  113. //
  114. // textBox2
  115. //
  116. this.textBox2.Location = new System.Drawing.Point(111, 73);
  117. this.textBox2.Name = "textBox2";
  118. this.textBox2.Size = new System.Drawing.Size(73, 21);
  119. this.textBox2.TabIndex = 6;
  120. //
  121. // label1
  122. //
  123. this.label1.AutoSize = true;
  124. this.label1.Location = new System.Drawing.Point(11, 73);
  125. this.label1.Name = "label1";
  126. this.label1.Size = new System.Drawing.Size(77, 12);
  127. this.label1.TabIndex = 5;
  128. this.label1.Text = "最大分辨率:";
  129. //
  130. // label2
  131. //
  132. this.label2.AutoSize = true;
  133. this.label2.Location = new System.Drawing.Point(193, 76);
  134. this.label2.Name = "label2";
  135. this.label2.Size = new System.Drawing.Size(11, 12);
  136. this.label2.TabIndex = 7;
  137. this.label2.Text = "*";
  138. //
  139. // textBox3
  140. //
  141. this.textBox3.Location = new System.Drawing.Point(210, 73);
  142. this.textBox3.Name = "textBox3";
  143. this.textBox3.Size = new System.Drawing.Size(73, 21);
  144. this.textBox3.TabIndex = 8;
  145. //
  146. // label3
  147. //
  148. this.label3.AutoSize = true;
  149. this.label3.Location = new System.Drawing.Point(47, 113);
  150. this.label3.Name = "label3";
  151. this.label3.Size = new System.Drawing.Size(41, 12);
  152. this.label3.TabIndex = 9;
  153. this.label3.Text = "点距:";
  154. //
  155. // textBox4
  156. //
  157. this.textBox4.Location = new System.Drawing.Point(111, 113);
  158. this.textBox4.Name = "textBox4";
  159. this.textBox4.Size = new System.Drawing.Size(172, 21);
  160. this.textBox4.TabIndex = 10;
  161. //
  162. // label4
  163. //
  164. this.label4.AutoSize = true;
  165. this.label4.Location = new System.Drawing.Point(284, 76);
  166. this.label4.Name = "label4";
  167. this.label4.Size = new System.Drawing.Size(17, 12);
  168. this.label4.TabIndex = 11;
  169. this.label4.Text = "PX";
  170. //
  171. // textBox5
  172. //
  173. this.textBox5.Location = new System.Drawing.Point(111, 147);
  174. this.textBox5.Name = "textBox5";
  175. this.textBox5.Size = new System.Drawing.Size(172, 21);
  176. this.textBox5.TabIndex = 13;
  177. //
  178. // label5
  179. //
  180. this.label5.AutoSize = true;
  181. this.label5.Location = new System.Drawing.Point(23, 150);
  182. this.label5.Name = "label5";
  183. this.label5.Size = new System.Drawing.Size(65, 12);
  184. this.label5.TabIndex = 12;
  185. this.label5.Text = "屏幕宽度:";
  186. //
  187. // label6
  188. //
  189. this.label6.AutoSize = true;
  190. this.label6.Location = new System.Drawing.Point(285, 116);
  191. this.label6.Name = "label6";
  192. this.label6.Size = new System.Drawing.Size(0, 12);
  193. this.label6.TabIndex = 14;
  194. //
  195. // label7
  196. //
  197. this.label7.AutoSize = true;
  198. this.label7.Location = new System.Drawing.Point(285, 150);
  199. this.label7.Name = "label7";
  200. this.label7.Size = new System.Drawing.Size(0, 12);
  201. this.label7.TabIndex = 15;
  202. //
  203. // button1
  204. //
  205. this.button1.Location = new System.Drawing.Point(113, 209);
  206. this.button1.Name = "button1";
  207. this.button1.Size = new System.Drawing.Size(75, 23);
  208. this.button1.TabIndex = 16;
  209. this.button1.Text = "确定";
  210. this.button1.UseVisualStyleBackColor = true;
  211. this.button1.Click += new System.EventHandler(this.button1_Click);
  212. //
  213. // button2
  214. //
  215. this.button2.Location = new System.Drawing.Point(210, 209);
  216. this.button2.Name = "button2";
  217. this.button2.Size = new System.Drawing.Size(75, 23);
  218. this.button2.TabIndex = 17;
  219. this.button2.Text = "取消";
  220. this.button2.UseVisualStyleBackColor = true;
  221. this.button2.Click += new System.EventHandler(this.button2_Click);
  222. //
  223. // PointDataDialog
  224. //
  225. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  226. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  227. this.ClientSize = new System.Drawing.Size(364, 261);
  228. this.Controls.Add(this.button2);
  229. this.Controls.Add(this.button1);
  230. this.Controls.Add(this.label7);
  231. this.Controls.Add(this.label6);
  232. this.Controls.Add(this.textBox5);
  233. this.Controls.Add(this.label5);
  234. this.Controls.Add(this.label4);
  235. this.Controls.Add(this.textBox4);
  236. this.Controls.Add(this.label3);
  237. this.Controls.Add(this.textBox3);
  238. this.Controls.Add(this.label2);
  239. this.Controls.Add(this.textBox2);
  240. this.Controls.Add(this.label1);
  241. this.Controls.Add(this.textBox1);
  242. this.Controls.Add(this.label13);
  243. this.Name = "PointDataDialog";
  244. this.Text = "新增点距";
  245. this.Controls.SetChildIndex(this.label13, 0);
  246. this.Controls.SetChildIndex(this.textBox1, 0);
  247. this.Controls.SetChildIndex(this.label1, 0);
  248. this.Controls.SetChildIndex(this.textBox2, 0);
  249. this.Controls.SetChildIndex(this.label2, 0);
  250. this.Controls.SetChildIndex(this.textBox3, 0);
  251. this.Controls.SetChildIndex(this.label3, 0);
  252. this.Controls.SetChildIndex(this.textBox4, 0);
  253. this.Controls.SetChildIndex(this.label4, 0);
  254. this.Controls.SetChildIndex(this.label5, 0);
  255. this.Controls.SetChildIndex(this.textBox5, 0);
  256. this.Controls.SetChildIndex(this.label6, 0);
  257. this.Controls.SetChildIndex(this.label7, 0);
  258. this.Controls.SetChildIndex(this.button1, 0);
  259. this.Controls.SetChildIndex(this.button2, 0);
  260. this.ResumeLayout(false);
  261. this.PerformLayout();
  262. }
  263. #endregion
  264. private void button1_Click(object sender, EventArgs e)
  265. {
  266. var id = pointId;
  267. if (string.IsNullOrEmpty(textBox1.Text))
  268. {
  269. MessageBox.Show(PdnResources.GetString("Menu.leaseentersiz.Text"));
  270. return;
  271. }
  272. else if (string.IsNullOrEmpty(textBox2.Text))
  273. {
  274. MessageBox.Show(PdnResources.GetString("Menu.seenterthemaximumres.Text"));
  275. return;
  276. }
  277. else if (string.IsNullOrEmpty(textBox3.Text))
  278. {
  279. MessageBox.Show(PdnResources.GetString("Menu.seenterthemaximumres.Text"));
  280. return;
  281. }
  282. else if (string.IsNullOrEmpty(textBox4.Text))
  283. {
  284. MessageBox.Show(PdnResources.GetString("Menu.aseenterthedotsp.Text"));
  285. return;
  286. }
  287. else if (string.IsNullOrEmpty(textBox5.Text))
  288. {
  289. MessageBox.Show(PdnResources.GetString("Menu.aseenterthescreenwi.Text"));
  290. return;
  291. }
  292. if (string.IsNullOrEmpty(id))
  293. {
  294. var point = new mic_screen_rules();
  295. point.delete_flag = 2;
  296. point.size = textBox1.Text;
  297. point.max_resolution = $"{textBox2.Text}×{textBox3.Text}";
  298. point.point_pitch = textBox4.Text;
  299. point.screen_width = textBox5.Text;
  300. mic_screen_rules_BLL.Add(point);
  301. fatherListView.BeginUpdate();
  302. var lv = new ListViewItem();
  303. lv.Text = "2";
  304. lv.SubItems.Add("×");
  305. lv.SubItems.Add(point.size);
  306. lv.SubItems.Add(point.max_resolution);
  307. lv.SubItems.Add(point.point_pitch);
  308. lv.SubItems.Add(point.screen_width);
  309. lv.SubItems.Add(point.id.ToString());
  310. fatherListView.Items.Add(lv);
  311. fatherListView.EndUpdate();
  312. }
  313. else {
  314. var point = mic_screen_rules_BLL.FindDefault(Convert.ToInt32(pointId));
  315. if (point == null)
  316. {
  317. MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
  318. }
  319. point.size = textBox1.Text;
  320. point.max_resolution = $"{textBox2.Text}×{textBox3.Text}";
  321. point.point_pitch = textBox4.Text;
  322. point.screen_width = textBox5.Text;
  323. mic_screen_rules_BLL.Update(point);
  324. fatherListView.BeginUpdate();
  325. var lv = fatherListView.Items[listIndex];
  326. lv.SubItems[2].Text = point.size;
  327. lv.SubItems[3].Text = point.max_resolution;
  328. lv.SubItems[4].Text = point.point_pitch;
  329. lv.SubItems[5].Text = point.screen_width;
  330. fatherListView.EndUpdate();
  331. }
  332. Close();
  333. }
  334. private void button2_Click(object sender, EventArgs e)
  335. {
  336. Hide();
  337. }
  338. }
  339. }