LabelMarkTimeControl.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Collections;
  11. using PaintDotNet.Base.SettingModel;
  12. namespace PaintDotNet.Setting.LabelComponent
  13. {
  14. /// <summary>
  15. /// 标注设置-标记设置->时间
  16. /// </summary>
  17. public class LabelMarkTimeControl : UserControl
  18. {
  19. #region 控件
  20. private System.Windows.Forms.Label label1;
  21. private System.Windows.Forms.Label label2;
  22. private System.Windows.Forms.Label label3;
  23. private System.Windows.Forms.Label label4;
  24. private System.Windows.Forms.Label label5;
  25. private System.Windows.Forms.Label label6;
  26. private System.Windows.Forms.Label label7;
  27. private System.Windows.Forms.Label label8;
  28. private System.Windows.Forms.Label label9;
  29. private System.Windows.Forms.Label label10;
  30. private System.Windows.Forms.Label label11;
  31. private System.Windows.Forms.ComboBox comboBox1;
  32. private System.Windows.Forms.ComboBox comboBox2;
  33. private System.Windows.Forms.Panel panel1;
  34. private System.Windows.Forms.Panel panel2;
  35. private System.Windows.Forms.Panel panel3;
  36. private NumericUpDown numericUpDown1;
  37. private NumericUpDown numericUpDown2;
  38. private NumericUpDown numericUpDown3;
  39. private NumericUpDown numericUpDown4;
  40. #endregion
  41. /// <summary>
  42. /// 时间样式
  43. /// </summary>
  44. private LabelStyleModel.TimeMark model;
  45. PaintDotNet.ColorsForm colorsForm1;
  46. PaintDotNet.ColorsForm colorsForm2;
  47. PaintDotNet.ColorsForm colorsForm3;
  48. ///// <summary>
  49. ///// 位置下拉选
  50. ///// </summary>
  51. //string[] position = new string[] { PdnResources.GetString("Menu.Upperleft.text")
  52. // , PdnResources.GetString("Menu.Upperright.text")
  53. // , PdnResources.GetString("Menu.Lowerleft.text")
  54. // , PdnResources.GetString("Menu.Lowerright.text")
  55. // };
  56. /// <summary>
  57. /// 字体列表
  58. /// </summary>
  59. ArrayList fontsItems = new ArrayList();
  60. public LabelMarkTimeControl(LabelStyleModel.TimeMark model)
  61. {
  62. this.model = model;
  63. InitializeComponent();
  64. InitializeControlData();
  65. InitializeData();
  66. }
  67. /// <summary>
  68. /// 获取当前页面model值
  69. /// </summary>
  70. /// <returns></returns>
  71. public LabelStyleModel.TimeMark getNowModel(LabelStyleModel.TimeMark model)
  72. {
  73. model.font = this.comboBox1.Text;
  74. model.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
  75. model.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  76. model.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
  77. model.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  78. model.position = this.comboBox2.SelectedIndex.ToString();
  79. model.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
  80. model.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  81. model.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
  82. return model;
  83. }
  84. /// <summary>
  85. /// 应用全部
  86. /// </summary>
  87. /// <param name="model"></param>
  88. public LabelStyleModel ApplyAll(LabelStyleModel model)
  89. {
  90. model.dateMark.font = this.comboBox1.Text;
  91. model.dateMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
  92. model.dateMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  93. model.dateMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
  94. model.dateMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  95. model.dateMark.position = this.comboBox2.SelectedIndex.ToString();
  96. model.dateMark.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
  97. model.dateMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  98. model.dateMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
  99. model.timeMark.font = this.comboBox1.Text;
  100. model.timeMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
  101. model.timeMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  102. model.timeMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
  103. model.timeMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  104. model.timeMark.position = this.comboBox2.SelectedIndex.ToString();
  105. model.timeMark.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
  106. model.timeMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  107. model.timeMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
  108. model.numberMark.font = this.comboBox1.Text;
  109. model.numberMark.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
  110. model.numberMark.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  111. model.numberMark.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
  112. model.numberMark.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  113. model.numberMark.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  114. model.numberMark.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
  115. model.gainNumber.font = this.comboBox1.Text;
  116. model.gainNumber.fontSize = Convert.ToInt32(this.numericUpDown2.Value);
  117. model.gainNumber.textColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  118. model.gainNumber.backgroundBoxColor = Convert.ToInt32(this.panel3.BackColor.ToArgb());
  119. model.gainNumber.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  120. model.gainNumber.position = this.comboBox2.SelectedIndex.ToString();
  121. model.gainNumber.positionSize = Convert.ToInt32(this.numericUpDown3.Value);
  122. model.gainNumber.backgroundColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  123. model.gainNumber.backgroundSize = Convert.ToInt32(this.numericUpDown4.Value);
  124. return model;
  125. }
  126. /// <summary>
  127. /// 设置下拉等数据源
  128. /// </summary>
  129. private void InitializeControlData()
  130. {
  131. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  132. foreach (FontFamily fontFamily in fonts.Families)
  133. {
  134. fontsItems.Add(fontFamily.Name);
  135. }
  136. this.comboBox1.DataSource = fontsItems;
  137. //绑定位置下拉
  138. this.comboBox2.DataSource = new BindingSource(InvariantData.tagLocation, null);
  139. this.comboBox2.DisplayMember = "Value";
  140. this.comboBox2.ValueMember = "Key";
  141. }
  142. /// <summary>
  143. /// 绑定样式数据
  144. /// </summary>
  145. private void InitializeData()
  146. {
  147. this.comboBox1.Text = this.model.font;
  148. this.comboBox2.SelectedIndex = Convert.ToInt32(this.model.position);
  149. this.numericUpDown1.Value = this.model.lineWidth;
  150. this.numericUpDown2.Value = this.model.fontSize;
  151. this.numericUpDown3.Value = this.model.positionSize;
  152. this.numericUpDown4.Value = this.model.backgroundSize;
  153. this.panel1.BackColor = Color.FromArgb(this.model.textColor);
  154. this.panel2.BackColor = Color.FromArgb(this.model.backgroundColor);
  155. this.panel3.BackColor = Color.FromArgb(this.model.backgroundBoxColor);
  156. }
  157. private void InitializeComponent()
  158. {
  159. this.comboBox1 = new System.Windows.Forms.ComboBox();
  160. this.comboBox2 = new System.Windows.Forms.ComboBox();
  161. this.label1 = new System.Windows.Forms.Label();
  162. this.label2 = new System.Windows.Forms.Label();
  163. this.label3 = new System.Windows.Forms.Label();
  164. this.label4 = new System.Windows.Forms.Label();
  165. this.label5 = new System.Windows.Forms.Label();
  166. this.label6 = new System.Windows.Forms.Label();
  167. this.label7 = new System.Windows.Forms.Label();
  168. this.label8 = new System.Windows.Forms.Label();
  169. this.label9 = new System.Windows.Forms.Label();
  170. this.label10 = new System.Windows.Forms.Label();
  171. this.label11 = new System.Windows.Forms.Label();
  172. this.panel1 = new System.Windows.Forms.Panel();
  173. this.panel2 = new System.Windows.Forms.Panel();
  174. this.panel3 = new System.Windows.Forms.Panel();
  175. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  176. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  177. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  178. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  179. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  180. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  181. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  182. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  183. this.SuspendLayout();
  184. //
  185. // comboBox1
  186. //
  187. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  188. this.comboBox1.FormattingEnabled = true;
  189. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  190. this.comboBox1.Name = "comboBox1";
  191. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  192. this.comboBox1.TabIndex = 1;
  193. //
  194. // comboBox2
  195. //
  196. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  197. this.comboBox2.FormattingEnabled = true;
  198. this.comboBox2.Location = new System.Drawing.Point(320, 5);
  199. this.comboBox2.Name = "comboBox2";
  200. this.comboBox2.Size = new System.Drawing.Size(152, 20);
  201. this.comboBox2.TabIndex = 1;
  202. //
  203. // label1
  204. //
  205. this.label1.AutoSize = true;
  206. this.label1.Location = new System.Drawing.Point(4, 8);
  207. this.label1.Name = "label1";
  208. this.label1.Size = new System.Drawing.Size(65, 12);
  209. this.label1.TabIndex = 0;
  210. this.label1.Text = PdnResources.GetString("Menu.Textfont.text") + ":";
  211. //
  212. // label2
  213. //
  214. this.label2.AutoSize = true;
  215. this.label2.Location = new System.Drawing.Point(6, 34);
  216. this.label2.Name = "label2";
  217. this.label2.Size = new System.Drawing.Size(65, 12);
  218. this.label2.TabIndex = 2;
  219. this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text") + ":";
  220. //
  221. // label3
  222. //
  223. this.label3.AutoSize = true;
  224. this.label3.Location = new System.Drawing.Point(6, 60);
  225. this.label3.Name = "label3";
  226. this.label3.Size = new System.Drawing.Size(65, 12);
  227. this.label3.TabIndex = 4;
  228. this.label3.Text = PdnResources.GetString("Menu.Textcolor.text") + ":";
  229. //
  230. // label4
  231. //
  232. this.label4.AutoSize = true;
  233. this.label4.Location = new System.Drawing.Point(254, 60);
  234. this.label4.Name = "label4";
  235. this.label4.Size = new System.Drawing.Size(65, 12);
  236. this.label4.TabIndex = 6;
  237. this.label4.Text = PdnResources.GetString("Menu.backgroundcolor.text") + ":";
  238. //
  239. // label5
  240. //
  241. this.label5.AutoSize = true;
  242. this.label5.Location = new System.Drawing.Point(6, 86);
  243. this.label5.Name = "label5";
  244. this.label5.Size = new System.Drawing.Size(77, 12);
  245. this.label5.TabIndex = 8;
  246. this.label5.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframecolor.text") + ":";
  247. //
  248. // label6
  249. //
  250. this.label6.AutoSize = true;
  251. this.label6.Location = new System.Drawing.Point(6, 112);
  252. this.label6.Name = "label6";
  253. this.label6.Size = new System.Drawing.Size(77, 12);
  254. this.label6.TabIndex = 9;
  255. this.label6.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframewidth.text") + ":";
  256. //
  257. // label7
  258. //
  259. this.label7.AutoSize = true;
  260. this.label7.Location = new System.Drawing.Point(254, 8);
  261. this.label7.Name = "label7";
  262. this.label7.Size = new System.Drawing.Size(41, 12);
  263. this.label7.TabIndex = 6;
  264. this.label7.Text = PdnResources.GetString("Menu.position.text") + ":";
  265. //
  266. // label8
  267. //
  268. this.label8.AutoSize = true;
  269. this.label8.Location = new System.Drawing.Point(254, 34);
  270. this.label8.Name = "label8";
  271. this.label8.Size = new System.Drawing.Size(65, 12);
  272. this.label8.TabIndex = 2;
  273. this.label8.Text = PdnResources.GetString("Menu.Set.Labelsettings.Locationsize.text") + ":";
  274. //
  275. // label9
  276. //
  277. this.label9.AutoSize = true;
  278. this.label9.Location = new System.Drawing.Point(461, 34);
  279. this.label9.Name = "label9";
  280. this.label9.Size = new System.Drawing.Size(11, 12);
  281. this.label9.TabIndex = 13;
  282. this.label9.Text = "%";
  283. //
  284. // label10
  285. //
  286. this.label10.AutoSize = true;
  287. this.label10.Location = new System.Drawing.Point(254, 86);
  288. this.label10.Name = "label10";
  289. this.label10.Size = new System.Drawing.Size(65, 12);
  290. this.label10.TabIndex = 2;
  291. this.label10.Text = PdnResources.GetString("Menu.Backgroundsize.text") + ":";
  292. //
  293. // label11
  294. //
  295. this.label11.AutoSize = true;
  296. this.label11.Location = new System.Drawing.Point(461, 86);
  297. this.label11.Name = "label11";
  298. this.label11.Size = new System.Drawing.Size(11, 12);
  299. this.label11.TabIndex = 13;
  300. this.label11.Text = "%";
  301. //
  302. // panel1
  303. //
  304. this.panel1.Location = new System.Drawing.Point(84, 57);
  305. this.panel1.Name = "panel1";
  306. this.panel1.Size = new System.Drawing.Size(152, 20);
  307. this.panel1.TabIndex = 5;
  308. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  309. //
  310. // panel2
  311. //
  312. this.panel2.Location = new System.Drawing.Point(320, 57);
  313. this.panel2.Name = "panel2";
  314. this.panel2.Size = new System.Drawing.Size(135, 20);
  315. this.panel2.TabIndex = 7;
  316. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  317. //
  318. // panel3
  319. //
  320. this.panel3.Location = new System.Drawing.Point(84, 83);
  321. this.panel3.Name = "panel3";
  322. this.panel3.Size = new System.Drawing.Size(152, 20);
  323. this.panel3.TabIndex = 10;
  324. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  325. //
  326. // numericUpDown1
  327. //
  328. this.numericUpDown1.Location = new System.Drawing.Point(84, 109);
  329. this.numericUpDown1.Name = "numericUpDown1";
  330. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  331. this.numericUpDown1.TabIndex = 11;
  332. //
  333. // numericUpDown2
  334. //
  335. this.numericUpDown2.Location = new System.Drawing.Point(84, 30);
  336. this.numericUpDown2.Maximum = new decimal(new int[] {
  337. 49000,
  338. 0,
  339. 0,
  340. 0});
  341. this.numericUpDown2.Minimum = new decimal(new int[] {
  342. 1,
  343. 0,
  344. 0,
  345. 0});
  346. this.numericUpDown2.Name = "numericUpDown2";
  347. this.numericUpDown2.Size = new System.Drawing.Size(152, 21);
  348. this.numericUpDown2.TabIndex = 12;
  349. this.numericUpDown2.Value = new decimal(new int[] {
  350. 1,
  351. 0,
  352. 0,
  353. 0});
  354. //
  355. // numericUpDown3
  356. //
  357. this.numericUpDown3.Location = new System.Drawing.Point(320, 31);
  358. this.numericUpDown3.Name = "numericUpDown3";
  359. this.numericUpDown3.Size = new System.Drawing.Size(135, 21);
  360. this.numericUpDown3.TabIndex = 12;
  361. //
  362. // numericUpDown4
  363. //
  364. this.numericUpDown4.Location = new System.Drawing.Point(320, 83);
  365. this.numericUpDown4.Name = "numericUpDown4";
  366. this.numericUpDown4.Size = new System.Drawing.Size(135, 21);
  367. this.numericUpDown4.TabIndex = 12;
  368. //
  369. // LabelMarkTimeControl
  370. //
  371. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  372. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  373. this.Controls.Add(this.numericUpDown1);
  374. this.Controls.Add(this.numericUpDown2);
  375. this.Controls.Add(this.numericUpDown3);
  376. this.Controls.Add(this.numericUpDown4);
  377. this.Controls.Add(this.panel1);
  378. this.Controls.Add(this.panel2);
  379. this.Controls.Add(this.panel3);
  380. this.Controls.Add(this.comboBox1);
  381. this.Controls.Add(this.comboBox2);
  382. this.Controls.Add(this.label1);
  383. this.Controls.Add(this.label2);
  384. this.Controls.Add(this.label3);
  385. this.Controls.Add(this.label4);
  386. this.Controls.Add(this.label5);
  387. this.Controls.Add(this.label6);
  388. this.Controls.Add(this.label7);
  389. this.Controls.Add(this.label8);
  390. this.Controls.Add(this.label9);
  391. this.Controls.Add(this.label10);
  392. this.Controls.Add(this.label11);
  393. this.Name = "LabelMarkTimeControl";
  394. this.Size = new System.Drawing.Size(490, 205);
  395. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  396. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  397. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  398. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  399. this.ResumeLayout(false);
  400. this.PerformLayout();
  401. this.colorsForm1 = new ColorsForm();
  402. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  403. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  404. this.colorsForm2 = new ColorsForm();
  405. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  406. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  407. this.colorsForm3 = new ColorsForm();
  408. this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
  409. this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  410. }
  411. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  412. {
  413. }
  414. /// <summary>
  415. /// panel1画板点击
  416. /// </summary>
  417. /// <param name="sender"></param>
  418. /// <param name="e"></param>
  419. private void panel1_Click(object sender, EventArgs e)
  420. {
  421. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  422. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  423. this.colorsForm1.ShowDialog();
  424. }
  425. private void panel1Changed(object sender, EventArgs e)
  426. {
  427. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  428. this.colorsForm1.Close();
  429. }
  430. /// <summary>
  431. /// panel2画板点击
  432. /// </summary>
  433. /// <param name="sender"></param>
  434. /// <param name="e"></param>
  435. private void panel2_Click(object sender, EventArgs e)
  436. {
  437. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  438. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  439. this.colorsForm2.ShowDialog();
  440. }
  441. private void panel2Changed(object sender, EventArgs e)
  442. {
  443. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  444. this.colorsForm2.Close();
  445. }
  446. /// <summary>
  447. /// panel3 画板点击
  448. /// </summary>
  449. /// <param name="sender"></param>
  450. /// <param name="e"></param>
  451. private void panel3_Click(object sender, EventArgs e)
  452. {
  453. this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel3.BackColor);
  454. this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.panel3Changed));
  455. this.colorsForm3.ShowDialog();
  456. }
  457. private void panel3Changed(object sender, EventArgs e)
  458. {
  459. this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
  460. this.colorsForm3.Close();
  461. }
  462. }
  463. }