AtlasComparisonDialog.cs 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942
  1. using Metis.ParameterSet;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.Base.XmlSaveModel;
  5. using PaintDotNet.DbOpreate.DbBll;
  6. using PaintDotNet.DbOpreate.DbModel;
  7. using PaintDotNet.GeneralAnalysis.CustomInterface;
  8. using PaintDotNet.Processing;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System.IO;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using System.Xml;
  18. namespace PaintDotNet.GeneralAnalysis
  19. {
  20. /// <summary>
  21. /// 图谱比照
  22. /// </summary>
  23. internal class AtlasComparisonDialog : PdnBaseForm
  24. {
  25. #region 控件
  26. private Label label6;
  27. private GroupBox groupBox2;
  28. private TreeView treeView1;
  29. private GroupBox groupBox3;
  30. private ListView listView1;
  31. private GroupBox groupBox4;
  32. private GroupBox groupBox5;
  33. private Button button1;
  34. private Button button2;
  35. private Button button3;
  36. private Button button4;
  37. private Button button5;
  38. private CheckBox checkBox1;
  39. private RadioButton radioButton2;
  40. private RadioButton radioButton1;
  41. private Panel panel1;
  42. private Label label1;
  43. private Label label2;
  44. private GroupBox groupBox1;
  45. private ImageList imageList1;
  46. private IContainer components;
  47. private Panel panel2;
  48. private RadioButton radioButton3;
  49. private RadioButton radioButton6;
  50. private RadioButton radioButton5;
  51. private RadioButton radioButton4;
  52. private PictureUserControl pictureUserControl1, pictureUserControl2,
  53. pictureUserControl3, pictureUserControl4, pictureUserControl5,
  54. pictureUserControl7, pictureUserControl8, pictureUserControl9, pictureUserControl10, pictureUserControl11,
  55. pictureUserControl20, pictureUserControl21, pictureUserControl22,
  56. pictureUserControl23, pictureUserControl24, pictureUserControl25,
  57. pictureUserControl26, pictureUserControl27, pictureUserControl28;
  58. #region 对比对照控件
  59. private Panel panel3;
  60. private Label label3;
  61. private NumericUpDown numericUpDown2;
  62. private NumericUpDown numericUpDown1;
  63. private Label label4;
  64. private Panel panel4;
  65. private Label label5;
  66. private TrackBar trackBar1;
  67. private NumericUpDown numericUpDown3;
  68. private Button button6;
  69. #endregion
  70. private ComboBox comboBox1;
  71. #endregion
  72. /// <summary>
  73. /// 组织的图谱数据集合
  74. /// </summary>
  75. public List<AtlasModel> atlasModels = new List<AtlasModel>();
  76. /// <summary>
  77. /// 1/2/4/8
  78. /// </summary>
  79. private int num = 1;
  80. /// <summary>
  81. /// 待比照的图片
  82. /// </summary>
  83. private Bitmap bitmap;
  84. /// <summary>
  85. /// 图片选择窗口
  86. /// </summary>
  87. private InterImagePickerDialog imagePickerDialog;
  88. /// <summary>
  89. /// 主空间
  90. /// </summary>
  91. private AppWorkspace appWorkspace;
  92. /// <summary>
  93. /// 关联图片
  94. /// </summary>
  95. public bool RelatedPic = false;
  96. /// <summary>
  97. /// 1平铺 2对比
  98. /// </summary>
  99. private int mode = 1;
  100. /// <summary>
  101. /// 步长 初始值1,依次增加
  102. /// </summary>
  103. private string stepLength = "00" + Startup.instance.step_length;
  104. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  105. public AtlasComparisonDialog(AppWorkspace appWorkspace)
  106. {
  107. this.appWorkspace = appWorkspace;
  108. InitializeComponent();
  109. InitializeLanguageText();
  110. this.panel3.Visible = false;
  111. this.panel2.Visible = true;
  112. this.pictureUserControl1 = new PictureUserControl(1, this);
  113. this.pictureUserControl2 = new PictureUserControl(2, this);
  114. InitializeRules();
  115. InitializeAtlasFile();
  116. InitializeTreeView();
  117. InitializeCompareControls();
  118. SetStyle(ControlStyles.UserPaint, true);
  119. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  120. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
  121. this.label6.Text = "";
  122. SetAnalyzeModelFromXml("Template.Manager.item2.AtlasComparison");
  123. this.FormClosing += new FormClosingEventHandler(this.ClosingEvent);
  124. //用来处理对比对照切换图片的时候,生成右边的二值图层
  125. this.pictureUserControl2.pictureBox1.Paint += this.pictureBox1_Paint;
  126. }
  127. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  128. {
  129. if(this.pictureUserControl2.bitmap!=null)
  130. {
  131. if (this.mode == 2)
  132. {
  133. IninializeBinaryCompare();
  134. }
  135. }
  136. }
  137. private void ClosingEvent(object sender, FormClosingEventArgs e)
  138. {
  139. this.saveLastData(sender,e);
  140. if (imagePickerDialog != null)
  141. {
  142. if (!imagePickerDialog.IsDisposed)
  143. {
  144. imagePickerDialog.Close();
  145. }
  146. }
  147. }
  148. /// <summary>
  149. /// 窗口加载
  150. /// </summary>
  151. /// <param name="sender"></param>
  152. /// <param name="e"></param>
  153. private void AtlasComparisonDialog_Load(object sender, EventArgs e)
  154. {
  155. pictureUserControl20 = new PictureUserControl(2, this); pictureUserControl21 = new PictureUserControl(2, this); pictureUserControl22 = new PictureUserControl(2, this);
  156. pictureUserControl23 = new PictureUserControl(2, this); pictureUserControl24 = new PictureUserControl(1, this); pictureUserControl25 = new PictureUserControl(2, this);
  157. pictureUserControl26 = new PictureUserControl(2, this); pictureUserControl27 = new PictureUserControl(2, this); pictureUserControl28 = new PictureUserControl(2, this);
  158. getLastData();
  159. }
  160. List<mic_rulers> list;
  161. /// <summary>
  162. /// 初始化标尺
  163. /// </summary>
  164. private void InitializeRules()
  165. {
  166. //List<mic_rulers> list = mic_rulers_BLL.FindAll();
  167. list = Startup.instance.mic_rulersAll;
  168. this.comboBox1.DisplayMember = "ruler_name";
  169. this.comboBox1.ValueMember = "id";
  170. this.comboBox1.DataSource = list;
  171. }
  172. /// <summary>
  173. /// 标尺乘以放大倍数
  174. /// </summary>
  175. /// <returns></returns>
  176. private double GetRulerMultiple()
  177. {
  178. DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
  179. Document document = Document.FromImageMat(Camera.Tools.ToMat(bitmap));
  180. dw.Document = document;
  181. if (list != null && list.Count > 0)
  182. {
  183. for (int i = 0; i < list.Count; i++)
  184. {
  185. if (list[i].ruler_name == this.comboBox1.Text)
  186. {
  187. dw.xmlSaveModel = list[i];
  188. }
  189. }
  190. }
  191. dw.InitRulerInfo();
  192. double pantographRatio = dw.GetRulerMultiple(MeasurementUnit.Micron);
  193. this.appWorkspace.RemoveDocumentWorkspace(dw);
  194. return pantographRatio;
  195. }
  196. /// <summary>
  197. /// 生成报告
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void button1_Click(object sender, EventArgs e)
  202. {
  203. if (this.checkBox1.Checked)
  204. this.button5.PerformClick();
  205. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  206. {
  207. List<Bitmap> bitList = new List<Bitmap>();
  208. if (bitmap == null)
  209. {
  210. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  211. return;
  212. }
  213. double pantographRatio = GetRulerMultiple();
  214. //平铺
  215. if (this.radioButton1.Checked)
  216. {
  217. switch (this.num)
  218. {
  219. case 1:
  220. if (this.pictureUserControl2.Bitmap != null)
  221. {
  222. this.pictureUserControl2.Bitmap.Tag = pantographRatio;
  223. bitList.Add(this.pictureUserControl2.Bitmap);
  224. }
  225. if (this.pictureUserControl1.Bitmap != null)
  226. {
  227. this.pictureUserControl1.Bitmap.Tag = pantographRatio;
  228. bitList.Add(this.pictureUserControl1.Bitmap);
  229. }
  230. break;
  231. case 2:
  232. if (this.pictureUserControl5.Bitmap != null)
  233. {
  234. this.pictureUserControl5.Bitmap.Tag = pantographRatio;
  235. bitList.Add(this.pictureUserControl5.Bitmap);
  236. }
  237. if (this.pictureUserControl4.Bitmap != null)
  238. {
  239. this.pictureUserControl4.Bitmap.Tag = pantographRatio;
  240. bitList.Add(this.pictureUserControl4.Bitmap);
  241. }
  242. if (this.pictureUserControl3.Bitmap != null)
  243. {
  244. this.pictureUserControl3.Bitmap.Tag = pantographRatio;
  245. bitList.Add(this.pictureUserControl3.Bitmap);
  246. }
  247. break;
  248. case 4:
  249. if (this.pictureUserControl8.Bitmap != null)
  250. {
  251. this.pictureUserControl8.Bitmap.Tag = pantographRatio;
  252. bitList.Add(this.pictureUserControl8.Bitmap);
  253. }
  254. if (this.pictureUserControl11.Bitmap != null)
  255. {
  256. this.pictureUserControl11.Bitmap.Tag = pantographRatio;
  257. bitList.Add(this.pictureUserControl11.Bitmap);
  258. }
  259. if (this.pictureUserControl7.Bitmap != null)
  260. {
  261. this.pictureUserControl7.Bitmap.Tag = pantographRatio;
  262. bitList.Add(this.pictureUserControl7.Bitmap);
  263. }
  264. if (this.pictureUserControl9.Bitmap != null)
  265. {
  266. this.pictureUserControl9.Bitmap.Tag = pantographRatio;
  267. bitList.Add(this.pictureUserControl9.Bitmap);
  268. }
  269. if (this.pictureUserControl10.Bitmap != null)
  270. {
  271. this.pictureUserControl10.Bitmap.Tag = pantographRatio;
  272. bitList.Add(this.pictureUserControl10.Bitmap);
  273. }
  274. break;
  275. case 8:
  276. if (this.pictureUserControl20.Bitmap != null)
  277. {
  278. this.pictureUserControl20.Bitmap.Tag = pantographRatio;
  279. bitList.Add(this.pictureUserControl20.Bitmap);
  280. }
  281. if (this.pictureUserControl21.Bitmap != null)
  282. {
  283. this.pictureUserControl21.Bitmap.Tag = pantographRatio;
  284. bitList.Add(this.pictureUserControl21.Bitmap);
  285. }
  286. if (this.pictureUserControl22.Bitmap != null)
  287. {
  288. this.pictureUserControl22.Bitmap.Tag = pantographRatio;
  289. bitList.Add(this.pictureUserControl22.Bitmap);
  290. }
  291. if (this.pictureUserControl23.Bitmap != null)
  292. {
  293. this.pictureUserControl23.Bitmap.Tag = pantographRatio;
  294. bitList.Add(this.pictureUserControl23.Bitmap);
  295. }
  296. if (this.pictureUserControl24.Bitmap != null)
  297. {
  298. this.pictureUserControl24.Bitmap.Tag = pantographRatio;
  299. bitList.Add(this.pictureUserControl24.Bitmap);
  300. }
  301. if (this.pictureUserControl25.Bitmap != null)
  302. {
  303. this.pictureUserControl25.Bitmap.Tag = pantographRatio;
  304. bitList.Add(this.pictureUserControl25.Bitmap);
  305. }
  306. if (this.pictureUserControl26.Bitmap != null)
  307. {
  308. this.pictureUserControl26.Bitmap.Tag = pantographRatio;
  309. bitList.Add(this.pictureUserControl26.Bitmap);
  310. }
  311. if (this.pictureUserControl27.Bitmap != null)
  312. {
  313. this.pictureUserControl27.Bitmap.Tag = pantographRatio;
  314. bitList.Add(this.pictureUserControl27.Bitmap);
  315. }
  316. if (this.pictureUserControl28.Bitmap != null)
  317. {
  318. this.pictureUserControl28.Bitmap.Tag = pantographRatio;
  319. bitList.Add(this.pictureUserControl28.Bitmap);
  320. }
  321. break;
  322. }
  323. }
  324. //对比
  325. else if (this.radioButton2.Checked)
  326. {
  327. if (this.pictureUserControl2.Bitmap != null)
  328. {
  329. this.pictureUserControl2.Bitmap.Tag = pantographRatio;
  330. bitList.Add(this.pictureUserControl2.Bitmap);
  331. }
  332. if (this.pictureUserControl1.ComBitmap != null && this.pictureUserControl1.Bitmap != null)
  333. {
  334. Bitmap comBit = GetCombineBit();
  335. if (comBit != null)
  336. {
  337. comBit.Tag = pantographRatio;
  338. bitList.Add(comBit);
  339. }
  340. }
  341. else if (this.pictureUserControl1.ComBitmap != null && this.pictureUserControl1.Bitmap == null)
  342. {
  343. this.pictureUserControl1.ComBitmap.Tag = pantographRatio;
  344. bitList.Add(this.pictureUserControl1.ComBitmap);
  345. }
  346. else if (this.pictureUserControl1.ComBitmap == null && this.pictureUserControl1.Bitmap != null)
  347. {
  348. this.pictureUserControl1.Bitmap.Tag = pantographRatio;
  349. bitList.Add(this.pictureUserControl1.Bitmap);
  350. }
  351. }
  352. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, null, bitList, null);
  353. }
  354. else
  355. {
  356. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  357. }
  358. }
  359. private Bitmap GetCombineBit()
  360. {
  361. if (this.pictureUserControl1.Bitmap != null && this.pictureUserControl1.ComBitmap != null)
  362. {
  363. Bitmap bitmap = null;
  364. try
  365. {
  366. int aw = this.pictureUserControl1.Bitmap.Width;
  367. int ah = this.pictureUserControl1.Bitmap.Height;
  368. int bw = this.pictureUserControl1.ComBitmap.Width;
  369. int bh = this.pictureUserControl1.ComBitmap.Height;
  370. int width = aw > bw ? aw : bw;
  371. int height = ah > bh ? ah : bh;
  372. bitmap = new Bitmap(width, height);
  373. Graphics graphics = Graphics.FromImage(bitmap);
  374. graphics.DrawImage(this.pictureUserControl1.Bitmap, (width - aw) / 2, (height - ah) / 2, aw, ah);
  375. graphics.DrawImage(this.pictureUserControl1.ComBitmap, (width - bw) / 2, (height - bh) / 2, bw, bh);
  376. return bitmap;
  377. }
  378. catch (Exception)
  379. {
  380. return null;
  381. }
  382. }
  383. else
  384. return null;
  385. }
  386. /// <summary>
  387. /// 关联图片,同步放大缩小平移旋转...
  388. /// </summary>
  389. /// <param name="sender"></param>
  390. /// <param name="e"></param>
  391. private void button2_Click(object sender, EventArgs e)
  392. {
  393. this.RelatedPic = !this.RelatedPic;
  394. }
  395. /// <summary>
  396. /// 浏览已经打开的所有图片
  397. /// </summary>
  398. /// <param name="sender"></param>
  399. /// <param name="e"></param>
  400. private void button4_Click(object sender, EventArgs e)
  401. {
  402. if (imagePickerDialog == null)
  403. {
  404. imagePickerDialog = new InterImagePickerDialog(this.appWorkspace);
  405. imagePickerDialog.StartPosition = FormStartPosition.Manual;
  406. if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width-150)
  407. {
  408. imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
  409. }
  410. else
  411. {
  412. imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
  413. }
  414. imagePickerDialog.Top = ((Button)sender).Bottom + 46 + this.Top;
  415. imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
  416. imagePickerDialog.Show();
  417. }
  418. else
  419. {
  420. if (!imagePickerDialog.IsDisposed)
  421. {
  422. imagePickerDialog.WindowState = FormWindowState.Normal;
  423. }
  424. else
  425. {
  426. imagePickerDialog = new InterImagePickerDialog(this.appWorkspace);
  427. imagePickerDialog.StartPosition = FormStartPosition.Manual;
  428. if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
  429. {
  430. imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
  431. }
  432. else
  433. {
  434. imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
  435. }
  436. imagePickerDialog.Top = ((Button)sender).Bottom + 46 + this.Top;
  437. imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
  438. imagePickerDialog.Show();
  439. }
  440. }
  441. }
  442. /// <summary>
  443. /// 从图库选择待对照图片
  444. /// </summary>
  445. /// <param name="sender"></param>
  446. /// <param name="e"></param>
  447. private void inputMat_ValueChanged(object sender, EventArgs e)
  448. {
  449. if (sender is DocumentWorkspace)
  450. {
  451. this.bitmap = ((DocumentWorkspace)sender).CompositionSurface.CreateAliasedBitmap();
  452. //如果存在相,则绘制相
  453. if (((DocumentWorkspace)sender).phaseModels!=null && ((DocumentWorkspace)sender).phaseModels.Count>0)
  454. {
  455. Graphics graphics = Graphics.FromImage(this.bitmap);
  456. foreach (PhaseModel model in ((DocumentWorkspace)sender).phaseModels)
  457. {
  458. if(model.mat!=null)
  459. {
  460. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat), new PointF(0,0));
  461. }
  462. }
  463. }
  464. switch (num)
  465. {
  466. case 1:
  467. this.pictureUserControl1.Bitmap = this.bitmap;
  468. break;
  469. case 2:
  470. this.pictureUserControl4.Bitmap = this.bitmap;
  471. break;
  472. case 4:
  473. this.pictureUserControl7.Bitmap = this.bitmap;
  474. break;
  475. case 8:
  476. this.pictureUserControl24.Bitmap = this.bitmap;
  477. break;
  478. }
  479. }
  480. }
  481. /// <summary>
  482. /// 打开文件浏览
  483. /// </summary>
  484. /// <param name="sender"></param>
  485. /// <param name="e"></param>
  486. private void button3_Click(object sender, EventArgs e)
  487. {
  488. OpenFileDialog dialog = new OpenFileDialog();
  489. dialog.Filter = PdnResources.GetString("Menu.Theimagefile.Text")+"|*.jpg;*.png;*.bmp;";
  490. dialog.InitialDirectory = Environment.CurrentDirectory;
  491. dialog.ShowDialog();
  492. if (dialog.FileName != String.Empty)
  493. {
  494. this.bitmap = new Bitmap(dialog.FileName);
  495. switch (num)
  496. {
  497. case 1:
  498. this.pictureUserControl1.Bitmap = this.bitmap;
  499. break;
  500. case 2:
  501. this.pictureUserControl4.Bitmap = this.bitmap;
  502. break;
  503. case 4:
  504. this.pictureUserControl7.Bitmap = this.bitmap;
  505. break;
  506. case 8:
  507. this.pictureUserControl24.Bitmap = this.bitmap;
  508. break;
  509. }
  510. }
  511. }
  512. /// <summary>
  513. /// 初始化对比控件
  514. /// </summary>
  515. private void InitializeCompareControls()
  516. {
  517. this.panel1.Controls.Clear();
  518. switch (this.num)
  519. {
  520. case 1:
  521. this.pictureUserControl2.Dock = DockStyle.Left;
  522. this.pictureUserControl2.Width = this.panel1.Width / 2;
  523. this.pictureUserControl1.Dock = DockStyle.Left;
  524. this.pictureUserControl1.Width = this.panel1.Width / 2;
  525. this.panel1.Controls.Add(this.pictureUserControl1);
  526. this.panel1.Controls.Add(this.pictureUserControl2);
  527. this.pictureUserControl1.Bitmap = this.bitmap;
  528. break;
  529. case 2:
  530. if(pictureUserControl3 == null) pictureUserControl3 = new PictureUserControl(2, this);
  531. pictureUserControl3.Dock = DockStyle.Left;
  532. pictureUserControl3.Width = this.panel1.Width / 3;
  533. if(pictureUserControl4==null) pictureUserControl4 = new PictureUserControl(1, this);
  534. pictureUserControl4.Dock = DockStyle.Left;
  535. pictureUserControl4.Width = this.panel1.Width / 3;
  536. if (pictureUserControl5 == null) pictureUserControl5 = new PictureUserControl(2, this);
  537. pictureUserControl5.Dock = DockStyle.Left;
  538. pictureUserControl5.Width = this.panel1.Width / 3;
  539. this.panel1.Controls.Add(pictureUserControl3);
  540. this.panel1.Controls.Add(pictureUserControl4);
  541. this.panel1.Controls.Add(pictureUserControl5);
  542. this.pictureUserControl4.Bitmap = this.bitmap;
  543. break;
  544. case 4:
  545. if (pictureUserControl7 == null) pictureUserControl7 = new PictureUserControl(1, this);
  546. pictureUserControl7.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
  547. pictureUserControl7.Width = this.panel1.Width / 3;
  548. pictureUserControl7.Height = this.panel1.Height / 3;
  549. pictureUserControl7.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
  550. if (pictureUserControl8 == null) pictureUserControl8 = new PictureUserControl(2, this);
  551. pictureUserControl8.Anchor = AnchorStyles.Top;
  552. pictureUserControl8.Width = this.panel1.Width / 3;
  553. pictureUserControl8.Height = this.panel1.Height / 3;
  554. pictureUserControl8.Location = new Point(this.panel1.Width / 3, 0);
  555. if (pictureUserControl9 == null) pictureUserControl9 = new PictureUserControl(2, this);
  556. pictureUserControl9.Anchor = AnchorStyles.Right;
  557. pictureUserControl9.Width = this.panel1.Width / 3;
  558. pictureUserControl9.Height = this.panel1.Height / 3;
  559. pictureUserControl9.Location = new Point((this.panel1.Width / 3)*2, this.panel1.Height / 3);
  560. if (pictureUserControl10 == null) pictureUserControl10 = new PictureUserControl(2, this);
  561. pictureUserControl10.Anchor = AnchorStyles.Bottom;
  562. pictureUserControl10.Width = this.panel1.Width / 3;
  563. pictureUserControl10.Height = this.panel1.Height / 3;
  564. pictureUserControl10.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3)*2);
  565. if (pictureUserControl11 == null) pictureUserControl11 = new PictureUserControl(2, this);
  566. pictureUserControl11.Anchor = AnchorStyles.Left;
  567. pictureUserControl11.Width = this.panel1.Width / 3;
  568. pictureUserControl11.Height = this.panel1.Height / 3;
  569. pictureUserControl11.Location = new Point(0, this.panel1.Height / 3);
  570. this.panel1.Controls.Add(pictureUserControl8);
  571. this.panel1.Controls.Add(pictureUserControl9);
  572. this.panel1.Controls.Add(pictureUserControl10);
  573. this.panel1.Controls.Add(pictureUserControl11);
  574. this.panel1.Controls.Add(pictureUserControl7);
  575. this.pictureUserControl7.Bitmap = this.bitmap;
  576. break;
  577. case 8:
  578. pictureUserControl20.Anchor = AnchorStyles.Top | AnchorStyles.Left;
  579. pictureUserControl20.Width = this.panel1.Width / 3;
  580. pictureUserControl20.Height = this.panel1.Height / 3;
  581. pictureUserControl20.Location = new Point(0, 0);
  582. pictureUserControl21.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
  583. pictureUserControl21.Width = this.panel1.Width / 3;
  584. pictureUserControl21.Height = this.panel1.Height / 3;
  585. pictureUserControl21.Location = new Point(this.panel1.Width / 3, 0);
  586. pictureUserControl22.Anchor = AnchorStyles.Top | AnchorStyles.Right;
  587. pictureUserControl22.Width = this.panel1.Width / 3;
  588. pictureUserControl22.Height = this.panel1.Height / 3;
  589. pictureUserControl22.Location = new Point((this.panel1.Width / 3) * 2, 0);
  590. pictureUserControl23.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
  591. pictureUserControl23.Width = this.panel1.Width / 3;
  592. pictureUserControl23.Height = this.panel1.Height / 3;
  593. pictureUserControl23.Location = new Point(0, this.panel1.Height / 3);
  594. pictureUserControl24.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
  595. pictureUserControl24.Width = this.panel1.Width / 3;
  596. pictureUserControl24.Height = this.panel1.Height / 3;
  597. pictureUserControl24.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
  598. pictureUserControl25.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
  599. pictureUserControl25.Width = this.panel1.Width / 3;
  600. pictureUserControl25.Height = this.panel1.Height / 3;
  601. pictureUserControl25.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
  602. pictureUserControl26.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
  603. pictureUserControl26.Width = this.panel1.Width / 3;
  604. pictureUserControl26.Height = this.panel1.Height / 3;
  605. pictureUserControl26.Location = new Point(0, (this.panel1.Height / 3)*2);
  606. pictureUserControl27.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
  607. pictureUserControl27.Width = this.panel1.Width / 3;
  608. pictureUserControl27.Height = this.panel1.Height / 3;
  609. pictureUserControl27.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
  610. pictureUserControl28.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
  611. pictureUserControl28.Width = this.panel1.Width / 3;
  612. pictureUserControl28.Height = this.panel1.Height / 3;
  613. pictureUserControl28.Location = new Point((this.panel1.Width / 3) * 2, (this.panel1.Height / 3)*2);
  614. this.panel1.Controls.Add(pictureUserControl20);
  615. this.panel1.Controls.Add(pictureUserControl21);
  616. this.panel1.Controls.Add(pictureUserControl22);
  617. this.panel1.Controls.Add(pictureUserControl23);
  618. this.panel1.Controls.Add(pictureUserControl24);
  619. this.panel1.Controls.Add(pictureUserControl25);
  620. this.panel1.Controls.Add(pictureUserControl26);
  621. this.panel1.Controls.Add(pictureUserControl27);
  622. this.panel1.Controls.Add(pictureUserControl28);
  623. this.pictureUserControl24.Bitmap = this.bitmap;
  624. break;
  625. }
  626. }
  627. /// <summary>
  628. /// 初始化图谱数据
  629. /// 读取图谱文件夹(Atlas文件夹)的xml文件并解析
  630. /// </summary>
  631. private void InitializeAtlasFile()
  632. {
  633. atlasModels.Clear();
  634. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Atlas\\");
  635. XmlDocument xml = new XmlDocument();
  636. foreach (string fileName in fileNames)
  637. {
  638. //Load Xml
  639. xml.Load(Application.StartupPath + "\\Atlas\\" + fileName);
  640. //读取根元素
  641. XmlElement root = xml.DocumentElement;
  642. //递归解析xml
  643. ParsingXml(root, 1, "");
  644. }
  645. }
  646. /// <summary>
  647. /// 初始化treeview
  648. /// </summary>
  649. private void InitializeTreeView()
  650. {
  651. this.treeView1.ImageList = new ImageList();
  652. this.treeView1.ImageList.Images.Add("Top", PdnResources.GetImageResource("Icons.SettingsIcon.png").Reference);
  653. this.treeView1.ImageList.Images.Add("Catalog", PdnResources.GetImageResource("Icons.ImageFromDiskIcon.png").Reference);
  654. this.treeView1.ImageList.Images.Add("Atlas", PdnResources.GetImageResource("Icons.AddNoiseEffect.png").Reference);
  655. if (this.atlasModels.Count > 0)
  656. {
  657. for (int i = 0; i < this.atlasModels.Count; i++)
  658. {
  659. if (this.atlasModels[i].parentId.Equals(""))
  660. {
  661. TreeNode anime = new TreeNode();
  662. anime.Tag = this.atlasModels[i].id;
  663. anime.Text = this.atlasModels[i].name;
  664. anime.ImageKey = "Top";
  665. this.treeView1.Nodes.Add(anime);
  666. RecursiveData(anime);
  667. }
  668. }
  669. }
  670. }
  671. /// <summary>
  672. /// 递归处理treeview数据
  673. /// </summary>
  674. private void RecursiveData(TreeNode anime)
  675. {
  676. List<AtlasModel> models = this.atlasModels.FindAll(a => a.parentId.Equals(anime.Tag));
  677. if (models != null && models.Count > 0)
  678. {
  679. for (int i = 0; i < models.Count; i++)
  680. {
  681. if (models[i].type == 1)
  682. {
  683. TreeNode animeC = new TreeNode();
  684. animeC.Tag = models[i].id;
  685. animeC.Text = models[i].name;
  686. animeC.ImageKey = "Catalog";
  687. animeC.SelectedImageKey = "Catalog";
  688. RecursiveData(animeC);
  689. anime.Nodes.Add(animeC);
  690. }
  691. }
  692. }
  693. }
  694. /// <summary>
  695. /// 递归解析xml
  696. /// </summary>
  697. /// <param name="element">节点</param>
  698. /// <param name="level">1根节点 2分类 3图铺</param>
  699. private void ParsingXml(XmlElement element, int level, string parentId)
  700. {
  701. if (level == 1)
  702. {
  703. AtlasModel model = new AtlasModel();
  704. model.name = element.GetAttribute("Name");
  705. model.id = Guid.NewGuid().ToString();
  706. model.parentId = parentId;
  707. model.path = model.name;
  708. model.type = 0;
  709. this.atlasModels.Add(model);
  710. XmlNodeList list = element.FirstChild.ChildNodes;
  711. if (list != null && list.Count > 0)
  712. {
  713. foreach (XmlNode node in list)
  714. {
  715. ParsingXml((XmlElement)node, 2, model.id);
  716. }
  717. }
  718. }
  719. else if (level == 2)
  720. {
  721. AtlasModel model = new AtlasModel();
  722. model.name = element.GetAttribute("Name");
  723. model.id = Guid.NewGuid().ToString();
  724. model.parentId = parentId;
  725. model.path = model.name;
  726. model.type = 1;
  727. this.atlasModels.Add(model);
  728. XmlNodeList list = element.FirstChild.ChildNodes;
  729. if (list != null && list.Count > 0)
  730. {
  731. foreach (XmlNode node in list)
  732. {
  733. if (node.FirstChild.Name.Equals("MapImage"))
  734. {
  735. ParsingXml((XmlElement)node, 3, model.id);
  736. }
  737. else
  738. {
  739. ParsingXml((XmlElement)node, 2, model.id);
  740. }
  741. }
  742. }
  743. }
  744. else if (level == 3)
  745. {
  746. AtlasModel model = new AtlasModel();
  747. model.name = element.GetAttribute("Name");
  748. model.id = Guid.NewGuid().ToString();
  749. model.parentId = parentId;
  750. model.path = model.name;
  751. model.type = 2;
  752. model.bitmap = DrawRulerHelper.Base64StringToImage(element.InnerText);
  753. this.atlasModels.Add(model);
  754. }
  755. }
  756. private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  757. {
  758. if (e.Node != null)
  759. {
  760. if (this.treeView1.SelectedNode != e.Node)
  761. {
  762. this.imageList1.Images.Clear();
  763. this.listView1.Items.Clear();
  764. this.treeView1.SelectedNode = e.Node;
  765. this.InitListViewData(this.treeView1.SelectedNode);
  766. this.InitializePlayUserControl();
  767. }
  768. }
  769. }
  770. private void InitializePlayUserControl()
  771. {
  772. switch(this.num)
  773. {
  774. case 1:
  775. this.pictureUserControl2.ImageCollection = this.imageList1.Images;
  776. this.pictureUserControl2.CurrentPosition = 1;
  777. break;
  778. case 2:
  779. this.pictureUserControl3.ImageCollection = this.imageList1.Images;
  780. this.pictureUserControl3.CurrentPosition = 2;
  781. this.pictureUserControl5.ImageCollection = this.imageList1.Images;
  782. this.pictureUserControl5.CurrentPosition = 1;
  783. break;
  784. case 4:
  785. this.pictureUserControl8.ImageCollection = this.imageList1.Images;
  786. this.pictureUserControl8.CurrentPosition = 1;
  787. this.pictureUserControl9.ImageCollection = this.imageList1.Images;
  788. this.pictureUserControl9.CurrentPosition = 2;
  789. this.pictureUserControl10.ImageCollection = this.imageList1.Images;
  790. this.pictureUserControl10.CurrentPosition = 3;
  791. this.pictureUserControl11.ImageCollection = this.imageList1.Images;
  792. this.pictureUserControl11.CurrentPosition = 4;
  793. break;
  794. case 8:
  795. this.pictureUserControl20.ImageCollection = this.imageList1.Images;
  796. this.pictureUserControl20.CurrentPosition = 1;
  797. this.pictureUserControl21.ImageCollection = this.imageList1.Images;
  798. this.pictureUserControl21.CurrentPosition = 2;
  799. this.pictureUserControl22.ImageCollection = this.imageList1.Images;
  800. this.pictureUserControl22.CurrentPosition = 3;
  801. this.pictureUserControl23.ImageCollection = this.imageList1.Images;
  802. this.pictureUserControl23.CurrentPosition = 4;
  803. this.pictureUserControl25.ImageCollection = this.imageList1.Images;
  804. this.pictureUserControl25.CurrentPosition = 5;
  805. this.pictureUserControl26.ImageCollection = this.imageList1.Images;
  806. this.pictureUserControl26.CurrentPosition = 6;
  807. this.pictureUserControl27.ImageCollection = this.imageList1.Images;
  808. this.pictureUserControl27.CurrentPosition = 7;
  809. this.pictureUserControl28.ImageCollection = this.imageList1.Images;
  810. this.pictureUserControl28.CurrentPosition = 8;
  811. break;
  812. }
  813. }
  814. /// <summary>
  815. /// 使用标尺的切换
  816. /// </summary>
  817. /// <param name="sender"></param>
  818. /// <param name="e"></param>
  819. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  820. {
  821. // TODO ZYH 标尺切换改变图像大小
  822. if (this.comboBox1.SelectedIndex >= 0)
  823. {
  824. }
  825. }
  826. private void InitListViewData(TreeNode node)
  827. {
  828. this.imageList1.Images.Clear();
  829. this.listView1.Items.Clear();
  830. if (node == null)
  831. {
  832. List<AtlasModel> lists = this.atlasModels.FindAll(a => a.bitmap != null);
  833. for (int i = 0; i < lists.Count; i++)
  834. {
  835. this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
  836. this.imageList1.Images.Add("img" + i, lists[i].bitmap);
  837. this.imageList1.Images.SetKeyName(i, lists[i].id);
  838. this.listView1.Items.Add("", i);
  839. this.listView1.Items[i].Tag = lists[i].id;
  840. this.listView1.Items[i].ImageIndex = i;
  841. this.listView1.Items[i].Text = lists[i].name;
  842. }
  843. }
  844. else
  845. {
  846. AtlasModel model = this.atlasModels.Find(a => a.id.Equals(node.Tag.ToString()));
  847. if (model != null)
  848. {
  849. if (model.type == 0 || model.type == 1)
  850. {
  851. List<AtlasModel> lists = this.atlasModels.FindAll(a => a.bitmap != null && a.parentId.Equals(model.id));
  852. for (int i = 0; i < lists.Count; i++)
  853. {
  854. this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
  855. this.imageList1.Images.Add("img" + i, lists[i].bitmap);
  856. this.imageList1.Images.SetKeyName(i, lists[i].id);
  857. this.listView1.Items.Add("", i);
  858. this.listView1.Items[i].Tag = lists[i].id;
  859. this.listView1.Items[i].ImageIndex = i;
  860. this.listView1.Items[i].Text = lists[i].name;
  861. }
  862. }
  863. else if (model.type == 2)
  864. {
  865. this.imageList1.ImageSize = new System.Drawing.Size(72, 72);
  866. this.imageList1.Images.Add("img", model.bitmap);
  867. this.imageList1.Images.SetKeyName(0, model.id);
  868. this.listView1.Items.Add("", 0);
  869. this.listView1.Items[0].Tag = model.id;
  870. this.listView1.Items[0].ImageIndex = 0;
  871. this.listView1.Items[0].Text = model.name;
  872. }
  873. }
  874. }
  875. }
  876. /// <summary>
  877. /// 设置
  878. /// </summary>
  879. /// <param name="sender"></param>
  880. /// <param name="e"></param>
  881. private void button5_Click(object sender, EventArgs e)
  882. {
  883. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.AtlasComparison");
  884. if (recombinationRateSetDialog.hasModule)
  885. {
  886. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  887. recombinationRateSetDialog.ShowDialog();
  888. }
  889. else
  890. {
  891. recombinationRateSetDialog = null;
  892. }
  893. /*using (AtlasSettingDialog atlasSettingDialog = new AtlasSettingDialog())
  894. {
  895. atlasSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  896. atlasSettingDialog.ShowDialog();
  897. }*/
  898. }
  899. private void panel1_SizeChanged(object sender, EventArgs e)
  900. {
  901. switch (this.num)
  902. {
  903. case 1:
  904. this.pictureUserControl1.Width = this.panel1.Width / 2;
  905. this.pictureUserControl2.Width = this.panel1.Width / 2;
  906. break;
  907. case 2:
  908. this.pictureUserControl3.Width = this.panel1.Width / 3;
  909. this.pictureUserControl4.Width = this.panel1.Width / 3;
  910. this.pictureUserControl5.Width = this.panel1.Width / 3;
  911. break;
  912. case 4:
  913. foreach (Control control in this.panel1.Controls)
  914. {
  915. control.Width = this.panel1.Width / 3;
  916. control.Height = this.panel1.Height / 3;
  917. }
  918. this.pictureUserControl7.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
  919. this.pictureUserControl8.Location = new Point(this.panel1.Width / 3, 0);
  920. this.pictureUserControl9.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
  921. this.pictureUserControl10.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
  922. this.pictureUserControl11.Location = new Point(0, this.panel1.Height / 3);
  923. break;
  924. case 8:
  925. foreach (Control control in this.panel1.Controls)
  926. {
  927. control.Width = this.panel1.Width / 3;
  928. control.Height = this.panel1.Height / 3;
  929. }
  930. pictureUserControl20.Location = new Point(0, 0);
  931. pictureUserControl21.Location = new Point(this.panel1.Width / 3, 0);
  932. pictureUserControl22.Location = new Point((this.panel1.Width / 3) * 2, 0);
  933. pictureUserControl23.Location = new Point(0, this.panel1.Height / 3);
  934. pictureUserControl24.Location = new Point(this.panel1.Width / 3, this.panel1.Height / 3);
  935. pictureUserControl25.Location = new Point((this.panel1.Width / 3) * 2, this.panel1.Height / 3);
  936. pictureUserControl26.Location = new Point(0, (this.panel1.Height / 3) * 2);
  937. pictureUserControl27.Location = new Point(this.panel1.Width / 3, (this.panel1.Height / 3) * 2);
  938. pictureUserControl28.Location = new Point((this.panel1.Width / 3) * 2, (this.panel1.Height / 3) * 2);
  939. break;
  940. }
  941. }
  942. /// <summary>
  943. /// 对照模式切换事件
  944. /// </summary>
  945. /// <param name="sender"></param>
  946. /// <param name="e"></param>
  947. private void radioButton_CheckedChanged(object sender, EventArgs e)
  948. {
  949. if(this.radioButton1.Checked)
  950. {
  951. this.mode = 1;
  952. this.panel3.Visible = false;
  953. this.panel2.Visible = true;
  954. }
  955. else if (this.radioButton2.Checked)
  956. {
  957. this.mode = 2;
  958. this.panel2.Visible = false;
  959. this.panel3.Visible = true;
  960. this.num = 1;
  961. this.radioButton3.Checked = true;
  962. this.IninializeBinaryCompare();
  963. }
  964. }
  965. #region 对比对照
  966. /// <summary>
  967. /// 对比对照
  968. /// </summary>
  969. private unsafe void IninializeBinaryCompare()
  970. {
  971. if(this.pictureUserControl2.Bitmap!=null)
  972. {
  973. OpenCvSharp.Mat source = PaintDotNet.Camera.Tools.ToMat(this.pictureUserControl2.Bitmap);
  974. OpenCvSharp.Mat srcGray;
  975. if (source.Type() == OpenCvSharp.MatType.CV_8UC1)
  976. {
  977. srcGray = source;
  978. }
  979. else
  980. {
  981. srcGray = source.CvtColor(OpenCvSharp.ColorConversionCodes.BGR2GRAY);
  982. }
  983. OpenCvSharp.Mat src = new OpenCvSharp.Mat(source.Rows, source.Cols, OpenCvSharp.MatType.CV_8UC4, new OpenCvSharp.Scalar(0, 0, 0, 0));
  984. int index1 = 0;
  985. byte* ptr1 = (byte*)srcGray.Data;
  986. int index2 = 0;
  987. byte* ptr2 = (byte*)src.Data;
  988. for (int o = 0; o < srcGray.Height; o++)
  989. {
  990. for (int p = 0; p < srcGray.Width; p++)
  991. {
  992. index1 = (int)((srcGray.Step() * o) + (p * 1));
  993. index2 = (int)((src.Step() * o) + (p * 4));
  994. if (ptr1[index1] >= this.numericUpDown1.Value && ptr1[index1] <= this.numericUpDown2.Value)
  995. {
  996. ptr2[index2] = this.panel4.BackColor.B;
  997. ptr2[index2 + 1] = this.panel4.BackColor.G;
  998. ptr2[index2 + 2] = this.panel4.BackColor.R;
  999. ptr2[index2 + 3] = (byte)this.numericUpDown3.Value;
  1000. }
  1001. }
  1002. }
  1003. this.pictureUserControl1.ComBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);
  1004. this.pictureUserControl1.pictureBox1.Refresh();
  1005. }
  1006. }
  1007. /// <summary>
  1008. /// 对比对照 二值初始值
  1009. /// </summary>
  1010. /// <param name="sender"></param>
  1011. /// <param name="e"></param>
  1012. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1013. {
  1014. IninializeBinaryCompare();
  1015. }
  1016. /// <summary>
  1017. /// 对比对照 二值结束值
  1018. /// </summary>
  1019. /// <param name="sender"></param>
  1020. /// <param name="e"></param>
  1021. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  1022. {
  1023. IninializeBinaryCompare();
  1024. }
  1025. /// <summary>
  1026. /// 对比对照 颜色panel点击事件
  1027. /// </summary>
  1028. /// <param name="sender"></param>
  1029. /// <param name="e"></param>
  1030. private void panel4_Click(object sender, EventArgs e)
  1031. {
  1032. IninializeBinaryCompare();
  1033. }
  1034. /// <summary>
  1035. /// 透明度值改变事件
  1036. /// </summary>
  1037. /// <param name="sender"></param>
  1038. /// <param name="e"></param>
  1039. private void trackBar1_ValueChanged(object sender, EventArgs e)
  1040. {
  1041. this.numericUpDown3.Value = this.trackBar1.Value;
  1042. }
  1043. /// <summary>
  1044. /// 透明度值改变事件
  1045. /// </summary>
  1046. /// <param name="sender"></param>
  1047. /// <param name="e"></param>
  1048. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  1049. {
  1050. this.trackBar1.Value = (int)this.numericUpDown3.Value;
  1051. IninializeBinaryCompare();
  1052. }
  1053. /// <summary>
  1054. /// 创建图片,合成图片
  1055. /// </summary>
  1056. /// <param name="sender"></param>
  1057. /// <param name="e"></param>
  1058. private void button6_Click(object sender, EventArgs e)
  1059. {
  1060. if (this.pictureUserControl1.Bitmap!=null && this.pictureUserControl1.ComBitmap!=null)
  1061. {
  1062. Bitmap bitmap = null;
  1063. try
  1064. {
  1065. int aw = this.pictureUserControl1.Bitmap.Width;
  1066. int ah = this.pictureUserControl1.Bitmap.Height;
  1067. int bw = this.pictureUserControl1.ComBitmap.Width;
  1068. int bh = this.pictureUserControl1.ComBitmap.Height;
  1069. int width = aw > bw ? aw : bw;
  1070. int height = ah > bh ? ah : bh;
  1071. bitmap = new Bitmap(width, height);
  1072. Graphics graphics = Graphics.FromImage(bitmap);
  1073. graphics.DrawImage(this.pictureUserControl1.Bitmap, (width - aw)/2, (height - ah)/2, aw, ah);
  1074. graphics.DrawImage(this.pictureUserControl1.ComBitmap, (width - bw)/2, (height - bh)/2, bw, bh);
  1075. //OpenCvSharp.Cv2.ImShow("123", PaintDotNet.Camera.Tools.ToMat(bitmap));
  1076. DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
  1077. Document document = Document.FromImageMat(Camera.Tools.ToMat(bitmap));
  1078. dw.Document = document;
  1079. if (list != null && list.Count >0)
  1080. {
  1081. for (int i = 0; i < list.Count; i++)
  1082. {
  1083. if (list[i].ruler_name == this.comboBox1.Text)
  1084. {
  1085. dw.xmlSaveModel = list[i];
  1086. }
  1087. }
  1088. }
  1089. dw.InitRulerInfo();
  1090. dw.fileText = this.Text + "-" + stepLength;
  1091. this.appWorkspace.ActiveDocumentWorkspace = dw;
  1092. Startup.instance.step_length += 1;
  1093. stepLength = "00" + Startup.instance.step_length;
  1094. }
  1095. catch(Exception)
  1096. {
  1097. }
  1098. finally
  1099. {
  1100. if (bitmap != null) bitmap.Dispose();
  1101. }
  1102. }
  1103. }
  1104. #endregion
  1105. private void pp_radioButton_CheckedChanged(object sender, EventArgs e)
  1106. {
  1107. if (this.radioButton3.Checked)
  1108. {
  1109. this.num = 1;
  1110. }
  1111. else if(this.radioButton4.Checked)
  1112. {
  1113. this.num = 2;
  1114. }
  1115. else if (this.radioButton5.Checked)
  1116. {
  1117. this.num = 4;
  1118. }
  1119. else if (this.radioButton6.Checked)
  1120. {
  1121. this.num = 8;
  1122. }
  1123. if (((RadioButton)sender).Checked)
  1124. {
  1125. InitializeCompareControls();
  1126. InitializePlayUserControl();
  1127. }
  1128. }
  1129. /// <summary>
  1130. /// 关联放大
  1131. /// </summary>
  1132. public void ZoomInButton_click()
  1133. {
  1134. foreach (Control control in this.panel1.Controls)
  1135. {
  1136. if(control.GetType() == typeof(PictureUserControl))
  1137. {
  1138. ((PictureUserControl)control).ZoomIn();
  1139. }
  1140. }
  1141. }
  1142. /// <summary>
  1143. /// 关联缩小
  1144. /// </summary>
  1145. public void ZoomOutButton_click()
  1146. {
  1147. foreach (Control control in this.panel1.Controls)
  1148. {
  1149. if (control.GetType() == typeof(PictureUserControl))
  1150. {
  1151. ((PictureUserControl)control).ZoomOut();
  1152. }
  1153. }
  1154. }
  1155. /// <summary>
  1156. /// 关联顺时针旋转90
  1157. /// </summary>
  1158. public void Rotate90Button_click()
  1159. {
  1160. foreach (Control control in this.panel1.Controls)
  1161. {
  1162. if (control.GetType() == typeof(PictureUserControl))
  1163. {
  1164. ((PictureUserControl)control).Rotate90();
  1165. }
  1166. }
  1167. }
  1168. /// <summary>
  1169. /// 关联逆时针旋转90
  1170. /// </summary>
  1171. public void Rotate_90Button_click()
  1172. {
  1173. foreach (Control control in this.panel1.Controls)
  1174. {
  1175. if (control.GetType() == typeof(PictureUserControl))
  1176. {
  1177. ((PictureUserControl)control).Rotate_90();
  1178. }
  1179. }
  1180. }
  1181. public void SetSelectFlag()
  1182. {
  1183. foreach (Control control in this.panel1.Controls)
  1184. {
  1185. if (control.GetType() == typeof(PictureUserControl))
  1186. {
  1187. ((PictureUserControl)control).selectFlag = false;
  1188. }
  1189. }
  1190. this.panel1.Refresh();
  1191. }
  1192. #region Windows Form Designer generated code
  1193. private void InitializeLanguageText()
  1194. {
  1195. this.radioButton2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Contrast.text");
  1196. this.radioButton1.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Tilecontrast.text");
  1197. this.groupBox5.Text = PdnResources.GetString("Menu.Setting.Text");
  1198. this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Currentlevel.text") + ":";
  1199. this.label1.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Useruler.text") + ":";
  1200. this.Text = PdnResources.GetString("Menu.GeneralAnalysis.MapComparison.Text");
  1201. this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Atlasselection.text");
  1202. this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Atlascatalog.text");
  1203. this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Controlmode.text");
  1204. this.button6.Text = PdnResources.GetString("Menu.Createpicture.text");
  1205. this.label5.Text = PdnResources.GetString("Menu.transparency.text") + ":";
  1206. this.label4.Text = PdnResources.GetString("Menu.color.text") + ":";
  1207. this.label3.Text = PdnResources.GetString("Menu.Binarization.text") + ":";
  1208. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  1209. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  1210. this.button5.Text = PdnResources.GetString("Menu.Setting.Text");
  1211. this.button4.Text = PdnResources.GetString("Menu.Gallery.text");
  1212. this.button3.Text = PdnResources.GetString("Menu.harddisk.text");
  1213. this.button2.Text = PdnResources.GetString("Menu.Generalanalysis.Atlascomparison.Associatedpicture.text");
  1214. this.button1.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  1215. }
  1216. private void InitializeComponent()
  1217. {
  1218. this.components = new System.ComponentModel.Container();
  1219. this.groupBox1 = new System.Windows.Forms.GroupBox();
  1220. this.checkBox1 = new System.Windows.Forms.CheckBox();
  1221. this.button5 = new System.Windows.Forms.Button();
  1222. this.button4 = new System.Windows.Forms.Button();
  1223. this.button3 = new System.Windows.Forms.Button();
  1224. this.button2 = new System.Windows.Forms.Button();
  1225. this.button1 = new System.Windows.Forms.Button();
  1226. this.groupBox2 = new System.Windows.Forms.GroupBox();
  1227. this.treeView1 = new System.Windows.Forms.TreeView();
  1228. this.groupBox3 = new System.Windows.Forms.GroupBox();
  1229. this.listView1 = new System.Windows.Forms.ListView();
  1230. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  1231. this.groupBox4 = new System.Windows.Forms.GroupBox();
  1232. this.panel2 = new System.Windows.Forms.Panel();
  1233. this.radioButton6 = new System.Windows.Forms.RadioButton();
  1234. this.radioButton5 = new System.Windows.Forms.RadioButton();
  1235. this.radioButton4 = new System.Windows.Forms.RadioButton();
  1236. this.radioButton3 = new System.Windows.Forms.RadioButton();
  1237. this.panel3 = new System.Windows.Forms.Panel();
  1238. this.button6 = new System.Windows.Forms.Button();
  1239. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  1240. this.trackBar1 = new System.Windows.Forms.TrackBar();
  1241. this.label5 = new System.Windows.Forms.Label();
  1242. this.panel4 = new System.Windows.Forms.Panel();
  1243. this.label4 = new System.Windows.Forms.Label();
  1244. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  1245. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  1246. this.label3 = new System.Windows.Forms.Label();
  1247. this.radioButton2 = new System.Windows.Forms.RadioButton();
  1248. this.radioButton1 = new System.Windows.Forms.RadioButton();
  1249. this.groupBox5 = new System.Windows.Forms.GroupBox();
  1250. this.label6 = new System.Windows.Forms.Label();
  1251. this.comboBox1 = new System.Windows.Forms.ComboBox();
  1252. this.label2 = new System.Windows.Forms.Label();
  1253. this.label1 = new System.Windows.Forms.Label();
  1254. this.panel1 = new System.Windows.Forms.Panel();
  1255. this.groupBox1.SuspendLayout();
  1256. this.groupBox2.SuspendLayout();
  1257. this.groupBox3.SuspendLayout();
  1258. this.groupBox4.SuspendLayout();
  1259. this.panel2.SuspendLayout();
  1260. this.panel3.SuspendLayout();
  1261. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  1262. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  1263. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  1264. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  1265. this.groupBox5.SuspendLayout();
  1266. this.SuspendLayout();
  1267. //
  1268. // groupBox1
  1269. //
  1270. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1271. | System.Windows.Forms.AnchorStyles.Right)));
  1272. this.groupBox1.Controls.Add(this.checkBox1);
  1273. this.groupBox1.Controls.Add(this.button5);
  1274. this.groupBox1.Controls.Add(this.button4);
  1275. this.groupBox1.Controls.Add(this.button3);
  1276. this.groupBox1.Controls.Add(this.button2);
  1277. this.groupBox1.Controls.Add(this.button1);
  1278. this.groupBox1.Location = new System.Drawing.Point(13, 13);
  1279. this.groupBox1.Name = "groupBox1";
  1280. this.groupBox1.Size = new System.Drawing.Size(1229, 52);
  1281. this.groupBox1.TabIndex = 0;
  1282. this.groupBox1.TabStop = false;
  1283. this.groupBox1.Text = "操作";
  1284. //
  1285. // checkBox1
  1286. //
  1287. this.checkBox1.AutoSize = true;
  1288. this.checkBox1.Location = new System.Drawing.Point(89, 23);
  1289. this.checkBox1.Name = "checkBox1";
  1290. this.checkBox1.Size = new System.Drawing.Size(132, 16);
  1291. this.checkBox1.TabIndex = 5;
  1292. this.checkBox1.Text = "生成报告时打开设置";
  1293. this.checkBox1.UseVisualStyleBackColor = true;
  1294. //
  1295. // button5
  1296. //
  1297. this.button5.Location = new System.Drawing.Point(7, 20);
  1298. this.button5.Name = "button5";
  1299. this.button5.Size = new System.Drawing.Size(75, 23);
  1300. this.button5.TabIndex = 4;
  1301. this.button5.Text = "设置";
  1302. this.button5.UseVisualStyleBackColor = true;
  1303. this.button5.Click += new System.EventHandler(this.button5_Click);
  1304. //
  1305. // button4
  1306. //
  1307. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1308. this.button4.Location = new System.Drawing.Point(905, 20);
  1309. this.button4.Name = "button4";
  1310. this.button4.Size = new System.Drawing.Size(75, 23);
  1311. this.button4.TabIndex = 3;
  1312. this.button4.Text = "图库";
  1313. this.button4.UseVisualStyleBackColor = true;
  1314. this.button4.Click += new System.EventHandler(this.button4_Click);
  1315. //
  1316. // button3
  1317. //
  1318. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1319. this.button3.Location = new System.Drawing.Point(986, 20);
  1320. this.button3.Name = "button3";
  1321. this.button3.Size = new System.Drawing.Size(75, 23);
  1322. this.button3.TabIndex = 2;
  1323. this.button3.Text = "硬盘";
  1324. this.button3.UseVisualStyleBackColor = true;
  1325. this.button3.Click += new System.EventHandler(this.button3_Click);
  1326. //
  1327. // button2
  1328. //
  1329. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1330. this.button2.Location = new System.Drawing.Point(1067, 20);
  1331. this.button2.Name = "button2";
  1332. this.button2.Size = new System.Drawing.Size(75, 23);
  1333. this.button2.TabIndex = 1;
  1334. this.button2.Text = "关联图片";
  1335. this.button2.UseVisualStyleBackColor = true;
  1336. this.button2.Click += new System.EventHandler(this.button2_Click);
  1337. //
  1338. // button1
  1339. //
  1340. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1341. this.button1.Location = new System.Drawing.Point(1148, 20);
  1342. this.button1.Name = "button1";
  1343. this.button1.Size = new System.Drawing.Size(75, 23);
  1344. this.button1.TabIndex = 0;
  1345. this.button1.Text = "生成报告";
  1346. this.button1.UseVisualStyleBackColor = true;
  1347. this.button1.Click += new System.EventHandler(this.button1_Click);
  1348. //
  1349. // groupBox2
  1350. //
  1351. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1352. | System.Windows.Forms.AnchorStyles.Left)));
  1353. this.groupBox2.Controls.Add(this.treeView1);
  1354. this.groupBox2.Location = new System.Drawing.Point(13, 72);
  1355. this.groupBox2.Name = "groupBox2";
  1356. this.groupBox2.Size = new System.Drawing.Size(186, 484);
  1357. this.groupBox2.TabIndex = 1;
  1358. this.groupBox2.TabStop = false;
  1359. this.groupBox2.Text = "图谱选择";
  1360. //
  1361. // treeView1
  1362. //
  1363. this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1364. | System.Windows.Forms.AnchorStyles.Left)
  1365. | System.Windows.Forms.AnchorStyles.Right)));
  1366. this.treeView1.Location = new System.Drawing.Point(7, 21);
  1367. this.treeView1.Name = "treeView1";
  1368. this.treeView1.Size = new System.Drawing.Size(173, 457);
  1369. this.treeView1.TabIndex = 0;
  1370. this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
  1371. //
  1372. // groupBox3
  1373. //
  1374. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1375. | System.Windows.Forms.AnchorStyles.Left)));
  1376. this.groupBox3.Controls.Add(this.listView1);
  1377. this.groupBox3.Location = new System.Drawing.Point(205, 72);
  1378. this.groupBox3.Name = "groupBox3";
  1379. this.groupBox3.Size = new System.Drawing.Size(133, 385);
  1380. this.groupBox3.TabIndex = 2;
  1381. this.groupBox3.TabStop = false;
  1382. this.groupBox3.Text = "图谱目录";
  1383. //
  1384. // listView1
  1385. //
  1386. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1387. | System.Windows.Forms.AnchorStyles.Left)
  1388. | System.Windows.Forms.AnchorStyles.Right)));
  1389. this.listView1.HideSelection = false;
  1390. this.listView1.LargeImageList = this.imageList1;
  1391. this.listView1.Location = new System.Drawing.Point(7, 21);
  1392. this.listView1.Name = "listView1";
  1393. this.listView1.Size = new System.Drawing.Size(120, 358);
  1394. this.listView1.TabIndex = 0;
  1395. this.listView1.UseCompatibleStateImageBehavior = false;
  1396. //
  1397. // imageList1
  1398. //
  1399. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  1400. this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
  1401. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  1402. //
  1403. // groupBox4
  1404. //
  1405. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  1406. | System.Windows.Forms.AnchorStyles.Right)));
  1407. this.groupBox4.Controls.Add(this.panel2);
  1408. this.groupBox4.Controls.Add(this.panel3);
  1409. this.groupBox4.Controls.Add(this.radioButton2);
  1410. this.groupBox4.Controls.Add(this.radioButton1);
  1411. this.groupBox4.Location = new System.Drawing.Point(205, 463);
  1412. this.groupBox4.Name = "groupBox4";
  1413. this.groupBox4.Size = new System.Drawing.Size(690, 93);
  1414. this.groupBox4.TabIndex = 3;
  1415. this.groupBox4.TabStop = false;
  1416. this.groupBox4.Text = "对照模式";
  1417. //
  1418. // panel2
  1419. //
  1420. this.panel2.Controls.Add(this.radioButton6);
  1421. this.panel2.Controls.Add(this.radioButton5);
  1422. this.panel2.Controls.Add(this.radioButton4);
  1423. this.panel2.Controls.Add(this.radioButton3);
  1424. this.panel2.Location = new System.Drawing.Point(87, 12);
  1425. this.panel2.Name = "panel2";
  1426. this.panel2.Size = new System.Drawing.Size(320, 75);
  1427. this.panel2.TabIndex = 2;
  1428. //
  1429. // radioButton6
  1430. //
  1431. this.radioButton6.AutoSize = true;
  1432. this.radioButton6.Location = new System.Drawing.Point(118, 14);
  1433. this.radioButton6.Name = "radioButton6";
  1434. this.radioButton6.Size = new System.Drawing.Size(29, 16);
  1435. this.radioButton6.TabIndex = 3;
  1436. this.radioButton6.TabStop = true;
  1437. this.radioButton6.Text = "8";
  1438. this.radioButton6.UseVisualStyleBackColor = true;
  1439. this.radioButton6.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
  1440. //
  1441. // radioButton5
  1442. //
  1443. this.radioButton5.AutoSize = true;
  1444. this.radioButton5.Location = new System.Drawing.Point(83, 14);
  1445. this.radioButton5.Name = "radioButton5";
  1446. this.radioButton5.Size = new System.Drawing.Size(29, 16);
  1447. this.radioButton5.TabIndex = 2;
  1448. this.radioButton5.TabStop = true;
  1449. this.radioButton5.Text = "4";
  1450. this.radioButton5.UseVisualStyleBackColor = true;
  1451. this.radioButton5.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
  1452. //
  1453. // radioButton4
  1454. //
  1455. this.radioButton4.AutoSize = true;
  1456. this.radioButton4.Location = new System.Drawing.Point(48, 14);
  1457. this.radioButton4.Name = "radioButton4";
  1458. this.radioButton4.Size = new System.Drawing.Size(29, 16);
  1459. this.radioButton4.TabIndex = 1;
  1460. this.radioButton4.TabStop = true;
  1461. this.radioButton4.Text = "2";
  1462. this.radioButton4.UseVisualStyleBackColor = true;
  1463. this.radioButton4.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
  1464. //
  1465. // radioButton3
  1466. //
  1467. this.radioButton3.AutoSize = true;
  1468. this.radioButton3.Checked = true;
  1469. this.radioButton3.Location = new System.Drawing.Point(13, 14);
  1470. this.radioButton3.Name = "radioButton3";
  1471. this.radioButton3.Size = new System.Drawing.Size(29, 16);
  1472. this.radioButton3.TabIndex = 0;
  1473. this.radioButton3.TabStop = true;
  1474. this.radioButton3.Text = "1";
  1475. this.radioButton3.UseVisualStyleBackColor = true;
  1476. this.radioButton3.CheckedChanged += new System.EventHandler(this.pp_radioButton_CheckedChanged);
  1477. //
  1478. // panel3
  1479. //
  1480. this.panel3.Controls.Add(this.button6);
  1481. this.panel3.Controls.Add(this.numericUpDown3);
  1482. this.panel3.Controls.Add(this.trackBar1);
  1483. this.panel3.Controls.Add(this.label5);
  1484. this.panel3.Controls.Add(this.panel4);
  1485. this.panel3.Controls.Add(this.label4);
  1486. this.panel3.Controls.Add(this.numericUpDown2);
  1487. this.panel3.Controls.Add(this.numericUpDown1);
  1488. this.panel3.Controls.Add(this.label3);
  1489. this.panel3.Location = new System.Drawing.Point(87, 12);
  1490. this.panel3.Name = "panel3";
  1491. this.panel3.Size = new System.Drawing.Size(320, 75);
  1492. this.panel3.TabIndex = 4;
  1493. //
  1494. // button6
  1495. //
  1496. this.button6.Location = new System.Drawing.Point(223, 38);
  1497. this.button6.Name = "button6";
  1498. this.button6.Size = new System.Drawing.Size(75, 23);
  1499. this.button6.TabIndex = 8;
  1500. this.button6.UseVisualStyleBackColor = true;
  1501. this.button6.Click += new System.EventHandler(this.button6_Click);
  1502. //
  1503. // numericUpDown3
  1504. //
  1505. this.numericUpDown3.Location = new System.Drawing.Point(169, 39);
  1506. this.numericUpDown3.Maximum = new decimal(new int[] {
  1507. 255,
  1508. 0,
  1509. 0,
  1510. 0});
  1511. this.numericUpDown3.Name = "numericUpDown3";
  1512. this.numericUpDown3.Size = new System.Drawing.Size(48, 21);
  1513. this.numericUpDown3.TabIndex = 7;
  1514. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  1515. //
  1516. // trackBar1
  1517. //
  1518. this.trackBar1.Location = new System.Drawing.Point(59, 41);
  1519. this.trackBar1.Maximum = 255;
  1520. this.trackBar1.Name = "trackBar1";
  1521. this.trackBar1.Size = new System.Drawing.Size(104, 45);
  1522. this.trackBar1.TabIndex = 6;
  1523. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  1524. this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
  1525. //
  1526. // label5
  1527. //
  1528. this.label5.AutoSize = true;
  1529. this.label5.Location = new System.Drawing.Point(11, 43);
  1530. this.label5.Name = "label5";
  1531. this.label5.Size = new System.Drawing.Size(0, 12);
  1532. this.label5.TabIndex = 5;
  1533. //
  1534. // panel4
  1535. //
  1536. this.panel4.BackColor = System.Drawing.Color.Red;
  1537. this.panel4.Location = new System.Drawing.Point(211, 10);
  1538. this.panel4.Name = "panel4";
  1539. this.panel4.Size = new System.Drawing.Size(48, 21);
  1540. this.panel4.TabIndex = 4;
  1541. this.panel4.Click += new System.EventHandler(this.panel4_Click);
  1542. //
  1543. // label4
  1544. //
  1545. this.label4.AutoSize = true;
  1546. this.label4.Location = new System.Drawing.Point(171, 14);
  1547. this.label4.Name = "label4";
  1548. this.label4.Size = new System.Drawing.Size(0, 12);
  1549. this.label4.TabIndex = 3;
  1550. //
  1551. // numericUpDown2
  1552. //
  1553. this.numericUpDown2.Location = new System.Drawing.Point(118, 10);
  1554. this.numericUpDown2.Maximum = new decimal(new int[] {
  1555. 255,
  1556. 0,
  1557. 0,
  1558. 0});
  1559. this.numericUpDown2.Name = "numericUpDown2";
  1560. this.numericUpDown2.Size = new System.Drawing.Size(48, 21);
  1561. this.numericUpDown2.TabIndex = 2;
  1562. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  1563. //
  1564. // numericUpDown1
  1565. //
  1566. this.numericUpDown1.Location = new System.Drawing.Point(65, 10);
  1567. this.numericUpDown1.Maximum = new decimal(new int[] {
  1568. 255,
  1569. 0,
  1570. 0,
  1571. 0});
  1572. this.numericUpDown1.Name = "numericUpDown1";
  1573. this.numericUpDown1.Size = new System.Drawing.Size(48, 21);
  1574. this.numericUpDown1.TabIndex = 1;
  1575. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  1576. //
  1577. // label3
  1578. //
  1579. this.label3.AutoSize = true;
  1580. this.label3.Location = new System.Drawing.Point(11, 14);
  1581. this.label3.Name = "label3";
  1582. this.label3.Size = new System.Drawing.Size(0, 12);
  1583. this.label3.TabIndex = 0;
  1584. //
  1585. // radioButton2
  1586. //
  1587. this.radioButton2.AutoSize = true;
  1588. this.radioButton2.Location = new System.Drawing.Point(10, 49);
  1589. this.radioButton2.Name = "radioButton2";
  1590. this.radioButton2.Size = new System.Drawing.Size(71, 16);
  1591. this.radioButton2.TabIndex = 1;
  1592. this.radioButton2.Text = "对比对照";
  1593. this.radioButton2.UseVisualStyleBackColor = true;
  1594. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
  1595. //
  1596. // radioButton1
  1597. //
  1598. this.radioButton1.AutoSize = true;
  1599. this.radioButton1.Checked = true;
  1600. this.radioButton1.Location = new System.Drawing.Point(10, 26);
  1601. this.radioButton1.Name = "radioButton1";
  1602. this.radioButton1.Size = new System.Drawing.Size(71, 16);
  1603. this.radioButton1.TabIndex = 0;
  1604. this.radioButton1.TabStop = true;
  1605. this.radioButton1.Text = "平铺对照";
  1606. this.radioButton1.UseVisualStyleBackColor = true;
  1607. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
  1608. //
  1609. // groupBox5
  1610. //
  1611. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  1612. this.groupBox5.Controls.Add(this.label6);
  1613. this.groupBox5.Controls.Add(this.comboBox1);
  1614. this.groupBox5.Controls.Add(this.label2);
  1615. this.groupBox5.Controls.Add(this.label1);
  1616. this.groupBox5.Location = new System.Drawing.Point(901, 463);
  1617. this.groupBox5.Name = "groupBox5";
  1618. this.groupBox5.Size = new System.Drawing.Size(341, 93);
  1619. this.groupBox5.TabIndex = 4;
  1620. this.groupBox5.TabStop = false;
  1621. this.groupBox5.Text = "设置";
  1622. //
  1623. // label6
  1624. //
  1625. this.label6.AutoSize = true;
  1626. this.label6.Location = new System.Drawing.Point(86, 54);
  1627. this.label6.Name = "label6";
  1628. this.label6.Size = new System.Drawing.Size(65, 12);
  1629. this.label6.TabIndex = 3;
  1630. this.label6.Text = "当前级别:";
  1631. //
  1632. // comboBox1
  1633. //
  1634. this.comboBox1.FormattingEnabled = true;
  1635. this.comboBox1.Location = new System.Drawing.Point(87, 22);
  1636. this.comboBox1.Name = "comboBox1";
  1637. this.comboBox1.Size = new System.Drawing.Size(248, 20);
  1638. this.comboBox1.TabIndex = 2;
  1639. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  1640. //
  1641. // label2
  1642. //
  1643. this.label2.AutoSize = true;
  1644. this.label2.Location = new System.Drawing.Point(15, 54);
  1645. this.label2.Name = "label2";
  1646. this.label2.Size = new System.Drawing.Size(65, 12);
  1647. this.label2.TabIndex = 1;
  1648. this.label2.Text = "当前级别:";
  1649. //
  1650. // label1
  1651. //
  1652. this.label1.AutoSize = true;
  1653. this.label1.Location = new System.Drawing.Point(15, 26);
  1654. this.label1.Name = "label1";
  1655. this.label1.Size = new System.Drawing.Size(65, 12);
  1656. this.label1.TabIndex = 0;
  1657. this.label1.Text = "使用标尺:";
  1658. //
  1659. // panel1
  1660. //
  1661. this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1662. | System.Windows.Forms.AnchorStyles.Left)
  1663. | System.Windows.Forms.AnchorStyles.Right)));
  1664. this.panel1.Location = new System.Drawing.Point(344, 72);
  1665. this.panel1.Name = "panel1";
  1666. this.panel1.Size = new System.Drawing.Size(898, 385);
  1667. this.panel1.TabIndex = 5;
  1668. this.panel1.SizeChanged += new System.EventHandler(this.panel1_SizeChanged);
  1669. //
  1670. // AtlasComparisonDialog
  1671. //
  1672. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  1673. this.ClientSize = new System.Drawing.Size(1254, 568);
  1674. this.Controls.Add(this.panel1);
  1675. this.Controls.Add(this.groupBox5);
  1676. this.Controls.Add(this.groupBox4);
  1677. this.Controls.Add(this.groupBox3);
  1678. this.Controls.Add(this.groupBox2);
  1679. this.Controls.Add(this.groupBox1);
  1680. this.Name = "AtlasComparisonDialog";
  1681. this.Text = "图谱比照";
  1682. this.Load += new System.EventHandler(this.AtlasComparisonDialog_Load);
  1683. this.Controls.SetChildIndex(this.groupBox1, 0);
  1684. this.Controls.SetChildIndex(this.groupBox2, 0);
  1685. this.Controls.SetChildIndex(this.groupBox3, 0);
  1686. this.Controls.SetChildIndex(this.groupBox4, 0);
  1687. this.Controls.SetChildIndex(this.groupBox5, 0);
  1688. this.Controls.SetChildIndex(this.panel1, 0);
  1689. this.groupBox1.ResumeLayout(false);
  1690. this.groupBox1.PerformLayout();
  1691. this.groupBox2.ResumeLayout(false);
  1692. this.groupBox3.ResumeLayout(false);
  1693. this.groupBox4.ResumeLayout(false);
  1694. this.groupBox4.PerformLayout();
  1695. this.panel2.ResumeLayout(false);
  1696. this.panel2.PerformLayout();
  1697. this.panel3.ResumeLayout(false);
  1698. this.panel3.PerformLayout();
  1699. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  1700. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  1701. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  1702. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  1703. this.groupBox5.ResumeLayout(false);
  1704. this.groupBox5.PerformLayout();
  1705. this.ResumeLayout(false);
  1706. }
  1707. #endregion
  1708. /// <summary>
  1709. /// 获取上次操作参数
  1710. /// </summary>
  1711. private void getLastData()
  1712. {
  1713. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1714. if (!System.IO.File.Exists(filePath))
  1715. {
  1716. generalAnalysisModel = new GeneralAnalysisModel();
  1717. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1718. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1719. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1720. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1721. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1722. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1723. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1724. generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
  1725. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1726. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1727. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1728. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1729. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1730. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1731. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1732. generalAnalysisModel.AtlasComparisonModels.hasUsed = false;
  1733. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1734. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1735. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1736. }
  1737. else
  1738. {
  1739. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1740. if (generalAnalysisModel.AtlasComparisonModels == null)
  1741. {
  1742. generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
  1743. }
  1744. if (generalAnalysisModel.AtlasComparisonModels.hasUsed)
  1745. {
  1746. checkBox1.Checked = generalAnalysisModel.AtlasComparisonModels.parameter1;
  1747. radioButton1.Checked = generalAnalysisModel.AtlasComparisonModels.parameter2 == 1 ? true:false;
  1748. radioButton2.Checked = generalAnalysisModel.AtlasComparisonModels.parameter2 == 2 ? true:false;
  1749. switch (generalAnalysisModel.AtlasComparisonModels.parameter3) {
  1750. case 0:
  1751. radioButton3.Checked = true;
  1752. radioButton4.Checked = false;
  1753. radioButton5.Checked = false;
  1754. radioButton6.Checked = false;
  1755. break;
  1756. case 1:
  1757. radioButton3.Checked = true;
  1758. radioButton4.Checked = false;
  1759. radioButton5.Checked = false;
  1760. radioButton6.Checked = false;
  1761. break;
  1762. case 2:
  1763. radioButton3.Checked = false;
  1764. radioButton4.Checked = true;
  1765. radioButton5.Checked = false;
  1766. radioButton6.Checked = false;
  1767. break;
  1768. case 3:
  1769. radioButton3.Checked = false;
  1770. radioButton4.Checked = false;
  1771. radioButton5.Checked = true;
  1772. radioButton6.Checked = false;
  1773. break;
  1774. case 4:
  1775. radioButton3.Checked = false;
  1776. radioButton4.Checked = false;
  1777. radioButton5.Checked = false;
  1778. radioButton6.Checked = true;
  1779. break;
  1780. }
  1781. numericUpDown1.Value = generalAnalysisModel.AtlasComparisonModels.parameter4;
  1782. numericUpDown2.Value = generalAnalysisModel.AtlasComparisonModels.parameter5;
  1783. panel4.BackColor = Color.FromArgb(generalAnalysisModel.AtlasComparisonModels.parameter6);
  1784. trackBar1.Value = generalAnalysisModel.AtlasComparisonModels.parameter7;
  1785. numericUpDown3.Value = generalAnalysisModel.AtlasComparisonModels.parameter7;
  1786. }
  1787. }
  1788. }
  1789. /// <summary>
  1790. /// 保存上次操作参数
  1791. /// </summary>
  1792. private void saveLastData(object sender, EventArgs e)
  1793. {
  1794. if (generalAnalysisModel.AtlasComparisonModels == null)
  1795. {
  1796. generalAnalysisModel.AtlasComparisonModels = new GeneralAnalysisModel.AtlasComparisonModel();
  1797. }
  1798. generalAnalysisModel.AtlasComparisonModels.hasUsed = true;
  1799. generalAnalysisModel.AtlasComparisonModels.parameter1 = checkBox1.Checked;
  1800. generalAnalysisModel.AtlasComparisonModels.parameter2 = radioButton1.Checked ? 1 : 2;
  1801. if (radioButton3.Checked) {
  1802. generalAnalysisModel.AtlasComparisonModels.parameter3 = 1;
  1803. }
  1804. else if (radioButton4.Checked)
  1805. {
  1806. generalAnalysisModel.AtlasComparisonModels.parameter3 = 2;
  1807. }
  1808. else if (radioButton5.Checked)
  1809. {
  1810. generalAnalysisModel.AtlasComparisonModels.parameter3 = 3;
  1811. }
  1812. else if (radioButton6.Checked)
  1813. {
  1814. generalAnalysisModel.AtlasComparisonModels.parameter3 = 4;
  1815. }
  1816. generalAnalysisModel.AtlasComparisonModels.parameter4 = (int)numericUpDown1.Value;
  1817. generalAnalysisModel.AtlasComparisonModels.parameter5 = (int)numericUpDown2.Value;
  1818. generalAnalysisModel.AtlasComparisonModels.parameter6 = panel4.BackColor.ToArgb();
  1819. generalAnalysisModel.AtlasComparisonModels.parameter7 = trackBar1.Value;
  1820. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1821. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1822. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1823. }
  1824. }
  1825. }