LabelCurveClosedControl.cs 13 KB

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