123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983 |
- 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
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- 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") + ":";
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- 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
- /// <summary>
- /// 网格调色板
- /// </summary>
- PaintDotNet.ColorsForm colorsFormGrid;
- /// <summary>
- /// 矩形调色板
- /// </summary>
- PaintDotNet.ColorsForm colorsFormRect;
- /// <summary>
- /// 圆形调色板
- /// </summary>
- 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);
- }
- /// <summary>
- /// 调色板回调函数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ce"></param>
- 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();
- }
- /// <summary>
- /// 网格Panel的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
-
- }
- }
|