LabelCurveControl.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 LabelCurveControl : 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.ComboBox comboBox1;
  17. private NumericUpDown numericUpDown1;
  18. private System.Windows.Forms.Panel panel1;
  19. #endregion
  20. /// <summary>
  21. /// 曲线样式
  22. /// </summary>
  23. private LabelStyleModel.CurveModel model;
  24. PaintDotNet.ColorsForm colorsForm1;
  25. public LabelCurveControl(LabelStyleModel.CurveModel model)
  26. {
  27. this.model = model;
  28. InitializeComponent();
  29. InitializeControlData();
  30. InitializeData();
  31. }
  32. /// <summary>
  33. /// 获取当前页面model值
  34. /// </summary>
  35. /// <returns></returns>
  36. public LabelStyleModel.CurveModel getNowModel(LabelStyleModel.CurveModel curveModel)
  37. {
  38. curveModel.lineStyle = this.comboBox1.SelectedIndex;
  39. curveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  40. curveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  41. return curveModel;
  42. }
  43. /// <summary>
  44. /// 应用全部
  45. /// </summary>
  46. /// <param name="model"></param>
  47. /// <returns></returns>
  48. public LabelStyleModel ApplyAll(LabelStyleModel labelStyleModel)
  49. {
  50. labelStyleModel.pencilModel.lineStyle = this.comboBox1.SelectedIndex;
  51. labelStyleModel.pencilModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  52. labelStyleModel.pencilModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  53. labelStyleModel.polylineModel.lineStyle = this.comboBox1.SelectedIndex;
  54. labelStyleModel.polylineModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  55. labelStyleModel.polylineModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  56. labelStyleModel.curveModel.lineStyle = this.comboBox1.SelectedIndex;
  57. labelStyleModel.curveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  58. labelStyleModel.curveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  59. labelStyleModel.closedCurveModel.lineStyle = this.comboBox1.SelectedIndex;
  60. labelStyleModel.closedCurveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  61. labelStyleModel.closedCurveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  62. return labelStyleModel;
  63. }
  64. /// <summary>
  65. /// 设置下拉等数据源
  66. /// </summary>
  67. private void InitializeControlData()
  68. {
  69. //绑定线样式数据
  70. this.comboBox1.Items.AddRange(InvariantData.dashStyles);
  71. }
  72. /// <summary>
  73. /// 绑定样式数据
  74. /// </summary>
  75. private void InitializeData()
  76. {
  77. this.comboBox1.SelectedIndex = this.model.lineStyle;
  78. this.numericUpDown1.Value = this.model.lineWidth;
  79. this.panel1.BackColor = Color.FromArgb(this.model.lineColor);
  80. }
  81. private void InitializeComponent()
  82. {
  83. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LabelCurveControl));
  84. this.label1 = new System.Windows.Forms.Label();
  85. this.label2 = new System.Windows.Forms.Label();
  86. this.label3 = new System.Windows.Forms.Label();
  87. this.comboBox1 = new System.Windows.Forms.ComboBox();
  88. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  89. this.panel1 = new System.Windows.Forms.Panel();
  90. this.colorsForm1 = new PaintDotNet.ColorsForm();
  91. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  92. this.SuspendLayout();
  93. //
  94. // label1
  95. //
  96. this.label1.AutoSize = true;
  97. this.label1.Location = new System.Drawing.Point(4, 8);
  98. this.label1.Name = "label1";
  99. this.label1.Size = new System.Drawing.Size(53, 12);
  100. this.label1.TabIndex = 0;
  101. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text")+":";
  102. //
  103. // label2
  104. //
  105. this.label2.AutoSize = true;
  106. this.label2.Location = new System.Drawing.Point(6, 34);
  107. this.label2.Name = "label2";
  108. this.label2.Size = new System.Drawing.Size(41, 12);
  109. this.label2.TabIndex = 2;
  110. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text")+":";
  111. //
  112. // label3
  113. //
  114. this.label3.AutoSize = true;
  115. this.label3.Location = new System.Drawing.Point(6, 60);
  116. this.label3.Name = "label3";
  117. this.label3.Size = new System.Drawing.Size(53, 12);
  118. this.label3.TabIndex = 4;
  119. this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text")+":";
  120. //
  121. // comboBox1
  122. //
  123. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  124. this.comboBox1.FormattingEnabled = true;
  125. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  126. this.comboBox1.Name = "comboBox1";
  127. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  128. this.comboBox1.TabIndex = 1;
  129. //
  130. // numericUpDown1
  131. //
  132. this.numericUpDown1.Location = new System.Drawing.Point(84, 31);
  133. this.numericUpDown1.Name = "numericUpDown1";
  134. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  135. this.numericUpDown1.TabIndex = 11;
  136. //
  137. // panel1
  138. //
  139. this.panel1.Location = new System.Drawing.Point(84, 57);
  140. this.panel1.Name = "panel1";
  141. this.panel1.Size = new System.Drawing.Size(152, 20);
  142. this.panel1.TabIndex = 5;
  143. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  144. //
  145. // colorsForm1
  146. //
  147. this.colorsForm1.AnalyzeSettingModel = null;
  148. this.colorsForm1.ClientSize = new System.Drawing.Size(209, 217);
  149. this.colorsForm1.EnableInstanceOpacity = true;
  150. this.colorsForm1.ForceActiveTitleBar = true;
  151. this.colorsForm1.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  152. this.colorsForm1.KeyPreview = true;
  153. this.colorsForm1.Location = new System.Drawing.Point(0, 0);
  154. this.colorsForm1.MaximizeBox = false;
  155. this.colorsForm1.MinimizeBox = false;
  156. this.colorsForm1.Name = "colorsForm1";
  157. this.colorsForm1.ShowInTaskbar = false;
  158. this.colorsForm1.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
  159. this.colorsForm1.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  160. this.colorsForm1.Text = PdnResources.GetString("Menu.color.text");
  161. //this.colorsForm1.UserPrimaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm1.UserPrimaryColor")));
  162. //this.colorsForm1.UserSecondaryColor = ((PaintDotNet.ColorBgra)(resources.GetObject("colorsForm1.UserSecondaryColor")));
  163. this.colorsForm1.Visible = false;
  164. this.colorsForm1.WhichUserColor = PaintDotNet.WhichUserColor.Primary;
  165. this.colorsForm1.UserPrimaryColorChanged += new PaintDotNet.ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  166. //
  167. // LabelCurveControl
  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.comboBox1);
  174. this.Controls.Add(this.label1);
  175. this.Controls.Add(this.label2);
  176. this.Controls.Add(this.label3);
  177. this.Name = "LabelCurveControl";
  178. this.Size = new System.Drawing.Size(490, 205);
  179. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  180. this.ResumeLayout(false);
  181. this.PerformLayout();
  182. }
  183. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  184. {
  185. }
  186. /// <summary>
  187. /// panel1画板点击
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void panel1_Click(object sender, EventArgs e)
  192. {
  193. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  194. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  195. this.colorsForm1.ShowDialog();
  196. }
  197. private void panel1Changed(object sender, EventArgs e)
  198. {
  199. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  200. this.colorsForm1.Close();
  201. }
  202. }
  203. }