using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace HearingAidLab
{
	/// <summary>
	/// Summary description for TestGame.
	/// </summary>
	public class TestGame : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnStep;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1 mainmenu;
		private StarGame.GameForm game;
		int nCurrentGame;

		public TestGame()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.Closing += new CancelEventHandler(TestGame_Closing);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnStep = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// btnStep
			// 
			this.btnStep.Location = new System.Drawing.Point(109, 16);
			this.btnStep.Name = "btnStep";
			this.btnStep.TabIndex = 0;
			this.btnStep.Text = "Step Game";
			this.btnStep.Click += new System.EventHandler(this.btnStep_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(6, 56);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(280, 23);
			this.label1.TabIndex = 1;
			this.label1.Text = "label1";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(6, 80);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(280, 23);
			this.label2.TabIndex = 2;
			this.label2.Text = "label2";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(6, 104);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(280, 23);
			this.label3.TabIndex = 3;
			this.label3.Text = "label3";
			// 
			// TestGame
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 150);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnStep);
			this.Name = "TestGame";
			this.Text = "TestGame";
			this.ResumeLayout(false);

		}
		#endregion

		public void Init()
		{
			nCurrentGame = 0;
			game = new StarGame.GameForm(mainmenu.def.bSingleScreen);
			game.Show();
			game.ButtonEvt+=new StarGame.GameForm.ButtonEventHandler(game_ButtonEvt);
			game.SetupGame(mainmenu.def.strFeedbackDir,(string) mainmenu.def.Feedback[nCurrentGame]);
			game.DrawButtons(mainmenu.def.Buttons);
		}
		private void btnStep_Click(object sender, System.EventArgs e)
		{
			//game.Finish();
			if(game.Step()==false)
			{
				nCurrentGame++;
				if(nCurrentGame==mainmenu.def.Feedback.Count)
					nCurrentGame=0;
				game.SetupGame(mainmenu.def.strFeedbackDir,(string) mainmenu.def.Feedback[nCurrentGame]);
				
			}
		
		}
		private void game_ButtonEvt(object sender, EventArgs e)
		{
			btnStep_Click(sender, e);
		}

		private void TestGame_Closing(object sender, CancelEventArgs e)
		{
			game.Close();
			mainmenu.Show();
		}
	}
}
