LabelMarkGainNumberControl .cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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 LabelMarkGainNumberControl : 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.GainNumber 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 LabelMarkGainNumberControl(LabelStyleModel.GainNumber 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.GainNumber getNowModel(LabelStyleModel.GainNumber 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 = new BindingSource(InvariantData.tagLocation, null);
  132. this.comboBox2.DisplayMember = "Value";
  133. this.comboBox2.ValueMember = "Key";
  134. }
  135. /// <summary>
  136. /// 绑定样式数据
  137. /// </summary>
  138. private void InitializeData()
  139. {
  140. this.comboBox1.Text = this.model.font;
  141. this.comboBox2.SelectedIndex = Convert.ToInt32(this.model.position);
  142. this.numericUpDown1.Value = this.model.lineWidth;
  143. this.numericUpDown2.Value = this.model.fontSize;
  144. this.numericUpDown3.Value = this.model.positionSize;
  145. this.numericUpDown4.Value = this.model.backgroundSize;
  146. this.panel1.BackColor = Color.FromArgb(this.model.textColor);
  147. this.panel2.BackColor = Color.FromArgb(this.model.backgroundColor);
  148. this.panel3.BackColor = Color.FromArgb(this.model.backgroundBoxColor);
  149. }
  150. private void InitializeComponent()
  151. {
  152. this.comboBox1 = new System.Windows.Forms.ComboBox();
  153. this.comboBox2 = new System.Windows.Forms.ComboBox();
  154. this.label1 = new System.Windows.Forms.Label();
  155. this.label2 = new System.Windows.Forms.Label();
  156. this.label3 = new System.Windows.Forms.Label();
  157. this.label4 = new System.Windows.Forms.Label();
  158. this.label5 = new System.Windows.Forms.Label();
  159. this.label6 = new System.Windows.Forms.Label();
  160. this.label7 = new System.Windows.Forms.Label();
  161. this.label8 = new System.Windows.Forms.Label();
  162. this.label9 = new System.Windows.Forms.Label();
  163. this.label10 = new System.Windows.Forms.Label();
  164. this.label11 = new System.Windows.Forms.Label();
  165. this.panel1 = new System.Windows.Forms.Panel();
  166. this.panel2 = new System.Windows.Forms.Panel();
  167. this.panel3 = new System.Windows.Forms.Panel();
  168. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  169. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  170. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  171. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  172. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  173. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  174. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  175. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  176. this.SuspendLayout();
  177. //
  178. // comboBox1
  179. //
  180. this.comboBox1.FormattingEnabled = true;
  181. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  182. this.comboBox1.Name = "comboBox1";
  183. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  184. this.comboBox1.TabIndex = 1;
  185. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  186. //
  187. // comboBox2
  188. //
  189. this.comboBox2.FormattingEnabled = true;
  190. this.comboBox2.Location = new System.Drawing.Point(320, 5);
  191. this.comboBox2.Name = "comboBox2";
  192. this.comboBox2.Size = new System.Drawing.Size(152, 20);
  193. this.comboBox2.TabIndex = 1;
  194. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  195. //
  196. // label1
  197. //
  198. this.label1.AutoSize = true;
  199. this.label1.Location = new System.Drawing.Point(4, 8);
  200. this.label1.Name = "label1";
  201. this.label1.Size = new System.Drawing.Size(65, 12);
  202. this.label1.TabIndex = 0;
  203. this.label1.Text = PdnResources.GetString("Menu.Textfont.text")+":";
  204. //
  205. // label2
  206. //
  207. this.label2.AutoSize = true;
  208. this.label2.Location = new System.Drawing.Point(6, 34);
  209. this.label2.Name = "label2";
  210. this.label2.Size = new System.Drawing.Size(65, 12);
  211. this.label2.TabIndex = 2;
  212. this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text")+":";
  213. //
  214. // label3
  215. //
  216. this.label3.AutoSize = true;
  217. this.label3.Location = new System.Drawing.Point(6, 60);
  218. this.label3.Name = "label3";
  219. this.label3.Size = new System.Drawing.Size(65, 12);
  220. this.label3.TabIndex = 4;
  221. this.label3.Text = PdnResources.GetString("Menu.Textcolor.text")+":";
  222. //
  223. // label4
  224. //
  225. this.label4.AutoSize = true;
  226. this.label4.Location = new System.Drawing.Point(254, 60);
  227. this.label4.Name = "label4";
  228. this.label4.Size = new System.Drawing.Size(65, 12);
  229. this.label4.TabIndex = 6;
  230. this.label4.Text = PdnResources.GetString("Menu.backgroundcolor.text")+":";
  231. //
  232. // label5
  233. //
  234. this.label5.AutoSize = true;
  235. this.label5.Location = new System.Drawing.Point(6, 86);
  236. this.label5.Name = "label5";
  237. this.label5.Size = new System.Drawing.Size(77, 12);
  238. this.label5.TabIndex = 8;
  239. this.label5.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframecolor.text")+":";
  240. //
  241. // label6
  242. //
  243. this.label6.AutoSize = true;
  244. this.label6.Location = new System.Drawing.Point(6, 112);
  245. this.label6.Name = "label6";
  246. this.label6.Size = new System.Drawing.Size(77, 12);
  247. this.label6.TabIndex = 9;
  248. this.label6.Text = PdnResources.GetString("Menu.Set.Labelsettings.Backgroundframewidth.text")+":";
  249. //
  250. // label7
  251. //
  252. this.label7.AutoSize = true;
  253. this.label7.Location = new System.Drawing.Point(254, 8);
  254. this.label7.Name = "label7";
  255. this.label7.Size = new System.Drawing.Size(41, 12);
  256. this.label7.TabIndex = 6;
  257. this.label7.Text = PdnResources.GetString("Menu.position.text")+":";
  258. //
  259. // label8
  260. //
  261. this.label8.AutoSize = true;
  262. this.label8.Location = new System.Drawing.Point(254, 34);
  263. this.label8.Name = "label8";
  264. this.label8.Size = new System.Drawing.Size(65, 12);
  265. this.label8.TabIndex = 2;
  266. this.label8.Text = PdnResources.GetString("Menu.Set.Labelsettings.Locationsize.text")+":";
  267. //
  268. // label9
  269. //
  270. this.label9.AutoSize = true;
  271. this.label9.Location = new System.Drawing.Point(461, 34);
  272. this.label9.Name = "label9";
  273. this.label9.Size = new System.Drawing.Size(11, 12);
  274. this.label9.TabIndex = 13;
  275. this.label9.Text = "%";
  276. //
  277. // label10
  278. //
  279. this.label10.AutoSize = true;
  280. this.label10.Location = new System.Drawing.Point(254, 86);
  281. this.label10.Name = "label10";
  282. this.label10.Size = new System.Drawing.Size(65, 12);
  283. this.label10.TabIndex = 2;
  284. this.label10.Text = PdnResources.GetString("Menu.Backgroundsize.text")+":";
  285. //
  286. // label11
  287. //
  288. this.label11.AutoSize = true;
  289. this.label11.Location = new System.Drawing.Point(461, 86);
  290. this.label11.Name = "label11";
  291. this.label11.Size = new System.Drawing.Size(11, 12);
  292. this.label11.TabIndex = 13;
  293. this.label11.Text = "%";
  294. //
  295. // panel1
  296. //
  297. this.panel1.Location = new System.Drawing.Point(84, 57);
  298. this.panel1.Name = "panel1";
  299. this.panel1.Size = new System.Drawing.Size(152, 20);
  300. this.panel1.TabIndex = 5;
  301. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  302. //
  303. // panel2
  304. //
  305. this.panel2.Location = new System.Drawing.Point(320, 57);
  306. this.panel2.Name = "panel2";
  307. this.panel2.Size = new System.Drawing.Size(135, 20);
  308. this.panel2.TabIndex = 7;
  309. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  310. //
  311. // panel3
  312. //
  313. this.panel3.Location = new System.Drawing.Point(84, 83);
  314. this.panel3.Name = "panel3";
  315. this.panel3.Size = new System.Drawing.Size(152, 20);
  316. this.panel3.TabIndex = 10;
  317. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  318. //
  319. // numericUpDown1
  320. //
  321. this.numericUpDown1.Location = new System.Drawing.Point(84, 109);
  322. this.numericUpDown1.Name = "numericUpDown1";
  323. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  324. this.numericUpDown1.TabIndex = 11;
  325. //
  326. // numericUpDown2
  327. //
  328. this.numericUpDown2.Location = new System.Drawing.Point(84, 30);
  329. this.numericUpDown2.Name = "numericUpDown2";
  330. this.numericUpDown2.Size = new System.Drawing.Size(152, 21);
  331. this.numericUpDown2.TabIndex = 12;
  332. //
  333. // numericUpDown3
  334. //
  335. this.numericUpDown3.Location = new System.Drawing.Point(320, 31);
  336. this.numericUpDown3.Name = "numericUpDown3";
  337. this.numericUpDown3.Size = new System.Drawing.Size(135, 21);
  338. this.numericUpDown3.TabIndex = 12;
  339. //
  340. // numericUpDown4
  341. //
  342. this.numericUpDown4.Location = new System.Drawing.Point(320, 83);
  343. this.numericUpDown4.Name = "numericUpDown4";
  344. this.numericUpDown4.Size = new System.Drawing.Size(135, 21);
  345. this.numericUpDown4.TabIndex = 12;
  346. //
  347. // LabelMarkGainNumberControl
  348. //
  349. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  350. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  351. this.Controls.Add(this.numericUpDown1);
  352. this.Controls.Add(this.numericUpDown2);
  353. this.Controls.Add(this.numericUpDown3);
  354. this.Controls.Add(this.numericUpDown4);
  355. this.Controls.Add(this.panel1);
  356. this.Controls.Add(this.panel2);
  357. this.Controls.Add(this.panel3);
  358. this.Controls.Add(this.comboBox1);
  359. this.Controls.Add(this.comboBox2);
  360. this.Controls.Add(this.label1);
  361. this.Controls.Add(this.label2);
  362. this.Controls.Add(this.label3);
  363. this.Controls.Add(this.label4);
  364. this.Controls.Add(this.label5);
  365. this.Controls.Add(this.label6);
  366. this.Controls.Add(this.label7);
  367. this.Controls.Add(this.label8);
  368. this.Controls.Add(this.label9);
  369. this.Controls.Add(this.label10);
  370. this.Controls.Add(this.label11);
  371. this.Name = "LabelMarkGainNumberControl";
  372. this.Size = new System.Drawing.Size(490, 205);
  373. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  374. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  375. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  376. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  377. this.ResumeLayout(false);
  378. this.PerformLayout();
  379. this.colorsForm1 = new ColorsForm();
  380. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  381. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  382. this.colorsForm2 = new ColorsForm();
  383. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  384. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  385. this.colorsForm3 = new ColorsForm();
  386. this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
  387. this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  388. }
  389. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  390. {
  391. }
  392. /// <summary>
  393. /// panel1画板点击
  394. /// </summary>
  395. /// <param name="sender"></param>
  396. /// <param name="e"></param>
  397. private void panel1_Click(object sender, EventArgs e)
  398. {
  399. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  400. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  401. this.colorsForm1.ShowDialog();
  402. }
  403. private void panel1Changed(object sender, EventArgs e)
  404. {
  405. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  406. this.colorsForm1.Close();
  407. }
  408. /// <summary>
  409. /// panel2画板点击
  410. /// </summary>
  411. /// <param name="sender"></param>
  412. /// <param name="e"></param>
  413. private void panel2_Click(object sender, EventArgs e)
  414. {
  415. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  416. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  417. this.colorsForm2.ShowDialog();
  418. }
  419. private void panel2Changed(object sender, EventArgs e)
  420. {
  421. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  422. this.colorsForm2.Close();
  423. }
  424. /// <summary>
  425. /// panel3 画板点击
  426. /// </summary>
  427. /// <param name="sender"></param>
  428. /// <param name="e"></param>
  429. private void panel3_Click(object sender, EventArgs e)
  430. {
  431. this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel3.BackColor);
  432. this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.panel3Changed));
  433. this.colorsForm3.ShowDialog();
  434. }
  435. private void panel3Changed(object sender, EventArgs e)
  436. {
  437. this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
  438. this.colorsForm3.Close();
  439. }
  440. }
  441. }