TheoreticalScaleDialog.cs 36 KB

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