//////////////////////////////
//	C# Test_Biorythm.cs
// Biorythm Control Component
//////////////////////////////
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;				//Assemblyを使う為
using Biorythm;

namespace Test_Program
{
	public partial class MyForm : Form
	{
		BrmBox brmBox;						//BrmBoxコントロール
		Button btn1, btn2, btn3, extbtn;	//ボタンコントロール

		[STAThread]
		public static void Main()
		{
			MyForm mf = new MyForm();
			Application.Run(mf);
		}

		public MyForm()
		{
			Assembly myOwn = Assembly.GetEntryAssembly();
			this.Icon = Icon.ExtractAssociatedIcon(myOwn.Location);	//プログラムアイコンをフォームにつける
			this.Size = new Size(640, 540);
			this.MinimumSize = new Size(320, 190);
			this.Text = "Biorythm Cycle";
			this.Load += MyForm_Load;
		}

		private void MyForm_Load(object sender, EventArgs e)
		{
			//ボタン1
			btn1 = new Button();
			btn1.Location = new Point(ClientSize.Width - btn1.Width - 10, 10);
			btn1.Text = "生年月日";
			btn1.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			btn1.Click += Button1_Click;
			this.Controls.Add(btn1);

			//ボタン2ボタン
			btn2 = new Button();
			btn2.Location = new Point(ClientSize.Width - btn2.Width - 10, btn1.Height + 20);
			btn2.Text = "指定日";
			btn2.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			btn2.Click += Button2_Click;
			this.Controls.Add(btn2);

			//ボタン3ボタン
			btn3 = new Button();
			btn3.Location = new Point(ClientSize.Width - btn3.Width - 10, btn1.Height + btn2.Height + 30);
			btn3.Text = "グラフ表示";
			btn3.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			btn3.Click += Button3_Click;
			this.Controls.Add(btn3);

			//終了ボタン
			extbtn = new Button();
			extbtn.Location = new Point(ClientSize.Width - extbtn.Width - 10, ClientSize.Height - extbtn.Height - 20);
			extbtn.Text = "終了";
			extbtn.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			extbtn.Click += Button4_Click;
			this.Controls.Add(extbtn);

			//ピクチャーボックスコントロール
			brmBox = new BrmBox();						//BrmBoxオブジェクトの作成
			brmBox.BorderStyle = BorderStyle.Fixed3D;
			brmBox.Location = new Point(10, 10);		//枠内の位置
			brmBox.Width = ClientSize.Width - btn1.Width - 30;
			brmBox.Height = ClientSize.Height - 20;
			brmBox.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right);
			this.Controls.Add(brmBox);					//brmBoxをコントロールに追加する
		}

		//終了処理
		protected override void OnFormClosing(FormClosingEventArgs e)
		{
			base.OnFormClosing(e);
			DialogResult dr = MessageBox.Show("終了しますか？", "確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
			if(dr == DialogResult.No)
			{
				e.Cancel = true;
			}
		}

		private void Button1_Click(object sender, EventArgs e)
		{
			//ボタン1
			brmBox.SetDOB();
		}

		private void Button2_Click(object sender, EventArgs e)
		{
			//ボタン2 - Phase 1
			brmBox.SetDOT();
		}

		private void Button3_Click(object sender, EventArgs e)
		{
			//ボタン3
			brmBox.Display();
		}

		private void Button4_Click(object sender, EventArgs e)
		{
			//終了処理
			Close();
		}
	}
}
