|
メトロノーム、お昼休みにできちゃったですよwww
using System;
using System.Windows.Forms;
namespace Metronome {
public partial class Form1 : Form {
public Form1() { InitializeComponent(); }
// comboBox1 : rythm選択 (2,3,...10)
// numericUpDown : tempo設定 (1,2,...,200)
// timer1 : 定周期タイマ
private int rythm;
private int tempo;
private int count; // label4に↓コレを書く(リズムに合わせて)
private string[] marks = { "●○○○○○○○○○○",
"○●○○○○○○○○○",
"○○●○○○○○○○○",
"○○○●○○○○○○○",
"○○○○●○○○○○○",
"○○○○○●○○○○○",
"○○○○○○●○○○○",
"○○○○○○○●○○○",
"○○○○○○○○●○○",
"○○○○○○○○○●○",
"○○○○○○○○○○●",
};
private void Form1_Load(object sender, EventArgs e) {
comboBox1.SelectedIndex = 0;
rythm = 2;
numericUpDown1.Value = 60;
tempo = 60;
timer1.Interval = 60000 / tempo;
count = 0;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e) {
tempo = (int)numericUpDown1.Value;
timer1.Interval = 60000 / tempo;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
rythm = comboBox1.SelectedIndex + 2;
}
private void timer1_Tick(object sender, EventArgs e) {
count = (count + 1) % rythm;
label4.Text = marks[count].Substring(0, rythm);
}
}
}
|