123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PaintDotNet.Base.SettingModel;
- using System.Collections;
- using TUCamera;
- using PaintDotNet.ImageCollect.CameraComponent;
- namespace PaintDotNet.Setting.LabelComponent
- {
- /// <summary>
- /// 相机设置,常规界面
- /// </summary>
- public class CommonCameraControl : UserControl
- {
- #region 控件
- private GroupBox gbxShadingCorrection;
- public CheckBox ckbShadingCorrect;
- private GroupBox gbxSharpening;
- private Label label2;
- private TrackBar tbrSharpness;
- private TextBox tbxSharpness;
- #endregion
- /// <summary>
- /// 相机参数的Model
- /// </summary>
- private CameraParamModel m_cameraParamModel;
- private TUCamera.TUCamera m_camera;
- private CommonRotateControl commonRotateControl1;
- private bool m_immediately = false; // 设置是否立刻生效,设置到相机
- public CommonCameraControl()
- {
- InitializeComponent();
- }
- public CommonCameraControl(CameraParamModel model, bool immediately = true)
- {
- m_immediately = immediately;
- m_cameraParamModel = model;
- m_camera = TUCameraManager.GetInstance().GetCurrentCamera();
- InitializeComponent();
- InitializeLanguageText();
- InitializeData();
- }
- public void ResetCameraParamModel(CameraParamModel model)
- {
- m_cameraParamModel = model;
- InitializeData();
- }
- /// <summary>
- /// 绑定样式数据
- /// </summary>
- private void InitializeData()
- {
- tbrSharpness.SetRange(0, 160);
- tbrSharpness.Value = m_cameraParamModel.parame.Sharpness;
- tbxSharpness.Text = m_cameraParamModel.parame.Sharpness.ToString();
- ckbShadingCorrect.Checked = m_cameraParamModel.parame.ShadingCorrection == 1;
- this.commonRotateControl1.Initialize(m_cameraParamModel, true);
- }
- #region 初始化组件
- private void InitializeLanguageText()
- {
- this.gbxShadingCorrection.Text = PdnResources.GetString("Menu.Image.ShadingCorrection.Text");
- this.ckbShadingCorrect.Text = PdnResources.GetString("Menu.use.text");
- this.gbxSharpening.Text = PdnResources.GetString("Menu.Imagesharpening.text");
- this.label2.Text = PdnResources.GetString("Menu.Sharpeningstrength.text") + ":";
- }
- /// <summary>
- /// 初始化组件
- /// </summary>
- private void InitializeComponent()
- {
- this.gbxShadingCorrection = new System.Windows.Forms.GroupBox();
- this.ckbShadingCorrect = new System.Windows.Forms.CheckBox();
- this.gbxSharpening = new System.Windows.Forms.GroupBox();
- this.tbxSharpness = new System.Windows.Forms.TextBox();
- commonRotateControl1 = new CommonRotateControl();
- this.label2 = new System.Windows.Forms.Label();
- this.tbrSharpness = new System.Windows.Forms.TrackBar();
- this.gbxShadingCorrection.SuspendLayout();
- this.gbxSharpening.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.tbrSharpness)).BeginInit();
- this.SuspendLayout();
- //
- // gbxShadingCorrection
- //
- this.gbxShadingCorrection.Controls.Add(this.ckbShadingCorrect);
- this.gbxShadingCorrection.Dock = System.Windows.Forms.DockStyle.Top;
- this.gbxShadingCorrection.Location = new System.Drawing.Point(8, 172);
- this.gbxShadingCorrection.Name = "gbxShadingCorrection";
- this.gbxShadingCorrection.Size = new System.Drawing.Size(474, 74);
- this.gbxShadingCorrection.TabIndex = 2;
- this.gbxShadingCorrection.TabStop = false;
- this.gbxShadingCorrection.Text = "阴影校正";
- //
- // ckbShadingCorrect
- //
- this.ckbShadingCorrect.AutoSize = true;
- this.ckbShadingCorrect.Location = new System.Drawing.Point(24, 37);
- this.ckbShadingCorrect.Name = "ckbShadingCorrect";
- this.ckbShadingCorrect.Size = new System.Drawing.Size(48, 16);
- this.ckbShadingCorrect.TabIndex = 2;
- this.ckbShadingCorrect.Text = "使用";
- this.ckbShadingCorrect.UseVisualStyleBackColor = true;
- this.ckbShadingCorrect.Click += new System.EventHandler(this.ckbShadingCorrect_Click);
- //
- // gbxSharpening
- //
- this.gbxSharpening.Controls.Add(this.tbxSharpness);
- this.gbxSharpening.Controls.Add(this.label2);
- this.gbxSharpening.Controls.Add(this.tbrSharpness);
- this.gbxSharpening.Dock = System.Windows.Forms.DockStyle.Top;
- this.gbxSharpening.Location = new System.Drawing.Point(8, 98);
- this.gbxSharpening.Name = "gbxSharpening";
- this.gbxSharpening.Size = new System.Drawing.Size(474, 74);
- this.gbxSharpening.TabIndex = 3;
- this.gbxSharpening.TabStop = false;
- this.gbxSharpening.Text = "图像锐化";
- //
- // tbxSharpness
- //
- this.tbxSharpness.Location = new System.Drawing.Point(382, 34);
- this.tbxSharpness.Name = "tbxSharpness";
- this.tbxSharpness.ReadOnly = true;
- this.tbxSharpness.Size = new System.Drawing.Size(55, 21);
- this.tbxSharpness.TabIndex = 5;
- this.tbxSharpness.Text = "5";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(22, 35);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 4;
- this.label2.Text = "锐化强度:";
- //
- // tbrSharpness
- //
- this.tbrSharpness.AutoSize = false;
- this.tbrSharpness.Location = new System.Drawing.Point(81, 33);
- this.tbrSharpness.Maximum = 200;
- this.tbrSharpness.Minimum = 5;
- this.tbrSharpness.Name = "tbrSharpness";
- this.tbrSharpness.Size = new System.Drawing.Size(295, 35);
- this.tbrSharpness.TabIndex = 2;
- this.tbrSharpness.TickStyle = System.Windows.Forms.TickStyle.None;
- this.tbrSharpness.Value = 5;
- this.tbrSharpness.Scroll += new System.EventHandler(this.tbrSharpness_Scroll);
- //
- // commonRotateControl1
- //
- this.commonRotateControl1.Dock = System.Windows.Forms.DockStyle.Top;
- this.commonRotateControl1.Location = new System.Drawing.Point(8, 8);
- this.commonRotateControl1.Name = "commonRotateControl1";
- this.commonRotateControl1.Size = new System.Drawing.Size(474, 90);
- this.commonRotateControl1.TabIndex = 4;
- //
- // CommonCameraControl
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.AutoSize = true;
- this.Controls.Add(this.gbxShadingCorrection);
- this.Controls.Add(this.gbxSharpening);
- this.Controls.Add(this.commonRotateControl1);
- this.Name = "CommonCameraControl";
- this.Padding = new System.Windows.Forms.Padding(8);
- this.Size = new System.Drawing.Size(490, 338);
- this.gbxShadingCorrection.ResumeLayout(false);
- this.gbxShadingCorrection.PerformLayout();
- this.gbxSharpening.ResumeLayout(false);
- this.gbxSharpening.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.tbrSharpness)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private void tbrSharpness_Scroll(object sender, EventArgs e)
- {
- m_camera.SetSharpness(tbrSharpness.Value);
- m_cameraParamModel.parame.Sharpness = tbrSharpness.Value;
- tbxSharpness.Text = tbrSharpness.Value.ToString();
- }
- private void ckbShadingCorrect_Click(object sender, EventArgs e)
- {
- m_cameraParamModel.parame.ShadingCorrection = ckbShadingCorrect.Checked ? 1 : 0;
- }
- }
- }
|