1. 程式人生 > >迴圈賦值版日語五十音圖

迴圈賦值版日語五十音圖

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        
      
      

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs ea)
        {
            this.WindowState = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            string[,] list = { { "あア", "いイ", "うウ", "えエ", "おオ" }, { "かカ", "きキ", "くク", "けケ", "こコ" }, { "さサ", "しシ", "すス", "せセ", "そソ" }, { "たタ", "ちチ", "つツ", "てテ", "とト" }, { "なナ", "にニ", "ぬヌ", "ねネ", "のノ" }, { "はハ", "ひヒ", "ふフ", "へヘ", "ほホ" }, { "まマ", "みミ", "むム", "めメ", "もモ" }, { "やヤ", "いイ", "ゆユ", "えエ", "よヨ" }, { "らラ", "りリ", "るル", "れレ", "ろロ" }, { "わワ", "いイ", "うウ", "えエ", "をヲ" }, { "んン", null, null, null, null }, { "がガ", "ぎギ", "ぐグ", "げゲ", "ごゴ" }, { "ざザ", "じジ", "ずズ", "ぜゼ", "ぞゾ" }, { "だダ", "ぢヂ", "づヅ", "でデ", "どド" }, { "ばバ", "びビ", "ぶブ", "べベ", "ぼボ" }, { "ぱパ", "ぴピ", "ぷプ", "ぺペ", "ぽポ" } };
            Button[,] b_list = new Button[16, 5];
            Size bsize = new Size(100, 50);

            TabControl[] tc = { new TabControl(), new TabControl(), new TabControl() };
            TabPage[] tp = { new TabPage("清音"), new TabPage("濁音"), new TabPage("半濁音") };
            Size s = new Size(550, 1022);

            for (int i = 0; i < tc.Length; i++)
            {
                tc[i].Location = new Point(i * 600 + 100, 0);
                tc[i].Size = s;
                tc[i].Controls.Add(tp[i]);
                this.Controls.Add(tc[i]);
            }

            try
            {
                using (SoundPlayer sp = new SoundPlayer("read/start.wav"))
                {
                    sp.Load();
                    sp.Play();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }


            for (int i = 0; i < 16; i++)
            {
                if (i == 10)
                {
                    b_list[i, 0] = new Button();
                    b_list[i, 0].BackColor = Color.FromArgb(255, 10 * 25, 4 * 60);
                    b_list[i, 0].Location = new Point(0, 950);
                    b_list[i, 0].Size = bsize;
                    b_list[i, 0].Text = list[i, 0];
                    b_list[i, 0].Font = new Font("微軟雅黑", 20);
                    tp[0].Controls.Add(b_list[i, 0]);
                    b_list[i, 0].Click += new EventHandler(this.button_click);
                    continue;
                }
                
                for (int j = 0; j < 5; j++)
                {
                    if (i == 11 || i==12 || i==13  )
                    {
                        b_list[i, j] = new Button();
                        b_list[i, j].BackColor = Color.FromArgb(255, i * 15, j * 60);
                        b_list[i, j].Location = new Point(j * 110, (i -10)*95);
                        b_list[i, j].Size = bsize;
                        b_list[i, j].Text = list[i, j];
                        b_list[i, j].Font = new Font("微軟雅黑", 25);
                        tp[1].Controls.Add(b_list[i, j]);
                        b_list[i, j].Click += new EventHandler(this.button_click);
                        continue;
                    }
                    else if (i == 14)
                    {
                        b_list[i, j] = new Button();
                        b_list[i, j].BackColor = Color.FromArgb(255, i * 15, j * 60);
                        b_list[i, j].Location = new Point(j * 110, (i - 9) * 95);
                        b_list[i, j].Size = bsize;
                        b_list[i, j].Text = list[i, j];
                        b_list[i, j].Font = new Font("微軟雅黑", 25);
                        tp[1].Controls.Add(b_list[i, j]);
                        b_list[i, j].Click += new EventHandler(this.button_click);
                        continue;
                    }
                    else if (i == 15)
                    {
                        b_list[i, j] = new Button();
                        b_list[i, j].BackColor = Color.FromArgb(255, i * 15, j * 60);
                        b_list[i, j].Location = new Point(j * 110, (i - 10) * 95);
                        b_list[i, j].Size = bsize;
                        b_list[i, j].Text = list[i, j];
                        b_list[i, j].Font = new Font("微軟雅黑", 25);
                        tp[2].Controls.Add(b_list[i, j]);
                        b_list[i, j].Click += new EventHandler(this.button_click);
                    }
                    b_list[i, j] = new Button();
                    b_list[i, j].BackColor = Color.FromArgb(255, i * 15, j * 60);
                    b_list[i, j].Location = new Point(j * 110, i * 95);
                    b_list[i, j].Size = bsize;
                    b_list[i, j].Text = list[i, j];
                    b_list[i, j].Font = new Font("微軟雅黑", 25);
                    tp[0].Controls.Add(b_list[i, j]);
                    b_list[i, j].Click += new EventHandler(this.button_click);
                }
            }
        }

       
            
            
            //for (int i = 0; i < 13; i++)
            //{
            //    if(i==10)
            //    {
            //        b_list[i,0].BackColor = Color.FromArgb(255, 10 * 25, 4 * 60);
            //        b_list[i, 0].Location = new Point(0, 950);
            //        b_list[i, 0].Size = bsize;
            //        b_list[i, 0].Text = list[i, 0];
            //        b_list[i, 0].Font = new Font("微軟雅黑", 20);
            //        tp[0].Controls.Add(b_list[i, 0]);
            //        b_list[i, 0].Click += new EventHandler(this.button_click);
            //        continue;
            //    }
                
            //    for (int j = 0; j < 5; j++)
            //    {
            //        if (i == 11)
            //        {
            //            MessageBox.Show("Test");
            //            b_list[i, j].BackColor = Color.FromArgb(255, i * 15, j * 60);
            //            b_list[i, j].Location = new Point(j * 110, (i + 1) * 95 * 5);
            //            b_list[i, j].Size = bsize;
            //            b_list[i, j].Text = list[i, j];
            //            b_list[i, j].Font = new Font("微軟雅黑", 25);
            //            tp[1].Controls.Add(b_list[i, j]);
            //            b_list[i, j].Click += new EventHandler(this.button_click);
            //            continue;
            //        }

                
            //    }
            //}
          

            //for (int i = 0; i < 3; i++)
            //{
            //    for (int j = 0; j < 5; j++)
            //    {
            //        b_list2[i, j].BackColor = Color.FromArgb(255, i * 25, j * 60);
            //        b_list2[i, j].Location = new Point(j * 110 , (i + 1) * 95);
            //        b_list2[i, j].Size = bsize;
            //        b_list2[i, j].Text = list2[i, j];
            //        b_list2[i, j].Font = new Font("微軟雅黑", 25);
            //        tp2.Controls.Add(b_list2[i, j]);
            //        b_list2[i, j].Click += new EventHandler(this.button_click);
            //    }
            //}

         

            //for (int i = 0; i < 1; i++)
            //{
            //    for (int j = 0; j < 5; j++)
            //    {
            //        b_list4[j].BackColor = Color.FromArgb(255, i * 25, j * 60);
            //        b_list4[j].Location = new Point(j * 110 , (i + 1) * 95 * 5);
            //        b_list4[j].Size = bsize;
            //        b_list4[j].Text = list4[j];
            //        b_list4[j].Font = new Font("微軟雅黑", 25);
            //        tp3.Controls.Add(b_list4[j]);
            //        b_list4[j].Click += new EventHandler(this.button_click);
            //    }
            //}
     
        private void button_click(object sender, EventArgs ea)
        {
            string b_name = ((Button)sender).Text;
            string s = "";
            if (b_name.Equals("あア"))
            {
                s = "read/a.wav";
            }
            else if (b_name.Equals("いイ"))
            {
                s = "read/i.wav";
            }
            else if (b_name.Equals("うウ"))
            {
                s = "read/u.wav";
            }
            else if (b_name.Equals("えエ"))
            {
                s = "read/e.wav";
            }
            else if (b_name.Equals("おオ"))
            {
                s = "read/o.wav";
            }
            else if (b_name.Equals("かカ"))
            {
                s = "read/ka.wav";
            }
            else if (b_name.Equals("きキ"))
            {
                s = "read/ki.wav";
            }
            else if (b_name.Equals("くク"))
            {
                s = "read/ku.wav";
            }
            else if (b_name.Equals("けケ"))
            {
                s = "read/ke.wav";
            }
            else if (b_name.Equals("こコ"))
            {
                s = "read/ko.wav";
            }
            else if (b_name.Equals("さサ"))
            {
                s = "read/sa.wav";
            }
            else if (b_name.Equals("しシ"))
            {
                s = "read/si.wav";
            }
            else if (b_name.Equals("すス"))
            {
                s = "read/su.wav";
            }
            else if (b_name.Equals("せセ"))
            {
                s = "read/se.wav";
            }
            else if (b_name.Equals("そソ"))
            {
                s = "read/so.wav";
            }
            else if (b_name.Equals("たタ"))
            {
                s = "read/ta.wav";
            }
            else if (b_name.Equals("ちチ"))
            {
                s = "read/ti.wav";
            }
            else if (b_name.Equals("つツ"))
            {
                s = "read/tu.wav";
            }
            else if (b_name.Equals("てテ"))
            {
                s = "read/te.wav";
            }
            else if (b_name.Equals("とト"))
            {
                s = "read/to.wav";
            }
            else if (b_name.Equals("なナ"))
            {
                s = "read/na.wav";
            }
            else if (b_name.Equals("にニ"))
            {
                s = "read/ni.wav";
            }
            else if (b_name.Equals("ぬヌ"))
            {
                s = "read/nu.wav";
            }
            else if (b_name.Equals("ねネ"))
            {
                s = "read/ne.wav";
            }
            else if (b_name.Equals("のノ"))
            {
                s = "read/no.wav";
            }
            else if (b_name.Equals("はハ"))
            {
                s = "read/ha.wav";
            }
            else if (b_name.Equals("ひヒ"))
            {
                s = "read/hi.wav";
            }
            else if (b_name.Equals("ふフ"))
            {
                s = "read/hu.wav";
            }
            else if (b_name.Equals("へヘ"))
            {
                s = "read/he.wav";
            }
            else if (b_name.Equals("ほホ"))
            {
                s = "read/ho.wav";
            }
            else if (b_name.Equals("まマ"))
            {
                s = "read/ma.wav";
            }
            else if (b_name.Equals("みミ"))
            {
                s = "read/mi.wav";
            }
            else if (b_name.Equals("むム"))
            {
                s = "read/mu.wav";
            }
            else if (b_name.Equals("めメ"))
            {
                s = "read/me.wav";
            }
            else if (b_name.Equals("もモ"))
            {
                s = "read/mo.wav";
            }
            else if (b_name.Equals("やヤ"))
            {
                s = "read/ya.wav";
            }
            else if (b_name.Equals("ゆユ"))
            {
                s = "read/yu.wav";
            }
            else if (b_name.Equals("よヨ"))
            {
                s = "read/yo.wav";
            }
            else if (b_name.Equals("らラ"))
            {
                s = "read/ra.wav";
            }
            else if (b_name.Equals("りリ"))
            {
                s = "read/ri.wav";
            }
            else if (b_name.Equals("るル"))
            {
                s = "read/ru.wav";
            }
            else if (b_name.Equals("れレ"))
            {
                s = "read/re.wav";
            }
            else if (b_name.Equals("ろロ"))
            {
                s = "read/ro.wav";
            }
            else if (b_name.Equals("わワ"))
            {
                s = "read/wa.wav";
            }
            else if (b_name.Equals("をヲ"))
            {
                s = "read/o.wav";
            }
            else if (b_name.Equals("んン"))
            {
                s = "read/n.wav";
            }
            else if (b_name.Equals("がガ"))
            {
                s = "read/ga.wav";
            }
            else if (b_name.Equals("ぎギ"))
            {
                s = "read/gi.wav";
            }
            else if (b_name.Equals("ぐグ"))
            {
                s = "read/gu.wav";
            }
            else if (b_name.Equals("げゲ"))
            {
                s = "read/ge.wav";
            }
            else if (b_name.Equals("ごゴ"))
            {
                s = "read/go.wav";
            }
            else if (b_name.Equals("ざザ"))
            {
                s = "read/za.wav";
            }
            else if (b_name.Equals("じジ"))
            {
                s = "read/zi.wav";
            }
            else if (b_name.Equals("ずズ"))
            {
                s = "read/zu.wav";
            }
            else if (b_name.Equals("ぜゼ"))
            {
                s = "read/ze.wav";
            }
            else if (b_name.Equals("ぞゾ"))
            {
                s = "read/zo.wav";
            }
            else if (b_name.Equals("だダ"))
            {
                s = "read/da.wav";
            }
            else if (b_name.Equals("ぢヂ"))
            {
                s = "read/zi.wav";
            }
            else if (b_name.Equals("づヅ"))
            {
                s = "read/zu.wav";
            }
            else if (b_name.Equals("でデ"))
            {
                s = "read/de.wav";
            }
            else if (b_name.Equals("どド"))
            {
                s = "read/do.wav";
            }
            else if (b_name.Equals("ばバ"))
            {
                s = "read/ba.wav";
            }
            else if (b_name.Equals("びビ"))
            {
                s = "read/bi.wav";
            }
            else if (b_name.Equals("ぶブ"))
            {
                s = "read/bu.wav";
            }
            else if (b_name.Equals("べベ"))
            {
                s = "read/be.wav";
            }
            else if (b_name.Equals("ぼボ"))
            {
                s = "read/bo.wav";
            }
            else if (b_name.Equals("ぱパ"))
            {
                s = "read/pa.wav";
            }
            else if (b_name.Equals("ぴピ"))
            {
                s = "read/pi.wav";
            }
            else if (b_name.Equals("ぷプ"))
            {
                s = "read/pu.wav";
            }
            else if (b_name.Equals("ぺペ"))
            {
                s = "read/pe.wav";
            }
            else if (b_name.Equals("ぽポ"))
            {
                s = "read/po.wav";
            }
            try
            {
                using (SoundPlayer sp = new SoundPlayer(s))
                {
                    sp.Load();
                    sp.Play();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
    }
}