LabelPolygonRectangleControl.cs 10 KB

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