ScriptStartRecordingDialog.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using OpenCvSharp;
  2. using PaintDotNet.CustomControl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows.Forms;
  6. namespace PaintDotNet.Instrument
  7. {
  8. /// <summary>
  9. /// 工具-正在执行的脚本
  10. /// </summary>
  11. internal class ScriptStartRecordingDialog : FloatingToolForm
  12. {
  13. private AppWorkspace appWorkspace;
  14. private Button button1;
  15. private Label label2;
  16. private Label label1;
  17. private string scriptName;
  18. private void InitializeComponent()
  19. {
  20. this.button1 = new System.Windows.Forms.Button();
  21. this.label1 = new System.Windows.Forms.Label();
  22. this.label2 = new System.Windows.Forms.Label();
  23. this.SuspendLayout();
  24. //
  25. // button1
  26. //
  27. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  28. this.button1.Location = new System.Drawing.Point(238, 41);
  29. this.button1.Name = "button1";
  30. this.button1.Size = new System.Drawing.Size(75, 23);
  31. this.button1.TabIndex = 7;
  32. this.button1.Text = "结束录制";
  33. this.button1.UseVisualStyleBackColor = true;
  34. this.button1.Click += new System.EventHandler(this.button1_Click);
  35. //
  36. // label1
  37. //
  38. this.label1.AutoSize = true;
  39. this.label1.Location = new System.Drawing.Point(11, 9);
  40. this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  41. this.label1.MaximumSize = new System.Drawing.Size(320, 0);
  42. this.label1.Name = "label1";
  43. this.label1.Size = new System.Drawing.Size(65, 12);
  44. this.label1.TabIndex = 9;
  45. this.label1.Text = "正在录制中";
  46. //
  47. // label2
  48. //
  49. this.label2.AutoSize = true;
  50. this.label2.Location = new System.Drawing.Point(80, 9);
  51. this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  52. this.label2.MaximumSize = new System.Drawing.Size(240, 0);
  53. this.label2.Name = "label2";
  54. this.label2.Size = new System.Drawing.Size(17, 12);
  55. this.label2.TabIndex = 10;
  56. this.label2.Text = " ";
  57. //
  58. // ScriptStartRecordingDialog
  59. //
  60. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  61. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  62. this.ClientSize = new System.Drawing.Size(325, 76);
  63. this.Controls.Add(this.label2);
  64. this.Controls.Add(this.label1);
  65. this.Controls.Add(this.button1);
  66. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  67. this.Margin = new System.Windows.Forms.Padding(6);
  68. this.Name = "ScriptStartRecordingDialog";
  69. this.Text = "录制脚本";
  70. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ScriptRunningDialog_FormClosing);
  71. this.VisibleChanged += new System.EventHandler(this.ScriptRunningDialog_VisibleChanged);
  72. this.Controls.SetChildIndex(this.button1, 0);
  73. this.Controls.SetChildIndex(this.label1, 0);
  74. this.Controls.SetChildIndex(this.label2, 0);
  75. this.ResumeLayout(false);
  76. this.PerformLayout();
  77. }
  78. public ScriptStartRecordingDialog(AppWorkspace appWorkspace, string scriptName)
  79. {
  80. this.appWorkspace = appWorkspace;
  81. InitializeComponent();
  82. this.scriptName = scriptName;
  83. //this.button1.Text = PdnResources.GetString("Menu.Nextstep.text");
  84. //this.label1.Text = PdnResources.GetString("Menu.Currentsteps.Text") + ":";
  85. //this.Text = PdnResources.GetString("Menu.Executecript.Text");
  86. //this.label2.Text = "" + (scriptName != null ? scriptName : "");
  87. }
  88. /// <summary>
  89. ///
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void button1_Click(object sender, EventArgs e)
  94. {
  95. foreach (var item in appWorkspace.addMicScriptStepList) {
  96. appWorkspace.micScriptStepList.Add(item);
  97. if (appWorkspace.micScriptStepParamList.ContainsKey(item))
  98. {
  99. if (appWorkspace.addMicScriptStepParamList.ContainsKey(item)) {
  100. appWorkspace.micScriptStepParamList[item] = appWorkspace.addMicScriptStepParamList[item];
  101. }
  102. }
  103. else {
  104. if (appWorkspace.addMicScriptStepParamList.ContainsKey(item))
  105. {
  106. appWorkspace.micScriptStepParamList.Add(item, appWorkspace.addMicScriptStepParamList[item]);
  107. }
  108. }
  109. }
  110. appWorkspace.addMicScriptStepList.Clear();
  111. appWorkspace.addMicScriptStepParamList.Clear();
  112. closeMethod();
  113. }
  114. protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
  115. {
  116. DialogResult dr = MessageBox.Show("您确定要停止录制脚本吗" + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  117. if (dr == DialogResult.OK)
  118. {
  119. appWorkspace.addMicScriptStepList.Clear();
  120. appWorkspace.addMicScriptStepParamList.Clear();
  121. closeMethod();
  122. }
  123. }
  124. private void ScriptRunningDialog_FormClosing(object sender, FormClosingEventArgs e)
  125. {
  126. }
  127. private void ScriptRunningDialog_VisibleChanged(object sender, EventArgs e)
  128. {
  129. if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
  130. {
  131. }
  132. else
  133. {
  134. }
  135. }
  136. /// <summary>
  137. /// 关闭触发事件
  138. /// </summary>
  139. private void closeMethod()
  140. {
  141. this.Visible = false;
  142. appWorkspace.ScriptDialog.Enabled = true;
  143. appWorkspace.startScriptRecording = false;
  144. ScriptEditDialog scriptEditDialog = new ScriptEditDialog(appWorkspace, this.appWorkspace.editScriptRecording, this.appWorkspace.ScriptRecordingModel, scriptName);
  145. scriptEditDialog.StartPosition = FormStartPosition.CenterScreen;
  146. scriptEditDialog.ShowDialog();
  147. }
  148. }
  149. }