executescript.cs

来自「自己做的一个浏览器~~大家请看看~如果合意给个彩头」· CS 代码 · 共 68 行

CS
68
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WebPort.Tools
{
	public partial class ExecuteScript : Form
	{
		/// <summary>
		/// 构造函数
		/// </summary>
		public ExecuteScript()
		{
			InitializeComponent();
		}

		private void Execute()
		{
			this.Enabled = false;
			MainForm main = this.Owner as MainForm;
			if (main != null)
			{
				try
				{
					HtmlDocument document = main.GetDocument();
					Script script = new Script(document);
					labelText.Text = "the script is running";
					if (script.Execute(textScript.Text, null))
						labelText.Text = "the script has been executed";
					else
						labelText.Text = "failed to execute the script";
					textScript.Modified = false;
				}
				catch
				{
					labelText.Text = "errors occured when executing the script";
				}
			}
			this.Enabled = true;
		}

		private void ExecuteScript_VisibleChanged(object sender, EventArgs e)
		{
			if (this.Visible)
				labelText.Text = "type script into the textbox above";
		}

		private void btnExecute_Click(object sender, EventArgs e)
		{
			Execute();
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void textScript_ModifiedChanged(object sender, EventArgs e)
		{
			if (textScript.Modified)
				labelText.Text = "the script has been modified";
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?