LabelStraightLineControl.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using PaintDotNet.Base.SettingModel;
  2. using System;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace PaintDotNet.Setting.LabelComponent
  6. {
  7. /// <summary>
  8. /// 标注设置-直线设置->直线
  9. /// </summary>
  10. public class LabelStraightLineControl : 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.LineChildLine model;
  24. PaintDotNet.ColorsForm colorsForm1;
  25. public LabelStraightLineControl(LabelStyleModel.LineChildLine 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.LineChildLine getNowModel(LabelStyleModel.LineChildLine 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.lineChildLine.lineStyle = this.comboBox1.SelectedIndex;
  51. model.lineChildLine.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  52. model.lineChildLine.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  53. model.lineChildLineSegment.lineStyle = this.comboBox1.SelectedIndex;
  54. model.lineChildLineSegment.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  55. model.lineChildLineSegment.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  56. return model;
  57. }
  58. /// <summary>
  59. /// 设置下拉等数据源
  60. /// </summary>
  61. private void InitializeControlData()
  62. {
  63. //绑定线样式数据
  64. this.comboBox1.Items.AddRange(InvariantData.dashStyles);
  65. }
  66. /// <summary>
  67. /// 绑定样式数据
  68. /// </summary>
  69. private void InitializeData()
  70. {
  71. this.comboBox1.SelectedIndex = this.model.lineStyle;
  72. this.numericUpDown1.Value = this.model.lineWidth;
  73. this.panel1.BackColor = Color.FromArgb(this.model.lineColor);
  74. }
  75. private void InitializeComponent()
  76. {
  77. this.label1 = new System.Windows.Forms.Label();
  78. this.label2 = new System.Windows.Forms.Label();
  79. this.label3 = new System.Windows.Forms.Label();
  80. this.comboBox1 = new System.Windows.Forms.ComboBox();
  81. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  82. this.panel1 = new System.Windows.Forms.Panel();
  83. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  84. this.SuspendLayout();
  85. //
  86. // comboBox1
  87. //
  88. this.comboBox1.FormattingEnabled = true;
  89. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  90. this.comboBox1.Name = "comboBox1";
  91. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  92. this.comboBox1.TabIndex = 1;
  93. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  94. //
  95. // label1
  96. //
  97. this.label1.AutoSize = true;
  98. this.label1.Location = new System.Drawing.Point(4, 8);
  99. this.label1.Name = "label1";
  100. this.label1.Size = new System.Drawing.Size(65, 12);
  101. this.label1.TabIndex = 0;
  102. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text")+":";
  103. //
  104. // label2
  105. //
  106. this.label2.AutoSize = true;
  107. this.label2.Location = new System.Drawing.Point(6, 34);
  108. this.label2.Name = "label2";
  109. this.label2.Size = new System.Drawing.Size(65, 12);
  110. this.label2.TabIndex = 2;
  111. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text")+":";
  112. //
  113. // label3
  114. //
  115. this.label3.AutoSize = true;
  116. this.label3.Location = new System.Drawing.Point(6, 60);
  117. this.label3.Name = "label3";
  118. this.label3.Size = new System.Drawing.Size(65, 12);
  119. this.label3.TabIndex = 4;
  120. this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text")+":";
  121. //
  122. // panel1
  123. //
  124. this.panel1.Location = new System.Drawing.Point(84, 57);
  125. this.panel1.Name = "panel1";
  126. this.panel1.Size = new System.Drawing.Size(152, 20);
  127. this.panel1.TabIndex = 5;
  128. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  129. //
  130. // numericUpDown1
  131. //
  132. this.numericUpDown1.Location = new System.Drawing.Point(84, 34);
  133. this.numericUpDown1.Name = "numericUpDown1";
  134. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  135. this.numericUpDown1.TabIndex = 11;
  136. //
  137. // LabelStraightLineControl
  138. //
  139. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  140. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  141. this.Controls.Add(this.numericUpDown1);
  142. this.Controls.Add(this.panel1);
  143. this.Controls.Add(this.comboBox1);
  144. this.Controls.Add(this.label1);
  145. this.Controls.Add(this.label2);
  146. this.Controls.Add(this.label3);
  147. this.Name = "LabelStraightLineControl";
  148. this.Size = new System.Drawing.Size(490, 205);
  149. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  150. this.ResumeLayout(false);
  151. this.PerformLayout();
  152. this.colorsForm1 = new ColorsForm();
  153. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  154. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  155. }
  156. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  157. {
  158. }
  159. /// <summary>
  160. /// panel1画板点击
  161. /// </summary>
  162. /// <param name="sender"></param>
  163. /// <param name="e"></param>
  164. private void panel1_Click(object sender, EventArgs e)
  165. {
  166. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  167. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  168. this.colorsForm1.ShowDialog();
  169. }
  170. private void panel1Changed(object sender, EventArgs e)
  171. {
  172. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  173. this.colorsForm1.Close();
  174. }
  175. }
  176. }