private void UpdateLines(RichText tas, Range range) { if (updating) { return; } updating = true; int start = range.Start.iLine; int end = range.End.iLine; while (start <= end) { InputRecord old = Lines.Count > start ? Lines[start] : null; string text = tas[start++].Text; InputRecord input = new InputRecord(text); if (old != null) { totalFrames -= old.Frames; string line = input.ToString(); if (text != line) { if (old.Frames == 0 && old.ZeroPadding == input.ZeroPadding && old.Equals(input) && line.Length >= text.Length) { line = string.Empty; } Range oldRange = tas.Selection.Clone(); tas.Selection = tas.GetLine(start - 1); tas.SelectedText = line; int actionPosition = input.ActionPosition(); if (!string.IsNullOrEmpty(line)) { int index = oldRange.Start.iChar + line.Length - text.Length; if (index < 0) { index = 0; } if (index > 4 && old.Angle == input.Angle) { index = 4; } if (old.Frames == input.Frames && old.ZeroPadding == input.ZeroPadding && old.Angle == input.Angle) { index = 4; } tas.Selection.Start = new Place(index, start - 1); } Text = titleBarText + " ***"; } Lines[start - 1] = input; } totalFrames += input.Frames; } UpdateStatusBar(); updating = false; }
private void UpdateLines(RichText tas, Range range) { if (updating) { return; } updating = true; int start = range.Start.iLine; int end = range.End.iLine; if (start > end) { int temp = start; start = end; end = temp; } int originalStart = start; bool modified = false; StringBuilder sb = new StringBuilder(); Place place = new Place(0, end); while (start <= end) { InputRecord old = Lines.Count > start ? Lines[start] : null; string text = tas[start++].Text; InputRecord input = new InputRecord(text); if (old != null) { totalFrames -= old.Frames; string line = input.ToString(); if (text != line) { if (old.Frames == 0 && input.Frames == 0 && old.ZeroPadding == input.ZeroPadding && old.Equals(input) && line.Length >= text.Length) { line = string.Empty; } Range oldRange = tas.Selection; if (!string.IsNullOrEmpty(line)) { int index = oldRange.Start.iChar + line.Length - text.Length; if (index < 0) { index = 0; } if (index > 4) { index = 4; } if (old.Frames == input.Frames && old.ZeroPadding == input.ZeroPadding) { index = 4; } place = new Place(index, start - 1); } modified = true; } else { place = new Place(4, start - 1); } text = line; Lines[start - 1] = input; } else { place = new Place(text.Length, start - 1); } if (start <= end) { sb.AppendLine(text); } else { sb.Append(text); } totalFrames += input.Frames; } if (modified) { tas.Selection = new Range(tas, 0, originalStart, tas[end].Count, end); tas.SelectedText = sb.ToString(); tas.Selection = new Range(tas, place.iChar, end, place.iChar, end); Text = titleBarText + " ***"; } UpdateStatusBar(); updating = false; }