Click here to Skip to main content
15,891,375 members
Articles / Mobile Apps

A C# implementation of Reversi (Othello) Game for PocketPC and Windows

Rate me:
Please Sign up or sign in to vote.
4.75/5 (13 votes)
4 Aug 20043 min read 91.7K   4.4K   36  
A C# implementation of Reversi (Othello) Game for PocketPC and Windows.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using gma.Reversi;

namespace gma.Mobile.Reversi
{
	/// <summary>
	/// Zusammenfassung f�r frmStartGame.
	/// </summary>
	public class frmStartGame : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.RadioButton radioButtonColor1;
		private System.Windows.Forms.RadioButton radioButtonColor2;
		private System.Windows.Forms.Button buttonOk;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button buttonCancel;
		private System.Windows.Forms.NumericUpDown numericUpDownAnimationSpeed;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.CheckBox checkBoxEnableUndo;
		private System.Windows.Forms.NumericUpDown numericUpDownDificulcy;
	
		public frmStartGame()
		{
			//
			// Erforderlich f�r die Windows Form-Designerunterst�tzung
			//
			InitializeComponent();

			//
			// TODO: Konstruktorcode hinter dem InitializeComponent-Aufruf hinzuf�gen
			//
		}

		/// <summary>
		/// Verwendete Ressourcen bereinigen.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Vom Windows Form-Designer generierter Code
		/// <summary>
		/// Erforderliche Methode f�r die Designerunterst�tzung. 
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor ge�ndert werden.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmStartGame));
			this.label1 = new System.Windows.Forms.Label();
			this.radioButtonColor1 = new System.Windows.Forms.RadioButton();
			this.radioButtonColor2 = new System.Windows.Forms.RadioButton();
			this.buttonOk = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.numericUpDownDificulcy = new System.Windows.Forms.NumericUpDown();
			this.buttonCancel = new System.Windows.Forms.Button();
			this.numericUpDownAnimationSpeed = new System.Windows.Forms.NumericUpDown();
			this.label3 = new System.Windows.Forms.Label();
			this.checkBoxEnableUndo = new System.Windows.Forms.CheckBox();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold);
			this.label1.Location = new System.Drawing.Point(24, 16);
			this.label1.Size = new System.Drawing.Size(88, 20);
			this.label1.Text = "My color is:";
			// 
			// radioButtonColor1
			// 
			this.radioButtonColor1.Location = new System.Drawing.Point(56, 40);
			this.radioButtonColor1.Text = "Black";
			// 
			// radioButtonColor2
			// 
			this.radioButtonColor2.Location = new System.Drawing.Point(56, 64);
			this.radioButtonColor2.Text = "White";
			// 
			// buttonOk
			// 
			this.buttonOk.Location = new System.Drawing.Point(80, 240);
			this.buttonOk.Text = "Ok";
			this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold);
			this.label2.Location = new System.Drawing.Point(24, 96);
			this.label2.Size = new System.Drawing.Size(72, 20);
			this.label2.Text = "Dificulcy:";
			// 
			// numericUpDownDificulcy
			// 
			this.numericUpDownDificulcy.Location = new System.Drawing.Point(56, 120);
			this.numericUpDownDificulcy.Maximum = new System.Decimal(new int[] {
																				   10,
																				   0,
																				   0,
																				   0});
			this.numericUpDownDificulcy.Minimum = new System.Decimal(new int[] {
																				   1,
																				   0,
																				   0,
																				   0});
			this.numericUpDownDificulcy.Size = new System.Drawing.Size(64, 20);
			this.numericUpDownDificulcy.Value = new System.Decimal(new int[] {
																				 1,
																				 0,
																				 0,
																				 0});
			// 
			// buttonCancel
			// 
			this.buttonCancel.Location = new System.Drawing.Point(160, 240);
			this.buttonCancel.Text = "Cancel";
			this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
			// 
			// numericUpDownAnimationSpeed
			// 
			this.numericUpDownAnimationSpeed.Location = new System.Drawing.Point(56, 176);
			this.numericUpDownAnimationSpeed.Maximum = new System.Decimal(new int[] {
																						10,
																						0,
																						0,
																						0});
			this.numericUpDownAnimationSpeed.Minimum = new System.Decimal(new int[] {
																						1,
																						0,
																						0,
																						0});
			this.numericUpDownAnimationSpeed.Size = new System.Drawing.Size(64, 20);
			this.numericUpDownAnimationSpeed.Value = new System.Decimal(new int[] {
																					  1,
																					  0,
																					  0,
																					  0});
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold);
			this.label3.Location = new System.Drawing.Point(24, 152);
			this.label3.Size = new System.Drawing.Size(128, 20);
			this.label3.Text = "Animation Speed:";
			// 
			// checkBoxEnableUndo
			// 
			this.checkBoxEnableUndo.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold);
			this.checkBoxEnableUndo.Location = new System.Drawing.Point(24, 208);
			this.checkBoxEnableUndo.Size = new System.Drawing.Size(104, 24);
			this.checkBoxEnableUndo.Text = "Enable Undo";
			// 
			// frmStartGame
			// 
			this.Controls.Add(this.checkBoxEnableUndo);
			this.Controls.Add(this.numericUpDownAnimationSpeed);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.buttonCancel);
			this.Controls.Add(this.numericUpDownDificulcy);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.buttonOk);
			this.Controls.Add(this.radioButtonColor2);
			this.Controls.Add(this.radioButtonColor1);
			this.Controls.Add(this.label1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Text = "Game Options";

		}
		#endregion

		public event System.EventHandler OnOkClicked;
		private void buttonOk_Click(object sender, System.EventArgs e)
		{
			//DialogResult=DialogResult.OK;
			if (OnOkClicked!=null) OnOkClicked(sender, e);
		}

		private void buttonCancel_Click(object sender, System.EventArgs e)
		{
			DialogResult=DialogResult.Cancel;
		}

		public int MyColor
		{
			get 
			{
				if (radioButtonColor1.Checked) return Board.PLAYER_RED;  
				else return Board.PLAYER_WHITE;  
			}
			set 
			{
				radioButtonColor1.Checked = (value==Board.PLAYER_RED);
				radioButtonColor2.Checked = (value!=Board.PLAYER_RED);
			}
		}

		public int SearchDepth
		{
			get { return (int)numericUpDownDificulcy.Value;} 
			set {numericUpDownDificulcy.Value=value;}
		}

		public int AnimationSpeed
		{
			get { return (int)numericUpDownAnimationSpeed.Value;} 
			set {numericUpDownAnimationSpeed.Value=value;}
		}

		public bool EnableUndo
		{
			get { return checkBoxEnableUndo.Checked;}
			set {checkBoxEnableUndo.Checked=value;}
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Germany Germany
Tweeter: @gmamaladze
Google+: gmamaladze
Blog: gmamaladze.wordpress.com

Comments and Discussions