LabelPolygonRoundedControl.cs 12 KB

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