public void RefreshHexEditor() { this.Updating = true; vScrollBar1.Value = offset / 16; string bytes2 = ""; string bytes3 = ""; string offsets = ""; // in case enlarging when at end of ROM while (last_line > current.Length) { offset -= 16; } // int offset_line = offset & 0xFFFFF0; for (int i = 0; i < line_count; i++) { offsets += (i * 16 + offset_line).ToString("X6"); if (i < line_count - 1) { offsets += "\r"; } for (int a = 0; a < 16; a++) { bytes2 += (current[i * 16 + offset_line + a]).ToString("X2") + " "; bytes3 += (original[i * 16 + offset_line + a]).ToString("X2") + " "; } } // ROMOffsets.BeginUpdate(); ROMOffsets.Text = offsets; ROMOffsets.EndUpdate(); // ROMData.BeginUpdate(); currentROMData.Text = bytes2; originalROMData.Text = bytes3; currentROMData.SelectionStart = 0; currentROMData.SelectionLength = currentROMData.Text.Length; currentROMData.SelectionColor = Color.DarkBlue; for (int offsetCounter = offset & 0xFFFFF0, i = 0; i < line_count * 16; i++) { // first set the length of the changed offsets, to colorize all at once (b/c faster) int changedStart = 0; int changedLength = 0; Change change = Do.FindOffset(oldProperties, offsetCounter++); if (change != null) { changedStart = i * 3; if (change.Values.Length == 1) { changedLength = 3; while (Do.Contains(oldProperties, offsetCounter++)) { changedLength += 3; } i += changedLength / 3; } else { offsetCounter--; changedLength = (change.Values.Length - (offsetCounter - change.Offset)) * 3; i += changedLength / 3; offsetCounter += changedLength / 3; offsetCounter++; } } if (changedLength > 0) { currentROMData.SelectionStart = changedStart; currentROMData.SelectionLength = changedLength; currentROMData.SelectionColor = change.Color; } } currentROMData.SelectionStart = originalROMData.SelectionStart = selectionStart; currentROMData.SelectionLength = originalROMData.SelectionLength = selectionLength; ROMData.Focus(); ROMData.EndUpdate(); // UpdateInformationLabels(); this.Updating = false; }