BshTransferAdjustDialog.cs 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. using Metis.ParameterSet;
  2. using PaintDotNet.Adjust;
  3. using PaintDotNet.Base;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.CustomControl;
  6. using PaintDotNet.Data.Action;
  7. using PaintDotNet.Data.Param;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Drawing;
  12. using System.Drawing.Imaging;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Windows.Forms;
  16. using static Metis.ParameterSet.ImageMenu;
  17. namespace PaintDotNet.Processing
  18. {
  19. /// <summary>
  20. /// 图像处理窗口
  21. /// </summary>
  22. internal class BshTransferAdjustDialog : Form
  23. {
  24. /// <summary>
  25. /// 步长 初始值1,依次增加
  26. /// </summary>
  27. string stepLength = "00" + Startup.instance.step_length;
  28. /// <summary>
  29. /// 主控件
  30. /// </summary>
  31. private AppWorkspace appWorkspace;
  32. /// <summary>
  33. /// 当前处理的程序
  34. /// </summary>
  35. private ParamObject action;
  36. /// <summary>
  37. /// 如果是脚本执行,将参数带入
  38. /// </summary>
  39. private Boolean initScriptValues = false;
  40. // <summary>
  41. /// 如果有参数保存,将参数带入
  42. /// </summary>
  43. private Boolean initPamasValues = false;
  44. /// <summary>
  45. /// 当前活动的图像
  46. /// </summary>
  47. private Bitmap bitmap;
  48. /// <summary>
  49. /// 调用调色板的控件
  50. /// </summary>
  51. private Panel panel2;
  52. /// <summary>
  53. /// 调用原图取色 显示色板的控件
  54. /// </summary>
  55. private Panel panel3;
  56. /// <summary>
  57. /// 是否使用原图取色
  58. /// </summary>
  59. private bool item3Checked;
  60. /// <summary>
  61. /// 调色板
  62. /// </summary>
  63. private ColorsForm colorsFormGrid;
  64. /// <summary>
  65. /// 像素格式
  66. /// </summary>
  67. private PixelFormat pixelFormat;
  68. /// <summary>
  69. /// 图像面板
  70. /// </summary>
  71. private DocumentWorkspaceWindow documentWorkspace;
  72. /// <summary>
  73. /// 公共按钮
  74. /// </summary>
  75. private CommonControlButtons commonControlButtons;
  76. /// <summary>
  77. /// 是否点击过应用按钮
  78. /// 如果没有点过,直接点确定还需要走一遍方法,
  79. /// 如果已经点过,直接拿当前图片
  80. /// </summary>
  81. private bool applyButtonClick = false;
  82. private PdnMenuItem MenuItem;
  83. /// <summary>
  84. /// 选中参数的索引
  85. /// </summary>
  86. private string index = "1";
  87. [Browsable(false)]
  88. public AppWorkspace AppWorkspace
  89. {
  90. get
  91. {
  92. return this.appWorkspace;
  93. }
  94. set
  95. {
  96. this.appWorkspace = value;
  97. }
  98. }
  99. ActionType menuIdOverall;
  100. /// <summary>
  101. /// dialog
  102. /// </summary>
  103. /// <param name="appWorkspace"></param>
  104. /// <param name="menuId">对应菜单的id</param>
  105. public BshTransferAdjustDialog(AppWorkspace appWorkspace, ActionType menuId, string dialogText,PdnMenuItem menuItem)
  106. {
  107. menuIdOverall = menuId;
  108. this.MenuItem = menuItem;
  109. InitializeComponent();
  110. InitializeLanguageText();
  111. //
  112. // 设置Dialog属性
  113. //
  114. this.AppWorkspace = appWorkspace;
  115. this.StartPosition = FormStartPosition.CenterScreen;
  116. this.Icon = PdnInfo.AppIcon;
  117. this.bitmap = this.AppWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap();
  118. this.pixelFormat = this.AppWorkspace.ActiveDocumentWorkspace.CompositionSurface.PixelFormat;
  119. this.Text = dialogText;
  120. //
  121. //初始化色板
  122. //
  123. this.colorsFormGrid = new ColorsForm();
  124. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  125. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  126. //
  127. //初始化图像控件
  128. //
  129. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  130. this.documentWorkspace.Dock = DockStyle.Fill;
  131. this.documentWorkspace.HookMouseEvents();
  132. this.documentWorkspace.AuxiliaryLineEnabled = false;
  133. this.documentWorkspace.Visible = false;
  134. this.groupBox1.Controls.Add(documentWorkspace);
  135. //
  136. //初始化操作按钮
  137. //
  138. this.commonControlButtons = new CommonControlButtons();
  139. this.commonControlButtons.Dock = DockStyle.Top;
  140. this.commonControlButtons.Height = 30;
  141. this.commonControlButtons.HideZoomToWindowAndActualSize();
  142. this.groupBox1.Controls.Add(commonControlButtons);
  143. switch (menuId)
  144. {
  145. //图像偏移
  146. case ActionType.ActionImageOffset:
  147. action = new Data.Action.Action507();
  148. ((Action507)action).one.Min = -bitmap.Height;
  149. ((Action507)action).one.Max = bitmap.Height;
  150. ((Action507)action).two.Min = -bitmap.Width;
  151. ((Action507)action).two.Max = bitmap.Width;
  152. break;
  153. //调节
  154. case ActionType.ActionRevertColor:
  155. action = new Data.Action.Action5010();
  156. break;
  157. case ActionType.ActionBgr2Gray:
  158. action = new Data.Action.Action5011();
  159. break;
  160. case ActionType.ActionWhiteBalance:
  161. action = new Data.Action.Action5012();
  162. //白平衡原图取点
  163. this.documentWorkspace.panel.MouseClick += PicturePreviewControl1_item3MouseDown;
  164. //picturePreviewControl1.item3MouseDown += PicturePreviewControl1_item3MouseDown;
  165. break;
  166. case ActionType.ActionColorBalance:
  167. action = new Data.Action.Action5013();
  168. break;
  169. case ActionType.ActionShadingCorrection:
  170. action = new Data.Action.Action5014();
  171. break;
  172. case ActionType.ActionHSB:
  173. action = new Data.Action.Action5015();
  174. break;
  175. case ActionType.ActionBCG:
  176. action = new Data.Action.Action5016();
  177. break;
  178. case ActionType.ActionImageRotate:
  179. action = new Data.Action.Action5017();
  180. break;
  181. //锐化
  182. case ActionType.ActionPortray:
  183. action = new Data.Action.Action5020();
  184. break;
  185. case ActionType.ActionEnhanceContour:
  186. action = new Data.Action.Action5021();
  187. break;
  188. case ActionType.ActionBlurMask:
  189. action = new Data.Action.Action5022();
  190. break;
  191. //平滑
  192. case ActionType.Sigma:
  193. action = new Data.Action.Action5030();
  194. break;
  195. case ActionType.GaussianFiltering:
  196. action = new Data.Action.Action5031();
  197. break;
  198. case ActionType.LowPassFiltering:
  199. action = new Data.Action.Action5032();
  200. break;
  201. case ActionType.MedianFiltering:
  202. action = new Data.Action.Action5033();
  203. break;
  204. case ActionType.GaussianBlur:
  205. action = new Data.Action.Action5034();
  206. break;
  207. case ActionType.BilateralFiltering:
  208. action = new Data.Action.Action5035();
  209. break;
  210. case ActionType.WaveletDenoising:
  211. action = new Data.Action.Action5036();
  212. break;
  213. //边缘检测
  214. case ActionType.Log:
  215. action = new Data.Action.Action5040();
  216. break;
  217. case ActionType.Canny:
  218. action = new Data.Action.Action5041();
  219. break;
  220. case ActionType.Sobel:
  221. action = new Data.Action.Action5042();
  222. break;
  223. case ActionType.Kirsch:
  224. action = new Data.Action.Action5043();
  225. break;
  226. case ActionType.Prewitt:
  227. action = new Data.Action.Action5044();
  228. break;
  229. case ActionType.Roberts:
  230. action = new Data.Action.Action5045();
  231. break;
  232. case ActionType.Laplace:
  233. action = new Data.Action.Action5046();
  234. break;
  235. //图像间操作
  236. case ActionType.ActionImageAddition:
  237. action = new Data.Action.Action5050();
  238. break;
  239. default:
  240. action = new Data.Action.Action5010();
  241. break;
  242. }
  243. if (action.Lists == null || action.Lists.Count < 1)
  244. {
  245. Label label = new Label();
  246. label.Left = 7;
  247. label.Top = 31;
  248. label.Size = new Size(60, 12);
  249. label.TextAlign = ContentAlignment.TopLeft;
  250. label.Text = PdnResources.GetString("Menu.Noparams.text");
  251. groupBoxParam.Controls.Add(label);
  252. this.button5.Visible = false;
  253. GetParameters(Startup.instance.imageMenuModel);
  254. }
  255. else
  256. {
  257. //如果是脚本执行,将参数带入(AppWorkspace.ScriptRunning && AppWorkspace.ScriptCurrentParam != null && AppWorkspace.ScriptCurrentParam.MenuId == action.MenuId);
  258. if (AppWorkspace.ScriptRunning && AppWorkspace.ScriptCurrentParam != null && AppWorkspace.ScriptCurrentParam.MenuId == action.MenuId)
  259. {
  260. this.initScriptValues = true;
  261. foreach (Args arg in action.Lists)
  262. {
  263. Args param1 = AppWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  264. if (param1.value != null)
  265. arg.Value = param1.value;
  266. }
  267. AppWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  268. }
  269. else
  270. {
  271. GetParameters(Startup.instance.imageMenuModel);
  272. this.initScriptValues = false;
  273. }
  274. int controlsTop = 0;
  275. //初始化手动控件
  276. for (int i = 0; i < action.Lists.Count; i++)
  277. {
  278. Args args = action.Lists[i];
  279. index = args.value.ToString();
  280. if (args is IntegerNumber || args is DecimalNumber || args is OddNumber)
  281. {
  282. CustomControl.NumberParamControl numberParam = new CustomControl.NumberParamControl();
  283. numberParam.Left = 78;
  284. numberParam.Top = 35 + controlsTop;
  285. //设置参数范围
  286. numberParam.paramIndex = 100 + i;
  287. if (args is DecimalNumber)
  288. {
  289. numberParam.DecimalPlaces = ((DecimalNumber)args).DecimalPlaces;
  290. numberParam.Minimum = (double)((DecimalNumber)args).Min;
  291. numberParam.Maximum = (double)((DecimalNumber)args).Max;
  292. }
  293. else if (args is OddNumber)
  294. {
  295. numberParam.Increment = 2;
  296. numberParam.Minimum = ((OddNumber)args).Min;
  297. numberParam.Maximum = ((OddNumber)args).Max;
  298. numberParam.IsOddNumber = true;
  299. }
  300. else
  301. {
  302. numberParam.DecimalPlaces = 0;
  303. numberParam.Minimum = ((IntegerNumber)args).Min;
  304. numberParam.Maximum = ((IntegerNumber)args).Max;
  305. }
  306. double fnum = 0;
  307. if (double.TryParse((initScriptValues || initPamasValues ? args.value : args.initialValue).ToString(), out fnum))
  308. {
  309. numberParam.Value = fnum;
  310. //args.Value = fnum;
  311. }
  312. groupBoxParam.Controls.Add(numberParam);
  313. groupBoxParam.Controls.SetChildIndex(numberParam, 100 + i);
  314. if (args is DecimalNumber)
  315. {
  316. numberParam.ValueChanged += new EventHandler(((DecimalNumber)args).numberParam_ValueChanged);
  317. }
  318. else if (args is OddNumber)
  319. {
  320. numberParam.ValueChanged += new EventHandler(((OddNumber)args).numberParam_ValueChanged);
  321. }
  322. else
  323. {
  324. numberParam.ValueChanged += new EventHandler(((IntegerNumber)args).numberParam_ValueChanged);
  325. }
  326. numberParam.ValueChanged += this.ParameterChangeEvent;
  327. Label label = new Label();
  328. label.Left = 19;
  329. label.Top = 40 + controlsTop;
  330. label.Size = new Size(65, 12);//55->65 调试值,提交备注:调试3-双边滤波-邻域直径。
  331. label.TextAlign = ContentAlignment.MiddleRight;
  332. label.Text = args.name + ":";
  333. groupBoxParam.Controls.Add(label);
  334. controlsTop += 45;
  335. }
  336. else if (args is ChoiseArray)
  337. {
  338. Label label = new Label();
  339. label.Left = 19;
  340. label.Top = 40 + controlsTop;
  341. label.Size = new Size(55, 12);
  342. label.TextAlign = ContentAlignment.MiddleRight;
  343. label.Text = args.name + ":";
  344. groupBoxParam.Controls.Add(label);
  345. //初始化选项列表
  346. for (int j = 0; j < args.choiseList.Count; j++)
  347. {
  348. BooleanObject argsChoise = args.choiseList[j] as BooleanObject;
  349. RadioButton radio = new RadioButton();
  350. if (argsChoise.key == args.value)
  351. {
  352. radio.Checked = true;
  353. }
  354. radio.AutoSize = true;
  355. radio.Location = new Point(88, 40 + controlsTop/*topMargin*/);
  356. radio.Text = argsChoise.name + "";
  357. radio.Tag = argsChoise.Key;
  358. radio.CheckedChanged += ((ChoiseArray)args).numberParam_ValueChanged;
  359. radio.CheckedChanged += Radio_CheckedChanged;
  360. groupBoxParam.Controls.Add(radio);
  361. if (argsChoise.Lists.Count > 0)
  362. {
  363. ColorNumber phaseColor = argsChoise.Lists[0] as ColorNumber;
  364. if (phaseColor.Key.Equals("phaseColor"))
  365. {
  366. Panel panel = new Panel();
  367. panel.BackColor = Color.FromArgb(int.Parse(phaseColor.Value.ToString()));
  368. panel.Size = new Size(53, 20);
  369. panel.Top = 37 + controlsTop;
  370. panel.Left = 178;
  371. groupBoxParam.Controls.Add(panel);
  372. panel.Click += new System.EventHandler(this.panel2_Click);
  373. panel.BackColorChanged += ((ColorNumber)phaseColor).numberParam_ValueChanged;
  374. panel.BackColorChanged += this.ParameterChangeEvent;
  375. this.panel2 = panel;
  376. }
  377. else if (phaseColor.Key.Equals("imageColor"))
  378. {
  379. Panel panel = new Panel();
  380. panel.BackColor = Color.FromArgb(int.Parse(phaseColor.Value.ToString()));
  381. panel.Size = new Size(53, 20);
  382. panel.Top = 37 + controlsTop;
  383. panel.Left = 178;
  384. groupBoxParam.Controls.Add(panel);
  385. panel.BackColorChanged += ((ColorNumber)phaseColor).numberParam_ValueChanged;
  386. panel.BackColorChanged += this.ParameterChangeEvent;
  387. this.panel3 = panel;
  388. }
  389. }
  390. controlsTop += 45;
  391. }
  392. }
  393. else if (args is ColorNumber)
  394. {
  395. Label label = new Label();
  396. label.Left = 19;
  397. label.Top = 40 + controlsTop;
  398. label.Size = new Size(65, 12);
  399. label.TextAlign = ContentAlignment.MiddleRight;
  400. label.Text = args.name + ":";
  401. //colorPanel.BackColorChanged += ((ColorNumber)arg).numberParam_ValueChanged;
  402. ////radio.CheckedChanged += ((ChoiseArray)args).numberParam_ValueChanged;
  403. groupBoxParam.Controls.Add(label);
  404. Panel panel = new Panel();
  405. panel.BackColor = Color.FromArgb(int.Parse(args.Value.ToString()));
  406. panel.Size = new Size(53, 20);
  407. panel.Top = 35 + controlsTop;
  408. panel.Left = 85;
  409. groupBoxParam.Controls.Add(panel);
  410. panel.Click += new System.EventHandler(this.panel2_Click);
  411. panel.BackColorChanged += ((ColorNumber)args).numberParam_ValueChanged;
  412. panel.BackColorChanged += this.ParameterChangeEvent;
  413. this.panel2 = panel;
  414. controlsTop += 45;
  415. }
  416. else if (args is StringArray)
  417. {
  418. Label label = new Label();
  419. label.Left = 19;
  420. label.Top = 40 + controlsTop;
  421. label.Size = new Size(55, 12);
  422. label.TextAlign = ContentAlignment.MiddleRight;
  423. label.Text = args.name + ":";
  424. groupBoxParam.Controls.Add(label);
  425. Panel panel = new Panel();
  426. panel.AutoSize = true;
  427. panel.Top = 40 + controlsTop;
  428. panel.Left = 78;
  429. int position = 1;
  430. int topMargin = 0;
  431. //循环字典,铺多个radio
  432. foreach (var item in (Dictionary<Enum, object>)((initScriptValues || initPamasValues ? args.value : args.initialValue)))
  433. {
  434. int xvalue = 0;
  435. if (position % 1 == 0) xvalue = 0;
  436. if (position % 2 == 0) xvalue = 1;
  437. if (position % 3 == 0) xvalue = 2;
  438. RadioButton radio = new RadioButton();
  439. if (position == 1)
  440. {
  441. radio.Checked = true;
  442. }
  443. radio.AutoSize = true;
  444. radio.Location = new Point(xvalue * 90, topMargin);
  445. radio.Text = item.Value.ToString();
  446. radio.Tag = item.Key;
  447. radio.CheckedChanged += ((StringArray)args).numberParam_ValueChanged;
  448. radio.CheckedChanged += this.ParameterChangeEvent;
  449. panel.Controls.Add(radio);
  450. if (position % 3 == 0) topMargin += 25;
  451. position++;
  452. }
  453. groupBoxParam.Controls.Add(panel);
  454. controlsTop += 45;
  455. }
  456. }
  457. }
  458. InitData();
  459. InitCommonButtonEvent();
  460. }
  461. private void startScriptAutomaticAction()
  462. {
  463. applyButtonImpl(null, null);
  464. sureButtonImpl(null, null);
  465. }
  466. private void ParameterChangeEvent(object sender, EventArgs e)
  467. {
  468. this.applyButtonClick = false;
  469. }
  470. private void InitCommonButtonEvent()
  471. {
  472. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  473. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  474. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  475. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  476. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  477. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  478. }
  479. private void zoomInButton_Click(object sender, EventArgs e)
  480. {
  481. this.documentWorkspace.ZoomIn();
  482. }
  483. private void zoomOutButton_Click(object sender, EventArgs e)
  484. {
  485. this.documentWorkspace.ZoomOut();
  486. }
  487. private void zoomToWindowButton_Click(object sender, EventArgs e)
  488. {
  489. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  490. }
  491. private void actualSizeButton_Click(object sender, EventArgs e)
  492. {
  493. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  494. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  495. }
  496. private void pointerButton_Click(object sender, EventArgs e)
  497. {
  498. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  499. }
  500. private void mobileModeButton_Click(object sender, EventArgs e)
  501. {
  502. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  503. }
  504. private void Radio_CheckedChanged(object sender, EventArgs e)
  505. {
  506. if (((RadioButton)sender).Tag.Equals("3"))//原图取色
  507. {
  508. this.item3Checked = ((RadioButton)sender).Checked;
  509. //picturePreviewControl1.selectColorMode(this.item3Checked);
  510. }
  511. OpenCvSharp.Mat mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  512. Document document = Document.FromMat(mat);
  513. this.documentWorkspace.Document = document;
  514. this.documentWorkspace.Refresh();
  515. //picturePreviewControl1.pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
  516. }
  517. /// <summary>
  518. /// 相颜色点击事件
  519. /// </summary>
  520. /// <param name="sender"></param>
  521. /// <param name="e"></param>
  522. private void panel2_Click(object sender, EventArgs e)
  523. {
  524. this.panel2 = ((Panel)sender);
  525. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(panel2.BackColor);
  526. this.colorsFormGrid.ShowDialog();
  527. }
  528. /// <summary>
  529. /// Panel2的调色板颜色改变
  530. /// </summary>
  531. /// <param name="sender"></param>
  532. /// <param name="e"></param>
  533. private void gridColorChanged(object sender, EventArgs e)
  534. {
  535. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  536. //更改背景色,触发事件
  537. this.panel2.BackColor = color;
  538. ////改变配置文件里面的相颜色
  539. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  540. OpenCvSharp.Mat mat = new OpenCvSharp.Mat();
  541. if (menuIdOverall == ActionType.ActionImageRotate)
  542. {
  543. OpenCvSharp.Mat src = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  544. //GeometryIntent.ImageRotate(src, mat, float.Parse(action.lists[0].value.ToString()), OpenCvSharp.InterpolationFlags.Linear);
  545. mat = GeometryIntent.MatRotate(src, float.Parse(action.lists[0].value.ToString()), new OpenCvSharp.Scalar(panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255));
  546. }
  547. else
  548. {
  549. mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  550. }
  551. //OpenCvSharp.Mat mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  552. Document document = Document.FromMat(mat);
  553. this.documentWorkspace.Document = document;
  554. this.documentWorkspace.Refresh();
  555. //picturePreviewControl1.pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
  556. //关闭色板
  557. this.colorsFormGrid.Close();
  558. }
  559. /// <summary>
  560. /// 初始化数据
  561. /// </summary>
  562. public void InitData()
  563. {
  564. Document document = Document.FromImage(this.bitmap);
  565. this.documentWorkspace.Document = document;
  566. this.documentWorkspace.Visible = true;
  567. this.documentWorkspace.Refresh();
  568. //给picturebox赋值
  569. //picturePreviewControl1.pictureBox1.Image = this.bitmap;
  570. //初始化/重置参数
  571. resetNumber();
  572. //this.initScriptValues = false;//阻止第二次进入仍然被赋值参数
  573. }
  574. private void resetNumber()
  575. {
  576. if (action is Action5012)//白平衡
  577. {
  578. //GetParameters(Startup.instance.imageMenuModel);
  579. this.item3Checked = false;
  580. //重新初始化选项列表
  581. Args args = action.Lists[0];
  582. for (int j = 0; j < args.choiseList.Count; j++)
  583. {
  584. BooleanObject argsChoise = args.choiseList[j] as BooleanObject;
  585. if (argsChoise.Lists.Count > 0)
  586. {
  587. ColorNumber phaseColor = argsChoise.Lists[0] as ColorNumber;
  588. if (phaseColor.Key.Equals("phaseColor"))//色板取色
  589. {
  590. this.panel2.BackColor = Color.FromArgb(int.Parse((initScriptValues || initPamasValues ? phaseColor.value : phaseColor.initialValue).ToString()));
  591. }
  592. else if (phaseColor.Key.Equals("imageColor"))//原图取色
  593. {
  594. this.panel3.BackColor = Color.FromArgb(int.Parse((initScriptValues || initPamasValues ? phaseColor.value : phaseColor.initialValue).ToString()));
  595. }
  596. }
  597. }
  598. }
  599. if (action is Action507 || action is Action5017)//图像偏移
  600. {
  601. //重新初始化选色面板
  602. for (int j = 0; j < action.Lists.Count; j++)
  603. {
  604. ColorNumber phaseColor = action.Lists[j] as ColorNumber;
  605. if (phaseColor is ColorNumber)
  606. {
  607. this.panel2.BackColor = Color.FromArgb(int.Parse((initScriptValues || initPamasValues ? phaseColor.value : phaseColor.initialValue).ToString()));
  608. break;
  609. }
  610. }
  611. }
  612. foreach (Control control in groupBoxParam.Controls)//遍历参数面板上的所有控件
  613. {
  614. if (control is CustomControl.NumberParamControl)
  615. {
  616. CustomControl.NumberParamControl numberParam = (CustomControl.NumberParamControl)control;
  617. if (numberParam.paramIndex >= 100)
  618. {
  619. //List<Args> list1s = action.Lists[0];
  620. Args args = /*list1s*/action.Lists[numberParam.paramIndex - 100];
  621. double fnum = 0;
  622. if (double.TryParse((initScriptValues || initPamasValues ? args.value : args.initialValue).ToString(), out fnum))
  623. {
  624. numberParam.Value = fnum;
  625. }
  626. //numberParam.Value = (int)args.initialValue;
  627. }
  628. }
  629. else if (control is RadioButton)
  630. {
  631. if (control.Tag.Equals(index))
  632. {
  633. ((RadioButton)control).Checked = true;
  634. }
  635. else
  636. {
  637. ((RadioButton)control).Checked = false;
  638. }
  639. }
  640. }
  641. }
  642. /// <summary>
  643. /// 原图取点的响应方法
  644. /// </summary>
  645. /// <param name="sender"></param>
  646. /// <param name="e"></param>
  647. private void PicturePreviewControl1_item3MouseDown(object sender, MouseEventArgs e)
  648. {
  649. if (this.item3Checked)
  650. {
  651. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(new System.Drawing.Point(e.X, e.Y));
  652. int x = point.X;
  653. int y = point.Y;
  654. if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
  655. {
  656. OpenCvSharp.Mat srt = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);
  657. OpenCvSharp.Vec3b bgr = srt.At<OpenCvSharp.Vec3b>(y, x);
  658. Color color = Color.FromArgb(bgr[2], bgr[1], bgr[0]);
  659. //更改背景色,触发事件
  660. this.panel3.BackColor = color;
  661. OpenCvSharp.Mat mat = action.PerformProcess(srt);
  662. //mat.Set(e.Location.Y, e.Location.X, new OpenCvSharp.Vec3b(0, 0, 255));//测试取点的位置
  663. //picturePreviewControl1.pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
  664. Document document = Document.FromMat(mat);
  665. this.documentWorkspace.Document = document;
  666. this.documentWorkspace.Refresh();
  667. }
  668. }
  669. }
  670. private void BshTransferAdjustDialog_Load(object sender, EventArgs e)
  671. {
  672. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  673. //图像名称输入框
  674. informationControl.fileNameTextBox1.Text = this.Text + "-" + stepLength;
  675. //picturePreviewControl1.isShown = true;
  676. parametersSettingControl.applyButtonClick += new EventHandler(applyButtonImpl);//注册事件,在窗体中事件处理代码中预览图像处理效果
  677. parametersSettingControl.sureButtonClick += new EventHandler(sureButtonImpl);//注册事件,在窗体中事件处理代码中预览图像处理效果
  678. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  679. {
  680. this.startScriptAutomaticAction();
  681. }
  682. }
  683. //应用
  684. private void applyButtonImpl(object sender, EventArgs e)
  685. {
  686. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  687. int itemCount = 100;
  688. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  689. System.Threading.ThreadStart copyThreadProc =
  690. delegate ()
  691. {
  692. try
  693. {
  694. OpenCvSharp.Mat mat = new OpenCvSharp.Mat();
  695. if (menuIdOverall == ActionType.ActionImageRotate)
  696. {
  697. OpenCvSharp.Mat src = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  698. //OpenCvSharp.Cv2.CvtColor(src, src, OpenCvSharp.ColorConversionCodes.BGRA2BGR);
  699. mat = GeometryIntent.MatRotate(src, float.Parse(action.lists[0].value.ToString()), new OpenCvSharp.Scalar( panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255));
  700. }
  701. else
  702. {
  703. mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  704. //OpenCvSharp.Cv2.CvtColor(mat, mat, OpenCvSharp.ColorConversionCodes.BGRA2BGR);
  705. }
  706. Document document = Document.FromMat(mat);
  707. this.documentWorkspace.Document = document;
  708. this.documentWorkspace.Refresh();
  709. this.applyButtonClick = true;
  710. }
  711. catch (Exception)
  712. {
  713. }
  714. finally
  715. {
  716. progressEvents.EndOperation(OperationResult.Finished);
  717. }
  718. };
  719. procClass.StartProgressAction(/*currentForm*/this, itemCount, copyThreadProc, progressEvents, null);
  720. }
  721. //确定
  722. internal void sureButtonImpl(object sender, EventArgs e)
  723. {
  724. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  725. int itemCount = 100;
  726. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  727. System.Threading.ThreadStart copyThreadProc =
  728. delegate ()
  729. {
  730. try
  731. {
  732. OpenCvSharp.Mat mat = new OpenCvSharp.Mat();
  733. if (!this.applyButtonClick)
  734. {
  735. if (menuIdOverall == ActionType.ActionImageRotate)
  736. {
  737. OpenCvSharp.Mat src = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  738. mat = GeometryIntent.MatRotate(src, float.Parse(action.lists[0].value.ToString()), new OpenCvSharp.Scalar(panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255));
  739. }
  740. else
  741. {
  742. mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  743. }
  744. if (this.pixelFormat == PixelFormat.Format8bppIndexed && mat.Type() != OpenCvSharp.MatType.CV_8UC1)
  745. {
  746. mat = mat.CvtColor(OpenCvSharp.ColorConversionCodes.BGR2GRAY);
  747. }
  748. }
  749. else
  750. {
  751. mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
  752. }
  753. this.Invoke(new EventHandler(delegate
  754. {
  755. //生成新图-是
  756. if (informationControl.radioButton1.Checked)
  757. {
  758. this.OpenFileImpl(mat);
  759. }
  760. else
  761. {
  762. Document document = Document.FromImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat));
  763. AppWorkspace.ActiveDocumentWorkspace.Document = document;
  764. }
  765. this.Close();
  766. }));
  767. }
  768. catch (Exception)
  769. {
  770. }
  771. finally
  772. {
  773. progressEvents.EndOperation(OperationResult.Finished);
  774. }
  775. };
  776. procClass.StartProgressAction(/*currentForm*/this, itemCount, copyThreadProc, progressEvents, null);
  777. }
  778. //生成新图
  779. private void OpenFileImpl(OpenCvSharp.Mat mat)
  780. {
  781. DocumentWorkspace dw = AppWorkspace.AddNewDocumentWorkspace();
  782. Document document = Document.FromImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat));
  783. dw.Document = document;
  784. dw.fileText = informationControl.fileNameTextBox1.Text;
  785. dw.xmlSaveModel = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel;
  786. dw.rules = this.appWorkspace.ActiveDocumentWorkspace.rules;
  787. AppWorkspace.ActiveDocumentWorkspace = dw;
  788. Startup.instance.step_length += 1;
  789. }
  790. //参数-重设
  791. private void button5_Click(object sender, EventArgs e)
  792. {
  793. GetParameters(Startup.instance.imageMenuModel);
  794. //初始化/重置参数
  795. resetNumber();
  796. Document document = Document.FromImage(this.bitmap);
  797. this.documentWorkspace.Document = document;
  798. this.documentWorkspace.Refresh();
  799. //picturePreviewControl1.pictureBox1.Image = this.bitmap;
  800. }
  801. /// <summary>
  802. /// Required designer variable.
  803. /// </summary>
  804. private System.ComponentModel.IContainer components = null;
  805. /// <summary>
  806. /// Clean up any resources being used.
  807. /// </summary>
  808. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  809. protected override void Dispose(bool disposing)
  810. {
  811. if (disposing && (components != null))
  812. {
  813. components.Dispose();
  814. }
  815. base.Dispose(disposing);
  816. }
  817. #region Windows Form Designer generated code
  818. private void InitializeLanguageText()
  819. {
  820. this.groupBoxParam.Text = PdnResources.GetString("Menu.params.text");
  821. this.button5.Text = PdnResources.GetString("Menu.rebuild.Text");
  822. this.groupBox1.Text = PdnResources.GetString("Menu.Preview.text");
  823. this.Text = PdnResources.GetString("Menu.geprocessiconditioningsaturationbrigh.Text");
  824. }
  825. /// <summary>
  826. /// Required method for Designer support - do not modify
  827. /// the contents of this method with the code editor.
  828. /// </summary>
  829. private void InitializeComponent()
  830. {
  831. this.parametersSettingControl = new PaintDotNet.CustomControl.ParametersSettingAdjustControl();
  832. this.informationControl = new PaintDotNet.CustomControl.InformationAdjustControl();
  833. this.groupBoxParam = new System.Windows.Forms.GroupBox();
  834. this.button5 = new System.Windows.Forms.Button();
  835. this.groupBox1 = new System.Windows.Forms.GroupBox();
  836. this.groupBoxParam.SuspendLayout();
  837. this.SuspendLayout();
  838. //
  839. // parametersSettingControl
  840. //
  841. this.parametersSettingControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  842. | System.Windows.Forms.AnchorStyles.Right)));
  843. this.parametersSettingControl.Location = new System.Drawing.Point(12, 12);
  844. this.parametersSettingControl.Name = "parametersSettingControl";
  845. this.parametersSettingControl.Size = new System.Drawing.Size(918, 58);
  846. this.parametersSettingControl.TabIndex = 9;
  847. //
  848. // informationControl
  849. //
  850. this.informationControl.Location = new System.Drawing.Point(12, 76);
  851. this.informationControl.Name = "informationControl";
  852. this.informationControl.Size = new System.Drawing.Size(373, 82);
  853. this.informationControl.TabIndex = 11;
  854. //
  855. // groupBoxParam
  856. //
  857. this.groupBoxParam.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  858. | System.Windows.Forms.AnchorStyles.Left)));
  859. this.groupBoxParam.Controls.Add(this.button5);
  860. this.groupBoxParam.Location = new System.Drawing.Point(12, 164);
  861. this.groupBoxParam.Name = "groupBoxParam";
  862. this.groupBoxParam.Size = new System.Drawing.Size(373, 353);
  863. this.groupBoxParam.TabIndex = 12;
  864. this.groupBoxParam.TabStop = false;
  865. //
  866. // button5
  867. //
  868. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  869. this.button5.Location = new System.Drawing.Point(292, 324);
  870. this.button5.Name = "button5";
  871. this.button5.Size = new System.Drawing.Size(75, 23);
  872. this.button5.TabIndex = 1;
  873. this.button5.UseVisualStyleBackColor = true;
  874. this.button5.Click += new System.EventHandler(this.button5_Click);
  875. //
  876. // groupBox1
  877. //
  878. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  879. | System.Windows.Forms.AnchorStyles.Left)
  880. | System.Windows.Forms.AnchorStyles.Right)));
  881. this.groupBox1.Location = new System.Drawing.Point(392, 77);
  882. this.groupBox1.Name = "groupBox1";
  883. this.groupBox1.Size = new System.Drawing.Size(538, 440);
  884. this.groupBox1.TabIndex = 13;
  885. this.groupBox1.TabStop = false;
  886. //
  887. // BshTransferAdjustDialog
  888. //
  889. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  890. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  891. this.ClientSize = new System.Drawing.Size(942, 529);
  892. this.Controls.Add(this.groupBox1);
  893. this.Controls.Add(this.groupBoxParam);
  894. this.Controls.Add(this.informationControl);
  895. this.Controls.Add(this.parametersSettingControl);
  896. this.Name = "BshTransferAdjustDialog";
  897. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BshTransferAdjustDialog_FormClosing);
  898. this.Load += new System.EventHandler(this.BshTransferAdjustDialog_Load);
  899. this.groupBoxParam.ResumeLayout(false);
  900. this.ResumeLayout(false);
  901. }
  902. #endregion
  903. private CustomControl.ParametersSettingAdjustControl parametersSettingControl;
  904. private CustomControl.InformationAdjustControl informationControl;
  905. private System.Windows.Forms.GroupBox groupBoxParam;
  906. private System.Windows.Forms.Button button5;
  907. private System.Windows.Forms.GroupBox groupBox1;
  908. private void BshTransferAdjustDialog_FormClosing(object sender, FormClosingEventArgs e)
  909. {
  910. #region [开启脚本录制]
  911. if (appWorkspace.startScriptRecording)
  912. {
  913. getScriptRecording();
  914. }
  915. #endregion
  916. string newpic = 1 + "";
  917. //获取参数实体
  918. ImageMenu imageMenu;
  919. if (Startup.instance.imageMenuModel != null)
  920. {
  921. imageMenu = Startup.instance.imageMenuModel;
  922. }
  923. else
  924. {
  925. imageMenu = new ImageMenu();
  926. imageMenu.ListParam = new List<ImageParam>();
  927. }
  928. //数字控制是否生成新图
  929. if (informationControl.radioButton1.Checked)
  930. newpic = 1 + "";
  931. else
  932. newpic = 0 + "";
  933. List<ImageParam> list = imageMenu.ListParam.Where(x => x.menuId == (int)action.MenuId).ToList();
  934. if (list.Count == 0)
  935. {
  936. ImageParam param = new ImageParam();
  937. param.menuId = (int)action.MenuId;
  938. param.param_key = "param_newpic";
  939. param.param_type = -1;
  940. param.param_value = newpic;
  941. imageMenu.ListParam.Add(param);
  942. }
  943. //判断页面是否有参数
  944. if (action.lists.Count > 0)
  945. {
  946. for (int i = 0; i < action.lists.Count; i++)
  947. {
  948. if (list.Count > 0)//是否存过参数
  949. {
  950. for (int j = 0; j < imageMenu.ListParam.Count; j++)//给参数实体赋值
  951. {
  952. if (imageMenu.ListParam[j].menuId == (int)action.MenuId && imageMenu.ListParam[j].param_key == action.lists[i].key)
  953. {
  954. imageMenu.ListParam[j].param_type = (int)action.lists[i].Type;
  955. imageMenu.ListParam[j].param_value = action.lists[i].value.ToString();
  956. //imageMenu.ListParam[j].param_newpic = informationControl.radioButton1.Checked;
  957. }
  958. else if (imageMenu.ListParam[j].menuId == (int)action.MenuId && imageMenu.ListParam[j].param_key == "param_newpic")
  959. {
  960. //imageMenu.ListParam[j].param_type = (int)action.lists[i].Type;
  961. imageMenu.ListParam[j].param_value = newpic;
  962. //imageMenu.ListParam[j].param_newpic = informationControl.radioButton1.Checked;
  963. }
  964. }
  965. //判断是否是白平衡
  966. if (action.MenuId == ActionType.ActionWhiteBalance)
  967. {
  968. for (int j = 0; j < imageMenu.ListParam.Count; j++)//给参数实体赋值
  969. {
  970. if (int.Parse(action.Lists[0].value.ToString()) > 1)
  971. {
  972. if (imageMenu.ListParam[j].param_key == "phaseColor" || imageMenu.ListParam[j].param_key == "imageColor")
  973. {
  974. imageMenu.ListParam[j].menuId = (int)action.MenuId;
  975. imageMenu.ListParam[j].param_key = action.Lists[0].choiseList[int.Parse(action.Lists[0].value.ToString()) - 1].Lists[0].key;
  976. imageMenu.ListParam[j].param_value = action.Lists[0].choiseList[int.Parse(action.Lists[0].value.ToString()) - 1].Lists[0].value.ToString();
  977. }
  978. }
  979. }
  980. }
  981. }
  982. else //如果没保存过新增
  983. {
  984. ImageParam param = new ImageParam();
  985. param.menuId = (int)action.MenuId;
  986. param.param_key = action.lists[i].key;
  987. param.param_type = (int)action.lists[i].Type;
  988. param.param_value = action.lists[i].value.ToString();
  989. //判断是否是白平衡
  990. if (action.MenuId == ActionType.ActionWhiteBalance)
  991. {
  992. ImageParam param5012 = new ImageParam();
  993. try
  994. {
  995. param5012.menuId = (int)action.MenuId;
  996. param5012.param_key = action.Lists[0].choiseList[int.Parse(action.Lists[0].value.ToString()) - 1].Lists[0].key;
  997. param5012.param_value = action.Lists[0].choiseList[int.Parse(action.Lists[0].value.ToString()) - 1].Lists[0].value.ToString();
  998. }
  999. catch (Exception)
  1000. {
  1001. //ImageParam param5012 = new ImageParam();
  1002. param5012.menuId = (int)action.MenuId;
  1003. param5012.param_key = "objectSelect";
  1004. param5012.param_value = "1";
  1005. }
  1006. imageMenu.ListParam.Add(param5012);
  1007. }
  1008. imageMenu.ListParam.Add(param);
  1009. }
  1010. }
  1011. }
  1012. else //没有参数,给是否生成新图赋值
  1013. {
  1014. if (list.Count > 0)
  1015. {
  1016. for (int j = 0; j < imageMenu.ListParam.Count; j++)
  1017. {
  1018. if (imageMenu.ListParam[j].menuId == (int)action.MenuId && imageMenu.ListParam[j].param_key == "param_newpic")
  1019. {
  1020. imageMenu.ListParam[j].param_value = newpic;
  1021. }
  1022. }
  1023. }
  1024. }
  1025. Startup.instance.imageMenuModel = imageMenu;
  1026. //按路径和名称保存xml文件
  1027. string userInfoXml = XmlSerializeHelper.XmlSerialize<ImageMenu>(imageMenu);
  1028. //xml保存路径
  1029. string filePath = Application.StartupPath + "\\Config\\" + "Default\\ParameterSaving\\ParameterSaving.xml";
  1030. //保存xml
  1031. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create);
  1032. }
  1033. /// <summary>
  1034. /// 初始化时获取参数
  1035. /// </summary>
  1036. /// <param name="imageMenu">系统读取的参数配置</param>
  1037. public void GetParameters(ImageMenu imageMenu)
  1038. {
  1039. List<ImageParam> list = new List<ImageParam>();
  1040. if (imageMenu.ListParam.Count > 0)
  1041. list = imageMenu.ListParam.Where(x => x.menuId == (int)action.MenuId).ToList();
  1042. if (list.Count > 0)
  1043. {
  1044. initPamasValues = true;
  1045. for (int i = 0; i < action.Lists.Count; i++)
  1046. {
  1047. for (int j = 0; j < list.Count; j++)
  1048. {
  1049. if (list[j].param_key.Equals(action.Lists[i].key))
  1050. {
  1051. action.Lists[i].Type = (Dtryt)list[j].param_type;
  1052. action.Lists[i].value = list[j].param_value;
  1053. break;
  1054. }
  1055. }
  1056. //判断是否是白平衡
  1057. if (action.MenuId == ActionType.ActionWhiteBalance)
  1058. {
  1059. for (int j = 0; j < list.Count; j++)//给参数实体赋值
  1060. {
  1061. if (list[j].param_key == "phaseColor")
  1062. {
  1063. action.Lists[0].choiseList[1].Lists[0].key = "phaseColor";
  1064. action.Lists[0].choiseList[1].Lists[0].value = list[j].param_value;
  1065. }
  1066. if (list[j].param_key == "imageColor")
  1067. {
  1068. action.Lists[0].choiseList[2].Lists[0].key = "imageColor";
  1069. action.Lists[0].choiseList[2].Lists[0].value = list[j].param_value;
  1070. }
  1071. }
  1072. }
  1073. }
  1074. for (int j = 0; j < list.Count; j++)
  1075. {
  1076. if ("param_newpic".Equals(list[j].param_key))
  1077. {
  1078. if (list[j].param_value == "1")
  1079. {
  1080. informationControl.radioButton1.Checked = true;
  1081. informationControl.radioButton2.Checked = false;
  1082. }
  1083. else
  1084. {
  1085. informationControl.radioButton1.Checked = false;
  1086. informationControl.radioButton2.Checked = true;
  1087. }
  1088. }
  1089. }
  1090. }
  1091. }
  1092. #region [脚本录制]
  1093. private void getScriptRecording()
  1094. {
  1095. List<Args> args = action.Lists;
  1096. if (action is Action5012) {
  1097. args[0].Type = Dtryt.Choise;
  1098. //if (Convert.ToInt32(args[0].value) == 2)
  1099. //{
  1100. // ColorNumber phase0Color = new ColorNumber();
  1101. // phase0Color.key = "imageColor";
  1102. // phase0Color.name = PdnResources.GetString("Menu.ImageProcessing.adjust.Theoriginalcolor.text");
  1103. // phase0Color.Value = this.panel2.BackColor.ToArgb();
  1104. // phase0Color.initialValue = this.panel2.BackColor.ToArgb();
  1105. // args.Add(phase0Color);
  1106. //} else if (Convert.ToInt32(args[0].value) == 3) {
  1107. // ColorNumber phaseColor = new ColorNumber();
  1108. // phaseColor.key = "phaseColor";
  1109. // phaseColor.name = PdnResources.GetString("Menu.ImageProcessing.adjust.Colorpicking.text");
  1110. // phaseColor.Value = this.panel3.BackColor.ToArgb();
  1111. // phaseColor.initialValue = this.panel3.BackColor.ToArgb();
  1112. // args.Add(phaseColor);
  1113. //}
  1114. }
  1115. appWorkspace.SetScriptStartRecording(MenuItem.MenuId, MenuItem.Text, args);
  1116. }
  1117. #endregion
  1118. }
  1119. }