public virtual void ToRichText(RichTextBuilder builder)
{
string format;
if (OpcodeFormats.TryGetValue(Opcode, out format)) {
for (int index = 0; index < format.Length; index++) {
if (format[index] == '{') {
if (format[index + 1] == '{') {
index++;
builder.Append('{');
} else {
int end;
for (end = ++index; format[end] != '}'; end++) ;
int operandIndex = int.Parse(format.Substring(index, end - index));
ScriptOperand operand = GetOperand(operandIndex);
operand.ToRichText(builder);
index = end;
}
} else
builder.Append(format[index]);
}
} else {
if (IsOpcodeDefined)
builder.Append(Opcode.ToString());
else {
builder.ForegroundColor = Color.Red;
builder.AppendFormat("{0:X2}", (int)Opcode);
builder.ForegroundColor = Color.Black;
}
foreach (ScriptOperand operand in Operands) {
builder.Append(" ");
operand.ToRichText(builder);
}
}
}