LabelMarkDateControl.cs 22 KB

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