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