
// byt[256] を16進数で修正する
private void Update(object sender, EventArgs e)
{
string wstr;
wstr = textBox1.Text; //表示中の Text Box
//Console.WriteLine(wstr);
edit.bytEdit(wstr);
SW = 2;
Invalidate();
}
|
// wstr : 表示中の Text Data
public void bytEdit(string wstr)
{
string[] ws;
ws= wstr.Split(new char[] {'\n'});
for(int i=0; i<ws.GetLength(0)-1; i++)
hexMode(ws[i], i);
}
|
0038: 2A000526 20004200 69006E00 61007200 ... |
// byt[256] の行(line)の文字を hex で更新
public void hexMode(string ws, int line)
{ int i,j;
Console.WriteLine("Len={0} ws={1}", ws.Length,ws);
j = 0;
for(i=6; i<42; )
{
if (ws[i]==' ' && ws[i+1]==' ') return;
if (ws[i]==' ')
{
i++;
continue;
}
byt[line*16+j] = hex2byte(ws.Substring(i,2));
i += 2;
j++;
if (j>=16) return;
}
}
|
// 2文字の16進数を byte に変換
public byte hex2byte(string str)
{ byte wk;
if (str[0] <= '9') wk = (byte)((str[0] & 0x0F)<<4);
else wk = (byte)(((str[0] + 9) & 0x0F)<<4);
if (str[1] <= '9') wk += (byte)(str[1] & 0x0F);
else wk += (byte)((str[1] + 9) & 0x0F);
return wk;
}
|
※・