前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
//黒, 白, 対局名, 日付, 結果, コミ
string[] m_tag = { "PB", "PW", "EV", "DT", "RE", "KM" };
string[] m_tagstr = new string[6];
|
// 出題図プロパティのチェック
private void KeyCheck()
{
・・・
for(i=0; i<6; i++)
{ if (m_WS==m_tag[i])
{ Token();
m_tagstr[i] = m_WS;
return;
}
}
Token(); // 以外のプロパティはスキップ
}
|
// SGF ファイルに保存
private void SGFSave(string file)
{ DialogResult rc;
if (File.Exists(file))
{ rc = MessageBox.Show("上書きで保存しますか", "選択",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (rc == DialogResult.No) return;
}
writer = new StreamWriter(file,false, Encoding.GetEncoding("utf-8"));
writer.WriteLine(head);
for (int i = 0; i < 6; i++)
{
if (m_tagstr[i] != string.Empty)
writer.Write(m_tag[i] + "[" + m_tagstr[i] + "]");
}
SaveBan();
・・・
|
item = menu.MenuItems.Add("ヘルプ(&H)");
item.MenuItems.Add(new MenuItem("Header 情報(&H)...", new EventHandler(this.Head_Dlg)));
|
// Header Dialog
private void Head_Dlg(object sender, EventArgs e)
{
int i;
MyDialog Mydlg = new MyDialog();
for(i=0; i<6; i++) Mydlg.textBox[i].Text = m_tagstr[i];
DialogResult dr = Mydlg.ShowDialog();
if (dr == DialogResult.OK)
{ for(i=0; i<6; i++) m_tagstr[i] = Mydlg.textBox[i].Text;
}
}
|
//★ Dialog Class
class MyDialog : Form
{
public string[] tag = { "黒", "白", "対局名", "日付", "結果", "コミ" };
public string[] tagstr = new string[6];
public TextBox[] textBox = new TextBox[6];
public Label[] label = new Label[6];
public MyDialog()
{
Text = "SGF Header";
MaximizeBox = false;
MinimizeBox = false;
ControlBox = false;
ShowInTaskbar = false;
FormBorderStyle = FormBorderStyle.FixedDialog;
Width = 250;
Height = 210;
Button btnOK = new Button();
btnOK.Text = "OK";
btnOK.Location = new Point(30, ClientSize.Height - btnOK.Height - 5);
btnOK.Parent = this;
btnOK.TabIndex = 2;
btnOK.Click += new EventHandler(btnOK_Click);
btnOK.DialogResult = DialogResult.OK;
Button btnCancel = new Button();
btnCancel.Text = "Cancel";
btnCancel.Location = new Point(ClientSize.Width - btnCancel.Width - 30,
ClientSize.Height - btnCancel.Height - 5);
btnCancel.Parent = this;
btnCancel.TabIndex = 3;
btnCancel.DialogResult = DialogResult.Cancel;
for(int i=0; i<6; i++)
{
tagstr[i]=string.Empty;
label[i] = new Label();
label[i].Parent = this;
label[i].Location = new Point(10, i*24+10);
label[i].Size = new Size(50, 24);
label[i].TabIndex = i;
label[i].Text = tag[i];
textBox[i] = new TextBox();
textBox[i].Parent = this;
textBox[i].Location = new Point(60, i*24+10);
textBox[i].Width = ClientSize.Width - 70;
textBox[i].TabIndex = 0;
}
}
void btnOK_Click(object sender, EventArgs e)
{
for(int i=0; i<6; i++)
{
if (textBox[i].Text!=string.Empty) tagstr[i] = textBox[i].Text;
}
}
}
|
![]()
[Previous Chapter ↑] LB tag をプログラム
※・