LabelArrowTwoWayControl.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 LabelArrowTwoWayControl : 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.TwoWayArrow model;
  24. PaintDotNet.ColorsForm colorsForm;
  25. public LabelArrowTwoWayControl(LabelStyleModel.TwoWayArrow model)
  26. {
  27. this.model = model;
  28. InitializeComponent();
  29. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linestyle.text") + ":";
  30. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  31. this.label3.Text = PdnResources.GetString("Menu.Set.Labelsettings.Linecolor.text") + ":";
  32. this.colorsForm = new ColorsForm();
  33. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  34. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  35. InitializeControlData();
  36. InitializeData();
  37. }
  38. /// <summary>
  39. /// 获取当前页面model值
  40. /// </summary>
  41. /// <returns></returns>
  42. public LabelStyleModel.TwoWayArrow getNowModel(LabelStyleModel.TwoWayArrow twoWayArrow)
  43. {
  44. twoWayArrow.lineStyle = this.comboBox1.SelectedIndex;
  45. twoWayArrow.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  46. twoWayArrow.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  47. return model;
  48. }
  49. /// <summary>
  50. /// 应用全部
  51. /// </summary>
  52. /// <param name="labelStyleModel"></param>
  53. /// <returns></returns>
  54. public LabelStyleModel ApplyAll(LabelStyleModel labelStyleModel)
  55. {
  56. labelStyleModel.oneWayArrowModel.lineStyle = this.comboBox1.SelectedIndex;
  57. labelStyleModel.oneWayArrowModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  58. labelStyleModel.oneWayArrowModel.lineColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  59. labelStyleModel.twoWayArrowModel.lineStyle = this.comboBox1.SelectedIndex;
  60. labelStyleModel.twoWayArrowModel.lineWidth = Convert.ToInt32(this.numericUpDown1.Value);
  61. labelStyleModel.twoWayArrowModel.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. 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. //
  100. // label2
  101. //
  102. this.label2.AutoSize = true;
  103. this.label2.Location = new System.Drawing.Point(6, 34);
  104. this.label2.Name = "label2";
  105. this.label2.Size = new System.Drawing.Size(41, 12);
  106. this.label2.TabIndex = 2;
  107. //
  108. // label3
  109. //
  110. this.label3.AutoSize = true;
  111. this.label3.Location = new System.Drawing.Point(6, 60);
  112. this.label3.Name = "label3";
  113. this.label3.Size = new System.Drawing.Size(53, 12);
  114. this.label3.TabIndex = 4;
  115. //
  116. // comboBox1
  117. //
  118. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  119. this.comboBox1.FormattingEnabled = true;
  120. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  121. this.comboBox1.Name = "comboBox1";
  122. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  123. this.comboBox1.TabIndex = 1;
  124. //
  125. // numericUpDown1
  126. //
  127. this.numericUpDown1.Location = new System.Drawing.Point(84, 31);
  128. this.numericUpDown1.Name = "numericUpDown1";
  129. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  130. this.numericUpDown1.TabIndex = 11;
  131. //
  132. // panel1
  133. //
  134. this.panel1.Location = new System.Drawing.Point(84, 57);
  135. this.panel1.Name = "panel1";
  136. this.panel1.Size = new System.Drawing.Size(152, 20);
  137. this.panel1.TabIndex = 5;
  138. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  139. //
  140. // LabelArrowTwoWayControl
  141. //
  142. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  143. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  144. this.Controls.Add(this.numericUpDown1);
  145. this.Controls.Add(this.panel1);
  146. this.Controls.Add(this.comboBox1);
  147. this.Controls.Add(this.label1);
  148. this.Controls.Add(this.label2);
  149. this.Controls.Add(this.label3);
  150. this.Name = "LabelArrowTwoWayControl";
  151. this.Size = new System.Drawing.Size(490, 205);
  152. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  153. this.ResumeLayout(false);
  154. this.PerformLayout();
  155. }
  156. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  157. {
  158. }
  159. /// <summary>
  160. /// 画板点击
  161. /// </summary>
  162. /// <param name="sender"></param>
  163. /// <param name="e"></param>
  164. private void panel1_Click(object sender, EventArgs e)
  165. {
  166. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  167. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  168. this.colorsForm.ShowDialog();
  169. }
  170. private void panel1Changed(object sender, EventArgs e)
  171. {
  172. this.panel1.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  173. this.colorsForm.Close();
  174. }
  175. }
  176. }