PropertiesSettingDialog.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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.components = new System.ComponentModel.Container();
  47. this.groupBox1 = new System.Windows.Forms.GroupBox();
  48. this.btnClose = new System.Windows.Forms.Button();
  49. this.button4 = new System.Windows.Forms.Button();
  50. this.button3 = new System.Windows.Forms.Button();
  51. this.button2 = new System.Windows.Forms.Button();
  52. this.button1 = new System.Windows.Forms.Button();
  53. this.groupBox2 = new System.Windows.Forms.GroupBox();
  54. this.btnReset = new System.Windows.Forms.Button();
  55. this.controlPanel = new System.Windows.Forms.Panel();
  56. this.timer1 = new System.Windows.Forms.Timer(this.components);
  57. this.groupBox1.SuspendLayout();
  58. this.groupBox2.SuspendLayout();
  59. this.SuspendLayout();
  60. //
  61. // groupBox1
  62. //
  63. this.groupBox1.Controls.Add(this.btnClose);
  64. this.groupBox1.Controls.Add(this.button4);
  65. this.groupBox1.Controls.Add(this.button3);
  66. this.groupBox1.Controls.Add(this.button2);
  67. this.groupBox1.Controls.Add(this.button1);
  68. this.groupBox1.Location = new System.Drawing.Point(9, 10);
  69. this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
  70. this.groupBox1.Name = "groupBox1";
  71. this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
  72. this.groupBox1.Size = new System.Drawing.Size(97, 502);
  73. this.groupBox1.TabIndex = 0;
  74. this.groupBox1.TabStop = false;
  75. //
  76. // btnClose
  77. //
  78. this.btnClose.Location = new System.Drawing.Point(12, 466);
  79. this.btnClose.Margin = new System.Windows.Forms.Padding(2);
  80. this.btnClose.Name = "btnClose";
  81. this.btnClose.Size = new System.Drawing.Size(61, 30);
  82. this.btnClose.TabIndex = 3;
  83. this.btnClose.Text = "关闭";
  84. this.btnClose.UseVisualStyleBackColor = true;
  85. this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
  86. //
  87. // button4
  88. //
  89. this.button4.Location = new System.Drawing.Point(12, 169);
  90. this.button4.Margin = new System.Windows.Forms.Padding(2);
  91. this.button4.Name = "button4";
  92. this.button4.Size = new System.Drawing.Size(61, 26);
  93. this.button4.TabIndex = 6;
  94. this.button4.Text = "常规";
  95. this.button4.UseVisualStyleBackColor = true;
  96. this.button4.Click += new System.EventHandler(this.button4_Click);
  97. //
  98. // button3
  99. //
  100. this.button3.Location = new System.Drawing.Point(12, 125);
  101. this.button3.Margin = new System.Windows.Forms.Padding(2);
  102. this.button3.Name = "button3";
  103. this.button3.Size = new System.Drawing.Size(61, 26);
  104. this.button3.TabIndex = 5;
  105. this.button3.Text = "边框";
  106. this.button3.UseVisualStyleBackColor = true;
  107. this.button3.Click += new System.EventHandler(this.button3_Click);
  108. //
  109. // button2
  110. //
  111. this.button2.Location = new System.Drawing.Point(12, 84);
  112. this.button2.Margin = new System.Windows.Forms.Padding(2);
  113. this.button2.Name = "button2";
  114. this.button2.Size = new System.Drawing.Size(61, 25);
  115. this.button2.TabIndex = 4;
  116. this.button2.Text = "调节";
  117. this.button2.UseVisualStyleBackColor = true;
  118. this.button2.Click += new System.EventHandler(this.button2_Click);
  119. //
  120. // button1
  121. //
  122. this.button1.Location = new System.Drawing.Point(12, 42);
  123. this.button1.Margin = new System.Windows.Forms.Padding(2);
  124. this.button1.Name = "button1";
  125. this.button1.Size = new System.Drawing.Size(61, 26);
  126. this.button1.TabIndex = 3;
  127. this.button1.Text = "显示";
  128. this.button1.UseVisualStyleBackColor = true;
  129. this.button1.Click += new System.EventHandler(this.button1_Click);
  130. //
  131. // groupBox2
  132. //
  133. this.groupBox2.Controls.Add(this.btnReset);
  134. this.groupBox2.Location = new System.Drawing.Point(124, 10);
  135. this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
  136. this.groupBox2.Name = "groupBox2";
  137. this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
  138. this.groupBox2.Size = new System.Drawing.Size(463, 60);
  139. this.groupBox2.TabIndex = 1;
  140. this.groupBox2.TabStop = false;
  141. //
  142. // btnReset
  143. //
  144. this.btnReset.Location = new System.Drawing.Point(384, 19);
  145. this.btnReset.Margin = new System.Windows.Forms.Padding(2);
  146. this.btnReset.Name = "btnReset";
  147. this.btnReset.Size = new System.Drawing.Size(64, 30);
  148. this.btnReset.TabIndex = 0;
  149. this.btnReset.Text = "初始化";
  150. this.btnReset.UseVisualStyleBackColor = true;
  151. this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
  152. //
  153. // controlPanel
  154. //
  155. this.controlPanel.AutoScroll = true;
  156. this.controlPanel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
  157. this.controlPanel.Location = new System.Drawing.Point(110, 74);
  158. this.controlPanel.Margin = new System.Windows.Forms.Padding(2);
  159. this.controlPanel.Name = "controlPanel";
  160. this.controlPanel.Size = new System.Drawing.Size(511, 437);
  161. this.controlPanel.TabIndex = 2;
  162. //
  163. // timer1
  164. //
  165. this.timer1.Enabled = true;
  166. this.timer1.Interval = 500;
  167. this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
  168. //
  169. // PropertiesSettingDialog
  170. //
  171. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  172. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  173. this.ClientSize = new System.Drawing.Size(630, 530);
  174. this.Controls.Add(this.controlPanel);
  175. this.Controls.Add(this.groupBox2);
  176. this.Controls.Add(this.groupBox1);
  177. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  178. this.Margin = new System.Windows.Forms.Padding(2);
  179. this.Name = "PropertiesSettingDialog";
  180. this.Text = "预览窗口-属性";
  181. this.Load += new System.EventHandler(this.PropertiesSettingDialog_Load);
  182. this.Controls.SetChildIndex(this.groupBox1, 0);
  183. this.Controls.SetChildIndex(this.groupBox2, 0);
  184. this.Controls.SetChildIndex(this.controlPanel, 0);
  185. this.groupBox1.ResumeLayout(false);
  186. this.groupBox2.ResumeLayout(false);
  187. this.ResumeLayout(false);
  188. }
  189. #endregion
  190. private System.Windows.Forms.GroupBox groupBox1;
  191. private System.Windows.Forms.GroupBox groupBox2;
  192. private System.Windows.Forms.Button button4;
  193. private System.Windows.Forms.Button button3;
  194. private System.Windows.Forms.Button button2;
  195. private System.Windows.Forms.Button button1;
  196. private System.Windows.Forms.Button btnReset;
  197. private System.Windows.Forms.Panel controlPanel;
  198. private System.Windows.Forms.Button btnClose;
  199. #endregion
  200. /// <summary>
  201. /// 相机参数
  202. /// </summary>
  203. public CameraParamModel m_cameraParamModel = Startup.instance.cameraParamModel;
  204. //各页面组件
  205. public DisplayCameraControl displayCameraControl;
  206. private AdjustContainer adjustCameraControl;
  207. private FrameCameraControl frameCameraControl;
  208. private CommonCameraControl commonCameraControl;
  209. private Timer timer1;
  210. private Form m_parent;
  211. public PropertiesSettingDialog(Form parent)
  212. {
  213. m_parent = parent;
  214. displayCameraControl = new DisplayCameraControl(m_cameraParamModel, true);
  215. displayCameraControl.Location = new Point(0, 0);
  216. adjustCameraControl = new AdjustContainer();
  217. adjustCameraControl.Initialize(m_cameraParamModel, true);
  218. adjustCameraControl.Location = new Point(0, 0);
  219. frameCameraControl = new FrameCameraControl(m_cameraParamModel, true);
  220. frameCameraControl.Location = new Point(0, 0);
  221. commonCameraControl = new CommonCameraControl();
  222. commonCameraControl.Location = new Point(0, 0);
  223. InitializeComponent();
  224. InitializeLanguageText();
  225. this.FormClosing += (s, e) =>
  226. {
  227. frameCameraControl.Dispose();
  228. //adjustCameraControl.Dispose();
  229. };
  230. button1_Click(null, null);
  231. }
  232. /// <summary>
  233. /// 设置直方图的图像
  234. /// </summary>
  235. /// <param name="mat"></param>
  236. public void resetMat(OpenCvSharp.Mat mat)
  237. {
  238. displayCameraControl.resetMat(mat);
  239. }
  240. private void button1_Click(object sender, EventArgs e)
  241. {
  242. this.controlPanel.Controls.Clear();
  243. displayCameraControl.Location = new Point(0, 0);
  244. this.controlPanel.Controls.Add(displayCameraControl);
  245. }
  246. private void button2_Click(object sender, EventArgs e)
  247. {
  248. this.controlPanel.Controls.Clear();
  249. this.controlPanel.Controls.Add(adjustCameraControl);
  250. }
  251. private void button3_Click(object sender, EventArgs e)
  252. {
  253. this.controlPanel.Controls.Clear();
  254. frameCameraControl.Location = new Point(0, 0);
  255. this.controlPanel.Controls.Add(frameCameraControl);
  256. }
  257. private void button4_Click(object sender, EventArgs e)
  258. {
  259. this.controlPanel.Controls.Clear();
  260. commonCameraControl.Location = new Point(0, 0);
  261. this.controlPanel.Controls.Add(commonCameraControl);
  262. }
  263. private void btnClose_Click(object sender, EventArgs e)
  264. {
  265. this.Close();
  266. this.Dispose();
  267. }
  268. private void btnReset_Click(object sender, EventArgs e)
  269. {
  270. CameraConfigs cameraConfig = CameraConfigs.GetInstance();
  271. Startup.instance.cameraParamModel = cameraConfig.GetCurrentCameraParamModel();
  272. m_cameraParamModel = Startup.instance.cameraParamModel;
  273. if (displayCameraControl != null)
  274. {
  275. displayCameraControl.ResetCameraParamModel(m_cameraParamModel);
  276. }
  277. if (frameCameraControl != null)
  278. {
  279. frameCameraControl.ResetCameraParamModel(m_cameraParamModel);
  280. }
  281. if (commonCameraControl != null)
  282. {
  283. commonCameraControl.Initialize(m_cameraParamModel);
  284. }
  285. if (m_parent != null/* && !m_parent.IsDisposed*/)
  286. {
  287. ((CameraPreviewDialog)m_parent).InitializeData();
  288. }
  289. }
  290. private void PropertiesSettingDialog_Load(object sender, EventArgs e)
  291. {
  292. commonCameraControl.Initialize(m_cameraParamModel, true);
  293. }
  294. private void timer1_Tick(object sender, EventArgs e)
  295. {
  296. adjustCameraControl.UpdateDisplay();
  297. }
  298. }
  299. }