using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PaintDotNet.Base.CommTool;
namespace PaintDotNet.GeneralAnalysis.Countometer
{
public class SettingDialog : PdnBaseForm
{
#region
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeLanguageText()
{
this.label17.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.ensure.text") + PdnResources.GetString("Menu.range.text") + ":";
this.lblRange.Text = "2000*2000" + PdnResources.GetString("Menu.Micron.text");
this.Text = PdnResources.GetString("Menu.paramssettings.text");
this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Horizontal.text") + ":";
this.chkPoint.Text = PdnResources.GetString("Menu.keepthehorizoalproportion.text");
this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Traveldistance.text");
this.label13.Text = PdnResources.GetString("Menu.Micron.text");
this.label14.Text = PdnResources.GetString("Menu.Micron.text");
this.label15.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Ydirection.text") + ":";
this.label16.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Xdirection.text") + ":";
this.chkRange.Text = PdnResources.GetString("Menu.keepthehorizoalproportion.text");
this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Deviceparamssetting.text");
this.label18.Text = PdnResources.GetString("Menu.step-size.text") + ":";
this.label8.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Databit.text") + ":";
this.label7.Text = PdnResources.GetString("Menu.Baudrate.text") + ":";
this.label6.Text = PdnResources.GetString("Menu.Deviceport.text") + ":";
this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Measurementpoints.text");
this.label12.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.point.text");
this.label11.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.point.text");
this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Vertical.text") + ":";
this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
this.btnClose.Text = PdnResources.GetString("Menu.File.Close.Text");
this.btnSave.Text = PdnResources.GetString("Menu.File.Save.Text");
this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.imitatelensparams.text");
this.label4.Text = PdnResources.GetString("Menu.Gridcolor.text") + ":";
this.label5.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Lensbackgroundcolor.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Emptypieceofcolor.text") + ":";
this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Lenscolor.text") + ":";
this.label1.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Backgroundcolor.text") + ":";
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.gridGridsColor = new System.Windows.Forms.Panel();
this.gridLensBgColor = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.gridBlocksColor = new System.Windows.Forms.Panel();
this.gridLensColor = new System.Windows.Forms.Panel();
this.gridBgColor = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.txtStep = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.txtBits = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtBaseBps = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.cmbPort = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label12 = new System.Windows.Forms.Label();
this.nudPointY = new System.Windows.Forms.NumericUpDown();
this.label11 = new System.Windows.Forms.Label();
this.nudPointX = new System.Windows.Forms.NumericUpDown();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.chkPoint = new System.Windows.Forms.CheckBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label13 = new System.Windows.Forms.Label();
this.nudRangeY = new System.Windows.Forms.NumericUpDown();
this.label14 = new System.Windows.Forms.Label();
this.nudRangeX = new System.Windows.Forms.NumericUpDown();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.chkRange = new System.Windows.Forms.CheckBox();
this.label17 = new System.Windows.Forms.Label();
this.lblRange = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPointY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudPointX)).BeginInit();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRangeY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudRangeX)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnClose);
this.groupBox1.Controls.Add(this.btnSave);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(669, 71);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "操作";
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(477, 24);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(84, 31);
this.btnClose.TabIndex = 1;
this.btnClose.Text = "关闭";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(567, 24);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(84, 31);
this.btnSave.TabIndex = 0;
this.btnSave.Text = "保存";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.gridGridsColor);
this.groupBox2.Controls.Add(this.gridLensBgColor);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.gridBlocksColor);
this.groupBox2.Controls.Add(this.gridLensColor);
this.groupBox2.Controls.Add(this.gridBgColor);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(12, 89);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(669, 161);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "模拟镜头参数";
//
// gridGridsColor
//
this.gridGridsColor.BackColor = System.Drawing.Color.Black;
this.gridGridsColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.gridGridsColor.Location = new System.Drawing.Point(371, 77);
this.gridGridsColor.Name = "gridGridsColor";
this.gridGridsColor.Size = new System.Drawing.Size(97, 26);
this.gridGridsColor.TabIndex = 19;
this.gridGridsColor.BackColorChanged += new System.EventHandler(this.gridGridsColor_BackColorChanged);
this.gridGridsColor.Click += new System.EventHandler(this.gridColor_Click);
//
// gridLensBgColor
//
this.gridLensBgColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.gridLensBgColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.gridLensBgColor.Location = new System.Drawing.Point(370, 33);
this.gridLensBgColor.Name = "gridLensBgColor";
this.gridLensBgColor.Size = new System.Drawing.Size(97, 26);
this.gridLensBgColor.TabIndex = 18;
this.gridLensBgColor.BackColorChanged += new System.EventHandler(this.gridLensBgColor_BackColorChanged);
this.gridLensBgColor.Click += new System.EventHandler(this.gridColor_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(282, 77);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(65, 12);
this.label4.TabIndex = 17;
this.label4.Text = "网格颜色:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(267, 40);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(77, 12);
this.label5.TabIndex = 16;
this.label5.Text = "镜头背景色:";
//
// gridBlocksColor
//
this.gridBlocksColor.BackColor = System.Drawing.Color.Transparent;
this.gridBlocksColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.gridBlocksColor.Location = new System.Drawing.Point(105, 117);
this.gridBlocksColor.Name = "gridBlocksColor";
this.gridBlocksColor.Size = new System.Drawing.Size(97, 26);
this.gridBlocksColor.TabIndex = 15;
this.gridBlocksColor.BackColorChanged += new System.EventHandler(this.gridBlocksColor_BackColorChanged);
this.gridBlocksColor.Click += new System.EventHandler(this.gridColor_Click);
//
// gridLensColor
//
this.gridLensColor.BackColor = System.Drawing.Color.White;
this.gridLensColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.gridLensColor.Location = new System.Drawing.Point(105, 77);
this.gridLensColor.Name = "gridLensColor";
this.gridLensColor.Size = new System.Drawing.Size(97, 26);
this.gridLensColor.TabIndex = 14;
this.gridLensColor.BackColorChanged += new System.EventHandler(this.gridLensColor_BackColorChanged);
this.gridLensColor.Click += new System.EventHandler(this.gridColor_Click);
//
// gridBgColor
//
this.gridBgColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.gridBgColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.gridBgColor.Location = new System.Drawing.Point(105, 37);
this.gridBgColor.Name = "gridBgColor";
this.gridBgColor.Size = new System.Drawing.Size(97, 26);
this.gridBgColor.TabIndex = 13;
this.gridBgColor.BackColorChanged += new System.EventHandler(this.gridBgColor_BackColorChanged);
this.gridBgColor.Click += new System.EventHandler(this.gridColor_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(29, 122);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 2;
this.label3.Text = "空块色:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(29, 77);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 1;
this.label2.Text = "镜头色:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(29, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "背景色:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.txtStep);
this.groupBox3.Controls.Add(this.label18);
this.groupBox3.Controls.Add(this.txtBits);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.txtBaseBps);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.cmbPort);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Location = new System.Drawing.Point(12, 256);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(669, 126);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "设备参数设置";
//
// txtStep
//
this.txtStep.Location = new System.Drawing.Point(104, 84);
this.txtStep.Name = "txtStep";
this.txtStep.Size = new System.Drawing.Size(100, 21);
this.txtStep.TabIndex = 7;
this.txtStep.Text = "0.381";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(38, 87);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(41, 12);
this.label18.TabIndex = 6;
this.label18.Text = "步长:";
//
// txtBits
//
this.txtBits.Location = new System.Drawing.Point(525, 36);
this.txtBits.Name = "txtBits";
this.txtBits.Size = new System.Drawing.Size(100, 21);
this.txtBits.TabIndex = 5;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(452, 41);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(53, 12);
this.label8.TabIndex = 4;
this.label8.Text = "数据位:";
//
// txtBaseBps
//
this.txtBaseBps.Location = new System.Drawing.Point(308, 36);
this.txtBaseBps.Name = "txtBaseBps";
this.txtBaseBps.Size = new System.Drawing.Size(100, 21);
this.txtBaseBps.TabIndex = 3;
this.txtBaseBps.Text = "9600";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(235, 41);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(53, 12);
this.label7.TabIndex = 2;
this.label7.Text = "波特率:";
//
// cmbPort
//
this.cmbPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPort.FormattingEnabled = true;
this.cmbPort.Location = new System.Drawing.Point(106, 38);
this.cmbPort.Name = "cmbPort";
this.cmbPort.Size = new System.Drawing.Size(98, 20);
this.cmbPort.TabIndex = 1;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(17, 41);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(65, 12);
this.label6.TabIndex = 0;
this.label6.Text = "设备端口:";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label12);
this.groupBox4.Controls.Add(this.nudPointY);
this.groupBox4.Controls.Add(this.label11);
this.groupBox4.Controls.Add(this.nudPointX);
this.groupBox4.Controls.Add(this.label10);
this.groupBox4.Controls.Add(this.label9);
this.groupBox4.Controls.Add(this.chkPoint);
this.groupBox4.Location = new System.Drawing.Point(12, 388);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(315, 214);
this.groupBox4.TabIndex = 4;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "测定点数";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(265, 129);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(29, 12);
this.label12.TabIndex = 3;
this.label12.Text = "微米";
//
// nudPointY
//
this.nudPointY.Location = new System.Drawing.Point(100, 123);
this.nudPointY.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.nudPointY.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudPointY.Name = "nudPointY";
this.nudPointY.Size = new System.Drawing.Size(160, 21);
this.nudPointY.TabIndex = 4;
this.nudPointY.Value = new decimal(new int[] {
10,
0,
0,
0});
this.nudPointY.ValueChanged += new System.EventHandler(this.nudPointY_ValueChanged);
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(265, 88);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(29, 12);
this.label11.TabIndex = 1;
this.label11.Text = "微米";
//
// nudPointX
//
this.nudPointX.Location = new System.Drawing.Point(100, 82);
this.nudPointX.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.nudPointX.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudPointX.Name = "nudPointX";
this.nudPointX.Size = new System.Drawing.Size(160, 21);
this.nudPointX.TabIndex = 1;
this.nudPointX.Value = new decimal(new int[] {
10,
0,
0,
0});
this.nudPointX.ValueChanged += new System.EventHandler(this.nudPointX_ValueChanged);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(29, 128);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(41, 12);
this.label10.TabIndex = 2;
this.label10.Text = "纵向:";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(29, 86);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(41, 12);
this.label9.TabIndex = 1;
this.label9.Text = "横向:";
//
// chkPoint
//
this.chkPoint.AutoSize = true;
this.chkPoint.Location = new System.Drawing.Point(32, 36);
this.chkPoint.Name = "chkPoint";
this.chkPoint.Size = new System.Drawing.Size(84, 16);
this.chkPoint.TabIndex = 1;
this.chkPoint.Text = "保持纵横比";
this.chkPoint.UseVisualStyleBackColor = true;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.label13);
this.groupBox5.Controls.Add(this.nudRangeY);
this.groupBox5.Controls.Add(this.label14);
this.groupBox5.Controls.Add(this.nudRangeX);
this.groupBox5.Controls.Add(this.label15);
this.groupBox5.Controls.Add(this.label16);
this.groupBox5.Controls.Add(this.chkRange);
this.groupBox5.Location = new System.Drawing.Point(344, 388);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(337, 214);
this.groupBox5.TabIndex = 5;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "走行距离";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(282, 125);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(29, 12);
this.label13.TabIndex = 9;
this.label13.Text = "微米";
//
// nudRangeY
//
this.nudRangeY.Location = new System.Drawing.Point(117, 119);
this.nudRangeY.Maximum = new decimal(new int[] {
99999,
0,
0,
0});
this.nudRangeY.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudRangeY.Name = "nudRangeY";
this.nudRangeY.Size = new System.Drawing.Size(160, 21);
this.nudRangeY.TabIndex = 10;
this.nudRangeY.Value = new decimal(new int[] {
100,
0,
0,
0});
this.nudRangeY.ValueChanged += new System.EventHandler(this.nudRangeY_ValueChanged);
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(282, 84);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(29, 12);
this.label14.TabIndex = 5;
this.label14.Text = "微米";
//
// nudRangeX
//
this.nudRangeX.Location = new System.Drawing.Point(117, 78);
this.nudRangeX.Maximum = new decimal(new int[] {
99999,
0,
0,
0});
this.nudRangeX.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudRangeX.Name = "nudRangeX";
this.nudRangeX.Size = new System.Drawing.Size(160, 21);
this.nudRangeX.TabIndex = 6;
this.nudRangeX.Value = new decimal(new int[] {
100,
0,
0,
0});
this.nudRangeX.ValueChanged += new System.EventHandler(this.nudRangeX_ValueChanged);
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(43, 124);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(47, 12);
this.label15.TabIndex = 8;
this.label15.Text = "Y方向:";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(43, 82);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(47, 12);
this.label16.TabIndex = 7;
this.label16.Text = "X方向:";
//
// chkRange
//
this.chkRange.AutoSize = true;
this.chkRange.Location = new System.Drawing.Point(43, 36);
this.chkRange.Name = "chkRange";
this.chkRange.Size = new System.Drawing.Size(84, 16);
this.chkRange.TabIndex = 0;
this.chkRange.Text = "保持纵横比";
this.chkRange.UseVisualStyleBackColor = true;
//
// label17
//
this.label17.AutoSize = true;
this.label17.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label17.Location = new System.Drawing.Point(12, 620);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(0, 16);
this.label17.TabIndex = 6;
//
// lblRange
//
this.lblRange.AutoSize = true;
this.lblRange.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblRange.Location = new System.Drawing.Point(138, 620);
this.lblRange.Name = "lblRange";
this.lblRange.Size = new System.Drawing.Size(0, 16);
this.lblRange.TabIndex = 7;
//
// SettingDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(693, 653);
this.Controls.Add(this.lblRange);
this.Controls.Add(this.label17);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "SettingDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "参数设置";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingDialog_FormClosing);
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox2, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox5, 0);
this.Controls.SetChildIndex(this.label17, 0);
this.Controls.SetChildIndex(this.lblRange, 0);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPointY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudPointX)).EndInit();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudRangeY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudRangeX)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel gridGridsColor;
private System.Windows.Forms.Panel gridLensBgColor;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Panel gridBlocksColor;
private System.Windows.Forms.Panel gridLensColor;
private System.Windows.Forms.Panel gridBgColor;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox txtBits;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtBaseBps;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ComboBox cmbPort;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.NumericUpDown nudPointY;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.NumericUpDown nudPointX;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.CheckBox chkPoint;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.NumericUpDown nudRangeY;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.NumericUpDown nudRangeX;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.CheckBox chkRange;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label lblRange;
private System.Windows.Forms.TextBox txtStep;
private System.Windows.Forms.Label label18;
#endregion
///
/// 网格调色板
///
PaintDotNet.ColorsForm colorsFormGrid;
///
/// 矩形调色板
///
PaintDotNet.ColorsForm colorsFormRect;
///
/// 圆形调色板
///
PaintDotNet.ColorsForm colorsFormCircular;
private string m_bgColor = "#ffffffff";
private string m_lensColor = "#ffffffff";
private string m_lensBgColor = "#ffffffff";
private string m_gridsColor = "#ffffffff";
private string m_blocksColor = "#ffffffff";
private string m_port;
private int m_bps;
private string m_checkBits;
private int m_pointRatio;
private decimal m_pointX;
private decimal m_pointY;
private int m_rangeRatio;
private decimal m_rangeX;
private decimal m_rangeY;
private int m_step;
private SQLiteHelper m_sqlHelper;
private object currentSender;
private string[] m_serialLst;
private Form m_parentForm;
public SettingDialog(Form form)
{
m_parentForm = form;
InitializeComponent();
InitializeLanguageText();
InitializeData();
GetSerialLst();
this.colorsFormGrid = new ColorsForm();
this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
this.colorsFormGrid.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
this.colorsFormRect = new ColorsForm();
this.colorsFormRect.StartPosition = FormStartPosition.CenterScreen;
this.colorsFormRect.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
this.colorsFormCircular = new ColorsForm();
this.colorsFormCircular.StartPosition = FormStartPosition.CenterScreen;
this.colorsFormCircular.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
}
private void GetSerialLst()
{
//清除cmbPort显示
cmbPort.SelectedIndex = -1;
cmbPort.Items.Clear();
//获取串口列表
m_serialLst = SerialPort.GetPortNames();
if (m_serialLst.Length > 0)
{
//取串口列表进行排序
Array.Sort(m_serialLst);
//将串口列表输出到comboBox
cmbPort.Items.AddRange(m_serialLst);
cmbPort.SelectedIndex = 0;
if (!string.IsNullOrEmpty(m_port))
{
for (int i = 0; i < m_serialLst.Length; ++i)
{
if (m_serialLst[i].Equals(m_port))
{
cmbPort.SelectedIndex = i;
}
}
}
}
}
public const int WM_DEVICE_CHANGE = 0x219; //设备改变
public const int DBT_DEVICEARRIVAL = 0x8000; //设备插入
public const int DBT_DEVICE_REMOVE_COMPLETE = 0x8004; //设备移除
//消息处理
protected override void WndProc(ref Message m)
{
switch (m.Msg) //判断消息类型
{
case WM_DEVICE_CHANGE: //设备改变消息
{
GetSerialLst(); //设备改变时重新获取串口列表
}
break;
}
base.WndProc(ref m);
}
private void InitializeData()
{
m_sqlHelper = new SQLiteHelper(); //连接数据库
m_sqlHelper.Connect();
string select_sql = "select * from mic_countometer_setting "; //查询的SQL语句
DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
if(dt != null && dt.Rows.Count > 0)
{
m_bgColor = dt.Rows[0]["bg_color"].ToString();
m_lensColor = dt.Rows[0]["lens_color"].ToString();
m_lensBgColor = dt.Rows[0]["lens_bg_color"].ToString();
m_gridsColor = dt.Rows[0]["grids_color"].ToString();
m_blocksColor = dt.Rows[0]["blocks_color"].ToString();
m_port = dt.Rows[0]["com_port"].ToString();
m_bps = int.Parse(dt.Rows[0]["base_bps"].ToString());
m_checkBits = dt.Rows[0]["base_check_bits"].ToString();
m_step = int.Parse(dt.Rows[0]["step"].ToString());
m_pointRatio = int.Parse(dt.Rows[0]["point_ratio"].ToString());
m_pointX = int.Parse(dt.Rows[0]["point_x"].ToString());
m_pointY = int.Parse(dt.Rows[0]["point_y"].ToString());
m_rangeRatio = int.Parse(dt.Rows[0]["range_ratio"].ToString());
m_rangeX = int.Parse(dt.Rows[0]["range_x"].ToString());
m_rangeY = int.Parse(dt.Rows[0]["range_y"].ToString());
this.txtStep.Text = m_step.ToString();
this.txtBaseBps.Text = m_bps.ToString();
this.txtBits.Text = m_checkBits.ToString();
if (m_pointRatio == 1)
{
this.chkPoint.Checked = true;
}
this.nudPointX.Value = m_pointX;
this.nudPointY.Value = m_pointY;
if (m_rangeRatio == 1)
{
this.chkRange.Checked = true;
}
this.nudRangeX.Value = m_rangeX;
this.nudRangeY.Value = m_rangeY;
}
this.gridBgColor.BackColor = ColorTranslator.FromHtml(m_bgColor);
this.gridLensBgColor.BackColor = ColorTranslator.FromHtml(m_lensBgColor);
this.gridLensColor.BackColor = ColorTranslator.FromHtml(m_lensColor);
this.gridGridsColor.BackColor = ColorTranslator.FromHtml(m_gridsColor);
this.gridBlocksColor.BackColor = ColorTranslator.FromHtml(m_blocksColor);
}
///
/// 调色板回调函数
///
///
///
private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
{
}
private void ShowColorsForm(object sender)
{
Panel panel = (Panel)sender;
this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(panel.BackColor);
this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
this.colorsFormGrid.ShowDialog();
}
///
/// 网格Panel的调色板颜色改变
///
///
///
private void gridColorChanged(object sender, EventArgs e)
{
Panel panel = (Panel)currentSender;
Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
panel.BackColor = color;
this.colorsFormGrid.Close();
}
private void gridColor_Click(object sender, EventArgs e)
{
currentSender = sender;
ShowColorsForm(sender);
}
private void gridBgColor_BackColorChanged(object sender, EventArgs e)
{
m_bgColor = ColorTranslator.ToHtml(this.gridBgColor.BackColor);
}
private void gridLensBgColor_BackColorChanged(object sender, EventArgs e)
{
m_lensBgColor = ColorTranslator.ToHtml(this.gridLensBgColor.BackColor);
}
private void gridLensColor_BackColorChanged(object sender, EventArgs e)
{
m_lensColor = ColorTranslator.ToHtml(this.gridLensColor.BackColor);
}
private void gridGridsColor_BackColorChanged(object sender, EventArgs e)
{
m_gridsColor = ColorTranslator.ToHtml(this.gridGridsColor.BackColor);
}
private void gridBlocksColor_BackColorChanged(object sender, EventArgs e)
{
m_blocksColor = ColorTranslator.ToHtml(this.gridBlocksColor.BackColor);
}
private void UpdateLblRange()
{
lblRange.Text = (nudPointX.Value * nudRangeX.Value).ToString() + "*" + (nudPointY.Value * nudRangeY.Value).ToString() + PdnResources.GetString("Menu.Micron.text");
}
private void nudRangeX_ValueChanged(object sender, EventArgs e)
{
UpdateLblRange();
}
private void nudRangeY_ValueChanged(object sender, EventArgs e)
{
UpdateLblRange();
}
private void nudPointX_ValueChanged(object sender, EventArgs e)
{
UpdateLblRange();
}
private void nudPointY_ValueChanged(object sender, EventArgs e)
{
UpdateLblRange();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 保存
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
string bps = txtBaseBps.Text.Trim();
if (string.IsNullOrEmpty(bps) || string.IsNullOrWhiteSpace(bps))
{
MessageBox.Show(PdnResources.GetString("Menu.Baudrempty.text"));
return;
}
string step = txtStep.Text.Trim();
if (string.IsNullOrEmpty(step) || string.IsNullOrWhiteSpace(step))
{
MessageBox.Show(PdnResources.GetString("Menu.Step-sizbeempty.text"));
return;
}
m_port = cmbPort.Text;
m_bps = int.Parse(bps);
m_checkBits = txtBits.Text.Trim();
m_step = int.Parse(step);
m_pointRatio = chkPoint.Checked ? 1 : 0;
m_pointX = nudPointX.Value;
m_pointY = nudPointY.Value;
m_rangeRatio = chkRange.Checked ? 1 : 0;
m_rangeX = nudRangeX.Value;
m_rangeY = nudRangeY.Value;
string update_sql = "update mic_countometer_setting set bg_color = ?, lens_color = ?, lens_bg_color = ?, grids_color = ?, blocks_color = ?, com_port = ?, base_bps = ?, base_check_bits = ?, step = ?, point_ratio = ?, point_x = ?, point_y = ?, range_ratio = ?, range_x = ?, range_y = ?"; //插入的SQL语句(带参数)
SQLiteParameter[] para = new SQLiteParameter[15]; //构造并绑定参数
string[] tag = { "bg_color", "lens_color", "lens_bg_color", "grids_color", "blocks_color", "com_port", "base_bps", "base_check_bits", "step", "point_ratio", "point_x", "point_y", "range_ratio", "range_x", "range_y" };
Object[] value = { m_bgColor, m_lensColor, m_lensBgColor, m_gridsColor, m_blocksColor, m_port, m_bps, m_checkBits, m_step, m_pointRatio, m_pointX, m_pointY, m_rangeRatio, m_rangeX, m_rangeY };
for (int i = 0; i < 15; i++)
{
para[i] = new SQLiteParameter(tag[i], value[i]);
}
m_sqlHelper.ExecuteNonQuery(update_sql, para); //执行插入操作
// 父窗口重新加载配置信息
((GeneralCountometerDialog)m_parentForm).SettingLoad();
//MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
this.Close();
}
private void SettingDialog_FormClosing(object sender, FormClosingEventArgs e)
{
m_sqlHelper.DisConnect();
}
}
}