TheoreticalScaleDialog.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. using PaintDotNet.DbOpreate.DbBll;
  2. using PaintDotNet.DbOpreate.DbModel;
  3. using PaintDotNet.ImageCollect;
  4. using PaintDotNet.Menus;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace PaintDotNet.Measuring
  16. {
  17. /// <summary>
  18. /// 理论比例尺
  19. /// </summary>
  20. partial class TheoreticalScaleDialog : Form
  21. {
  22. /// <summary>
  23. /// 主控件
  24. /// </summary>
  25. AppWorkspace appWorkspace;
  26. /// <summary>
  27. /// 初始化下拉标记
  28. /// </summary>
  29. private bool initComboBox = false;
  30. /// <summary>
  31. /// 初始化下拉标记All
  32. /// </summary>
  33. private bool initComboBoxAll = false;
  34. /// <summary>
  35. /// 下拉框添加项目
  36. /// </summary>
  37. public static DictionaryEntry addComboboxitem;
  38. /// <summary>
  39. /// 下拉框添加项目区分(2:物镜 1:中间变倍器 3:相机适配器)
  40. /// </summary>
  41. public static int addComboboxitemKb;
  42. /// <summary>
  43. /// 下拉框项目(物镜)
  44. /// </summary>
  45. private ArrayList dataList2;
  46. /// <summary>
  47. /// 下拉框项目(中间变倍器)
  48. /// </summary>
  49. private ArrayList dataList1;
  50. /// <summary>
  51. /// 下拉框项目(相机适配器)
  52. /// </summary>
  53. private ArrayList dataList3;
  54. /// <summary>
  55. /// 临时数据
  56. /// </summary>
  57. public ListViewItem viewItem;
  58. /// <summary>
  59. /// 感光软件边长
  60. /// </summary>
  61. private string sideLength;
  62. /// <summary>
  63. /// 边长分辨率
  64. /// </summary>
  65. private string resolution;
  66. private string pixel_size;
  67. #region 控件
  68. private Label label1;
  69. private Label label2;
  70. private Label label3;
  71. private Label label4;
  72. private Label label5;
  73. private Label label6;
  74. private Label label7;
  75. private Label label8;
  76. private Label label9;
  77. private Label label10;
  78. private ComboBox comboBox1;
  79. private ComboBox comboBox2;
  80. private ComboBox comboBox3;
  81. private ComboBox comboBox4;
  82. private Button button1;
  83. private Button button2;
  84. private Button button3;
  85. private Button button4;
  86. private Button button5;
  87. private Button button6;
  88. private Label label11;
  89. private TextBox textBox1;
  90. public Button button7;
  91. private void InitializeLanguageText()
  92. {
  93. this.label1.Text = PdnResources.GetString("Menu.Objectlens.text") + ":";
  94. this.label2.Text = PdnResources.GetString("Menu.Intermediatemultiplier.text") + ":";
  95. this.label3.Text = PdnResources.GetString("Menu.Cameraadapter.text") + ":";
  96. this.label4.Text = PdnResources.GetString("Menu.Totalmagnification.text") + ":";
  97. this.label5.Text = PdnResources.GetString("Menu.ImageResolution.text") + ":";
  98. this.label6.Text = PdnResources.GetString("Menu.Cameramodel.text") + ":";
  99. this.label7.Text = PdnResources.GetString("Menu.scale.text") + ":";
  100. this.label8.Text = PdnResources.GetString("Menu.Objectlens.text") + "*" + PdnResources.GetString("Menu.Intermediatemultiplier.text") + "*" + PdnResources.GetString("Menu.Cameraadapter.text");
  101. this.label9.Text = PdnResources.GetString("Menu.heresolutionofthecurre.Text");
  102. this.label10.Text = PdnResources.GetString("Menu.Automaticcalculation.Text");
  103. this.comboBox4.Items.AddRange(new object[] {
  104. PdnResources.GetString("Menu.Maintainthecamerarecordandcor.Text")});
  105. this.button7.Text = PdnResources.GetString("Menu.Applyscale.text");
  106. this.Text = PdnResources.GetString("Menu.MeasureAction.TheoreticalScale.Text");
  107. }
  108. private void InitializeComponent()
  109. {
  110. this.label1 = new System.Windows.Forms.Label();
  111. this.label2 = new System.Windows.Forms.Label();
  112. this.label3 = new System.Windows.Forms.Label();
  113. this.label4 = new System.Windows.Forms.Label();
  114. this.label5 = new System.Windows.Forms.Label();
  115. this.label6 = new System.Windows.Forms.Label();
  116. this.label7 = new System.Windows.Forms.Label();
  117. this.label8 = new System.Windows.Forms.Label();
  118. this.label9 = new System.Windows.Forms.Label();
  119. this.label10 = new System.Windows.Forms.Label();
  120. this.comboBox1 = new System.Windows.Forms.ComboBox();
  121. this.comboBox2 = new System.Windows.Forms.ComboBox();
  122. this.comboBox3 = new System.Windows.Forms.ComboBox();
  123. this.comboBox4 = new System.Windows.Forms.ComboBox();
  124. this.button1 = new System.Windows.Forms.Button();
  125. this.button2 = new System.Windows.Forms.Button();
  126. this.button3 = new System.Windows.Forms.Button();
  127. this.button4 = new System.Windows.Forms.Button();
  128. this.button5 = new System.Windows.Forms.Button();
  129. this.button6 = new System.Windows.Forms.Button();
  130. this.button7 = new System.Windows.Forms.Button();
  131. this.label11 = new System.Windows.Forms.Label();
  132. this.textBox1 = new System.Windows.Forms.TextBox();
  133. this.SuspendLayout();
  134. //
  135. // label1
  136. //
  137. this.label1.AutoSize = true;
  138. this.label1.ForeColor = System.Drawing.SystemColors.MenuText;
  139. this.label1.Location = new System.Drawing.Point(49, 25);
  140. this.label1.Name = "label1";
  141. this.label1.Size = new System.Drawing.Size(41, 12);
  142. this.label1.TabIndex = 0;
  143. this.label1.Text = "物镜:";
  144. //
  145. // label2
  146. //
  147. this.label2.AutoSize = true;
  148. this.label2.ForeColor = System.Drawing.SystemColors.MenuText;
  149. this.label2.Location = new System.Drawing.Point(13, 53);
  150. this.label2.Name = "label2";
  151. this.label2.Size = new System.Drawing.Size(77, 12);
  152. this.label2.TabIndex = 1;
  153. this.label2.Text = "中间变倍器:";
  154. //
  155. // label3
  156. //
  157. this.label3.AutoSize = true;
  158. this.label3.ForeColor = System.Drawing.SystemColors.MenuText;
  159. this.label3.Location = new System.Drawing.Point(13, 81);
  160. this.label3.Name = "label3";
  161. this.label3.Size = new System.Drawing.Size(77, 12);
  162. this.label3.TabIndex = 2;
  163. this.label3.Text = "相机适配器:";
  164. //
  165. // label4
  166. //
  167. this.label4.AutoSize = true;
  168. this.label4.ForeColor = System.Drawing.SystemColors.MenuText;
  169. this.label4.Location = new System.Drawing.Point(13, 149);
  170. this.label4.Name = "label4";
  171. this.label4.Size = new System.Drawing.Size(77, 12);
  172. this.label4.TabIndex = 3;
  173. this.label4.Text = "总放大倍数:";
  174. //
  175. // label5
  176. //
  177. this.label5.AutoSize = true;
  178. this.label5.ForeColor = System.Drawing.SystemColors.MenuText;
  179. this.label5.Location = new System.Drawing.Point(13, 181);
  180. this.label5.Name = "label5";
  181. this.label5.Size = new System.Drawing.Size(77, 12);
  182. this.label5.TabIndex = 4;
  183. this.label5.Text = "图像分辨率:";
  184. this.label5.Visible = false;
  185. //
  186. // label6
  187. //
  188. this.label6.AutoSize = true;
  189. this.label6.ForeColor = System.Drawing.SystemColors.MenuText;
  190. this.label6.Location = new System.Drawing.Point(25, 181);
  191. this.label6.Name = "label6";
  192. this.label6.Size = new System.Drawing.Size(65, 12);
  193. this.label6.TabIndex = 5;
  194. this.label6.Text = "相机型号:";
  195. //
  196. // label7
  197. //
  198. this.label7.AutoSize = true;
  199. this.label7.ForeColor = System.Drawing.SystemColors.MenuText;
  200. this.label7.Location = new System.Drawing.Point(37, 207);
  201. this.label7.Name = "label7";
  202. this.label7.Size = new System.Drawing.Size(53, 12);
  203. this.label7.TabIndex = 6;
  204. this.label7.Text = "比例尺:";
  205. //
  206. // label8
  207. //
  208. this.label8.AutoSize = true;
  209. this.label8.ForeColor = System.Drawing.SystemColors.MenuText;
  210. this.label8.Location = new System.Drawing.Point(90, 149);
  211. this.label8.Name = "label8";
  212. this.label8.Size = new System.Drawing.Size(0, 12);
  213. this.label8.TabIndex = 7;
  214. //
  215. // label9
  216. //
  217. this.label9.AutoSize = true;
  218. this.label9.ForeColor = System.Drawing.SystemColors.MenuText;
  219. this.label9.Location = new System.Drawing.Point(90, 181);
  220. this.label9.Name = "label9";
  221. this.label9.Size = new System.Drawing.Size(0, 12);
  222. this.label9.TabIndex = 8;
  223. this.label9.Visible = false;
  224. //
  225. // label10
  226. //
  227. this.label10.AutoSize = true;
  228. this.label10.ForeColor = System.Drawing.SystemColors.MenuText;
  229. this.label10.Location = new System.Drawing.Point(90, 207);
  230. this.label10.Name = "label10";
  231. this.label10.Size = new System.Drawing.Size(0, 12);
  232. this.label10.TabIndex = 9;
  233. //
  234. // comboBox1
  235. //
  236. this.comboBox1.FormattingEnabled = true;
  237. this.comboBox1.Location = new System.Drawing.Point(90, 50);
  238. this.comboBox1.Name = "comboBox1";
  239. this.comboBox1.Size = new System.Drawing.Size(135, 20);
  240. this.comboBox1.TabIndex = 10;
  241. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  242. //
  243. // comboBox2
  244. //
  245. this.comboBox2.FormattingEnabled = true;
  246. this.comboBox2.Location = new System.Drawing.Point(90, 22);
  247. this.comboBox2.Name = "comboBox2";
  248. this.comboBox2.Size = new System.Drawing.Size(135, 20);
  249. this.comboBox2.TabIndex = 11;
  250. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  251. //
  252. // comboBox3
  253. //
  254. this.comboBox3.FormattingEnabled = true;
  255. this.comboBox3.Location = new System.Drawing.Point(90, 81);
  256. this.comboBox3.Name = "comboBox3";
  257. this.comboBox3.Size = new System.Drawing.Size(135, 20);
  258. this.comboBox3.TabIndex = 12;
  259. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  260. //
  261. // comboBox4
  262. //
  263. this.comboBox4.FormattingEnabled = true;
  264. this.comboBox4.Location = new System.Drawing.Point(90, 178);
  265. this.comboBox4.Name = "comboBox4";
  266. this.comboBox4.Size = new System.Drawing.Size(135, 20);
  267. this.comboBox4.TabIndex = 13;
  268. this.comboBox4.SelectedValueChanged += new System.EventHandler(this.comboBox4_SelectedValueChanged);
  269. //
  270. // button1
  271. //
  272. this.button1.Location = new System.Drawing.Point(239, 22);
  273. this.button1.Name = "button1";
  274. this.button1.Size = new System.Drawing.Size(25, 25);
  275. this.button1.TabIndex = 14;
  276. this.button1.Text = "+";
  277. this.button1.UseVisualStyleBackColor = true;
  278. this.button1.Click += new System.EventHandler(this.button1_Click);
  279. //
  280. // button2
  281. //
  282. this.button2.Location = new System.Drawing.Point(272, 22);
  283. this.button2.Name = "button2";
  284. this.button2.Size = new System.Drawing.Size(25, 25);
  285. this.button2.TabIndex = 15;
  286. this.button2.Text = "-";
  287. this.button2.UseVisualStyleBackColor = true;
  288. this.button2.Click += new System.EventHandler(this.button2_Click);
  289. //
  290. // button3
  291. //
  292. this.button3.Location = new System.Drawing.Point(239, 49);
  293. this.button3.Name = "button3";
  294. this.button3.Size = new System.Drawing.Size(25, 25);
  295. this.button3.TabIndex = 16;
  296. this.button3.Text = "+";
  297. this.button3.UseVisualStyleBackColor = true;
  298. this.button3.Click += new System.EventHandler(this.button3_Click);
  299. //
  300. // button4
  301. //
  302. this.button4.Location = new System.Drawing.Point(272, 50);
  303. this.button4.Name = "button4";
  304. this.button4.Size = new System.Drawing.Size(25, 25);
  305. this.button4.TabIndex = 17;
  306. this.button4.Text = "-";
  307. this.button4.UseVisualStyleBackColor = true;
  308. this.button4.Click += new System.EventHandler(this.button4_Click);
  309. //
  310. // button5
  311. //
  312. this.button5.Location = new System.Drawing.Point(239, 77);
  313. this.button5.Name = "button5";
  314. this.button5.Size = new System.Drawing.Size(25, 25);
  315. this.button5.TabIndex = 18;
  316. this.button5.Text = "+";
  317. this.button5.UseVisualStyleBackColor = true;
  318. this.button5.Click += new System.EventHandler(this.button5_Click);
  319. //
  320. // button6
  321. //
  322. this.button6.Location = new System.Drawing.Point(272, 77);
  323. this.button6.Name = "button6";
  324. this.button6.Size = new System.Drawing.Size(25, 25);
  325. this.button6.TabIndex = 19;
  326. this.button6.Text = "-";
  327. this.button6.UseVisualStyleBackColor = true;
  328. this.button6.Click += new System.EventHandler(this.button6_Click);
  329. //
  330. // button7
  331. //
  332. this.button7.Location = new System.Drawing.Point(106, 244);
  333. this.button7.Name = "button7";
  334. this.button7.Size = new System.Drawing.Size(78, 25);
  335. this.button7.TabIndex = 20;
  336. this.button7.Text = "应用比例尺";
  337. this.button7.UseVisualStyleBackColor = true;
  338. this.button7.Click += new System.EventHandler(this.button7_Click);
  339. //
  340. // label11
  341. //
  342. this.label11.AutoSize = true;
  343. this.label11.ForeColor = System.Drawing.SystemColors.MenuText;
  344. this.label11.Location = new System.Drawing.Point(13, 121);
  345. this.label11.Name = "label11";
  346. this.label11.Size = new System.Drawing.Size(65, 12);
  347. this.label11.TabIndex = 21;
  348. this.label11.Text = "附加倍率:";
  349. //
  350. // textBox1
  351. //
  352. this.textBox1.Location = new System.Drawing.Point(90, 118);
  353. this.textBox1.Name = "textBox1";
  354. this.textBox1.Size = new System.Drawing.Size(135, 21);
  355. this.textBox1.TabIndex = 22;
  356. this.textBox1.Text = "1";
  357. this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
  358. //
  359. // TheoreticalScaleDialog
  360. //
  361. this.BackColor = System.Drawing.SystemColors.Control;
  362. this.ClientSize = new System.Drawing.Size(312, 301);
  363. this.Controls.Add(this.textBox1);
  364. this.Controls.Add(this.label11);
  365. this.Controls.Add(this.button7);
  366. this.Controls.Add(this.button6);
  367. this.Controls.Add(this.button5);
  368. this.Controls.Add(this.button4);
  369. this.Controls.Add(this.button3);
  370. this.Controls.Add(this.button2);
  371. this.Controls.Add(this.button1);
  372. this.Controls.Add(this.comboBox4);
  373. this.Controls.Add(this.comboBox3);
  374. this.Controls.Add(this.comboBox2);
  375. this.Controls.Add(this.comboBox1);
  376. this.Controls.Add(this.label10);
  377. this.Controls.Add(this.label9);
  378. this.Controls.Add(this.label8);
  379. this.Controls.Add(this.label7);
  380. this.Controls.Add(this.label6);
  381. this.Controls.Add(this.label5);
  382. this.Controls.Add(this.label4);
  383. this.Controls.Add(this.label3);
  384. this.Controls.Add(this.label2);
  385. this.Controls.Add(this.label1);
  386. this.MaximizeBox = false;
  387. this.MaximumSize = new System.Drawing.Size(328, 340);
  388. this.MinimizeBox = false;
  389. this.MinimumSize = new System.Drawing.Size(328, 340);
  390. this.Name = "TheoreticalScaleDialog";
  391. this.ShowInTaskbar = false;
  392. this.Text = "理论比例尺";
  393. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TheoreticalScaleDialog_FormClosing);
  394. this.Load += new System.EventHandler(this.TheoreticalScaleDialog_Load);
  395. this.ResumeLayout(false);
  396. this.PerformLayout();
  397. }
  398. private void TheoreticalScaleDialog_Load(object sender, EventArgs e)
  399. {
  400. }
  401. #endregion
  402. /// <summary>
  403. /// 初始化
  404. /// </summary>
  405. public TheoreticalScaleDialog(AppWorkspace appWorkspace, ArrayList arrayList1, ArrayList arrayList2, ArrayList arrayList3)
  406. {
  407. this.appWorkspace = appWorkspace;
  408. InitializeComponent();
  409. InitializeLanguageText();
  410. this.dataList2 = new ArrayList();
  411. this.dataList1 = new ArrayList();
  412. this.dataList3 = new ArrayList();
  413. if (MeasureActionMenu.InitKb)
  414. this.InitCombobox();
  415. else
  416. {
  417. this.dataList2 = arrayList2;
  418. this.dataList1 = arrayList1;
  419. this.dataList3 = arrayList3;
  420. if (arrayList2 != null && arrayList2.Count > 0)
  421. {
  422. this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  423. this.comboBox2.DataSource = arrayList2;
  424. this.comboBox2.DisplayMember = "Value";
  425. this.comboBox2.ValueMember = "Key";
  426. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  427. }
  428. if (arrayList1 != null && arrayList1.Count > 0)
  429. {
  430. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  431. this.comboBox1.DataSource = arrayList1;
  432. this.comboBox1.DisplayMember = "Value";
  433. this.comboBox1.ValueMember = "Key";
  434. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  435. }
  436. if (arrayList3 != null && arrayList3.Count > 0)
  437. {
  438. this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  439. this.comboBox3.DataSource = arrayList3;
  440. this.comboBox3.DisplayMember = "Value";
  441. this.comboBox3.ValueMember = "Key";
  442. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  443. }
  444. }
  445. this.comboBox3_SelectedIndexChanged(null, null);
  446. this.GetCameraInformation();
  447. }
  448. /// <summary>
  449. /// 取得相机信息初始化相机型号下拉框
  450. /// </summary>
  451. private void GetCameraInformation()
  452. {
  453. // 相机信息数据取得
  454. var screenList = mic_camerasettings_BLL.FindAll();
  455. ArrayList arrayList = new ArrayList();
  456. if (screenList != null && screenList.Count > 0)
  457. {
  458. foreach (var item in screenList)
  459. {
  460. arrayList.Add(item.camera_model);
  461. }
  462. this.comboBox4.DataSource = null;
  463. this.comboBox4.DataSource = arrayList;
  464. }
  465. else
  466. {
  467. arrayList.Add(PdnResources.GetString("Menu.Nocamerarecord.text"));
  468. this.comboBox4.DataSource = null;
  469. this.comboBox4.DataSource = arrayList;
  470. }
  471. }
  472. /// <summary>
  473. /// 刷新理论比例尺
  474. /// </summary>
  475. /// <param name="sender"></param>
  476. /// <param name="e"></param>
  477. public void RefreshListView()
  478. {
  479. if (this.dataList2 == null)
  480. {
  481. this.dataList2 = new ArrayList();
  482. }
  483. if (this.dataList1 == null)
  484. {
  485. this.dataList1 = new ArrayList();
  486. }
  487. if (this.dataList3 == null)
  488. {
  489. this.dataList3 = new ArrayList();
  490. }
  491. if (addComboboxitemKb == 2 && !this.dataList2.Contains(addComboboxitem))
  492. {
  493. this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  494. this.comboBox2.DataSource = null;
  495. this.dataList2.Add(addComboboxitem);
  496. this.comboBox2.DataSource = this.dataList2;
  497. this.comboBox2.DisplayMember = "Value";
  498. this.comboBox2.ValueMember = "Key";
  499. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  500. this.comboBox2.SelectedIndex = this.dataList2.Count - 1;
  501. }
  502. if (addComboboxitemKb == 1 && !this.dataList1.Contains(addComboboxitem))
  503. {
  504. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  505. this.comboBox1.DataSource = null;
  506. this.dataList1.Add(addComboboxitem);
  507. this.comboBox1.DataSource = this.dataList1;
  508. this.comboBox1.DisplayMember = "Value";
  509. this.comboBox1.ValueMember = "Key";
  510. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  511. this.comboBox1.SelectedIndex = this.dataList1.Count - 1;
  512. }
  513. if (addComboboxitemKb == 3 && !this.dataList3.Contains(addComboboxitem))
  514. {
  515. this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  516. this.comboBox3.DataSource = null;
  517. this.dataList3.Add(addComboboxitem);
  518. this.comboBox3.DataSource = this.dataList3;
  519. this.comboBox3.DisplayMember = "Value";
  520. this.comboBox3.ValueMember = "Key";
  521. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  522. this.comboBox3.SelectedIndex = this.dataList3.Count - 1;
  523. }
  524. }
  525. /// <summary>
  526. /// 初始化设置
  527. /// </summary>
  528. private void InitCombobox()
  529. {
  530. // 物镜
  531. this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  532. this.comboBox2.DataSource = null;
  533. this.dataList2.Add(new DictionaryEntry((decimal)1, "1X"));
  534. this.dataList2.Add(new DictionaryEntry((decimal)2, "2X"));
  535. this.dataList2.Add(new DictionaryEntry((decimal)3, "3X"));
  536. this.dataList2.Add(new DictionaryEntry((decimal)4, "4X"));
  537. this.comboBox2.DataSource = this.dataList2;
  538. this.comboBox2.DisplayMember = "Value";
  539. this.comboBox2.ValueMember = "Key";
  540. this.comboBox2.SelectedIndex = 0;
  541. this.comboBox2.Focus();
  542. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  543. // 中间变倍器
  544. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  545. this.comboBox1.DataSource = null;
  546. this.dataList1.Add(new DictionaryEntry((decimal)1, "1X"));
  547. this.dataList1.Add(new DictionaryEntry((decimal)1.5, "1.5X"));
  548. this.dataList1.Add(new DictionaryEntry((decimal)2, "2X"));
  549. this.dataList1.Add(new DictionaryEntry((decimal)3, "3X"));
  550. this.dataList1.Add(new DictionaryEntry((decimal)4, "4X"));
  551. this.comboBox1.DataSource = this.dataList1;
  552. this.comboBox1.DisplayMember = "Value";
  553. this.comboBox1.ValueMember = "Key";
  554. this.comboBox1.SelectedIndex = 0;
  555. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  556. this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  557. // 相机适配器
  558. this.comboBox3.DataSource = null;
  559. this.dataList3.Add(new DictionaryEntry((decimal)0.4, "0.4X"));
  560. this.dataList3.Add(new DictionaryEntry((decimal)0.6, "0.6X"));
  561. this.comboBox3.DataSource = this.dataList3;
  562. this.comboBox3.DisplayMember = "Value";
  563. this.comboBox3.ValueMember = "Key";
  564. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  565. this.comboBox3.SelectedIndex = 0;
  566. List<mic_rulers> list = mic_rulers_BLL.FindAll();
  567. this.label9.Text = list[0].ruler_width + "*" + list[0].ruler_height;
  568. MeasureActionMenu.InitKb = false;
  569. }
  570. /// <summary>
  571. /// 画面计算
  572. /// </summary>
  573. private void CalculatedValue()
  574. {
  575. if (this.initComboBox)
  576. {
  577. if (this.dataList1 == null || this.dataList2 == null || this.dataList1 == null)
  578. {
  579. this.label8.Text = "0";
  580. }
  581. else
  582. {
  583. decimal value;
  584. try
  585. {
  586. value = Convert.ToDecimal(textBox1.Text);
  587. if (value == 0) {
  588. value = 1;
  589. }
  590. }
  591. catch (Exception ex)
  592. {
  593. value = 1;
  594. }
  595. // 总放大倍数
  596. this.label8.Text = (Convert.ToDecimal(this.comboBox2.SelectedValue)
  597. * Convert.ToDecimal(this.comboBox1.SelectedValue) * Convert.ToDecimal(this.comboBox3.SelectedValue) * value).ToString();
  598. if (this.comboBox4.DataSource != null
  599. && this.comboBox1.SelectedValue != null && Convert.ToDecimal(this.comboBox1.SelectedValue) != 0
  600. && this.comboBox2.SelectedValue != null && Convert.ToDecimal(this.comboBox2.SelectedValue) != 0
  601. && this.comboBox3.SelectedValue != null && Convert.ToDecimal(this.comboBox3.SelectedValue) != 0 && this.pixel_size!=null)
  602. 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();
  603. else
  604. this.label10.Text = string.Empty;
  605. }
  606. }
  607. }
  608. /// <summary>
  609. /// 添加按钮按下(物镜)
  610. /// </summary>
  611. /// <param name="sender"></param>
  612. /// <param name="e"></param>
  613. private void button1_Click(object sender, EventArgs e)
  614. {
  615. AddingRecordDialog addingRecordDialog = new AddingRecordDialog(2);
  616. addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
  617. addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Objectlens.text")+ ")";
  618. addingRecordDialog.dataList = new ArrayList();
  619. addingRecordDialog.dataList = (ArrayList)this.comboBox2.DataSource;
  620. addingRecordDialog.ShowDialog(this);
  621. }
  622. /// <summary>
  623. /// 添加按钮按下(中间变倍器)
  624. /// </summary>
  625. /// <param name="sender"></param>
  626. /// <param name="e"></param>
  627. private void button3_Click(object sender, EventArgs e)
  628. {
  629. AddingRecordDialog addingRecordDialog = new AddingRecordDialog(1);
  630. addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
  631. addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Intermediatemultiplier.text")+ ")";
  632. addingRecordDialog.dataList = new ArrayList();
  633. addingRecordDialog.dataList = (ArrayList)this.comboBox1.DataSource;
  634. addingRecordDialog.ShowDialog(this);
  635. }
  636. /// <summary>
  637. /// 添加按钮按下(相机适配器)
  638. /// </summary>
  639. /// <param name="sender"></param>
  640. /// <param name="e"></param>
  641. private void button5_Click(object sender, EventArgs e)
  642. {
  643. AddingRecordDialog addingRecordDialog = new AddingRecordDialog(3);
  644. addingRecordDialog.StartPosition = FormStartPosition.CenterParent;
  645. addingRecordDialog.Text = addingRecordDialog.Text + "("+ PdnResources.GetString("Menu.Cameraadapter.text")+ ")";
  646. addingRecordDialog.dataList = new ArrayList();
  647. addingRecordDialog.dataList = (ArrayList)this.comboBox3.DataSource;
  648. addingRecordDialog.ShowDialog(this);
  649. }
  650. /// <summary>
  651. /// 物镜删除项目
  652. /// </summary>
  653. /// <param name="sender"></param>
  654. /// <param name="e"></param>
  655. private void button2_Click(object sender, EventArgs e)
  656. {
  657. if (this.dataList2.Count > 0)
  658. {
  659. if (this.comboBox2.SelectedIndex == -1)
  660. this.comboBox2.SelectedIndex = 0;
  661. int index = this.comboBox2.SelectedIndex;
  662. this.dataList2.RemoveAt(this.comboBox2.SelectedIndex);
  663. this.comboBox2.DataSource = null;
  664. this.comboBox2.DataSource = this.dataList2;
  665. if (index == 0 && this.dataList2.Count > 0)
  666. this.comboBox2.SelectedIndex = index;
  667. else
  668. this.comboBox2.SelectedIndex = index - 1;
  669. this.comboBox2.DisplayMember = "Value";
  670. this.comboBox2.ValueMember = "Key";
  671. }
  672. }
  673. /// <summary>
  674. /// 中间变倍器删除项目
  675. /// </summary>
  676. /// <param name="sender"></param>
  677. /// <param name="e"></param>
  678. private void button4_Click(object sender, EventArgs e)
  679. {
  680. if (this.dataList1.Count > 0)
  681. {
  682. if (this.comboBox1.SelectedIndex == -1)
  683. this.comboBox1.SelectedIndex = 0;
  684. int index = this.comboBox1.SelectedIndex;
  685. this.dataList1.RemoveAt(this.comboBox1.SelectedIndex);
  686. this.comboBox1.DataSource = null;
  687. this.comboBox1.DataSource = this.dataList1;
  688. if (index == 0 && this.dataList1.Count > 0)
  689. this.comboBox1.SelectedIndex = index;
  690. else
  691. this.comboBox1.SelectedIndex = index - 1;
  692. this.comboBox1.DisplayMember = "Value";
  693. this.comboBox1.ValueMember = "Key";
  694. }
  695. }
  696. /// <summary>
  697. /// 相机适配器删除项目
  698. /// </summary>
  699. /// <param name="sender"></param>
  700. /// <param name="e"></param>
  701. private void button6_Click(object sender, EventArgs e)
  702. {
  703. if (this.dataList3.Count > 0)
  704. {
  705. if (this.comboBox3.SelectedIndex == -1)
  706. this.comboBox3.SelectedIndex = 0;
  707. int index = this.comboBox3.SelectedIndex;
  708. this.dataList3.RemoveAt(this.comboBox3.SelectedIndex);
  709. this.comboBox3.DataSource = null;
  710. this.comboBox3.DataSource = this.dataList3;
  711. if (index == 0 && this.dataList3.Count > 0)
  712. this.comboBox3.SelectedIndex = index;
  713. else
  714. this.comboBox3.SelectedIndex = index - 1;
  715. this.comboBox3.DisplayMember = "Value";
  716. this.comboBox3.ValueMember = "Key";
  717. }
  718. }
  719. /// <summary>
  720. /// 物镜下拉数据更改
  721. /// </summary>
  722. /// <param name="sender"></param>
  723. /// <param name="e"></param>
  724. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  725. {
  726. this.CalculatedValue();
  727. this.initComboBox = true;
  728. }
  729. /// <summary>
  730. /// 中间变倍器数据更改
  731. /// </summary>
  732. /// <param name="sender"></param>
  733. /// <param name="e"></param>
  734. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  735. {
  736. this.CalculatedValue();
  737. this.initComboBox = true;
  738. }
  739. /// <summary>
  740. /// 相机适配器数据更改
  741. /// </summary>
  742. /// <param name="sender"></param>
  743. /// <param name="e"></param>
  744. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  745. {
  746. this.CalculatedValue();
  747. this.initComboBox = true;
  748. }
  749. public mic_rulers mic_Rulers;
  750. /// <summary>
  751. /// 向标尺添加临时数据
  752. /// </summary>
  753. /// <param name="sender"></param>
  754. /// <param name="e"></param>
  755. private void button7_Click(object sender, EventArgs e)
  756. {
  757. if(this.pixel_size !=null)
  758. {
  759. viewItem = new ListViewItem();
  760. mic_Rulers = new mic_rulers();
  761. //int id = 0;
  762. ////判断标尺是否存在
  763. //for (int i = 0; i < Startup.instance.mic_rulersAll.Count; i++)
  764. //{
  765. // if (Startup.instance.mic_rulersAll[i].ruler_name.Equals(PdnResources.GetString("Menu.Temporaryruler.Text")))
  766. // {
  767. // MessageBox.Show(PdnResources.GetString("Menu.hecurrentscalenamealreadyexists.Text"));
  768. // return;
  769. // }
  770. // if (Startup.instance.mic_rulersAll[i].id < id)
  771. // {
  772. // id = Startup.instance.mic_rulersAll[i].id;
  773. // }
  774. //}
  775. //mic_Rulers.id = id - 1;
  776. mic_Rulers.ruler_name = "理论比例尺";
  777. try
  778. {
  779. mic_Rulers.gain_multiple = decimal.Parse(this.label8.Text);
  780. }
  781. catch (Exception)
  782. {
  783. mic_Rulers.gain_multiple = 1;
  784. }
  785. mic_Rulers.pixel_length = 1;
  786. //mic_Rulers.physical_length = (decimal.Parse(this.sideLength) / decimal.Parse(this.label8.Text)); //实际物理长度 = 软件感光边长/总放大倍数
  787. try
  788. {
  789. mic_Rulers.physical_length = decimal.Parse(this.label10.Text);
  790. }
  791. catch (Exception)
  792. {
  793. mic_Rulers.physical_length = 1;
  794. }
  795. mic_Rulers.ruler_units = 4;
  796. mic_Rulers.ruler_width = 0;
  797. mic_Rulers.ruler_height = 0;
  798. mic_Rulers.ruler_zoom = this.comboBox1.Text;
  799. mic_Rulers.objective_lens = this.comboBox2.Text;
  800. mic_Rulers.ruler_type = 1;
  801. mic_rulers_BLL.Add(mic_Rulers);
  802. Startup.instance.mic_rulersAll.Add(mic_Rulers);
  803. if (CameraPreviewDialog.cameraPreviewDialog != null)
  804. CameraPreviewDialog.cameraPreviewDialog.BindingRule();
  805. //viewItem.SubItems.Add(PdnResources.GetString("Menu.Temporaryruler.Text"));
  806. //viewItem.SubItems.Add(this.label8.Text);
  807. //viewItem.SubItems.Add(this.resolution);
  808. //viewItem.SubItems.Add(this.sideLength);
  809. //viewItem.SubItems.Add(PdnResources.GetString("Menu.Micron.text"));
  810. //viewItem.SubItems.Add("0*0");
  811. //viewItem.SubItems.Add("");
  812. //viewItem.SubItems.Add("");
  813. //viewItem.SubItems.Add("");
  814. //viewItem.SubItems.Add("");
  815. //viewItem.SubItems.Add("");
  816. //viewItem.SubItems.Add("");
  817. //viewItem.Tag = "temporary";
  818. //RuleListForm.viewItem = viewItem;
  819. MessageBox.Show(PdnResources.GetString("Menu.Applicationsuccessfully.Text")+ "!");
  820. this.Close();
  821. this.appWorkspace.RefueshRuleList();
  822. //this.appWorkspace.ActivateTemporaryRuler();
  823. }
  824. else
  825. {
  826. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectcameramodel.Text")+"!");
  827. }
  828. }
  829. /// <summary>
  830. /// 画面关闭
  831. /// </summary>
  832. /// <param name="sender"></param>
  833. /// <param name="e"></param>
  834. private void TheoreticalScaleDialog_FormClosing(object sender, FormClosingEventArgs e)
  835. {
  836. MeasureActionMenu.ArrayList1 = (ArrayList)this.comboBox1.DataSource;
  837. MeasureActionMenu.ArrayList2 = (ArrayList)this.comboBox2.DataSource;
  838. MeasureActionMenu.ArrayList3 = (ArrayList)this.comboBox3.DataSource;
  839. }
  840. /// <summary>
  841. /// 相机型号改变
  842. /// </summary>
  843. /// <param name="sender"></param>
  844. /// <param name="e"></param>
  845. private void comboBox4_SelectedValueChanged(object sender, EventArgs e)
  846. {
  847. // 相机信息数据取得
  848. var screenList = mic_camerasettings_BLL.FindAll();
  849. if (screenList != null && screenList.Count > 0)
  850. {
  851. foreach (var item in screenList)
  852. {
  853. if (item.camera_model.Equals(this.comboBox4.SelectedValue))
  854. {
  855. this.pixel_size = item.pixel_size;
  856. //this.resolution = item.resolution;
  857. }
  858. }
  859. //this.label9.Text = this.resolution;
  860. }
  861. else
  862. {
  863. //this.label9.Text = "0";
  864. }
  865. this.CalculatedValue();
  866. this.initComboBoxAll = true;
  867. }
  868. private void textBox1_TextChanged(object sender, EventArgs e)
  869. {
  870. this.CalculatedValue();
  871. }
  872. }
  873. }