using OpenCvSharp;
using PaintDotNet.CustomControl;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace PaintDotNet.Instrument
{
///
/// 工具-正在执行的脚本
///
internal class ScriptRunningDialog : FloatingToolForm
{
private AppWorkspace appWorkspace;
private Button button1;
private Label label2;
private Label label1;
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(238, 41);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 7;
this.button1.Text = "下一步";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 9);
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label1.MaximumSize = new System.Drawing.Size(320, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 9;
this.label1.Text = "当前步骤:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(80, 9);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.MaximumSize = new System.Drawing.Size(240, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(17, 12);
this.label2.TabIndex = 10;
this.label2.Text = " ";
//
// ScriptRunningDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(325, 76);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(6);
this.Name = "ScriptRunningDialog";
this.Text = "执行脚本";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ScriptRunningDialog_FormClosing);
this.VisibleChanged += new System.EventHandler(this.ScriptRunningDialog_VisibleChanged);
this.Controls.SetChildIndex(this.button1, 0);
this.Controls.SetChildIndex(this.label1, 0);
this.Controls.SetChildIndex(this.label2, 0);
this.ResumeLayout(false);
this.PerformLayout();
}
public ScriptRunningDialog(AppWorkspace appWorkspace, string scriptName)
{
this.appWorkspace = appWorkspace;
InitializeComponent();
this.button1.Text = PdnResources.GetString("Menu.Nextstep.text");
this.label1.Text = PdnResources.GetString("Menu.Currentsteps.Text") + ":";
this.Text = PdnResources.GetString("Menu.Executecript.Text");
this.label2.Text = "" + (scriptName != null ? scriptName : "");
}
///
/// 设置当前执行到脚本功能的名称
///
///
public void setScriptText(string text, Boolean lastStep)
{
this.label2.Text = "" + text;
this.label2.Refresh();
if (lastStep)
button1.Text = PdnResources.GetString("Menu.perationcompleted.Text");
else
button1.Text = PdnResources.GetString("Menu.Nextstep.text");
}
///
/// 当前步骤操作完成:操作完成/下一步
///
///
///
private void button1_Click(object sender, EventArgs e)
{
//if (button1.Text.Equals("操作完成"))
//{
// this.Close();
//}
if (appWorkspace.ActiveDocumentWorkspace != null) {
appWorkspace.ActiveDocumentWorkspace.ActiveTool= Annotation.Enum.DrawToolType.Pointer;
}
appWorkspace.ScriptStopping = false;
this.appWorkspace.ResumeScriptRunning();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
{
base.OnClosing(e);
}
else
{
e.Cancel = true;
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.eyousureyouwanttoexitthesc.Text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
this.appWorkspace.ShutDownScriptRunning();
}
}
private void ScriptRunningDialog_FormClosing(object sender, FormClosingEventArgs e)
{
//e.Cancel = true;
if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
{
}
else
{
}
}
private void ScriptRunningDialog_VisibleChanged(object sender, EventArgs e)
{
if (!appWorkspace.ScriptRunning && !appWorkspace.ScriptStopping)
{
}
else
{
}
}
}
}