LabelMarkPointControl.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 PaintDotNet.Base.SettingModel;
  11. namespace PaintDotNet.Setting.LabelComponent
  12. {
  13. /// <summary>
  14. /// 标注设置-标记设置->点标记
  15. /// </summary>
  16. public class LabelMarkPointControl : UserControl
  17. {
  18. #region 控件
  19. private System.Windows.Forms.Label label1;
  20. private System.Windows.Forms.Label label2;
  21. private System.Windows.Forms.ComboBox comboBox1;
  22. private System.Windows.Forms.Panel panel1;
  23. #endregion
  24. /// <summary>
  25. /// 点标记样式
  26. /// </summary>
  27. private LabelStyleModel.PointMark model;
  28. PaintDotNet.ColorsForm colorsForm1;
  29. /// <summary>
  30. /// 点样式下拉选
  31. /// </summary>
  32. // string[] pointStyle = new string[] { PdnResources.GetString("Menu.LabelAction.ArrowAction.Text")
  33. // , PdnResources.GetString("Menu.Set.Labelsettings.Dots.text")
  34. // , PdnResources.GetString("Menu.Set.Labelsettings.triangle.text") };
  35. public LabelMarkPointControl(LabelStyleModel.PointMark model)
  36. {
  37. this.model = model;
  38. InitializeComponent();
  39. InitializeControlData();
  40. InitializeData();
  41. }
  42. /// <summary>
  43. /// 获取当前页面model值
  44. /// </summary>
  45. /// <returns></returns>
  46. public LabelStyleModel.PointMark getNowModel(LabelStyleModel.PointMark model)
  47. {
  48. model.pointStyle = this.comboBox1.SelectedIndex.ToString();
  49. model.pointColor = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  50. return model;
  51. }
  52. /// <summary>
  53. /// 设置下拉等数据源
  54. /// </summary>
  55. private void InitializeControlData()
  56. {
  57. //绑定点样式下拉选
  58. this.comboBox1.DataSource = new BindingSource(InvariantData.someStyle, null);
  59. this.comboBox1.DisplayMember = "Value";
  60. this.comboBox1.ValueMember = "Key";
  61. //this.comboBox1.DataSource = pointStyle;
  62. }
  63. /// <summary>
  64. /// 绑定样式数据
  65. /// </summary>
  66. private void InitializeData()
  67. {
  68. this.comboBox1.SelectedIndex = int.Parse(this.model.pointStyle);
  69. this.panel1.BackColor = Color.FromArgb(this.model.pointColor);
  70. }
  71. private void InitializeComponent()
  72. {
  73. this.comboBox1 = new System.Windows.Forms.ComboBox();
  74. this.label1 = new System.Windows.Forms.Label();
  75. this.label2 = new System.Windows.Forms.Label();
  76. this.panel1 = new System.Windows.Forms.Panel();
  77. this.SuspendLayout();
  78. //
  79. // comboBox1
  80. //
  81. this.comboBox1.FormattingEnabled = true;
  82. this.comboBox1.Location = new System.Drawing.Point(84, 4);
  83. this.comboBox1.Name = "comboBox1";
  84. this.comboBox1.Size = new System.Drawing.Size(152, 20);
  85. this.comboBox1.TabIndex = 1;
  86. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  87. //
  88. // label1
  89. //
  90. this.label1.AutoSize = true;
  91. this.label1.Location = new System.Drawing.Point(4, 8);
  92. this.label1.Name = "label1";
  93. this.label1.Size = new System.Drawing.Size(65, 12);
  94. this.label1.TabIndex = 0;
  95. this.label1.Text = PdnResources.GetString("Menu.Set.Labelsettings.Pointstyle.text")+":";
  96. //
  97. // label2
  98. //
  99. this.label2.AutoSize = true;
  100. this.label2.Location = new System.Drawing.Point(6, 34);
  101. this.label2.Name = "label2";
  102. this.label2.Size = new System.Drawing.Size(65, 12);
  103. this.label2.TabIndex = 2;
  104. this.label2.Text = PdnResources.GetString("Menu.Set.Labelsettings.Pointcolor.text")+":";
  105. //
  106. // panel1
  107. //
  108. this.panel1.Location = new System.Drawing.Point(84, 31);
  109. this.panel1.Name = "panel1";
  110. this.panel1.Size = new System.Drawing.Size(152, 20);
  111. this.panel1.TabIndex = 5;
  112. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  113. //
  114. // LabelMarkPointControl
  115. //
  116. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  117. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  118. this.Controls.Add(this.panel1);
  119. this.Controls.Add(this.comboBox1);
  120. this.Controls.Add(this.label1);
  121. this.Controls.Add(this.label2);
  122. this.Name = "LabelMarkPointControl";
  123. this.Size = new System.Drawing.Size(490, 205);
  124. this.ResumeLayout(false);
  125. this.PerformLayout();
  126. this.colorsForm1 = new ColorsForm();
  127. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  128. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  129. }
  130. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  131. {
  132. }
  133. /// <summary>
  134. /// panel1画板点击
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void panel1_Click(object sender, EventArgs e)
  139. {
  140. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  141. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  142. this.colorsForm1.ShowDialog();
  143. }
  144. private void panel1Changed(object sender, EventArgs e)
  145. {
  146. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  147. this.colorsForm1.Close();
  148. }
  149. }
  150. }