LabelCircleControl.cs 9.7 KB

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