PropertiesSettingDialog.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using PaintDotNet.Setting.LabelComponent;
  5. using PaintDotNet.Base.SettingModel;
  6. namespace PaintDotNet.ImageCollect.CameraPreviewComponent.Properties
  7. {
  8. internal class PropertiesSettingDialog : FloatingToolForm
  9. {
  10. #region
  11. /// <summary>
  12. /// Required designer variable.
  13. /// </summary>
  14. private System.ComponentModel.IContainer components = null;
  15. /// <summary>
  16. /// Clean up any resources being used.
  17. /// </summary>
  18. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  19. protected override void Dispose(bool disposing)
  20. {
  21. if (disposing && (components != null))
  22. {
  23. components.Dispose();
  24. }
  25. base.Dispose(disposing);
  26. }
  27. #region Windows Form Designer generated code
  28. private void InitializeLanguageText()
  29. {
  30. this.groupBox1.Text = PdnResources.GetString("Menu.Type.text");
  31. this.button4.Text = PdnResources.GetString("Menu.ImageCollection.CameraConventional.Text");
  32. this.button3.Text = PdnResources.GetString("Menu.ImageCollection.CameraFrame.Text");
  33. this.button2.Text = PdnResources.GetString("Menu.Image.Adjust.Text");
  34. this.button1.Text = PdnResources.GetString("Menu.display.text");
  35. this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
  36. this.btnReset.Text = PdnResources.GetString("Menu.imagecapture.Previewwindow.init.text");
  37. this.btnClose.Text = PdnResources.GetString("Menu.File.Close.Text");
  38. this.Text = PdnResources.GetString("Menu.imagecapture.Previewwindow.Previewwindoperties.text");
  39. }
  40. /// <summary>
  41. /// Required method for Designer support - do not modify
  42. /// the contents of this method with the code editor.
  43. /// </summary>
  44. private void InitializeComponent()
  45. {
  46. this.groupBox1 = new System.Windows.Forms.GroupBox();
  47. this.btnClose = new System.Windows.Forms.Button();
  48. this.button4 = new System.Windows.Forms.Button();
  49. this.button3 = new System.Windows.Forms.Button();
  50. this.button2 = new System.Windows.Forms.Button();
  51. this.button1 = new System.Windows.Forms.Button();
  52. this.groupBox2 = new System.Windows.Forms.GroupBox();
  53. this.btnReset = new System.Windows.Forms.Button();
  54. this.controlPanel = new System.Windows.Forms.Panel();
  55. this.groupBox1.SuspendLayout();
  56. this.groupBox2.SuspendLayout();
  57. this.SuspendLayout();
  58. //
  59. // groupBox1
  60. //
  61. this.groupBox1.Controls.Add(this.btnClose);
  62. this.groupBox1.Controls.Add(this.button4);
  63. this.groupBox1.Controls.Add(this.button3);
  64. this.groupBox1.Controls.Add(this.button2);
  65. this.groupBox1.Controls.Add(this.button1);
  66. this.groupBox1.Location = new System.Drawing.Point(9, 10);
  67. this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
  68. this.groupBox1.Name = "groupBox1";
  69. this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
  70. this.groupBox1.Size = new System.Drawing.Size(97, 502);
  71. this.groupBox1.TabIndex = 0;
  72. this.groupBox1.TabStop = false;
  73. //
  74. // btnClose
  75. //
  76. this.btnClose.Location = new System.Drawing.Point(12, 466);
  77. this.btnClose.Margin = new System.Windows.Forms.Padding(2);
  78. this.btnClose.Name = "btnClose";
  79. this.btnClose.Size = new System.Drawing.Size(61, 30);
  80. this.btnClose.TabIndex = 3;
  81. this.btnClose.Text = "关闭";
  82. this.btnClose.UseVisualStyleBackColor = true;
  83. this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
  84. //
  85. // button4
  86. //
  87. this.button4.Location = new System.Drawing.Point(12, 169);
  88. this.button4.Margin = new System.Windows.Forms.Padding(2);
  89. this.button4.Name = "button4";
  90. this.button4.Size = new System.Drawing.Size(61, 26);
  91. this.button4.TabIndex = 6;
  92. this.button4.Text = "常规";
  93. this.button4.UseVisualStyleBackColor = true;
  94. this.button4.Click += new System.EventHandler(this.button4_Click);
  95. //
  96. // button3
  97. //
  98. this.button3.Location = new System.Drawing.Point(12, 125);
  99. this.button3.Margin = new System.Windows.Forms.Padding(2);
  100. this.button3.Name = "button3";
  101. this.button3.Size = new System.Drawing.Size(61, 26);
  102. this.button3.TabIndex = 5;
  103. this.button3.Text = "边框";
  104. this.button3.UseVisualStyleBackColor = true;
  105. this.button3.Click += new System.EventHandler(this.button3_Click);
  106. //
  107. // button2
  108. //
  109. this.button2.Location = new System.Drawing.Point(12, 84);
  110. this.button2.Margin = new System.Windows.Forms.Padding(2);
  111. this.button2.Name = "button2";
  112. this.button2.Size = new System.Drawing.Size(61, 25);
  113. this.button2.TabIndex = 4;
  114. this.button2.Text = "调节";
  115. this.button2.UseVisualStyleBackColor = true;
  116. this.button2.Click += new System.EventHandler(this.button2_Click);
  117. //
  118. // button1
  119. //
  120. this.button1.Location = new System.Drawing.Point(12, 42);
  121. this.button1.Margin = new System.Windows.Forms.Padding(2);
  122. this.button1.Name = "button1";
  123. this.button1.Size = new System.Drawing.Size(61, 26);
  124. this.button1.TabIndex = 3;
  125. this.button1.Text = "显示";
  126. this.button1.UseVisualStyleBackColor = true;
  127. this.button1.Click += new System.EventHandler(this.button1_Click);
  128. //
  129. // groupBox2
  130. //
  131. this.groupBox2.Controls.Add(this.btnReset);
  132. this.groupBox2.Location = new System.Drawing.Point(124, 10);
  133. this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
  134. this.groupBox2.Name = "groupBox2";
  135. this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
  136. this.groupBox2.Size = new System.Drawing.Size(463, 60);
  137. this.groupBox2.TabIndex = 1;
  138. this.groupBox2.TabStop = false;
  139. //
  140. // btnReset
  141. //
  142. this.btnReset.Location = new System.Drawing.Point(384, 19);
  143. this.btnReset.Margin = new System.Windows.Forms.Padding(2);
  144. this.btnReset.Name = "btnReset";
  145. this.btnReset.Size = new System.Drawing.Size(64, 30);
  146. this.btnReset.TabIndex = 0;
  147. this.btnReset.Text = "初始化";
  148. this.btnReset.UseVisualStyleBackColor = true;
  149. this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
  150. //
  151. // controlPanel
  152. //
  153. this.controlPanel.AutoScroll = true;
  154. this.controlPanel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
  155. this.controlPanel.Location = new System.Drawing.Point(110, 74);
  156. this.controlPanel.Margin = new System.Windows.Forms.Padding(2);
  157. this.controlPanel.Name = "controlPanel";
  158. this.controlPanel.Size = new System.Drawing.Size(511, 437);
  159. this.controlPanel.TabIndex = 2;
  160. //
  161. // PropertiesSettingDialog
  162. //
  163. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  164. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  165. this.ClientSize = new System.Drawing.Size(630, 530);
  166. this.Controls.Add(this.controlPanel);
  167. this.Controls.Add(this.groupBox2);
  168. this.Controls.Add(this.groupBox1);
  169. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  170. this.Margin = new System.Windows.Forms.Padding(2);
  171. this.Name = "PropertiesSettingDialog";
  172. this.Text = "预览窗口-属性";
  173. this.Activated += new System.EventHandler(this.PropertiesSettingDialog_Activated);
  174. this.Controls.SetChildIndex(this.groupBox1, 0);
  175. this.Controls.SetChildIndex(this.groupBox2, 0);
  176. this.Controls.SetChildIndex(this.controlPanel, 0);
  177. this.groupBox1.ResumeLayout(false);
  178. this.groupBox2.ResumeLayout(false);
  179. this.ResumeLayout(false);
  180. }
  181. #endregion
  182. private System.Windows.Forms.GroupBox groupBox1;
  183. private System.Windows.Forms.GroupBox groupBox2;
  184. private System.Windows.Forms.Button button4;
  185. private System.Windows.Forms.Button button3;
  186. private System.Windows.Forms.Button button2;
  187. private System.Windows.Forms.Button button1;
  188. private System.Windows.Forms.Button btnReset;
  189. private System.Windows.Forms.Panel controlPanel;
  190. private System.Windows.Forms.Button btnClose;
  191. #endregion
  192. /// <summary>
  193. /// 相机参数
  194. /// </summary>
  195. public CameraParamModel m_cameraParamModel = Startup.instance.cameraParamModel;
  196. //各页面组件
  197. public DisplayCameraControl displayCameraControl;
  198. private AdjustCameraControl adjustCameraControl;
  199. private FrameCameraControl frameCameraControl;
  200. private CommonCameraControl commonCameraControl;
  201. private Form m_parent;
  202. public PropertiesSettingDialog(Form parent)
  203. {
  204. m_parent = parent;
  205. displayCameraControl = new DisplayCameraControl(m_cameraParamModel, true);
  206. displayCameraControl.Location = new Point(0, 0);
  207. adjustCameraControl = new AdjustCameraControl(m_cameraParamModel, true, true);
  208. adjustCameraControl.Location = new Point(0, 0);
  209. frameCameraControl = new FrameCameraControl(m_cameraParamModel, true);
  210. frameCameraControl.Location = new Point(0, 0);
  211. commonCameraControl = new CommonCameraControl(m_cameraParamModel, true);
  212. commonCameraControl.Location = new Point(0, 0);
  213. InitializeComponent();
  214. InitializeLanguageText();
  215. this.FormClosing += (s, e) =>
  216. {
  217. frameCameraControl.Dispose();
  218. adjustCameraControl.Dispose();
  219. };
  220. button1_Click(null, null);
  221. }
  222. /// <summary>
  223. /// 设置直方图的图像
  224. /// </summary>
  225. /// <param name="mat"></param>
  226. public void resetMat(OpenCvSharp.Mat mat)
  227. {
  228. displayCameraControl.resetMat(mat);
  229. }
  230. private void button1_Click(object sender, EventArgs e)
  231. {
  232. this.controlPanel.Controls.Clear();
  233. displayCameraControl.Location = new Point(0, 0);
  234. this.controlPanel.Controls.Add(displayCameraControl);
  235. }
  236. private void button2_Click(object sender, EventArgs e)
  237. {
  238. this.controlPanel.Controls.Clear();
  239. adjustCameraControl.Location = new Point(0, 0);
  240. this.controlPanel.Controls.Add(adjustCameraControl);
  241. }
  242. private void button3_Click(object sender, EventArgs e)
  243. {
  244. this.controlPanel.Controls.Clear();
  245. frameCameraControl.Location = new Point(0, 0);
  246. this.controlPanel.Controls.Add(frameCameraControl);
  247. }
  248. private void button4_Click(object sender, EventArgs e)
  249. {
  250. this.controlPanel.Controls.Clear();
  251. commonCameraControl.Location = new Point(0, 0);
  252. this.controlPanel.Controls.Add(commonCameraControl);
  253. }
  254. private void btnClose_Click(object sender, EventArgs e)
  255. {
  256. this.Close();
  257. this.Dispose();
  258. }
  259. private void btnReset_Click(object sender, EventArgs e)
  260. {
  261. CameraConfigs cameraConfig = CameraConfigs.GetInstance();
  262. Startup.instance.cameraParamModel = cameraConfig.GetCurrentCameraParamModel();
  263. m_cameraParamModel = Startup.instance.cameraParamModel;
  264. if (displayCameraControl != null)
  265. {
  266. displayCameraControl.ResetCameraParamModel(m_cameraParamModel);
  267. }
  268. if (frameCameraControl != null)
  269. {
  270. frameCameraControl.ResetCameraParamModel(m_cameraParamModel);
  271. }
  272. if (commonCameraControl != null)
  273. {
  274. commonCameraControl.ResetCameraParamModel(m_cameraParamModel);
  275. }
  276. if (m_parent != null/* && !m_parent.IsDisposed*/)
  277. {
  278. ((CameraPreviewDialog)m_parent).InitializeData();
  279. }
  280. }
  281. private void PropertiesSettingDialog_Activated(object sender, EventArgs e)
  282. {
  283. m_cameraParamModel = Startup.instance.cameraParamModel;
  284. adjustCameraControl.ResetCameraParamModel(m_cameraParamModel);
  285. frameCameraControl.ResetCameraParamModel(m_cameraParamModel);
  286. commonCameraControl.ResetCameraParamModel(m_cameraParamModel);
  287. }
  288. }
  289. }