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 { /// /// 理论比例尺 /// partial class TheoreticalScaleDialog : Form { /// /// 主控件 /// AppWorkspace appWorkspace; /// /// 初始化下拉标记 /// private bool initComboBox = false; /// /// 初始化下拉标记All /// private bool initComboBoxAll = false; /// /// 下拉框添加项目 /// public static DictionaryEntry addComboboxitem; /// /// 下拉框添加项目区分(2:物镜 1:中间变倍器 3:相机适配器) /// public static int addComboboxitemKb; /// /// 下拉框项目(物镜) /// private ArrayList dataList2; /// /// 下拉框项目(中间变倍器) /// private ArrayList dataList1; /// /// 下拉框项目(相机适配器) /// private ArrayList dataList3; /// /// 临时数据 /// public ListViewItem viewItem; /// /// 感光软件边长 /// private string sideLength; /// /// 边长分辨率 /// 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 /// /// 初始化 /// 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(); } /// /// 取得相机信息初始化相机型号下拉框 /// 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; } } /// /// 刷新理论比例尺 /// /// /// 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; } } /// /// 初始化设置 /// 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 list = mic_rulers_BLL.FindAll(); this.label9.Text = list[0].ruler_width + "*" + list[0].ruler_height; MeasureActionMenu.InitKb = false; } /// /// 画面计算 /// 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; } } } /// /// 添加按钮按下(物镜) /// /// /// 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); } /// /// 添加按钮按下(中间变倍器) /// /// /// 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); } /// /// 添加按钮按下(相机适配器) /// /// /// 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); } /// /// 物镜删除项目 /// /// /// 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"; } } /// /// 中间变倍器删除项目 /// /// /// 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"; } } /// /// 相机适配器删除项目 /// /// /// 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"; } } /// /// 物镜下拉数据更改 /// /// /// private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { this.CalculatedValue(); this.initComboBox = true; } /// /// 中间变倍器数据更改 /// /// /// private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { this.CalculatedValue(); this.initComboBox = true; } /// /// 相机适配器数据更改 /// /// /// private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { this.CalculatedValue(); this.initComboBox = true; } public mic_rulers mic_Rulers; /// /// 向标尺添加临时数据 /// /// /// 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")+"!"); } } /// /// 画面关闭 /// /// /// 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; } /// /// 相机型号改变 /// /// /// 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(); } } }