123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 |
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.ImageCollect;
- using PaintDotNet.Menus;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.Measuring
- {
- /// <summary>
- /// 理论比例尺
- /// </summary>
- partial class TheoreticalScaleDialog : Form
- {
- /// <summary>
- /// 主控件
- /// </summary>
- AppWorkspace appWorkspace;
- /// <summary>
- /// 初始化下拉标记
- /// </summary>
- private bool initComboBox = false;
- /// <summary>
- /// 初始化下拉标记All
- /// </summary>
- private bool initComboBoxAll = false;
- /// <summary>
- /// 下拉框添加项目
- /// </summary>
- public static DictionaryEntry addComboboxitem;
- /// <summary>
- /// 下拉框添加项目区分(2:物镜 1:中间变倍器 3:相机适配器)
- /// </summary>
- public static int addComboboxitemKb;
- /// <summary>
- /// 下拉框项目(物镜)
- /// </summary>
- private ArrayList dataList2;
- /// <summary>
- /// 下拉框项目(中间变倍器)
- /// </summary>
- private ArrayList dataList1;
- /// <summary>
- /// 下拉框项目(相机适配器)
- /// </summary>
- private ArrayList dataList3;
- /// <summary>
- /// 临时数据
- /// </summary>
- public ListViewItem viewItem;
- /// <summary>
- /// 感光软件边长
- /// </summary>
- private string sideLength;
- /// <summary>
- /// 边长分辨率
- /// </summary>
- private string resolution;
- private string pixel_size;
- #region 控件
- private Label label1;
- private Label label2;
- private Label label3;
- private Label label4;
- private Label label5;
- private Label label6;
- private Label label7;
- private Label label8;
- private Label label9;
- private Label label10;
- private ComboBox comboBox1;
- private ComboBox comboBox2;
- private ComboBox comboBox3;
- private ComboBox comboBox4;
- private Button button1;
- private Button button2;
- private Button button3;
- private Button button4;
- private Button button5;
- private Button button6;
- private Label label11;
- private TextBox textBox1;
- public Button button7;
- private void InitializeLanguageText()
- {
- this.label1.Text = PdnResources.GetString("Menu.Objectlens.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Intermediatemultiplier.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.Cameraadapter.text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Totalmagnification.text") + ":";
- this.label5.Text = PdnResources.GetString("Menu.ImageResolution.text") + ":";
- this.label6.Text = PdnResources.GetString("Menu.Cameramodel.text") + ":";
- this.label7.Text = PdnResources.GetString("Menu.scale.text") + ":";
- this.label8.Text = PdnResources.GetString("Menu.Objectlens.text") + "*" + PdnResources.GetString("Menu.Intermediatemultiplier.text") + "*" + PdnResources.GetString("Menu.Cameraadapter.text");
- this.label9.Text = PdnResources.GetString("Menu.heresolutionofthecurre.Text");
- this.label10.Text = PdnResources.GetString("Menu.Automaticcalculation.Text");
- this.comboBox4.Items.AddRange(new object[] {
- PdnResources.GetString("Menu.Maintainthecamerarecordandcor.Text")});
- this.button7.Text = PdnResources.GetString("Menu.Applyscale.text");
- this.Text = PdnResources.GetString("Menu.MeasureAction.TheoreticalScale.Text");
- }
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.comboBox3 = new System.Windows.Forms.ComboBox();
- this.comboBox4 = new System.Windows.Forms.ComboBox();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.button7 = new System.Windows.Forms.Button();
- this.label11 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label1.Location = new System.Drawing.Point(49, 25);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(41, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "物镜:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label2.Location = new System.Drawing.Point(13, 53);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(77, 12);
- this.label2.TabIndex = 1;
- this.label2.Text = "中间变倍器:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label3.Location = new System.Drawing.Point(13, 81);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(77, 12);
- this.label3.TabIndex = 2;
- this.label3.Text = "相机适配器:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label4.Location = new System.Drawing.Point(13, 149);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(77, 12);
- this.label4.TabIndex = 3;
- this.label4.Text = "总放大倍数:";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label5.Location = new System.Drawing.Point(13, 181);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(77, 12);
- this.label5.TabIndex = 4;
- this.label5.Text = "图像分辨率:";
- this.label5.Visible = false;
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label6.Location = new System.Drawing.Point(25, 181);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 5;
- this.label6.Text = "相机型号:";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label7.Location = new System.Drawing.Point(37, 207);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(53, 12);
- this.label7.TabIndex = 6;
- this.label7.Text = "比例尺:";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label8.Location = new System.Drawing.Point(90, 149);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(0, 12);
- this.label8.TabIndex = 7;
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label9.Location = new System.Drawing.Point(90, 181);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(0, 12);
- this.label9.TabIndex = 8;
- this.label9.Visible = false;
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label10.Location = new System.Drawing.Point(90, 207);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(0, 12);
- this.label10.TabIndex = 9;
- //
- // comboBox1
- //
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(90, 50);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(135, 20);
- this.comboBox1.TabIndex = 10;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // comboBox2
- //
- this.comboBox2.FormattingEnabled = true;
- this.comboBox2.Location = new System.Drawing.Point(90, 22);
- this.comboBox2.Name = "comboBox2";
- this.comboBox2.Size = new System.Drawing.Size(135, 20);
- this.comboBox2.TabIndex = 11;
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- //
- // comboBox3
- //
- this.comboBox3.FormattingEnabled = true;
- this.comboBox3.Location = new System.Drawing.Point(90, 81);
- this.comboBox3.Name = "comboBox3";
- this.comboBox3.Size = new System.Drawing.Size(135, 20);
- this.comboBox3.TabIndex = 12;
- this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- //
- // comboBox4
- //
- this.comboBox4.FormattingEnabled = true;
- this.comboBox4.Location = new System.Drawing.Point(90, 178);
- this.comboBox4.Name = "comboBox4";
- this.comboBox4.Size = new System.Drawing.Size(135, 20);
- this.comboBox4.TabIndex = 13;
- this.comboBox4.SelectedValueChanged += new System.EventHandler(this.comboBox4_SelectedValueChanged);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(239, 22);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(25, 25);
- this.button1.TabIndex = 14;
- this.button1.Text = "+";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(272, 22);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(25, 25);
- this.button2.TabIndex = 15;
- this.button2.Text = "-";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(239, 49);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(25, 25);
- this.button3.TabIndex = 16;
- this.button3.Text = "+";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(272, 50);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(25, 25);
- this.button4.TabIndex = 17;
- this.button4.Text = "-";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(239, 77);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(25, 25);
- this.button5.TabIndex = 18;
- this.button5.Text = "+";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(272, 77);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(25, 25);
- this.button6.TabIndex = 19;
- this.button6.Text = "-";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(106, 244);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(78, 25);
- this.button7.TabIndex = 20;
- this.button7.Text = "应用比例尺";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.ForeColor = System.Drawing.SystemColors.MenuText;
- this.label11.Location = new System.Drawing.Point(13, 121);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(65, 12);
- this.label11.TabIndex = 21;
- this.label11.Text = "附加倍率:";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(90, 118);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(135, 21);
- this.textBox1.TabIndex = 22;
- this.textBox1.Text = "1";
- this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
- //
- // TheoreticalScaleDialog
- //
- this.BackColor = System.Drawing.SystemColors.Control;
- this.ClientSize = new System.Drawing.Size(312, 301);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.label11);
- this.Controls.Add(this.button7);
- this.Controls.Add(this.button6);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.comboBox4);
- this.Controls.Add(this.comboBox3);
- this.Controls.Add(this.comboBox2);
- this.Controls.Add(this.comboBox1);
- this.Controls.Add(this.label10);
- this.Controls.Add(this.label9);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(328, 340);
- this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(328, 340);
- this.Name = "TheoreticalScaleDialog";
- this.ShowInTaskbar = false;
- this.Text = "理论比例尺";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TheoreticalScaleDialog_FormClosing);
- this.Load += new System.EventHandler(this.TheoreticalScaleDialog_Load);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- private void TheoreticalScaleDialog_Load(object sender, EventArgs e)
- {
- }
- #endregion
- /// <summary>
- /// 初始化
- /// </summary>
- public TheoreticalScaleDialog(AppWorkspace appWorkspace, ArrayList arrayList1, ArrayList arrayList2, ArrayList arrayList3)
- {
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- this.dataList2 = new ArrayList();
- this.dataList1 = new ArrayList();
- this.dataList3 = new ArrayList();
- if (MeasureActionMenu.InitKb)
- this.InitCombobox();
- else
- {
- this.dataList2 = arrayList2;
- this.dataList1 = arrayList1;
- this.dataList3 = arrayList3;
- if (arrayList2 != null && arrayList2.Count > 0)
- {
- this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- this.comboBox2.DataSource = arrayList2;
- this.comboBox2.DisplayMember = "Value";
- this.comboBox2.ValueMember = "Key";
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- }
- if (arrayList1 != null && arrayList1.Count > 0)
- {
- this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox1.DataSource = arrayList1;
- this.comboBox1.DisplayMember = "Value";
- this.comboBox1.ValueMember = "Key";
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- }
- if (arrayList3 != null && arrayList3.Count > 0)
- {
- this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- this.comboBox3.DataSource = arrayList3;
- this.comboBox3.DisplayMember = "Value";
- this.comboBox3.ValueMember = "Key";
- this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- }
- }
- this.comboBox3_SelectedIndexChanged(null, null);
- this.GetCameraInformation();
- }
- /// <summary>
- /// 取得相机信息初始化相机型号下拉框
- /// </summary>
- private void GetCameraInformation()
- {
- // 相机信息数据取得
- var screenList = mic_camerasettings_BLL.FindAll();
- ArrayList arrayList = new ArrayList();
- if (screenList != null && screenList.Count > 0)
- {
- foreach (var item in screenList)
- {
- arrayList.Add(item.camera_model);
- }
- this.comboBox4.DataSource = null;
- this.comboBox4.DataSource = arrayList;
- }
- else
- {
- arrayList.Add(PdnResources.GetString("Menu.Nocamerarecord.text"));
- this.comboBox4.DataSource = null;
- this.comboBox4.DataSource = arrayList;
- }
- }
- /// <summary>
- /// 刷新理论比例尺
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public void RefreshListView()
- {
- if (this.dataList2 == null)
- {
- this.dataList2 = new ArrayList();
- }
- if (this.dataList1 == null)
- {
- this.dataList1 = new ArrayList();
- }
- if (this.dataList3 == null)
- {
- this.dataList3 = new ArrayList();
- }
- if (addComboboxitemKb == 2 && !this.dataList2.Contains(addComboboxitem))
- {
- this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- this.comboBox2.DataSource = null;
- this.dataList2.Add(addComboboxitem);
- this.comboBox2.DataSource = this.dataList2;
- this.comboBox2.DisplayMember = "Value";
- this.comboBox2.ValueMember = "Key";
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- this.comboBox2.SelectedIndex = this.dataList2.Count - 1;
- }
- if (addComboboxitemKb == 1 && !this.dataList1.Contains(addComboboxitem))
- {
- this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox1.DataSource = null;
- this.dataList1.Add(addComboboxitem);
- this.comboBox1.DataSource = this.dataList1;
- this.comboBox1.DisplayMember = "Value";
- this.comboBox1.ValueMember = "Key";
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox1.SelectedIndex = this.dataList1.Count - 1;
- }
- if (addComboboxitemKb == 3 && !this.dataList3.Contains(addComboboxitem))
- {
- this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- this.comboBox3.DataSource = null;
- this.dataList3.Add(addComboboxitem);
- this.comboBox3.DataSource = this.dataList3;
- this.comboBox3.DisplayMember = "Value";
- this.comboBox3.ValueMember = "Key";
- this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- this.comboBox3.SelectedIndex = this.dataList3.Count - 1;
- }
- }
- /// <summary>
- /// 初始化设置
- /// </summary>
- private void InitCombobox()
- {
- // 物镜
- this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- this.comboBox2.DataSource = null;
- this.dataList2.Add(new DictionaryEntry((decimal)1, "1X"));
- this.dataList2.Add(new DictionaryEntry((decimal)2, "2X"));
- this.dataList2.Add(new DictionaryEntry((decimal)3, "3X"));
- this.dataList2.Add(new DictionaryEntry((decimal)4, "4X"));
- this.comboBox2.DataSource = this.dataList2;
- this.comboBox2.DisplayMember = "Value";
- this.comboBox2.ValueMember = "Key";
- this.comboBox2.SelectedIndex = 0;
- this.comboBox2.Focus();
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- // 中间变倍器
- this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox1.DataSource = null;
- this.dataList1.Add(new DictionaryEntry((decimal)1, "1X"));
- this.dataList1.Add(new DictionaryEntry((decimal)1.5, "1.5X"));
- this.dataList1.Add(new DictionaryEntry((decimal)2, "2X"));
- this.dataList1.Add(new DictionaryEntry((decimal)3, "3X"));
- this.dataList1.Add(new DictionaryEntry((decimal)4, "4X"));
- this.comboBox1.DataSource = this.dataList1;
- this.comboBox1.DisplayMember = "Value";
- this.comboBox1.ValueMember = "Key";
- this.comboBox1.SelectedIndex = 0;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- // 相机适配器
- this.comboBox3.DataSource = null;
- this.dataList3.Add(new DictionaryEntry((decimal)0.4, "0.4X"));
- this.dataList3.Add(new DictionaryEntry((decimal)0.6, "0.6X"));
- this.comboBox3.DataSource = this.dataList3;
- this.comboBox3.DisplayMember = "Value";
- this.comboBox3.ValueMember = "Key";
- this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- this.comboBox3.SelectedIndex = 0;
- List<mic_rulers> list = mic_rulers_BLL.FindAll();
- this.label9.Text = list[0].ruler_width + "*" + list[0].ruler_height;
- MeasureActionMenu.InitKb = false;
- }
- /// <summary>
- /// 画面计算
- /// </summary>
- private void CalculatedValue()
- {
- if (this.initComboBox)
- {
- if (this.dataList1 == null || this.dataList2 == null || this.dataList1 == null)
- {
- this.label8.Text = "0";
- }
- else
- {
- decimal value;
- try
- {
- value = Convert.ToDecimal(textBox1.Text);
- if (value == 0) {
- value = 1;
- }
- }
- catch (Exception ex)
- {
- value = 1;
- }
- // 总放大倍数
- this.label8.Text = (Convert.ToDecimal(this.comboBox2.SelectedValue)
- * Convert.ToDecimal(this.comboBox1.SelectedValue) * Convert.ToDecimal(this.comboBox3.SelectedValue) * value).ToString();
- if (this.comboBox4.DataSource != null
- && this.comboBox1.SelectedValue != null && Convert.ToDecimal(this.comboBox1.SelectedValue) != 0
- && this.comboBox2.SelectedValue != null && Convert.ToDecimal(this.comboBox2.SelectedValue) != 0
- && this.comboBox3.SelectedValue != null && Convert.ToDecimal(this.comboBox3.SelectedValue) != 0 && this.pixel_size!=null)
- this.label10.Text = (Math.Round(Convert.ToDecimal(this.pixel_size) / Convert.ToDecimal(this.comboBox3.SelectedValue) / Convert.ToDecimal(this.comboBox1.SelectedValue) / Convert.ToDecimal(this.comboBox2.SelectedValue) ,4)/*/ Convert.ToDecimal(this.resolution) / value,4)*/).ToString();
- else
- this.label10.Text = string.Empty;
- }
- }
- }
- /// <summary>
- /// 添加按钮按下(物镜)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- AddingRecordDialog addingRecordDialog = new AddingRecordDialog(2);
- addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
- addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Objectlens.text")+ ")";
- addingRecordDialog.dataList = new ArrayList();
- addingRecordDialog.dataList = (ArrayList)this.comboBox2.DataSource;
- addingRecordDialog.ShowDialog(this);
- }
- /// <summary>
- /// 添加按钮按下(中间变倍器)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- AddingRecordDialog addingRecordDialog = new AddingRecordDialog(1);
- addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
- addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Intermediatemultiplier.text")+ ")";
- addingRecordDialog.dataList = new ArrayList();
- addingRecordDialog.dataList = (ArrayList)this.comboBox1.DataSource;
- addingRecordDialog.ShowDialog(this);
- }
- /// <summary>
- /// 添加按钮按下(相机适配器)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- AddingRecordDialog addingRecordDialog = new AddingRecordDialog(3);
- addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
- addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Cameraadapter.text")+ ")";
- addingRecordDialog.dataList = new ArrayList();
- addingRecordDialog.dataList = (ArrayList)this.comboBox3.DataSource;
- addingRecordDialog.ShowDialog(this);
- }
- /// <summary>
- /// 物镜删除项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.dataList2.Count > 0)
- {
- if (this.comboBox2.SelectedIndex == -1)
- this.comboBox2.SelectedIndex = 0;
- int index = this.comboBox2.SelectedIndex;
- this.dataList2.RemoveAt(this.comboBox2.SelectedIndex);
- this.comboBox2.DataSource = null;
- this.comboBox2.DataSource = this.dataList2;
- if (index == 0 && this.dataList2.Count > 0)
- this.comboBox2.SelectedIndex = index;
- else
- this.comboBox2.SelectedIndex = index - 1;
- this.comboBox2.DisplayMember = "Value";
- this.comboBox2.ValueMember = "Key";
- }
- }
- /// <summary>
- /// 中间变倍器删除项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.dataList1.Count > 0)
- {
- if (this.comboBox1.SelectedIndex == -1)
- this.comboBox1.SelectedIndex = 0;
- int index = this.comboBox1.SelectedIndex;
- this.dataList1.RemoveAt(this.comboBox1.SelectedIndex);
- this.comboBox1.DataSource = null;
- this.comboBox1.DataSource = this.dataList1;
- if (index == 0 && this.dataList1.Count > 0)
- this.comboBox1.SelectedIndex = index;
- else
- this.comboBox1.SelectedIndex = index - 1;
- this.comboBox1.DisplayMember = "Value";
- this.comboBox1.ValueMember = "Key";
- }
- }
- /// <summary>
- /// 相机适配器删除项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.dataList3.Count > 0)
- {
- if (this.comboBox3.SelectedIndex == -1)
- this.comboBox3.SelectedIndex = 0;
- int index = this.comboBox3.SelectedIndex;
- this.dataList3.RemoveAt(this.comboBox3.SelectedIndex);
- this.comboBox3.DataSource = null;
- this.comboBox3.DataSource = this.dataList3;
- if (index == 0 && this.dataList3.Count > 0)
- this.comboBox3.SelectedIndex = index;
- else
- this.comboBox3.SelectedIndex = index - 1;
- this.comboBox3.DisplayMember = "Value";
- this.comboBox3.ValueMember = "Key";
- }
- }
- /// <summary>
- /// 物镜下拉数据更改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.CalculatedValue();
- this.initComboBox = true;
- }
- /// <summary>
- /// 中间变倍器数据更改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.CalculatedValue();
- this.initComboBox = true;
- }
- /// <summary>
- /// 相机适配器数据更改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.CalculatedValue();
- this.initComboBox = true;
- }
- public mic_rulers mic_Rulers;
- /// <summary>
- /// 向标尺添加临时数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- if(this.pixel_size !=null)
- {
- viewItem = new ListViewItem();
- mic_Rulers = new mic_rulers();
- //int id = 0;
- ////判断标尺是否存在
- //for (int i = 0; i < Startup.instance.mic_rulersAll.Count; i++)
- //{
- // if (Startup.instance.mic_rulersAll[i].ruler_name.Equals(PdnResources.GetString("Menu.Temporaryruler.Text")))
- // {
- // MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
- // return;
- // }
- // if (Startup.instance.mic_rulersAll[i].id < id)
- // {
- // id = Startup.instance.mic_rulersAll[i].id;
- // }
- //}
- //mic_Rulers.id = id - 1;
- mic_Rulers.ruler_name = "理论比例尺";
- try
- {
- mic_Rulers.gain_multiple = decimal.Parse(this.label8.Text);
- }
- catch (Exception)
- {
- mic_Rulers.gain_multiple = 1;
- }
- mic_Rulers.pixel_length = 1;
- //mic_Rulers.physical_length = (decimal.Parse(this.sideLength) / decimal.Parse(this.label8.Text)); //实际物理长度 = 软件感光边长/总放大倍数
- try
- {
- mic_Rulers.physical_length = decimal.Parse(this.label10.Text);
- }
- catch (Exception)
- {
- mic_Rulers.physical_length = 1;
- }
- mic_Rulers.ruler_units = 4;
- mic_Rulers.ruler_width = 0;
- mic_Rulers.ruler_height = 0;
- mic_Rulers.ruler_zoom = this.comboBox1.Text;
- mic_Rulers.objective_lens = this.comboBox2.Text;
- mic_Rulers.ruler_type = 1;
- mic_rulers_BLL.Add(mic_Rulers);
- Startup.instance.mic_rulersAll.Add(mic_Rulers);
- if (CameraPreviewDialog.cameraPreviewDialog != null)
- CameraPreviewDialog.cameraPreviewDialog.BindingRule();
- //viewItem.SubItems.Add(PdnResources.GetString("Menu.Temporaryruler.Text"));
- //viewItem.SubItems.Add(this.label8.Text);
- //viewItem.SubItems.Add(this.resolution);
- //viewItem.SubItems.Add(this.sideLength);
- //viewItem.SubItems.Add(PdnResources.GetString("Menu.Micron.text"));
- //viewItem.SubItems.Add("0*0");
- //viewItem.SubItems.Add("");
- //viewItem.SubItems.Add("");
- //viewItem.SubItems.Add("");
- //viewItem.SubItems.Add("");
- //viewItem.SubItems.Add("");
- //viewItem.SubItems.Add("");
- //viewItem.Tag = "temporary";
- //RuleListForm.viewItem = viewItem;
- MessageBox.Show(PdnResources.GetString("Menu.Applicationsuccessfully.Text")+ "!");
- this.Close();
- this.appWorkspace.RefueshRuleList();
- //this.appWorkspace.ActivateTemporaryRuler();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectcameramodel.Text")+"!");
- }
- }
- /// <summary>
- /// 画面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void TheoreticalScaleDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- MeasureActionMenu.ArrayList1 = (ArrayList)this.comboBox1.DataSource;
- MeasureActionMenu.ArrayList2 = (ArrayList)this.comboBox2.DataSource;
- MeasureActionMenu.ArrayList3 = (ArrayList)this.comboBox3.DataSource;
- }
- /// <summary>
- /// 相机型号改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox4_SelectedValueChanged(object sender, EventArgs e)
- {
- // 相机信息数据取得
- var screenList = mic_camerasettings_BLL.FindAll();
- if (screenList != null && screenList.Count > 0)
- {
- foreach (var item in screenList)
- {
- if (item.camera_model.Equals(this.comboBox4.SelectedValue))
- {
- this.pixel_size = item.pixel_size;
- //this.resolution = item.resolution;
- }
- }
- //this.label9.Text = this.resolution;
- }
- else
- {
- //this.label9.Text = "0";
- }
- this.CalculatedValue();
- this.initComboBoxAll = true;
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- this.CalculatedValue();
- }
- }
- }
|