123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278 |
- using Resources;
- using SmartCoalApplication.Base.SettingModel;
- using SmartCoalApplication.Core;
- using SmartCoalApplication.Core.DbOpreate.DbBll;
- using SmartCoalApplication.Core.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 SmartCoalApplication.Rule
- {
- /// <summary>
- /// 自定义标尺
- /// </summary>
- internal class CustomRulerDialog : PdnBaseForm
- {
- private GroupBox groupBox1;
- private Button button3;
- private Button button2;
- private Button button1;
- private GroupBox groupBox2;
- private Button button4;
- private RadioButton radioButton2;
- private RadioButton radioButton1;
- private Panel panel1;
- private Label label3;
- private Label label2;
- private Label label1;
- private TextBox textBox1;
- private NumericUpDown numericUpDown2;
- private NumericUpDown numericUpDown1;
- private Panel panel2;
- private NumericUpDown numericUpDown3;
- private Label label6;
- private Label label5;
- private TextBox textBox2;
- private Label label4;
- private Panel panel3;
- private ListView listView1;
- private Label label8;
- private Label label7;
- private ComboBox comboBox1;
- /// <summary>
- /// 主配置,包含了选定的标尺的配置
- /// </summary>
- private ConfigModel configModel = Program.instance.configModel;
- /// <summary>
- /// 工作控件
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 标尺数据,编辑标尺时使用
- /// </summary>
- private mic_rulers ruleModel;
- /// <summary>
- /// 1新增 2编辑
- /// </summary>
- private int status;
- public CustomRulerDialog(AppWorkspace appWorkspace, mic_rulers ruleModel, int status)
- {
- this.status = status;
- this.appWorkspace = appWorkspace;
- this.ruleModel = ruleModel;
- InitializeComponent();
- InitializeLanguageText();
- InitOtherInfo();
- InitListViewHeader();
- InitListViewDate();
- if (this.ruleModel != null)
- InitializeEditData();
- }
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = PdnResources.GetString("Menu.Type.text");
- this.button3.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.button2.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Calculatescale.text");
- this.button1.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Anyruler.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Savetype.text");
- this.button4.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.radioButton2.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Saveforever.text");
- this.radioButton1.Text = PdnResources.GetString("Menu.porarypreservation.Text");
- this.label3.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Micron/pixel.text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Rulername.text") + ":";
- this.label8.Text = PdnResources.GetString("Menu.nothing.Text");
- this.label7.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Currentrulercalculated:none.text") + ":";
- this.label6.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.Calculatetheunit.text") + ":";
- this.label5.Text = PdnResources.GetString("Menu.Totalmagnification.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Rulername.text") + ":";
- this.Text = PdnResources.GetString("Menu.user-definedruler.text");
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.panel1 = new System.Windows.Forms.Panel();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.panel2 = new System.Windows.Forms.Panel();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.panel3 = new System.Windows.Forms.Panel();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.listView1 = new System.Windows.Forms.ListView();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.panel2.SuspendLayout();
- this.panel3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(13, 13);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(98, 462);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(10, 424);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 2;
- this.button3.Text = "关闭";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(10, 82);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "推算标尺";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(10, 41);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "任意标尺";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.Controls.Add(this.button4);
- this.groupBox2.Controls.Add(this.radioButton2);
- this.groupBox2.Controls.Add(this.radioButton1);
- this.groupBox2.Location = new System.Drawing.Point(118, 13);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(563, 54);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "保存类型";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(463, 19);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 2;
- this.button4.Text = "保存";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(215, 22);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(71, 16);
- this.radioButton2.TabIndex = 1;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "永久保存";
- this.radioButton2.UseVisualStyleBackColor = true;
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(69, 22);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(71, 16);
- this.radioButton1.TabIndex = 0;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "临时保存";
- this.radioButton1.UseVisualStyleBackColor = true;
- //
- // panel1
- //
- this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.panel1.Controls.Add(this.numericUpDown2);
- this.panel1.Controls.Add(this.numericUpDown1);
- this.panel1.Controls.Add(this.textBox1);
- this.panel1.Controls.Add(this.label3);
- this.panel1.Controls.Add(this.label2);
- this.panel1.Controls.Add(this.label1);
- this.panel1.Location = new System.Drawing.Point(118, 74);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(563, 401);
- this.panel1.TabIndex = 2;
- //
- // numericUpDown2
- //
- this.numericUpDown2.DecimalPlaces = 2;
- this.numericUpDown2.Increment = new decimal(new int[] {
- 1,
- 0,
- 0,
- 65536});
- this.numericUpDown2.Location = new System.Drawing.Point(118, 116);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.numericUpDown2.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 131072});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(139, 21);
- this.numericUpDown2.TabIndex = 5;
- this.numericUpDown2.Value = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- //
- // numericUpDown1
- //
- this.numericUpDown1.DecimalPlaces = 2;
- this.numericUpDown1.Increment = new decimal(new int[] {
- 1,
- 0,
- 0,
- 65536});
- this.numericUpDown1.Location = new System.Drawing.Point(118, 76);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.numericUpDown1.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 131072});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(139, 21);
- this.numericUpDown1.TabIndex = 4;
- this.numericUpDown1.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(118, 36);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(139, 21);
- this.textBox1.TabIndex = 3;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(50, 118);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(0, 12);
- this.label3.TabIndex = 2;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(44, 79);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(0, 12);
- this.label2.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(48, 40);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 12);
- this.label1.TabIndex = 0;
- //
- // panel2
- //
- this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.panel2.Controls.Add(this.comboBox1);
- this.panel2.Controls.Add(this.panel3);
- this.panel2.Controls.Add(this.listView1);
- this.panel2.Controls.Add(this.numericUpDown3);
- this.panel2.Controls.Add(this.label6);
- this.panel2.Controls.Add(this.label5);
- this.panel2.Controls.Add(this.textBox2);
- this.panel2.Controls.Add(this.label4);
- this.panel2.Location = new System.Drawing.Point(118, 74);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(563, 401);
- this.panel2.TabIndex = 3;
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(106, 76);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(134, 20);
- this.comboBox1.TabIndex = 8;
- this.comboBox1.SelectionChangeCommitted += new System.EventHandler(this.comboBox1_SelectionChangeCommitted);
- //
- // panel3
- //
- this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.panel3.BackColor = System.Drawing.Color.DimGray;
- this.panel3.Controls.Add(this.label8);
- this.panel3.Controls.Add(this.label7);
- this.panel3.Location = new System.Drawing.Point(3, 363);
- this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(557, 35);
- this.panel3.TabIndex = 7;
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label8.ForeColor = System.Drawing.Color.White;
- this.label8.Location = new System.Drawing.Point(188, 10);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(0, 16);
- this.label8.TabIndex = 1;
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.label7.ForeColor = System.Drawing.Color.White;
- this.label7.Location = new System.Drawing.Point(38, 10);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(0, 16);
- this.label7.TabIndex = 0;
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.FullRowSelect = true;
- this.listView1.HideSelection = false;
- this.listView1.Location = new System.Drawing.Point(3, 115);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(557, 242);
- this.listView1.TabIndex = 6;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- //
- // numericUpDown3
- //
- this.numericUpDown3.DecimalPlaces = 2;
- this.numericUpDown3.Increment = new decimal(new int[] {
- 1,
- 0,
- 0,
- 65536});
- this.numericUpDown3.Location = new System.Drawing.Point(370, 36);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.numericUpDown3.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 131072});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(134, 21);
- this.numericUpDown3.TabIndex = 4;
- this.numericUpDown3.Value = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(44, 79);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 3;
- this.label6.Text = "推算单位:";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(309, 39);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(65, 12);
- this.label5.TabIndex = 2;
- this.label5.Text = "放大倍数:";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(106, 36);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(134, 21);
- this.textBox2.TabIndex = 1;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(44, 39);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(65, 12);
- this.label4.TabIndex = 0;
- this.label4.Text = "标尺名称:";
- //
- // CustomRulerDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(693, 487);
- this.Controls.Add(this.panel2);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "CustomRulerDialog";
- this.Text = "自定义标尺";
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.panel1, 0);
- this.Controls.SetChildIndex(this.panel2, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.panel1.ResumeLayout(false);
- this.panel1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.panel2.ResumeLayout(false);
- this.panel2.PerformLayout();
- this.panel3.ResumeLayout(false);
- this.panel3.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 初始化其他信息
- /// </summary>
- private void InitOtherInfo()
- {
- this.panel2.Visible = false;
- this.button1.BackColor = Color.Gray;
- this.button1.ForeColor = Color.White;
- this.button1.FlatStyle = FlatStyle.Flat;
- this.button1.FlatAppearance.BorderSize = 0;
- //单位选择
- this.comboBox1.DataSource = new BindingSource(InvariantData.unitsDictionary, null);
- this.comboBox1.SelectedIndex = 4;//默认选中微米
- this.comboBox1.DisplayMember = "Value";
- this.comboBox1.ValueMember = "Key";
- SystemLayer.SafeNativeMethods.SetCueText(this.textBox1, PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- SystemLayer.SafeNativeMethods.SetCueText(this.textBox2, PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- }
- /// <summary>
- /// 初始化标尺列头
- /// </summary>
- private void InitListViewHeader()
- {
- this.listView1.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = PdnResources.GetString("Menu.Imagement.Rulersetting.active.text");
- header0.Width = 38;
- this.listView1.Columns.Add(header0);
- ColumnHeader header = new ColumnHeader();
- header.Text = PdnResources.GetString("Menu.Rulername.text");
- header.Width = 150;
- this.listView1.Columns.Add(header);
- ColumnHeader header1 = new ColumnHeader();
- header1.Text = PdnResources.GetString("Menu.unit.text") + "/" + PdnResources.GetString("MeasurementUnit.Pixel");
- header1.Width = 70;
- this.listView1.Columns.Add(header1);
- ColumnHeader header2 = new ColumnHeader();
- header2.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text");
- this.listView1.Columns.Add(header2);
- ColumnHeader header3 = new ColumnHeader();
- header3.Text = PdnResources.GetString("Menu.Pixellength.text");
- this.listView1.Columns.Add(header3);
- ColumnHeader header4 = new ColumnHeader();
- header4.Text = PdnResources.GetString("Menu.Physicallength.text");
- this.listView1.Columns.Add(header4);
- ColumnHeader header5 = new ColumnHeader();
- header5.Text = PdnResources.GetString("Menu.Unitsofmeasurement.text");
- this.listView1.Columns.Add(header5);
- ColumnHeader header6 = new ColumnHeader();
- header6.Text = PdnResources.GetString("Menu.ImageResolution.text");
- header6.Width = 80;
- this.listView1.Columns.Add(header6);
- ColumnHeader header7 = new ColumnHeader();
- header7.Text = PdnResources.GetString("Menu.magnificationchanger.text");
- this.listView1.Columns.Add(header7);
- ColumnHeader header8 = new ColumnHeader();
- header8.Text = PdnResources.GetString("Menu.interface.text");
- this.listView1.Columns.Add(header8);
- ColumnHeader header9 = new ColumnHeader();
- header9.Text = PdnResources.GetString("Menu.oculars.text");
- this.listView1.Columns.Add(header9);
- ColumnHeader header10 = new ColumnHeader();
- header10.Text = PdnResources.GetString("Menu.thecamera.text");
- this.listView1.Columns.Add(header10);
- ColumnHeader header11 = new ColumnHeader();
- header11.Text = PdnResources.GetString("Menu.Objectlens.text");
- this.listView1.Columns.Add(header11);
- ColumnHeader header12 = new ColumnHeader();
- header12.Text = PdnResources.GetString("Menu.microscope.text");
- this.listView1.Columns.Add(header12);
- }
- /// <summary>
- /// 初始化标尺列表
- /// </summary>
- private void InitListViewDate()
- {
- this.listView1.Items.Clear();
- List<mic_rulers> list = mic_rulers_BLL.FindAll();
- if (list != null)
- {
- for (int i = 0; i < list.Count; i++)
- {
- mic_rulers rule = list[i];
- if (this.ruleModel != null && this.ruleModel.id == rule.id)
- {
- continue;
- }
- ListViewItem item = new ListViewItem();
- item.Tag = rule.id;
- item.Text = "";
- if (configModel != null)
- {
- if (configModel.RulerId == rule.id)
- {
- //index = i;
- item.Text = "√";
- }
- }
- //计算每像素物理长度
- double proportion = Math.Round((double)rule.physical_length / rule.pixel_length, 4);
- string content = proportion.ToString() + InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), rule.ruler_units)))].ToString() + "/" + PdnResources.GetString("MeasurementUnit.Pixel");
- item.SubItems.Add(rule.ruler_name);
- item.SubItems.Add(content);
- item.SubItems.Add(rule.gain_multiple.ToString());
- item.SubItems.Add(rule.pixel_length.ToString());
- item.SubItems.Add(rule.physical_length.ToString());
- item.SubItems.Add(InvariantData.unitsDictionary[(int)((MeasurementUnit)(Enum.ToObject(typeof(MeasurementUnit), rule.ruler_units)))].ToString());
- item.SubItems.Add(rule.ruler_width + "*" + rule.ruler_height);
- item.SubItems.Add(rule.ruler_zoom);
- item.SubItems.Add(rule.ruler_connector);
- item.SubItems.Add(rule.ruler_eyepiece);
- item.SubItems.Add(rule.ruler_camera);
- item.SubItems.Add(rule.objective_lens);
- item.SubItems.Add(rule.microscope);
- this.listView1.Items.Add(item);
- }
- }
- if (RuleListForm.viewItem != null)
- {
- //原暂存标尺为静态对象,无法多次添加到不同的listview,固重新new一个
- ListViewItem tempItem = new ListViewItem();
- tempItem.Text = RuleListForm.viewItem.Text;
- tempItem.Tag = RuleListForm.viewItem.Tag;
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[1]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[2]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[3]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[4]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[5]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[6]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[7]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[8]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[9]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[10]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[11]);
- tempItem.SubItems.Add(RuleListForm.viewItem.SubItems[12]);
- this.listView1.Items.Add(tempItem);
- }
- if (RuleListForm.viewItemList != null && RuleListForm.viewItemList.Count > 0)
- {
- List<ListViewItem> tempListItem = new List<ListViewItem>();
- for (int i = 0; i < RuleListForm.viewItemList.Count; i++)
- {
- ListViewItem tempItem = new ListViewItem();
- tempItem.Text = RuleListForm.viewItemList[i].Text;
- tempItem.Tag = RuleListForm.viewItemList[i].Tag;
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[1]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[2]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[3]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[4]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[5]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[6]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[7]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[8]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[9]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[10]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[11]);
- tempItem.SubItems.Add(RuleListForm.viewItemList[i].SubItems[12]);
- tempListItem.Add(tempItem);
- }
- foreach (ListViewItem item in tempListItem)
- {
- this.listView1.Items.Add(item);
- }
- }
- }
- /// <summary>
- /// 关闭按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 编辑时初始化数据
- /// </summary>
- public void InitializeEditData()
- {
- if (this.ruleModel != null)
- {
- this.radioButton2.Checked = true;
- this.radioButton1.Visible = false;
- if (this.ruleModel.ruler_type == 2)
- {
- this.button2.Visible = false;
- this.textBox1.Text = this.ruleModel.ruler_name;
- this.numericUpDown2.Value = this.ruleModel.gain_multiple;
- this.numericUpDown1.Value = this.ruleModel.physical_length / 100;
- }
- if (this.ruleModel.ruler_type == 3)
- {
- this.panel1.Visible = false;
- this.panel2.Visible = true;
- ChangeButtonStyle(this.button2, this.button1);
- this.button1.Visible = false;
- this.textBox2.Text = this.ruleModel.ruler_name;
- this.numericUpDown3.Value = this.ruleModel.gain_multiple;
- this.comboBox1.SelectedIndex = this.ruleModel.ruler_units - 1;
- }
- }
- }
- /// <summary>
- /// 修改按钮样式
- /// </summary>
- /// <param name="displayButton">要修改的按钮</param>
- /// <param name="hideButton">要恢复的按钮</param>
- private void ChangeButtonStyle(Button displayButton, Button hideButton1)
- {
- hideButton1.BackColor = Color.FromArgb(255, 240, 240, 240);
- hideButton1.ForeColor = Color.FromArgb(255, 0, 0, 0);
- hideButton1.FlatStyle = FlatStyle.Standard;
- hideButton1.FlatAppearance.BorderSize = 1;
- displayButton.BackColor = Color.Gray;
- displayButton.ForeColor = Color.White;
- displayButton.FlatStyle = FlatStyle.Flat;
- displayButton.FlatAppearance.BorderSize = 0;
- }
- /// <summary>
- /// 任意标尺按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.panel1.Visible)
- return;
- this.panel2.Visible = false;
- this.panel1.Visible = true;
- ChangeButtonStyle(this.button1, this.button2);
- }
- /// <summary>
- /// 推算标尺按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.panel1.Visible = false;
- this.panel2.Visible = true;
- ChangeButtonStyle(this.button2, this.button1);
- }
- public mic_rulers mic_Rulers;
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- //新建
- if (this.status == 1)
- {
- //临时保存
- if (this.radioButton1.Checked)
- {
- //任意标尺
- if (this.panel1.Visible)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- try
- {
- mic_Rulers = new mic_rulers();
- int id = 0;
- //判断标尺是否存在
- for (int i = 0; i < Program.instance.mic_rulersAll.Count; i++)
- {
- if (Program.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox1.Text + "-" + PdnResources.GetString("Menu.temporary.Text")))
- {
- MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
- return;
- }
- if (Program.instance.mic_rulersAll[i].id < id)
- {
- id = Program.instance.mic_rulersAll[i].id;
- }
- }
- mic_Rulers.id = id - 1;
- mic_Rulers.ruler_name = this.textBox1.Text + "-" + PdnResources.GetString("Menu.temporary.Text");
- mic_Rulers.gain_multiple = this.numericUpDown2.Value;
- mic_Rulers.pixel_length = 100;//固定1像素,乘以100
- mic_Rulers.physical_length = Convert.ToInt32(this.numericUpDown1.Value * 100);
- mic_Rulers.ruler_units = Program.instance.companyEnume[PdnResources.GetString("Menu.Micron.text")];
- mic_Rulers.ruler_width = 0;
- mic_Rulers.ruler_height = 0;
- Program.instance.mic_rulersAll.Add(mic_Rulers);
- //ListViewItem listViewItem = new ListViewItem();
- //listViewItem.SubItems.Add(this.textBox1.Text + "-"+ PdnResources.GetString("Menu.temporary.Text"));
- //listViewItem.SubItems.Add(this.numericUpDown2.Value.ToString());//放大倍数
- //listViewItem.SubItems.Add("100");//固定1像素,乘以100
- //listViewItem.SubItems.Add((Convert.ToInt32(this.numericUpDown1.Value * 100)).ToString());//物理长度
- //listViewItem.SubItems.Add(PdnResources.GetString("Menu.Micron.text"));
- //listViewItem.SubItems.Add("0*0");
- //listViewItem.SubItems.Add("");
- //listViewItem.SubItems.Add("");
- //listViewItem.SubItems.Add("");
- //listViewItem.SubItems.Add("");
- //listViewItem.SubItems.Add("");
- //listViewItem.SubItems.Add("");
- //listViewItem.Tag = "temporaryList";
- //RuleListForm.viewItemList.Add(listViewItem);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Ruleradditionfaile.Text"));
- return;
- }
- }
- //推算标尺
- if (this.panel2.Visible)
- {
- if (string.IsNullOrEmpty(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- if (this.listView1.SelectedItems == null || this.listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecarulerfirst.Text"));
- return;
- }
- try
- {
- mic_Rulers = new mic_rulers();
- int id = 0;
- //判断标尺是否存在
- for (int i = 0; i < Program.instance.mic_rulersAll.Count; i++)
- {
- if (Program.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox2.Text + "-" + PdnResources.GetString("Menu.temporary.Text")))
- {
- MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
- return;
- }
- if (Program.instance.mic_rulersAll[i].id < id)
- {
- id = Program.instance.mic_rulersAll[i].id;
- }
- }
- string[] str = this.listView1.SelectedItems[0].SubItems[7].Text.Split('*');//拆分像素
- decimal referenceMultiple = decimal.Parse(this.listView1.SelectedItems[0].SubItems[3].Text);//参考标尺放大倍数
- mic_Rulers.id = id - 1;
- mic_Rulers.ruler_name = this.textBox2.Text + "-" + PdnResources.GetString("Menu.temporary.Text");
- mic_Rulers.gain_multiple = this.numericUpDown3.Value;
- mic_Rulers.pixel_length = float.Parse(this.listView1.SelectedItems[0].SubItems[4].Text);
- mic_Rulers.physical_length = Convert.ToInt32(this.listView1.SelectedItems[0].SubItems[5].Text) * (referenceMultiple / this.numericUpDown3.Value);
- mic_Rulers.ruler_units = Program.instance.companyEnume[this.comboBox1.Text];
- mic_Rulers.ruler_width = int.Parse(str[0]);
- mic_Rulers.ruler_height = int.Parse(str[1]);
- mic_Rulers.ruler_zoom = this.listView1.SelectedItems[0].SubItems[8].Text;
- mic_Rulers.ruler_connector = this.listView1.SelectedItems[0].SubItems[9].Text;
- mic_Rulers.ruler_eyepiece = this.listView1.SelectedItems[0].SubItems[10].Text;
- mic_Rulers.ruler_camera = this.listView1.SelectedItems[0].SubItems[11].Text;
- mic_Rulers.objective_lens = this.listView1.SelectedItems[0].SubItems[12].Text;
- mic_Rulers.microscope = this.listView1.SelectedItems[0].SubItems[13].Text;
- Program.instance.mic_rulersAll.Add(mic_Rulers);
- //ListViewItem listViewItem = new ListViewItem();
- //listViewItem.SubItems.Add(this.textBox2.Text + "-"+ PdnResources.GetString("Menu.temporary.Text"));
- //listViewItem.SubItems.Add(this.numericUpDown3.Value.ToString());//放大倍数
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[3]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[4]);
- //listViewItem.SubItems.Add(this.comboBox1.Text);//单位
- ////string[] str = this.listView1.SelectedItems[0].SubItems[6].ToString().Split('*');
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[6]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[7]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[8]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[9]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[10]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[11]);
- //listViewItem.SubItems.Add(this.listView1.SelectedItems[0].SubItems[12]);
- //listViewItem.Tag = "temporaryList";
- //RuleListForm.viewItemList.Add(listViewItem);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message/*PdnResources.GetString("Menu.Ruleradditionfaile.Text")*/);
- return;
- }
- }
- }
- //永久保存
- if (this.radioButton2.Checked)
- {
- //任意标尺
- if (this.panel1.Visible)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- //判断标尺是否存在
- for (int i = 0; i < Program.instance.mic_rulersAll.Count; i++)
- {
- if (Program.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
- return;
- }
- }
- try
- {
- //组织数据,保存到数据库
- mic_rulers rule = new mic_rulers();
- rule.ruler_name = this.textBox1.Text;
- rule.gain_multiple = this.numericUpDown2.Value;
- rule.pixel_length = 100;
- rule.physical_length = this.numericUpDown1.Value * 100;
- rule.ruler_units = Program.instance.companyEnume[PdnResources.GetString("Menu.Micron.text")];
- rule.ruler_width = 0;
- rule.ruler_height = 0;
- rule.ruler_zoom = "";
- rule.ruler_connector = "";
- rule.ruler_eyepiece = "";
- rule.ruler_camera = "";
- rule.objective_lens = "";
- rule.microscope = "";
- rule.ruler_type = 2;
- mic_rulers_BLL.Add(rule);
- Program.instance.mic_rulersAll.Add(rule);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Ruleradditionfaile.Text"));
- return;
- }
- }
- //推算标尺
- if (this.panel2.Visible)
- {
- if (string.IsNullOrEmpty(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- if (this.listView1.SelectedItems == null || this.listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecarulerfirst.Text"));
- return;
- }
- //判断标尺是否存在
- for (int i = 0; i < Program.instance.mic_rulersAll.Count; i++)
- {
- if (Program.instance.mic_rulersAll[i].ruler_name.Equals(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
- return;
- }
- }
- try
- {
- //组织数据,保存到数据库
- mic_rulers rule = new mic_rulers();
- decimal referenceMultiple = decimal.Parse(this.listView1.SelectedItems[0].SubItems[3].Text);//参考标尺放大倍数
- rule.ruler_name = this.textBox2.Text;
- rule.gain_multiple = this.numericUpDown3.Value;
- rule.pixel_length = float.Parse(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[4].Text) ? "0" :
- this.listView1.SelectedItems[0].SubItems[4].Text);
- rule.physical_length = decimal.Parse(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[5].Text) ? "0" :
- this.listView1.SelectedItems[0].SubItems[5].Text) * (referenceMultiple / this.numericUpDown3.Value);
- rule.ruler_units = (int)this.comboBox1.SelectedValue;
- rule.ruler_width = Convert.ToInt32(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[0]) ? "0" :
- this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[0]);
- rule.ruler_height = Convert.ToInt32(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[1]) ? "0" :
- this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[1]);
- rule.ruler_zoom = this.listView1.SelectedItems[0].SubItems[8].Text;
- rule.ruler_connector = this.listView1.SelectedItems[0].SubItems[9].Text;
- rule.ruler_eyepiece = this.listView1.SelectedItems[0].SubItems[10].Text;
- rule.ruler_camera = this.listView1.SelectedItems[0].SubItems[11].Text;
- rule.objective_lens = this.listView1.SelectedItems[0].SubItems[12].Text;
- rule.microscope = this.listView1.SelectedItems[0].SubItems[13].Text;
- rule.ruler_type = 3;
- mic_rulers_BLL.Add(rule);
- Program.instance.mic_rulersAll.Add(rule);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Ruleradditionfaile.Text"));
- return;
- }
- }
- }
- }
- //编辑
- if (this.status == 2 && this.ruleModel != null)
- {
- //任意标尺
- if (this.ruleModel.ruler_type == 2)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- try
- {
- this.ruleModel.ruler_name = this.textBox1.Text;
- this.ruleModel.gain_multiple = this.numericUpDown2.Value;
- this.ruleModel.pixel_length = 100;
- this.ruleModel.physical_length = this.numericUpDown1.Value * 100;
- this.ruleModel.ruler_units = Program.instance.companyEnume[PdnResources.GetString("Menu.Micron.text")];
- this.ruleModel.ruler_width = 0;
- this.ruleModel.ruler_height = 0;
- this.ruleModel.ruler_zoom = "";
- this.ruleModel.ruler_connector = "";
- this.ruleModel.ruler_eyepiece = "";
- this.ruleModel.ruler_camera = "";
- this.ruleModel.objective_lens = "";
- this.ruleModel.microscope = "";
- this.ruleModel.ruler_type = 2;
- mic_rulers_BLL.Update(this.ruleModel);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Ruleredifailed.Text"));
- return;
- }
- }
- //推算标尺
- if (this.ruleModel.ruler_type == 3)
- {
- if (string.IsNullOrEmpty(this.textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterarulername.text"));
- return;
- }
- if (this.listView1.SelectedItems == null || this.listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecarulerfirst.Text"));
- return;
- }
- try
- {
- decimal referenceMultiple = decimal.Parse(this.listView1.SelectedItems[0].SubItems[3].Text);//参考标尺放大倍数
- this.ruleModel.ruler_name = this.textBox2.Text;
- this.ruleModel.gain_multiple = this.numericUpDown3.Value;
- this.ruleModel.pixel_length = float.Parse(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[4].Text) ? "0" :
- this.listView1.SelectedItems[0].SubItems[4].Text);
- this.ruleModel.physical_length = decimal.Parse(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[5].Text) ? "0" :
- this.listView1.SelectedItems[0].SubItems[5].Text) * (referenceMultiple / this.numericUpDown3.Value);
- this.ruleModel.ruler_units = (int)this.comboBox1.SelectedValue;
- this.ruleModel.ruler_width = Convert.ToInt32(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[0]) ? "0" :
- this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[0]);
- this.ruleModel.ruler_height = Convert.ToInt32(string.IsNullOrEmpty(this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[1]) ? "0" :
- this.listView1.SelectedItems[0].SubItems[7].Text.Split('*')[1]);
- this.ruleModel.ruler_zoom = this.listView1.SelectedItems[0].SubItems[8].Text;
- this.ruleModel.ruler_connector = this.listView1.SelectedItems[0].SubItems[9].Text;
- this.ruleModel.ruler_eyepiece = this.listView1.SelectedItems[0].SubItems[10].Text;
- this.ruleModel.ruler_camera = this.listView1.SelectedItems[0].SubItems[11].Text;
- this.ruleModel.objective_lens = this.listView1.SelectedItems[0].SubItems[12].Text;
- this.ruleModel.microscope = this.listView1.SelectedItems[0].SubItems[13].Text;
- this.ruleModel.ruler_type = 3;
- mic_rulers_BLL.Update(this.ruleModel);
- }
- catch (Exception)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Ruleredifailed.Text"));
- return;
- }
- }
- this.appWorkspace.RefreshActiveRuler();
- }
- //刷新标尺列表
- this.appWorkspace.RefueshRuleList();
- //刷新预览窗口
- //if (CameraPreviewDialog.cameraPreviewDialog != null)
- // CameraPreviewDialog.cameraPreviewDialog.BindingRule();
- this.Close();
- }
- /// <summary>
- /// 推算标尺的放大倍数改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- GetCalculateRuler();
- }
- /// <summary>
- /// 推算标尺的单位改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
- {
- GetCalculateRuler();
- }
- /// <summary>
- /// 计算推算标尺并显示
- /// </summary>
- private void GetCalculateRuler()
- {
- if (this.listView1.SelectedItems == null || this.listView1.SelectedItems.Count == 0)
- return;
- else
- {
- double unitLength = (Convert.ToDouble(this.listView1.SelectedItems[0].SubItems[5].Text) / Convert.ToDouble(this.listView1.SelectedItems[0].SubItems[4].Text));
- double finalUnitLength = unitLength * Convert.ToDouble(this.listView1.SelectedItems[0].SubItems[3].Text) / (double)this.numericUpDown3.Value;
- int oldUnit = InvariantData.unitsDictionary.FirstOrDefault(q => q.Value == this.listView1.SelectedItems[0].SubItems[6].Text).Key;
- int nowUnit = (int)this.comboBox1.SelectedValue;
- switch (oldUnit)
- {
- case 1://英寸
- switch (nowUnit)
- {
- case 1:
- break;
- case 2:
- finalUnitLength = 2.54 * finalUnitLength;
- break;
- case 3:
- finalUnitLength = 25.4 * finalUnitLength;
- break;
- case 4:
- finalUnitLength = 25400 * finalUnitLength;
- break;
- case 5:
- finalUnitLength = 25400000 * finalUnitLength;
- break;
- }
- break;
- case 2://厘米
- switch (nowUnit)
- {
- case 1:
- finalUnitLength = 0.3937008 * finalUnitLength;
- break;
- case 2:
- break;
- case 3:
- finalUnitLength = 10 * finalUnitLength;
- break;
- case 4:
- finalUnitLength = 10000 * finalUnitLength;
- break;
- case 5:
- finalUnitLength = 10000000 * finalUnitLength;
- break;
- }
- break;
- case 3://毫米
- switch (nowUnit)
- {
- case 1:
- finalUnitLength = 0.0393701 * finalUnitLength;
- break;
- case 2:
- finalUnitLength = 0.1 * finalUnitLength;
- break;
- case 3:
- break;
- case 4:
- finalUnitLength = 1000 * finalUnitLength;
- break;
- case 5:
- finalUnitLength = 1000000 * finalUnitLength;
- break;
- }
- break;
- case 4://微米
- switch (nowUnit)
- {
- case 1:
- finalUnitLength = 0.00003937007874 * finalUnitLength;
- break;
- case 2:
- finalUnitLength = 0.0001 * finalUnitLength;
- break;
- case 3:
- finalUnitLength = 0.001 * finalUnitLength;
- break;
- case 4:
- break;
- case 5:
- finalUnitLength = 1000 * finalUnitLength;
- break;
- }
- break;
- case 5://纳米
- switch (nowUnit)
- {
- case 1:
- finalUnitLength = 3.9370e-8 * finalUnitLength;
- break;
- case 2:
- finalUnitLength = 1e-7 * finalUnitLength;
- break;
- case 3:
- finalUnitLength = 1e-6 * finalUnitLength;
- break;
- case 4:
- finalUnitLength = 0.001 * finalUnitLength;
- break;
- case 5:
- break;
- }
- break;
- }
- this.label8.Text = Math.Round(finalUnitLength, 4) + this.comboBox1.Text + "/" + PdnResources.GetString("Menu.Pixel.text");
- }
- }
- /// <summary>
- /// 选择标尺改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- GetCalculateRuler();
- }
- }
- }
|