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 PaintDotNet.ImageCollect;
using PaintDotNet.Camera;
using PaintDotNet.Base.CommTool;
using System.IO;
namespace PaintDotNet.Setting.LabelComponent
{
///
/// 相机设置,常规界面
///
public class CommonCameraControl : UserControl
{
#region 控件
private GroupBox gbxShadingCorrection;
public CheckBox ckbShadingCorrect;
private GroupBox gbxSharpening;
private Label label2;
private TrackBar tbrSharpness;
private TextBox tbxSharpness;
#endregion
///
/// 相机参数的Model
///
private CameraParamModel m_cameraParamModel;
private ICamera m_camera;
private CommonRotateControl commonRotateControl1;
private GroupBox groupBox1;
private Panel panel1;
private TextBox txbNameEx;
private Label lblName;
private bool m_immediately = false; // 设置是否立刻生效,设置到相机
public CommonCameraControl()
{
InitializeComponent();
ConfigModel.OnCameraNameExChanged += OnCameraNameChanged;
}
protected override void Dispose(bool disposing)
{
ConfigModel.OnCameraNameExChanged -= OnCameraNameChanged;
base.Dispose(disposing);
}
private void OnCameraNameChanged()
{
txbNameEx.Text = m_camera.GetExofName();
}
public void Initialize(CameraParamModel model, bool immediately = true)
{
m_immediately = immediately;
m_cameraParamModel = model;
m_camera = CameraManager.CurrentCamera;
InitializeLanguageText();
InitializeData();
OnCameraNameChanged();
}
public void ResetCameraParamModel(CameraParamModel model)
{
m_cameraParamModel = model;
InitializeData();
}
///
/// 绑定样式数据
///
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();
}
#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") + ":";
}
///
/// 初始化组件
///
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();
this.label2 = new System.Windows.Forms.Label();
this.tbrSharpness = new System.Windows.Forms.TrackBar();
this.commonRotateControl1 = new PaintDotNet.ImageCollect.CommonRotateControl();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.txbNameEx = new System.Windows.Forms.TextBox();
this.lblName = new System.Windows.Forms.Label();
this.gbxShadingCorrection.SuspendLayout();
this.gbxSharpening.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tbrSharpness)).BeginInit();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
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;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(8, 246);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(8, 12, 8, 8);
this.groupBox1.Size = new System.Drawing.Size(474, 55);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "相机名称";
//
// panel1
//
this.panel1.Controls.Add(this.txbNameEx);
this.panel1.Controls.Add(this.lblName);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(8, 26);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(458, 21);
this.panel1.TabIndex = 0;
//
// txbNameEx
//
this.txbNameEx.Dock = System.Windows.Forms.DockStyle.Left;
this.txbNameEx.Location = new System.Drawing.Point(41, 0);
this.txbNameEx.Name = "txbNameEx";
this.txbNameEx.Size = new System.Drawing.Size(123, 21);
this.txbNameEx.TabIndex = 2;
this.txbNameEx.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txbNameEx_KeyDown);
//
// lblName
//
this.lblName.AutoSize = true;
this.lblName.Dock = System.Windows.Forms.DockStyle.Left;
this.lblName.Location = new System.Drawing.Point(0, 0);
this.lblName.Name = "lblName";
this.lblName.Padding = new System.Windows.Forms.Padding(0, 4, 0, 0);
this.lblName.Size = new System.Drawing.Size(41, 16);
this.lblName.TabIndex = 3;
this.lblName.Text = "别名:";
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// CommonCameraControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.Controls.Add(this.groupBox1);
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.groupBox1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void tbrSharpness_Scroll(object sender, EventArgs e)
{
m_camera.Sharpness = 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;
}
string _cameraNameEx;
private void txbNameEx_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
var nameEx = txbNameEx.Text;
m_camera.SetExofName(nameEx);
}
}
}
}