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

namespace CounterApp
{
	/// <summary>
	/// Form1 の概要の説明です。
	/// </summary>
	public class CounterForm : System.Windows.Forms.Form
	{
        private System.Windows.Forms.Label lblValue;
        private System.Windows.Forms.Button btnIncrement;
        private System.Windows.Forms.Button btnDecrement;
        private System.Windows.Forms.Button btnClear;
		/// <summary>
		/// 必要なデザイナ変数です。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public CounterForm()
		{
			//
			// Windows フォーム デザイナ サポートに必要です。
			//
			InitializeComponent();

			//
			// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
			//
		}

		/// <summary>
		/// 使用されているリソースに後処理を実行します。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows フォーム デザイナで生成されたコード 
		/// <summary>
		/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
		/// コード エディタで変更しないでください。
		/// </summary>
		private void InitializeComponent()
		{
            this.lblValue = new System.Windows.Forms.Label();
            this.btnIncrement = new System.Windows.Forms.Button();
            this.btnDecrement = new System.Windows.Forms.Button();
            this.btnClear = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // lblValue
            // 
            this.lblValue.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.lblValue.Font = new System.Drawing.Font("MS UI Gothic", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(128)));
            this.lblValue.Location = new System.Drawing.Point(16, 16);
            this.lblValue.Name = "lblValue";
            this.lblValue.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.lblValue.Size = new System.Drawing.Size(136, 32);
            this.lblValue.TabIndex = 0;
            this.lblValue.Text = "0";
            // 
            // btnIncrement
            // 
            this.btnIncrement.Location = new System.Drawing.Point(248, 16);
            this.btnIncrement.Name = "btnIncrement";
            this.btnIncrement.Size = new System.Drawing.Size(32, 32);
            this.btnIncrement.TabIndex = 1;
            this.btnIncrement.Text = "+";
            this.btnIncrement.Click += new System.EventHandler(this.btnIncrement_Click);
            // 
            // btnDecrement
            // 
            this.btnDecrement.Location = new System.Drawing.Point(168, 16);
            this.btnDecrement.Name = "btnDecrement";
            this.btnDecrement.Size = new System.Drawing.Size(32, 32);
            this.btnDecrement.TabIndex = 2;
            this.btnDecrement.Text = "-";
            this.btnDecrement.Click += new System.EventHandler(this.btnDecrement_Click);
            // 
            // btnClear
            // 
            this.btnClear.Location = new System.Drawing.Point(208, 16);
            this.btnClear.Name = "btnClear";
            this.btnClear.Size = new System.Drawing.Size(32, 32);
            this.btnClear.TabIndex = 3;
            this.btnClear.Text = "0";
            this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
            // 
            // CounterForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
            this.ClientSize = new System.Drawing.Size(298, 63);
            this.Controls.Add(this.btnClear);
            this.Controls.Add(this.btnDecrement);
            this.Controls.Add(this.btnIncrement);
            this.Controls.Add(this.lblValue);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Name = "CounterForm";
            this.Text = "Counter";
            this.ResumeLayout(false);

        }
		#endregion

		/// <summary>
		/// アプリケーションのメイン エントリ ポイントです。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new CounterForm());
		}

        private WinDevMagazine.ICounter counter = new WinDevMagazine.Counter(); 

        private void btnIncrement_Click(object sender, System.EventArgs e) {
          counter.increment();
          lblValue.Text = counter.count.ToString();
        }

        private void btnDecrement_Click(object sender, System.EventArgs e) {
          counter.decrement();
          lblValue.Text = counter.count.ToString();
        }

        private void btnClear_Click(object sender, System.EventArgs e) {
          counter.clear();
          lblValue.Text = counter.count.ToString();
        }
	}
}
