ScriptRunningDialog.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 ScriptRunningDialog : FloatingToolForm
  12. {
  13. private AppWorkspace appWorkspace;
  14. private Button button1;
  15. private Label label2;
  16. private Label label1;
  17. private void InitializeComponent()
  18. {
  19. this.button1 = new System.Windows.Forms.Button();
  20. this.label1 = new System.Windows.Forms.Label();
  21. this.label2 = new System.Windows.Forms.Label();
  22. this.SuspendLayout();
  23. //
  24. // button1
  25. //
  26. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  27. this.button1.Location = new System.Drawing.Point(238, 41);
  28. this.button1.Name = "button1";
  29. this.button1.Size = new System.Drawing.Size(75, 23);
  30. this.button1.TabIndex = 7;
  31. this.button1.Text = "下一步";
  32. this.button1.UseVisualStyleBackColor = true;
  33. this.button1.Click += new System.EventHandler(this.button1_Click);
  34. //
  35. // label1
  36. //
  37. this.label1.AutoSize = true;
  38. this.label1.Location = new System.Drawing.Point(11, 9);
  39. this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  40. this.label1.MaximumSize = new System.Drawing.Size(320, 0);
  41. this.label1.Name = "label1";
  42. this.label1.Size = new System.Drawing.Size(65, 12);
  43. this.label1.TabIndex = 9;
  44. this.label1.Text = "当前步骤:";
  45. //
  46. // label2
  47. //
  48. this.label2.AutoSize = true;
  49. this.label2.Location = new System.Drawing.Point(80, 9);
  50. this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  51. this.label2.MaximumSize = new System.Drawing.Size(240, 0);
  52. this.label2.Name = "label2";
  53. this.label2.Size = new System.Drawing.Size(17, 12);
  54. this.label2.TabIndex = 10;
  55. this.label2.Text = " ";
  56. //
  57. // ScriptRunningDialog
  58. //
  59. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  60. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  61. this.ClientSize = new System.Drawing.Size(325, 76);
  62. this.Controls.Add(this.label2);
  63. this.Controls.Add(this.label1);
  64. this.Controls.Add(this.button1);
  65. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  66. this.Margin = new System.Windows.Forms.Padding(6);
  67. this.Name = "ScriptRunningDialog";
  68. this.Text = "执行脚本";
  69. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ScriptRunningDialog_FormClosing);
  70. this.VisibleChanged += new System.EventHandler(this.ScriptRunningDialog_VisibleChanged);
  71. this.Controls.SetChildIndex(this.button1, 0);
  72. this.Controls.SetChildIndex(this.label1, 0);
  73. this.Controls.SetChildIndex(this.label2, 0);
  74. this.ResumeLayout(false);
  75. this.PerformLayout();
  76. }
  77. public ScriptRunningDialog(AppWorkspace appWorkspace, string scriptName)
  78. {
  79. this.appWorkspace = appWorkspace;
  80. InitializeComponent();
  81. this.button1.Text = PdnResources.GetString("Menu.Nextstep.text");
  82. this.label1.Text = PdnResources.GetString("Menu.Currentsteps.Text") + ":";
  83. this.Text = PdnResources.GetString("Menu.Executecript.Text");
  84. this.label2.Text = "" + (scriptName != null ? scriptName : "");
  85. }
  86. /// <summary>
  87. /// 设置当前执行到脚本功能的名称
  88. /// </summary>
  89. /// <param name="text"></param>
  90. public void setScriptText(string text, Boolean lastStep)
  91. {
  92. this.label2.Text = "" + text;
  93. this.label2.Refresh();
  94. if (lastStep)
  95. button1.Text = PdnResources.GetString("Menu.perationcompleted.Text");
  96. else
  97. button1.Text = PdnResources.GetString("Menu.Nextstep.text");
  98. }
  99. /// <summary>
  100. /// 当前步骤操作完成:操作完成/下一步
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void button1_Click(object sender, EventArgs e)
  105. {
  106. //if (button1.Text.Equals("操作完成"))
  107. //{
  108. // this.Close();
  109. //}
  110. if (appWorkspace.ActiveDocumentWorkspace != null) {
  111. appWorkspace.ActiveDocumentWorkspace.ActiveTool= Annotation.Enum.DrawToolType.Pointer;
  112. }
  113. appWorkspace.ScriptStopping = false;
  114. this.appWorkspace.ResumeScriptRunning();
  115. }
  116. protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
  117. {
  118. if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
  119. {
  120. base.OnClosing(e);
  121. }
  122. else
  123. {
  124. e.Cancel = true;
  125. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.eyousureyouwanttoexitthesc.Text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  126. if (dr == DialogResult.OK)
  127. this.appWorkspace.ShutDownScriptRunning();
  128. }
  129. }
  130. private void ScriptRunningDialog_FormClosing(object sender, FormClosingEventArgs e)
  131. {
  132. //e.Cancel = true;
  133. if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
  134. {
  135. }
  136. else
  137. {
  138. }
  139. }
  140. private void ScriptRunningDialog_VisibleChanged(object sender, EventArgs e)
  141. {
  142. if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
  143. {
  144. }
  145. else
  146. {
  147. }
  148. }
  149. }
  150. }