LabelMarkNumberControl.cs 21 KB

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