123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- 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
- {
- /// <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 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();
- }
- /// <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();
- }
- #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();
- 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);
- }
- }
- }
- }
|