LabelCircleOvalControl.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 PaintDotNet.Base.SettingModel;
  11. namespace PaintDotNet.Setting.LabelComponent
  12. {
  13. /// <summary>
  14. /// 标注设置-圆设置->椭圆
  15. /// </summary>
  16. public class LabelCircleOvalControl : UserControl
  17. {
  18. #region 控件
  19. private System.Windows.Forms.Label label1;
  20. private System.Windows.Forms.Label label2;
  21. private System.Windows.Forms.Label label3;
  22. private System.Windows.Forms.Label label4;
  23. private System.Windows.Forms.ComboBox comboBox1;
  24. private NumericUpDown numericUpDown1;
  25. private System.Windows.Forms.Panel panel1;
  26. private System.Windows.Forms.Panel panel2;
  27. #endregion
  28. /// <summary>
  29. /// 椭圆样式
  30. /// </summary>
  31. private LabelStyleModel.Oval model;
  32. PaintDotNet.ColorsForm colorsForm1;
  33. PaintDotNet.ColorsForm colorsForm2;
  34. public LabelCircleOvalControl(LabelStyleModel.Oval model)
  35. {
  36. this.model = model;
  37. InitializeComponent();
  38. InitializeControlData();
  39. InitializeData();
  40. }
  41. /// <summary>
  42. /// 获取当前页面model值
  43. /// </summary>
  44. /// <returns></returns>
  45. public LabelStyleModel.Oval getNowModel(LabelStyleModel.Oval oval)
  46. {
  47. oval.lineStyle = this.comboBox1.SelectedIndex;
  48. oval.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  49. oval.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  50. oval.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  51. return oval;
  52. }
  53. /// <summary>
  54. /// 应用全部
  55. /// </summary>
  56. /// <param name="labelStyleModel"></param>
  57. /// <returns></returns>
  58. public LabelStyleModel ApplyAll(LabelStyleModel labelStyleModel)
  59. {
  60. labelStyleModel.circleModel.lineStyle = this.comboBox1.SelectedIndex;
  61. labelStyleModel.circleModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  62. labelStyleModel.circleModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  63. labelStyleModel.circleModel.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  64. labelStyleModel.ovalModel.lineStyle = this.comboBox1.SelectedIndex;
  65. labelStyleModel.ovalModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  66. labelStyleModel.ovalModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  67. labelStyleModel.ovalModel.fillColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  68. return labelStyleModel;
  69. }
  70. /// <summary>
  71. /// 设置下拉等数据源
  72. /// </summary>
  73. private void InitializeControlData()
  74. {
  75. //绑定线样式数据
  76. this.comboBox1.Items.AddRange(InvariantData.dashStyles);
  77. }
  78. /// <summary>
  79. /// 绑定样式数据
  80. /// </summary>
  81. private void InitializeData()
  82. {
  83. this.comboBox1.SelectedIndex = this.model.lineStyle;
  84. this.numericUpDown1.Value = this.model.lineWidth;
  85. this.panel1.BackColor = Color.FromArgb(this.model.lineColor);
  86. this.panel2.BackColor = Color.FromArgb(this.model.fillColor);
  87. }
  88. private void InitializeComponent()
  89. {
  90. this.label1 = new System.Windows.Forms.Label();
  91. this.label2 = new System.Windows.Forms.Label();
  92. this.label3 = new System.Windows.Forms.Label();
  93. this.label4 = new System.Windows.Forms.Label();
  94. this.comboBox1 = new System.Windows.Forms.ComboBox();
  95. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  96. this.panel1 = new System.Windows.Forms.Panel();
  97. this.panel2 = new System.Windows.Forms.Panel();
  98. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  99. this.SuspendLayout();
  100. //
  101. // label1
  102. //
  103. this.label1.AutoSize = true;
  104. this.label1.Location = new System.Drawing.Point(4, 8);
  105. this.label1.Name = "label1";
  106. this.label1.Size = new System.Drawing.Size(53, 12);
  107. this.label1.TabIndex = 0;
  108. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text")+":";
  109. //
  110. // label2
  111. //
  112. this.label2.AutoSize = true;
  113. this.label2.Location = new System.Drawing.Point(6, 34);
  114. this.label2.Name = "label2";
  115. this.label2.Size = new System.Drawing.Size(41, 12);
  116. this.label2.TabIndex = 2;
  117. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text")+":";
  118. //
  119. // label3
  120. //
  121. this.label3.AutoSize = true;
  122. this.label3.Location = new System.Drawing.Point(6, 60);
  123. this.label3.Name = "label3";
  124. this.label3.Size = new System.Drawing.Size(53, 12);
  125. this.label3.TabIndex = 4;
  126. this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text")+":";
  127. //
  128. // label4
  129. //
  130. this.label4.AutoSize = true;
  131. this.label4.Location = new System.Drawing.Point(254, 8);
  132. this.label4.Name = "label4";
  133. this.label4.Size = new System.Drawing.Size(65, 12);
  134. this.label4.TabIndex = 4;
  135. this.label4.Text = PdnResources.GetString("Menu.Set.Labelsettings.Fillcolor.text")+":";
  136. //
  137. // comboBox1
  138. //
  139. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  140. this.comboBox1.FormattingEnabled = true;
  141. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  142. this.comboBox1.Name = "comboBox1";
  143. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  144. this.comboBox1.TabIndex = 1;
  145. //
  146. // numericUpDown1
  147. //
  148. this.numericUpDown1.Location = new System.Drawing.Point(84, 31);
  149. this.numericUpDown1.Name = "numericUpDown1";
  150. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  151. this.numericUpDown1.TabIndex = 11;
  152. //
  153. // panel1
  154. //
  155. this.panel1.Location = new System.Drawing.Point(84, 57);
  156. this.panel1.Name = "panel1";
  157. this.panel1.Size = new System.Drawing.Size(152, 20);
  158. this.panel1.TabIndex = 5;
  159. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  160. //
  161. // panel2
  162. //
  163. this.panel2.Location = new System.Drawing.Point(320, 5);
  164. this.panel2.Name = "panel2";
  165. this.panel2.Size = new System.Drawing.Size(152, 20);
  166. this.panel2.TabIndex = 5;
  167. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  168. //
  169. // LabelCircleOvalControl
  170. //
  171. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  172. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  173. this.Controls.Add(this.numericUpDown1);
  174. this.Controls.Add(this.panel1);
  175. this.Controls.Add(this.panel2);
  176. this.Controls.Add(this.comboBox1);
  177. this.Controls.Add(this.label1);
  178. this.Controls.Add(this.label2);
  179. this.Controls.Add(this.label3);
  180. this.Controls.Add(this.label4);
  181. this.Name = "LabelCircleOvalControl";
  182. this.Size = new System.Drawing.Size(490, 205);
  183. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  184. this.ResumeLayout(false);
  185. this.PerformLayout();
  186. this.colorsForm1 = new ColorsForm();
  187. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  188. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  189. this.colorsForm2 = new ColorsForm();
  190. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  191. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  192. }
  193. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  194. {
  195. }
  196. /// <summary>
  197. /// panel1画板点击
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void panel1_Click(object sender, EventArgs e)
  202. {
  203. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  204. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  205. this.colorsForm1.ShowDialog();
  206. }
  207. private void panel1Changed(object sender, EventArgs e)
  208. {
  209. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  210. this.colorsForm1.Close();
  211. }
  212. /// <summary>
  213. /// panel2画板点击
  214. /// </summary>
  215. /// <param name="sender"></param>
  216. /// <param name="e"></param>
  217. private void panel2_Click(object sender, EventArgs e)
  218. {
  219. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  220. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  221. this.colorsForm2.ShowDialog();
  222. }
  223. private void panel2Changed(object sender, EventArgs e)
  224. {
  225. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  226. this.colorsForm2.Close();
  227. }
  228. }
  229. }