LabelMarkNumberControl.cs 17 KB

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