LabelStraightLineSegmentControl.cs 7.8 KB

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