123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.Setting
- {
- /// <summary>
- /// 相机维护
- /// </summary>
- public partial class CameraSettingsAddDialog : Form
- {
- #region 控件
- private Label label2;
- private TextBox textBox1;
- private TextBox textBox2;
- private Label label1;
- private Label label5;
- private Button button1;
- private Button button2;
- #endregion
- private string pointId = string.Empty;
- private ListView fatherListView;
- private Label label4;
- private int listIndex = 0;
- public CameraSettingsAddDialog(string id, ListView listView, int index = 0)
- {
- StartPosition = FormStartPosition.CenterScreen;
- InitializeComponent();
- InitializeLanguageText();
- #region [展示控件]
- pointId = id;
- fatherListView = listView;
- listIndex = index;
- if (!string.IsNullOrEmpty(pointId))
- {
- var point = mic_camerasettings_BLL.FindDefault(Convert.ToInt32(pointId));
- if (point == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
- }
- textBox1.Text = point.camera_model;
- textBox2.Text = point.pixel_size;
- //textBox3.Text = point.resolution;
- }
- #endregion
- }
- #region 初始化
- private void InitializeLanguageText()
- {
- this.label1.Text = PdnResources.GetString("Menu.Cameramodel.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.PixelSize.text") + ":";
- //this.label3.Text = PdnResources.GetString("Menu.Set.Generalsettings.Sidelengthresolution.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Micron.text");
- this.button1.Text = PdnResources.GetString("Menu.ensure.text");
- this.button2.Text = PdnResources.GetString("Menu.cancel.text");
- this.Text = PdnResources.GetString("Menu.Set.Generalsettings.Cameramaintenance.text");
- }
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.label4 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(20, 43);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "相机型号:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(8, 75);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(77, 12);
- this.label2.TabIndex = 1;
- this.label2.Text = "像素点尺寸:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(81, 40);
- this.textBox1.MaxLength = 10;
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(160, 21);
- this.textBox1.TabIndex = 3;
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(81, 72);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(160, 21);
- this.textBox2.TabIndex = 4;
- this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(-1, 136);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(287, 12);
- this.label5.TabIndex = 7;
- this.label5.Text = "-----------------------------------------------";
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(98, 165);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(80, 30);
- this.button1.TabIndex = 8;
- this.button1.Text = "确定";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(189, 165);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(80, 30);
- this.button2.TabIndex = 9;
- this.button2.Text = "取消";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(247, 75);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(29, 12);
- this.label4.TabIndex = 10;
- this.label4.Text = "微米";
- //
- // CameraSettingsAddDialog
- //
- this.ClientSize = new System.Drawing.Size(284, 208);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "CameraSettingsAddDialog";
- this.Text = "相机维护";
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- /// <summary>
- /// 格式限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
- e.Handled = true;
- //小数点的处理
- if ((int)e.KeyChar == 46)
- {
- if (textBox2.Text.Length <= 0)
- e.Handled = true; //小数点不能在第一位
- else
- {
- float f;
- float oldf;
- bool b1 = false, b2 = false;
- b1 = float.TryParse(textBox2.Text, out oldf);
- b2 = float.TryParse(textBox2.Text + e.KeyChar.ToString(), out f);
- if (b2 == false)
- {
- if (b1 == true)
- e.Handled = true;
- else
- e.Handled = false;
- }
- }
- }
- }
- /// <summary>
- /// 格式限制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
- //{
- // if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
- // e.Handled = true;
- // //小数点的处理
- // if ((int)e.KeyChar == 46)
- // {
- // if (textBox3.Text.Length <= 0)
- // e.Handled = true; //小数点不能在第一位
- // else
- // {
- // float f;
- // float oldf;
- // bool b1 = false, b2 = false;
- // b1 = float.TryParse(textBox3.Text, out oldf);
- // b2 = float.TryParse(textBox3.Text + e.KeyChar.ToString(), out f);
- // if (b2 == false)
- // {
- // if (b1 == true)
- // e.Handled = true;
- // else
- // e.Handled = false;
- // }
- // }
- // }
- //}
- ///// <summary>
- ///// textbox1获得焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox1_Enter(object sender, EventArgs e)
- //{
- // if (textbox1HasText == false)
- // this.textBox1.Text = "";
- // this.textBox1.ForeColor = Color.Black;
- //}
- ///// <summary>
- ///// textbox1失去焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox1_Leave(object sender, EventArgs e)
- //{
- // if (this.textBox1.Text == "")
- // {
- // this.textBox1.Text = "请输入相机型号";
- // this.textBox1.ForeColor = Color.LightGray;
- // textbox1HasText = false;
- // }
- // else
- // textbox1HasText = true;
- //}
- ///// <summary>
- ///// textbox2获得焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox2_Enter(object sender, EventArgs e)
- //{
- // if (textbox2HasText == false)
- // this.textBox2.Text = "";
- // this.textBox2.ForeColor = Color.Black;
- //}
- ///// <summary>
- ///// textbox2失去焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox2_Leave(object sender, EventArgs e)
- //{
- // if (this.textBox2.Text == "")
- // {
- // this.textBox2.Text = "请输入感光软件边长";
- // this.textBox2.ForeColor = Color.LightGray;
- // textbox2HasText = false;
- // }
- // else
- // textbox2HasText = true;
- //}
- ///// <summary>
- ///// textbox3获得焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox3_Enter(object sender, EventArgs e)
- //{
- // if (textbox3HasText == false)
- // this.textBox3.Text = "";
- // this.textBox3.ForeColor = Color.Black;
- //}
- ///// <summary>
- ///// textbox3失去焦点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void Textbox3_Leave(object sender, EventArgs e)
- //{
- // if (this.textBox3.Text == "")
- // {
- // this.textBox3.Text = "请输入边长分辨率";
- // this.textBox3.ForeColor = Color.LightGray;
- // textbox3HasText = false;
- // }
- // else
- // textbox3HasText = true;
- //}
- /// <summary>
- /// 确认按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- var id = pointId;
- if (string.IsNullOrEmpty(textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Cameramodelplease.Text"));
- return;
- }
- else if (string.IsNullOrEmpty(textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthsidelengthofphotosensitiveso.Text"));
- return;
- }
- //else if (string.IsNullOrEmpty(textBox3.Text))
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.leaseenterthesidelengthr.Text"));
- // return;
- //}
- if (string.IsNullOrEmpty(id))
- {
- var point = new mic_camerasettings();
- point.delete_flag = 2;
- point.camera_model = textBox1.Text;
- point.pixel_size = textBox2.Text;
- //point.resolution = textBox3.Text;
- mic_camerasettings_BLL.Add(point);
- fatherListView.BeginUpdate();
- var lv = new ListViewItem();
- lv.Text = "2";
- lv.SubItems.Add("×");
- lv.SubItems.Add(point.camera_model);
- lv.SubItems.Add(point.pixel_size);
- //lv.SubItems.Add(point.resolution);
- lv.Tag = point.id;
- fatherListView.Items.Add(lv);
- fatherListView.EndUpdate();
- }
- else
- {
- var point = mic_camerasettings_BLL.FindDefault(Convert.ToInt32(pointId));
- var screenRulesId = config.Camera;
- if (point == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Abnormalinformatio.Text"));
- }
- point.camera_model = textBox1.Text;
- point.pixel_size = textBox2.Text;
- //point.resolution = textBox3.Text;
- mic_camerasettings_BLL.Update(point);
- fatherListView.BeginUpdate();
- var lv = fatherListView.Items[listIndex];
- lv.SubItems[1].Text = screenRulesId == int.Parse(id.ToString()) ? "√" : "×";
- lv.SubItems[2].Text = point.camera_model;
- lv.SubItems[3].Text = point.pixel_size;
- //lv.SubItems[4].Text = point.resolution;
- fatherListView.EndUpdate();
- }
- Close();
- }
- private ConfigModel config = Startup.instance.configModel;
- /// <summary>
- ///取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- Hide();
- }
- }
- }
|