CommonCameraControl.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. using System.Collections;
  12. using TUCamera;
  13. using PaintDotNet.ImageCollect.CameraComponent;
  14. namespace PaintDotNet.Setting.LabelComponent
  15. {
  16. /// <summary>
  17. /// 相机设置,常规界面
  18. /// </summary>
  19. public class CommonCameraControl : UserControl
  20. {
  21. #region 控件
  22. private GroupBox gbxShadingCorrection;
  23. public CheckBox ckbShadingCorrect;
  24. private GroupBox gbxSharpening;
  25. private Label label2;
  26. private TrackBar tbrSharpness;
  27. private TextBox tbxSharpness;
  28. #endregion
  29. /// <summary>
  30. /// 相机参数的Model
  31. /// </summary>
  32. private CameraParamModel m_cameraParamModel;
  33. private TUCamera.TUCamera m_camera;
  34. private CommonRotateControl commonRotateControl1;
  35. private bool m_immediately = false; // 设置是否立刻生效,设置到相机
  36. public CommonCameraControl()
  37. {
  38. InitializeComponent();
  39. }
  40. public CommonCameraControl(CameraParamModel model, bool immediately = true)
  41. {
  42. m_immediately = immediately;
  43. m_cameraParamModel = model;
  44. m_camera = TUCameraManager.GetInstance().GetCurrentCamera();
  45. InitializeComponent();
  46. InitializeLanguageText();
  47. InitializeData();
  48. }
  49. public void ResetCameraParamModel(CameraParamModel model)
  50. {
  51. m_cameraParamModel = model;
  52. InitializeData();
  53. }
  54. /// <summary>
  55. /// 绑定样式数据
  56. /// </summary>
  57. private void InitializeData()
  58. {
  59. tbrSharpness.SetRange(0, 160);
  60. tbrSharpness.Value = m_cameraParamModel.parame.Sharpness;
  61. tbxSharpness.Text = m_cameraParamModel.parame.Sharpness.ToString();
  62. ckbShadingCorrect.Checked = m_cameraParamModel.parame.ShadingCorrection == 1;
  63. this.commonRotateControl1.Initialize(m_cameraParamModel, true);
  64. }
  65. #region 初始化组件
  66. private void InitializeLanguageText()
  67. {
  68. this.gbxShadingCorrection.Text = PdnResources.GetString("Menu.Image.ShadingCorrection.Text");
  69. this.ckbShadingCorrect.Text = PdnResources.GetString("Menu.use.text");
  70. this.gbxSharpening.Text = PdnResources.GetString("Menu.Imagesharpening.text");
  71. this.label2.Text = PdnResources.GetString("Menu.Sharpeningstrength.text") + ":";
  72. }
  73. /// <summary>
  74. /// 初始化组件
  75. /// </summary>
  76. private void InitializeComponent()
  77. {
  78. this.gbxShadingCorrection = new System.Windows.Forms.GroupBox();
  79. this.ckbShadingCorrect = new System.Windows.Forms.CheckBox();
  80. this.gbxSharpening = new System.Windows.Forms.GroupBox();
  81. this.tbxSharpness = new System.Windows.Forms.TextBox();
  82. commonRotateControl1 = new CommonRotateControl();
  83. this.label2 = new System.Windows.Forms.Label();
  84. this.tbrSharpness = new System.Windows.Forms.TrackBar();
  85. this.gbxShadingCorrection.SuspendLayout();
  86. this.gbxSharpening.SuspendLayout();
  87. ((System.ComponentModel.ISupportInitialize)(this.tbrSharpness)).BeginInit();
  88. this.SuspendLayout();
  89. //
  90. // gbxShadingCorrection
  91. //
  92. this.gbxShadingCorrection.Controls.Add(this.ckbShadingCorrect);
  93. this.gbxShadingCorrection.Dock = System.Windows.Forms.DockStyle.Top;
  94. this.gbxShadingCorrection.Location = new System.Drawing.Point(8, 172);
  95. this.gbxShadingCorrection.Name = "gbxShadingCorrection";
  96. this.gbxShadingCorrection.Size = new System.Drawing.Size(474, 74);
  97. this.gbxShadingCorrection.TabIndex = 2;
  98. this.gbxShadingCorrection.TabStop = false;
  99. this.gbxShadingCorrection.Text = "阴影校正";
  100. //
  101. // ckbShadingCorrect
  102. //
  103. this.ckbShadingCorrect.AutoSize = true;
  104. this.ckbShadingCorrect.Location = new System.Drawing.Point(24, 37);
  105. this.ckbShadingCorrect.Name = "ckbShadingCorrect";
  106. this.ckbShadingCorrect.Size = new System.Drawing.Size(48, 16);
  107. this.ckbShadingCorrect.TabIndex = 2;
  108. this.ckbShadingCorrect.Text = "使用";
  109. this.ckbShadingCorrect.UseVisualStyleBackColor = true;
  110. this.ckbShadingCorrect.Click += new System.EventHandler(this.ckbShadingCorrect_Click);
  111. //
  112. // gbxSharpening
  113. //
  114. this.gbxSharpening.Controls.Add(this.tbxSharpness);
  115. this.gbxSharpening.Controls.Add(this.label2);
  116. this.gbxSharpening.Controls.Add(this.tbrSharpness);
  117. this.gbxSharpening.Dock = System.Windows.Forms.DockStyle.Top;
  118. this.gbxSharpening.Location = new System.Drawing.Point(8, 98);
  119. this.gbxSharpening.Name = "gbxSharpening";
  120. this.gbxSharpening.Size = new System.Drawing.Size(474, 74);
  121. this.gbxSharpening.TabIndex = 3;
  122. this.gbxSharpening.TabStop = false;
  123. this.gbxSharpening.Text = "图像锐化";
  124. //
  125. // tbxSharpness
  126. //
  127. this.tbxSharpness.Location = new System.Drawing.Point(382, 34);
  128. this.tbxSharpness.Name = "tbxSharpness";
  129. this.tbxSharpness.ReadOnly = true;
  130. this.tbxSharpness.Size = new System.Drawing.Size(55, 21);
  131. this.tbxSharpness.TabIndex = 5;
  132. this.tbxSharpness.Text = "5";
  133. //
  134. // label2
  135. //
  136. this.label2.AutoSize = true;
  137. this.label2.Location = new System.Drawing.Point(22, 35);
  138. this.label2.Name = "label2";
  139. this.label2.Size = new System.Drawing.Size(65, 12);
  140. this.label2.TabIndex = 4;
  141. this.label2.Text = "锐化强度:";
  142. //
  143. // tbrSharpness
  144. //
  145. this.tbrSharpness.AutoSize = false;
  146. this.tbrSharpness.Location = new System.Drawing.Point(81, 33);
  147. this.tbrSharpness.Maximum = 200;
  148. this.tbrSharpness.Minimum = 5;
  149. this.tbrSharpness.Name = "tbrSharpness";
  150. this.tbrSharpness.Size = new System.Drawing.Size(295, 35);
  151. this.tbrSharpness.TabIndex = 2;
  152. this.tbrSharpness.TickStyle = System.Windows.Forms.TickStyle.None;
  153. this.tbrSharpness.Value = 5;
  154. this.tbrSharpness.Scroll += new System.EventHandler(this.tbrSharpness_Scroll);
  155. //
  156. // commonRotateControl1
  157. //
  158. this.commonRotateControl1.Dock = System.Windows.Forms.DockStyle.Top;
  159. this.commonRotateControl1.Location = new System.Drawing.Point(8, 8);
  160. this.commonRotateControl1.Name = "commonRotateControl1";
  161. this.commonRotateControl1.Size = new System.Drawing.Size(474, 90);
  162. this.commonRotateControl1.TabIndex = 4;
  163. //
  164. // CommonCameraControl
  165. //
  166. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  167. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  168. this.AutoSize = true;
  169. this.Controls.Add(this.gbxShadingCorrection);
  170. this.Controls.Add(this.gbxSharpening);
  171. this.Controls.Add(this.commonRotateControl1);
  172. this.Name = "CommonCameraControl";
  173. this.Padding = new System.Windows.Forms.Padding(8);
  174. this.Size = new System.Drawing.Size(490, 338);
  175. this.gbxShadingCorrection.ResumeLayout(false);
  176. this.gbxShadingCorrection.PerformLayout();
  177. this.gbxSharpening.ResumeLayout(false);
  178. this.gbxSharpening.PerformLayout();
  179. ((System.ComponentModel.ISupportInitialize)(this.tbrSharpness)).EndInit();
  180. this.ResumeLayout(false);
  181. }
  182. #endregion
  183. private void tbrSharpness_Scroll(object sender, EventArgs e)
  184. {
  185. m_camera.SetSharpness(tbrSharpness.Value);
  186. m_cameraParamModel.parame.Sharpness = tbrSharpness.Value;
  187. tbxSharpness.Text = tbrSharpness.Value.ToString();
  188. }
  189. private void ckbShadingCorrect_Click(object sender, EventArgs e)
  190. {
  191. m_cameraParamModel.parame.ShadingCorrection = ckbShadingCorrect.Checked ? 1 : 0;
  192. }
  193. }
  194. }