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

namespace matrix
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		public System.Windows.Forms.GroupBox Frame2;
		internal System.Windows.Forms.ComboBox Combo1;
		public System.Windows.Forms.Button Command1;
        public System.Windows.Forms.GroupBox Frame1;
		public System.Windows.Forms.RadioButton _Option1_4;
		public System.Windows.Forms.RadioButton _Option1_8;
        public System.Windows.Forms.RadioButton _Option1_9;
		public System.Windows.Forms.RadioButton _Option1_6;
		public System.Windows.Forms.RadioButton _Option1_5;
		public System.Windows.Forms.RadioButton _Option1_3;
		public System.Windows.Forms.RadioButton _Option1_2;
        public System.Windows.Forms.RadioButton _Option1_1;
		public System.Windows.Forms.ToolTip ToolTip1;
        public RadioButton _Option1_7;
        private TextBox textBox4;
        private TextBox textBox3;
        private TextBox textBox2;
        private TextBox textBox1;
        public RadioButton _Option1_10;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			InitializeComponent();

		}

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

		#region Vom Windows Form-Designer generierter Code
		/// <summary>
		/// Content of the Methode should not be modified by the Code-Editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.Frame2 = new System.Windows.Forms.GroupBox();
            this.Combo1 = new System.Windows.Forms.ComboBox();
            this.Command1 = new System.Windows.Forms.Button();
            this.Frame1 = new System.Windows.Forms.GroupBox();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this._Option1_7 = new System.Windows.Forms.RadioButton();
            this._Option1_4 = new System.Windows.Forms.RadioButton();
            this._Option1_8 = new System.Windows.Forms.RadioButton();
            this._Option1_9 = new System.Windows.Forms.RadioButton();
            this._Option1_6 = new System.Windows.Forms.RadioButton();
            this._Option1_5 = new System.Windows.Forms.RadioButton();
            this._Option1_3 = new System.Windows.Forms.RadioButton();
            this._Option1_2 = new System.Windows.Forms.RadioButton();
            this._Option1_1 = new System.Windows.Forms.RadioButton();
            this.ToolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this._Option1_10 = new System.Windows.Forms.RadioButton();
            this.Frame2.SuspendLayout();
            this.Frame1.SuspendLayout();
            this.SuspendLayout();
            // 
            // Frame2
            // 
            this.Frame2.BackColor = System.Drawing.SystemColors.Control;
            this.Frame2.Controls.Add(this.Combo1);
            this.Frame2.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Frame2.Location = new System.Drawing.Point(8, 7);
            this.Frame2.Name = "Frame2";
            this.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Frame2.Size = new System.Drawing.Size(201, 53);
            this.Frame2.TabIndex = 16;
            this.Frame2.TabStop = false;
            this.Frame2.Text = "キー番号選択";
            // 
            // Combo1
            // 
            this.Combo1.Items.AddRange(new object[] {
            "1",
            "2",
            "3",
            "4",
            "5"});
            this.Combo1.Location = new System.Drawing.Point(32, 22);
            this.Combo1.Name = "Combo1";
            this.Combo1.Size = new System.Drawing.Size(96, 20);
            this.Combo1.TabIndex = 0;
            this.Combo1.Text = "1";
            // 
            // Command1
            // 
            this.Command1.BackColor = System.Drawing.SystemColors.Control;
            this.Command1.Cursor = System.Windows.Forms.Cursors.Default;
            this.Command1.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Command1.Location = new System.Drawing.Point(8, 423);
            this.Command1.Name = "Command1";
            this.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Command1.Size = new System.Drawing.Size(201, 37);
            this.Command1.TabIndex = 15;
            this.Command1.Text = "処理開始";
            this.Command1.UseVisualStyleBackColor = false;
            this.Command1.Click += new System.EventHandler(this.Command1_Click);
            // 
            // Frame1
            // 
            this.Frame1.BackColor = System.Drawing.SystemColors.Control;
            this.Frame1.Controls.Add(this._Option1_10);
            this.Frame1.Controls.Add(this.textBox4);
            this.Frame1.Controls.Add(this.textBox3);
            this.Frame1.Controls.Add(this.textBox2);
            this.Frame1.Controls.Add(this.textBox1);
            this.Frame1.Controls.Add(this._Option1_7);
            this.Frame1.Controls.Add(this._Option1_4);
            this.Frame1.Controls.Add(this._Option1_8);
            this.Frame1.Controls.Add(this._Option1_9);
            this.Frame1.Controls.Add(this._Option1_6);
            this.Frame1.Controls.Add(this._Option1_5);
            this.Frame1.Controls.Add(this._Option1_3);
            this.Frame1.Controls.Add(this._Option1_2);
            this.Frame1.Controls.Add(this._Option1_1);
            this.Frame1.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Frame1.Location = new System.Drawing.Point(8, 66);
            this.Frame1.Name = "Frame1";
            this.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Frame1.Size = new System.Drawing.Size(201, 332);
            this.Frame1.TabIndex = 14;
            this.Frame1.TabStop = false;
            this.Frame1.Text = "APIテスト";
            // 
            // textBox4
            // 
            this.textBox4.Location = new System.Drawing.Point(104, 224);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(91, 19);
            this.textBox4.TabIndex = 16;
            // 
            // textBox3
            // 
            this.textBox3.Location = new System.Drawing.Point(7, 224);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(91, 19);
            this.textBox3.TabIndex = 15;
            // 
            // textBox2
            // 
            this.textBox2.Location = new System.Drawing.Point(104, 199);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(91, 19);
            this.textBox2.TabIndex = 14;
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(7, 199);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(91, 19);
            this.textBox1.TabIndex = 13;
            // 
            // _Option1_7
            // 
            this._Option1_7.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_7.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_7.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_7.Location = new System.Drawing.Point(24, 177);
            this._Option1_7.Name = "_Option1_7";
            this._Option1_7.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_7.Size = new System.Drawing.Size(161, 16);
            this._Option1_7.TabIndex = 12;
            this._Option1_7.TabStop = true;
            this._Option1_7.Text = "Write_WriteKey";
            this._Option1_7.UseVisualStyleBackColor = false;
            // 
            // _Option1_4
            // 
            this._Option1_4.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_4.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_4.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_4.Location = new System.Drawing.Point(24, 111);
            this._Option1_4.Name = "_Option1_4";
            this._Option1_4.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_4.Size = new System.Drawing.Size(153, 15);
            this._Option1_4.TabIndex = 6;
            this._Option1_4.TabStop = true;
            this._Option1_4.Text = "Read_Dongle_SerNr";
            this._Option1_4.UseVisualStyleBackColor = false;
            // 
            // _Option1_8
            // 
            this._Option1_8.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_8.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_8.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_8.Location = new System.Drawing.Point(24, 258);
            this._Option1_8.Name = "_Option1_8";
            this._Option1_8.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_8.Size = new System.Drawing.Size(161, 16);
            this._Option1_8.TabIndex = 10;
            this._Option1_8.TabStop = true;
            this._Option1_8.Text = "Encrypt / Decrypt Data";
            this._Option1_8.UseVisualStyleBackColor = false;
            // 
            // _Option1_9
            // 
            this._Option1_9.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_9.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_9.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_9.Location = new System.Drawing.Point(24, 281);
            this._Option1_9.Name = "_Option1_9";
            this._Option1_9.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_9.Size = new System.Drawing.Size(161, 15);
            this._Option1_9.TabIndex = 11;
            this._Option1_9.TabStop = true;
            this._Option1_9.Text = "Get Version of Matrix-API";
            this._Option1_9.UseVisualStyleBackColor = false;
            // 
            // _Option1_6
            // 
            this._Option1_6.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_6.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_6.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_6.Location = new System.Drawing.Point(24, 155);
            this._Option1_6.Name = "_Option1_6";
            this._Option1_6.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_6.Size = new System.Drawing.Size(161, 16);
            this._Option1_6.TabIndex = 8;
            this._Option1_6.TabStop = true;
            this._Option1_6.Text = "Write_Dongle_Data";
            this._Option1_6.UseVisualStyleBackColor = false;
            // 
            // _Option1_5
            // 
            this._Option1_5.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_5.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_5.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_5.Location = new System.Drawing.Point(24, 133);
            this._Option1_5.Name = "_Option1_5";
            this._Option1_5.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_5.Size = new System.Drawing.Size(161, 16);
            this._Option1_5.TabIndex = 7;
            this._Option1_5.TabStop = true;
            this._Option1_5.Text = "Read_Dongle_Data";
            this._Option1_5.UseVisualStyleBackColor = false;
            // 
            // _Option1_3
            // 
            this._Option1_3.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_3.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_3.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_3.Location = new System.Drawing.Point(24, 89);
            this._Option1_3.Name = "_Option1_3";
            this._Option1_3.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_3.Size = new System.Drawing.Size(161, 15);
            this._Option1_3.TabIndex = 5;
            this._Option1_3.TabStop = true;
            this._Option1_3.Text = "Version_of_Dongle";
            this._Option1_3.UseVisualStyleBackColor = false;
            // 
            // _Option1_2
            // 
            this._Option1_2.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_2.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_2.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_2.Location = new System.Drawing.Point(24, 66);
            this._Option1_2.Name = "_Option1_2";
            this._Option1_2.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_2.Size = new System.Drawing.Size(161, 16);
            this._Option1_2.TabIndex = 4;
            this._Option1_2.TabStop = true;
            this._Option1_2.Text = "Memory_of_Dongle";
            this._Option1_2.UseVisualStyleBackColor = false;
            // 
            // _Option1_1
            // 
            this._Option1_1.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_1.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_1.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_1.Location = new System.Drawing.Point(24, 44);
            this._Option1_1.Name = "_Option1_1";
            this._Option1_1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_1.Size = new System.Drawing.Size(161, 16);
            this._Option1_1.TabIndex = 3;
            this._Option1_1.TabStop = true;
            this._Option1_1.Text = "Number_of_Dongles";
            this._Option1_1.UseVisualStyleBackColor = false;
            // 
            // _Option1_10
            // 
            this._Option1_10.BackColor = System.Drawing.SystemColors.Control;
            this._Option1_10.Cursor = System.Windows.Forms.Cursors.Default;
            this._Option1_10.ForeColor = System.Drawing.SystemColors.ControlText;
            this._Option1_10.Location = new System.Drawing.Point(24, 302);
            this._Option1_10.Name = "_Option1_10";
            this._Option1_10.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this._Option1_10.Size = new System.Drawing.Size(161, 15);
            this._Option1_10.TabIndex = 17;
            this._Option1_10.TabStop = true;
            this._Option1_10.Text = "Login/Logout";
            this._Option1_10.UseVisualStyleBackColor = false;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
            this.ClientSize = new System.Drawing.Size(224, 472);
            this.Controls.Add(this.Frame2);
            this.Controls.Add(this.Command1);
            this.Controls.Add(this.Frame1);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.Text = "MatrixリモートAPI";
            this.Frame2.ResumeLayout(false);
            this.Frame1.ResumeLayout(false);
            this.Frame1.PerformLayout();
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Entry point for Application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Command1_Click(object sender, System.EventArgs e)
		{
			Funktionen();
		}

		private void Funktionen()
		{
            short dng_no;

            MatrixDemo demo = new MatrixDemo();

            dng_no = Int16.Parse(Combo1.Text);
            demo.SetDNGNum(dng_no);

		
			if(_Option1_1.Checked)
			{
				demo.Number_of_Dongles();
			}

			if(_Option1_2.Checked)
			{
				demo.Memory_of_Dongle();
			}

			if(_Option1_3.Checked)
			{
				demo.Version_of_Dongle();
			}

			if(_Option1_4.Checked)
			{
				demo.Read_Dongle_SerNr();
			}

			if(_Option1_5.Checked)
			{
				demo.Read_Dongle_Data();
			}

			if(_Option1_6.Checked)
			{
				demo.Write_Dongle_Data();
			}

			if(_Option1_7.Checked)
			{
                int[] key;
                key = new int[4];

                try
                {
                    key[0] = Int32.Parse(textBox1.Text);
                    key[1] = Int32.Parse(textBox2.Text);
                    key[2] = Int32.Parse(textBox3.Text);
                    key[3] = Int32.Parse(textBox4.Text);

                    demo.Dongle_WriteKey( key );
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

			}

			if(_Option1_8.Checked)
			{
				demo.Dongle_Encrypt_Decrypt();
			}

			if(_Option1_9.Checked)
			{
				demo.Version_of_API();
			}

            if (_Option1_10.Checked)
            {
                demo.Dongle_Network();
            }

		}

	}
}
