123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- 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;
- namespace PaintDotNet.Preview2
- {
- /// <summary>
- /// 相机设置,常规界面
- /// </summary>
- public class OtherControl : UserControl
- {
- #region 控件
- private GroupBox gbxShadingCorrection;
- private GroupBox gbxSharpening;
- #endregion
- /// <summary>
- /// 相机参数的Model
- /// </summary>
- private CameraParamModel.ParameterSets _settings
- {
- get
- {
- return CameraConfigs.Settings;
- }
- }
- private ICamera m_camera => CameraManager.CurrentCamera;
- private CameraParamBar2 pmbSharpness;
- private Button btnCapTempl;
- private CheckBox checkBox1;
- private RadioButton radioButton2;
- private Button button1;
- private Panel panel1;
- private RadioButton radioButton1;
- public OtherControl()
- {
- InitializeComponent();
- }
- public void Initialize()
- {
- InitializeLanguageText();
- InitializeData();
- }
- /// <summary>
- /// 绑定样式数据
- /// </summary>
- private void InitializeData()
- {
- if (m_camera.IsOpen())
- {
- Range range = m_camera.GetSharpnessRange();
- pmbSharpness.DecimalPalces = 0;
- pmbSharpness.Max = (int)range.Max;
- pmbSharpness.Min = (int)range.Min;
- pmbSharpness.Value = _settings.Sharpness;
- pmbSharpness.OnValueChange += (value) => { m_camera.Sharpness = value; };
- UpdateSettings();
- }
- checkBox1.Checked = Preview2Context.ShandingCorrectionState != 0;
- radioButton1.Checked = Preview2Context.ShandingCorrectionState == 1;
- radioButton2.Checked = Preview2Context.ShandingCorrectionState == 2;
- }
- public void UpdateSettings()
- {
- checkBox1.Checked = _settings.FlatFieldCorrection != 0;
- checkBox1_CheckedChanged(null, null);
- radioButton1.Checked = _settings.FlatFieldCorrection == 1;
- radioButton2.Checked = _settings.FlatFieldCorrection == 2;
- radioButton2_CheckedChanged(null, null);
- }
- #region 初始化组件
- private void InitializeLanguageText()
- {
- this.gbxShadingCorrection.Text = PdnResources.GetString("Menu.Image.ShadingCorrection.Text");
- this.gbxSharpening.Text = PdnResources.GetString("Menu.Imagesharpening.text");
- pmbSharpness.Caption = PdnResources.GetString("Menu.Sharpeningstrength.text");
- this.checkBox1.Text = PdnResources.GetString("Preview2.EnableShadowCorrection");
- this.radioButton2.Text =PdnResources.GetString("Preview2.CameraCorrection");
- this.radioButton1.Text = PdnResources.GetString("Preview2.SoftwareCorrection");
- this.button1.Text = PdnResources.GetString("Menu.compute.text");
- this.btnCapTempl.Text = PdnResources.GetString("Preview2.ShootingCorrectionTemplate");
- }
- /// <summary>
- /// 初始化组件
- /// </summary>
- private void InitializeComponent()
- {
- this.gbxShadingCorrection = new System.Windows.Forms.GroupBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.button1 = new System.Windows.Forms.Button();
- this.btnCapTempl = new System.Windows.Forms.Button();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.gbxSharpening = new System.Windows.Forms.GroupBox();
- this.pmbSharpness = new PaintDotNet.Preview2.CameraParamBar2();
- this.gbxShadingCorrection.SuspendLayout();
- this.panel1.SuspendLayout();
- this.gbxSharpening.SuspendLayout();
- this.SuspendLayout();
- //
- // gbxShadingCorrection
- //
- this.gbxShadingCorrection.Controls.Add(this.panel1);
- this.gbxShadingCorrection.Controls.Add(this.checkBox1);
- this.gbxShadingCorrection.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.gbxShadingCorrection.Location = new System.Drawing.Point(0, 67);
- this.gbxShadingCorrection.Name = "gbxShadingCorrection";
- this.gbxShadingCorrection.Size = new System.Drawing.Size(470, 95);
- this.gbxShadingCorrection.TabIndex = 2;
- this.gbxShadingCorrection.TabStop = false;
- this.gbxShadingCorrection.Text = "阴影校正";
- //
- // panel1
- //
- this.panel1.Controls.Add(this.button1);
- this.panel1.Controls.Add(this.btnCapTempl);
- this.panel1.Controls.Add(this.radioButton2);
- this.panel1.Controls.Add(this.radioButton1);
- this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.panel1.Location = new System.Drawing.Point(3, 42);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(464, 50);
- this.panel1.TabIndex = 6;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(221, 26);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(59, 23);
- this.button1.TabIndex = 5;
- this.button1.Text = "计算";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // btnCapTempl
- //
- this.btnCapTempl.Location = new System.Drawing.Point(103, 26);
- this.btnCapTempl.Name = "btnCapTempl";
- this.btnCapTempl.Size = new System.Drawing.Size(112, 23);
- this.btnCapTempl.TabIndex = 2;
- this.btnCapTempl.Text = "拍摄校正模板";
- this.btnCapTempl.UseVisualStyleBackColor = true;
- this.btnCapTempl.Click += new System.EventHandler(this.btnCapTempl_Click);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(26, 29);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(71, 16);
- this.radioButton2.TabIndex = 4;
- this.radioButton2.Text = "相机校正";
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(26, 7);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(71, 16);
- this.radioButton1.TabIndex = 4;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "软件校正";
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(18, 20);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(96, 16);
- this.checkBox1.TabIndex = 3;
- this.checkBox1.Text = "启用阴影校正";
- this.checkBox1.UseVisualStyleBackColor = true;
- this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
- this.checkBox1.Click += new System.EventHandler(this.checkBox1_Click);
- //
- // gbxSharpening
- //
- this.gbxSharpening.Controls.Add(this.pmbSharpness);
- this.gbxSharpening.Dock = System.Windows.Forms.DockStyle.Top;
- this.gbxSharpening.Location = new System.Drawing.Point(0, 8);
- this.gbxSharpening.Name = "gbxSharpening";
- this.gbxSharpening.Padding = new System.Windows.Forms.Padding(4);
- this.gbxSharpening.Size = new System.Drawing.Size(470, 52);
- this.gbxSharpening.TabIndex = 3;
- this.gbxSharpening.TabStop = false;
- this.gbxSharpening.Text = "图像锐化";
- //
- // pmbSharpness
- //
- this.pmbSharpness.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- this.pmbSharpness.Caption = "锐化强度";
- this.pmbSharpness.DecimalPalces = -1;
- this.pmbSharpness.Dock = System.Windows.Forms.DockStyle.Top;
- this.pmbSharpness.IsFloat = false;
- this.pmbSharpness.IsRangeVisible = false;
- this.pmbSharpness.Location = new System.Drawing.Point(4, 18);
- this.pmbSharpness.Max = 100;
- this.pmbSharpness.Min = 0;
- this.pmbSharpness.Name = "pmbSharpness";
- this.pmbSharpness.Padding = new System.Windows.Forms.Padding(4);
- this.pmbSharpness.Size = new System.Drawing.Size(462, 26);
- this.pmbSharpness.TabIndex = 0;
- this.pmbSharpness.Value = 0;
- //
- // OtherControl
- //
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
- this.Controls.Add(this.gbxShadingCorrection);
- this.Controls.Add(this.gbxSharpening);
- this.Name = "OtherControl";
- this.Padding = new System.Windows.Forms.Padding(0, 8, 0, 0);
- this.Size = new System.Drawing.Size(470, 162);
- this.gbxShadingCorrection.ResumeLayout(false);
- this.gbxShadingCorrection.PerformLayout();
- this.panel1.ResumeLayout(false);
- this.panel1.PerformLayout();
- this.gbxSharpening.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private void metroButton1_Click(object sender, EventArgs e)
- {
- }
- private void btnCapTempl_Click(object sender, EventArgs e)
- {
- m_camera.FlatCapture();
- }
- private void radioButton2_Click(object sender, EventArgs e)
- {
- m_camera.FlatCorretion = 1;
- Preview2Context.ShandingCorrectionState = 2;
- }
- private void radioButton1_Click(object sender, EventArgs e)
- {
- m_camera.FlatCorretion = 0;
- Preview2Context.ShandingCorrectionState = 1;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- m_camera.FlatCalculate();
- Preview2Context.ShandingCorrectionState = 2;
- }
- private void checkBox1_Click(object sender, EventArgs e)
- {
- if (checkBox1.Checked)
- {
- if (radioButton1.Checked)
- { Preview2Context.ShandingCorrectionState = 1; }
- else if (radioButton2.Checked)
- {
- Preview2Context.ShandingCorrectionState = 0;
- m_camera.FlatCorretion = 1;
- }
- }
- else
- {
- Preview2Context.ShandingCorrectionState = 0;
- m_camera.FlatCorretion = 0;
- }
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- panel1.Enabled = checkBox1.Checked;
- }
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- btnCapTempl.Enabled = radioButton2.Checked;
- button1.Enabled = radioButton2.Checked;
- }
- }
- }
|