PaxScripter 'Hello'application written in C#.

demo_hello1.jpg arrowr.jpg demo_hello2.jpg
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using PaxScript.Net;

namespace Hello
{
	public class Form1 : System.Windows.Forms.Form
	{
		private PaxScript.Net.PaxScripter paxScripter1;
		public System.Windows.Forms.Button button1; // !!!!!!!
		private System.ComponentModel.IContainer components;

		public static Form1 f; // !!!!!!!

		public Form1()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.paxScripter1 = new PaxScript.Net.PaxScripter(this.components);
			this.button1 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			//
			// paxScripter1
			//
			this.paxScripter1.OnChangeState += new PaxScript.Net.ChangeStateHandler(this.paxScripter1_OnChangeState);
			//
			// button1
			//
			this.button1.Location = new System.Drawing.Point(40, 32);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(75, 24);
			this.button1.TabIndex = 0;
			this.button1.Text = "Click Me";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			//
			// Form1
			//
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(160, 86);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Hello";
			this.ResumeLayout(false);

		}
		#endregion

		[STAThread]
		static void Main()
		{
			f = new Form1(); // !!!!!!!
			Application.Run(f);
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			paxScripter1.Run(RunMode.Run);
			if (paxScripter1.HasErrors)
				paxScripter1.Reset();
		}

		private void paxScripter1_OnChangeState(PaxScript.Net.PaxScripter sender, PaxScript.Net.ChangeStateEventArgs e)
		{
			if (e.NewState == ScripterState.Error)
			{
				foreach (ScriptError err in paxScripter1.Error_List)
					MessageBox.Show("Error: " + err.Message);
			}
			else if (e.OldState == ScripterState.Init)
			{
				paxScripter1.AddModule("1");
				paxScripter1.AddCode("1", @"Hello.Form1.f.button1.Text = ""Hello"";");
			}

		}
	}
}


Copyright © 2005-2024 Alexander Baranovsky. All rights reserved.