LabelCurvePencilControl.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 LabelCurvePencilControl : 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.Pencil model;
  24. PaintDotNet.ColorsForm colorsForm1;
  25. public LabelCurvePencilControl(LabelStyleModel.Pencil 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.Pencil getNowModel(LabelStyleModel.Pencil model)
  37. {
  38. model.lineStyle = this.comboBox1.SelectedIndex;
  39. model.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  40. model.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  41. return model;
  42. }
  43. /// <summary>
  44. /// 应用全部
  45. /// </summary>
  46. /// <param name="model"></param>
  47. /// <returns></returns>
  48. public LabelStyleModel ApplyAll(LabelStyleModel model)
  49. {
  50. model.pencilModel.lineStyle = this.comboBox1.SelectedIndex;
  51. model.pencilModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  52. model.pencilModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  53. model.polylineModel.lineStyle = this.comboBox1.SelectedIndex;
  54. model.polylineModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  55. model.polylineModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  56. model.curveModel.lineStyle = this.comboBox1.SelectedIndex;
  57. model.curveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  58. model.curveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  59. model.closedCurveModel.lineStyle = this.comboBox1.SelectedIndex;
  60. model.closedCurveModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  61. model.closedCurveModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  62. return model;
  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. this.label1 = new System.Windows.Forms.Label();
  84. this.label2 = new System.Windows.Forms.Label();
  85. this.label3 = new System.Windows.Forms.Label();
  86. this.comboBox1 = new System.Windows.Forms.ComboBox();
  87. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  88. this.panel1 = new System.Windows.Forms.Panel();
  89. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  90. this.SuspendLayout();
  91. //
  92. // label1
  93. //
  94. this.label1.AutoSize = true;
  95. this.label1.Location = new System.Drawing.Point(4, 8);
  96. this.label1.Name = "label1";
  97. this.label1.Size = new System.Drawing.Size(53, 12);
  98. this.label1.TabIndex = 0;
  99. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text")+":";
  100. //
  101. // label2
  102. //
  103. this.label2.AutoSize = true;
  104. this.label2.Location = new System.Drawing.Point(6, 34);
  105. this.label2.Name = "label2";
  106. this.label2.Size = new System.Drawing.Size(41, 12);
  107. this.label2.TabIndex = 2;
  108. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text")+":";
  109. //
  110. // label3
  111. //
  112. this.label3.AutoSize = true;
  113. this.label3.Location = new System.Drawing.Point(6, 60);
  114. this.label3.Name = "label3";
  115. this.label3.Size = new System.Drawing.Size(53, 12);
  116. this.label3.TabIndex = 4;
  117. this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text")+":";
  118. //
  119. // comboBox1
  120. //
  121. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  122. this.comboBox1.FormattingEnabled = true;
  123. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  124. this.comboBox1.Name = "comboBox1";
  125. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  126. this.comboBox1.TabIndex = 1;
  127. //
  128. // numericUpDown1
  129. //
  130. this.numericUpDown1.Location = new System.Drawing.Point(84, 31);
  131. this.numericUpDown1.Name = "numericUpDown1";
  132. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  133. this.numericUpDown1.TabIndex = 11;
  134. //
  135. // panel1
  136. //
  137. this.panel1.Location = new System.Drawing.Point(84, 57);
  138. this.panel1.Name = "panel1";
  139. this.panel1.Size = new System.Drawing.Size(152, 20);
  140. this.panel1.TabIndex = 5;
  141. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  142. //
  143. // LabelCurvePencilControl
  144. //
  145. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  146. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  147. this.Controls.Add(this.numericUpDown1);
  148. this.Controls.Add(this.panel1);
  149. this.Controls.Add(this.comboBox1);
  150. this.Controls.Add(this.label1);
  151. this.Controls.Add(this.label2);
  152. this.Controls.Add(this.label3);
  153. this.Name = "LabelCurvePencilControl";
  154. this.Size = new System.Drawing.Size(490, 205);
  155. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  156. this.ResumeLayout(false);
  157. this.PerformLayout();
  158. this.colorsForm1 = new ColorsForm();
  159. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  160. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  161. }
  162. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  163. {
  164. }
  165. /// <summary>
  166. /// panel1画板点击
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void panel1_Click(object sender, EventArgs e)
  171. {
  172. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  173. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  174. this.colorsForm1.ShowDialog();
  175. }
  176. private void panel1Changed(object sender, EventArgs e)
  177. {
  178. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  179. this.colorsForm1.Close();
  180. }
  181. }
  182. }