diff options
Diffstat (limited to 'ExecuteForm.cs')
-rw-r--r-- | ExecuteForm.cs | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/ExecuteForm.cs b/ExecuteForm.cs new file mode 100644 index 0000000..d21f229 --- /dev/null +++ b/ExecuteForm.cs @@ -0,0 +1,152 @@ +// SIDFX +// Copyright (C) 2004 Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// $Id$ +// +using System; +using System.Windows.Forms; +using System.Threading; +using HardsidInterface; + +namespace SIDFX +{ + /// <summary> + /// Description of ExecuteForm. + /// </summary> + public class ExecuteForm : System.Windows.Forms.Form + { + private System.ComponentModel.IContainer components; + private System.Windows.Forms.Button m_stopButton; + private System.Windows.Forms.Button m_okButton; + private System.Windows.Forms.Timer m_timer; + private System.Windows.Forms.Label m_status; + + private Thread m_thread; + + public ExecuteForm(CompileScript script) + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + m_status.Text="Running..."; + + m_thread=new Thread(new ThreadStart(script.Run)); + } + + public void Run(Form parent) + { + m_timer.Enabled=true; + m_thread.Start(); + ShowDialog(parent); + } + + #region Windows Forms Designer generated code + /// <summary> + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// </summary> + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.m_status = new System.Windows.Forms.Label(); + this.m_timer = new System.Windows.Forms.Timer(this.components); + this.m_okButton = new System.Windows.Forms.Button(); + this.m_stopButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // m_status + // + this.m_status.Location = new System.Drawing.Point(8, 8); + this.m_status.Name = "m_status"; + this.m_status.Size = new System.Drawing.Size(136, 24); + this.m_status.TabIndex = 2; + this.m_status.Text = "label1"; + // + // m_timer + // + this.m_timer.Tick += new System.EventHandler(this.OnTimer); + // + // m_okButton + // + this.m_okButton.Enabled = false; + this.m_okButton.Location = new System.Drawing.Point(112, 40); + this.m_okButton.Name = "m_okButton"; + this.m_okButton.Size = new System.Drawing.Size(88, 24); + this.m_okButton.TabIndex = 1; + this.m_okButton.Text = "OK"; + this.m_okButton.Click += new System.EventHandler(this.OnOK); + // + // m_stopButton + // + this.m_stopButton.Location = new System.Drawing.Point(8, 40); + this.m_stopButton.Name = "m_stopButton"; + this.m_stopButton.Size = new System.Drawing.Size(88, 24); + this.m_stopButton.TabIndex = 0; + this.m_stopButton.Text = "Stop!"; + this.m_stopButton.Click += new System.EventHandler(this.OnStop); + // + // ExecuteForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); + this.ClientSize = new System.Drawing.Size(210, 71); + this.ControlBox = false; + this.Controls.Add(this.m_status); + this.Controls.Add(this.m_okButton); + this.Controls.Add(this.m_stopButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExecuteForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Script"; + this.ResumeLayout(false); + } + #endregion + void OnTimer(object sender, System.EventArgs e) + { + if (!m_thread.IsAlive) + { + m_stopButton.Enabled=false; + m_okButton.Enabled=true; + m_timer.Enabled=false; + m_status.Text="Stopped"; + } + } + + void OnOK(object sender, System.EventArgs e) + { + for(uint r=0;r<25;r++) + { + Hardsid.Write(r,0); + } + + Close(); + } + + void OnStop(object sender, System.EventArgs e) + { + if (m_thread.IsAlive) + { + m_thread.Abort(); + OnTimer(null,null); + } + } + } +} |