[C#] 纯文本查看 复制代码
g.DrawString(addr.ToString("X").PadLeft(8,'0') + " "
+ BitConverter.ToString(byte[],index,len).Replace('-',' ')
+ " " + Encoding.ASCII.GetString(byte[],index,len));
[C#] 纯文本查看 复制代码
protected virtual void DrawHex(Graphics g) {
int len = this._TopLineStartIndex + m_nLinesForDraw;
if (len > m_nLineCount) len = m_nLineCount;
for (int i = this._TopLineStartIndex; i < len; i++) {
string strDraw = (this._StartAddr + i * 16).ToString("X").PadLeft(8, '0') + " ";
//g.DrawString(strDraw, this.Font, Brushes.Blue, this._LeftOffset,
//(i - this._TopLineStartIndex + 1) * this.Font.Height);
//百度网盘那个用的是上面这句 自己改 csdn的是下面这句
TextRenderer.DrawText(g, strDraw, this.Font, new Point(this._LeftOffset,
(i - this._TopLineStartIndex + 1) * this.Font.Height), this._AddrColor);
int index = i * 16;
for (int j = 0; j < 16; j++) {
TextRenderer.DrawText(g, this._ByteData[index].ToString("X")
.PadLeft(2, '0'), this.Font,
new Point(m_nArrHexLeftOffset[j] + this._LeftOffset,
(i - this._TopLineStartIndex + 1) * this.Font.Height),
clrHexForeColor, clrHexBackColor);
TextRenderer.DrawText(g,
((char)(this._ByteData[index] == 0 ? (byte)'.' : this._ByteData[index]))
.ToString(), this.Font,
new Point(m_nArrAscLeftOffset[j] + this._LeftOffset, (
i - this._TopLineStartIndex + 1) * this.Font.Height),
clrASCIIForeColor, clrASCIIBackColor);
if (++index == this._ByteData.Length) return;
}
}
}