/// <summary> /// Links the specified rich text box to this rich text box. Whenever either richtextbox /// scrolls, the other will scroll too. /// </summary> /// <param name="richTextBox">The RichTextBox to link.</param> public void AddLinkedRichTextBox(MyRichTextBox richTextBox) { if (richTextBox == this) { throw new ArgumentException("Cannot link a RichTextBox to itself!", "richTextBox"); } if (!linkedRichTextBoxes.Contains(richTextBox)) { //add the richtextbox to our list of linked richtextboxes linkedRichTextBoxes.Add(richTextBox); //add this to the richtextbox's list of linked richtextboxes richTextBox.AddLinkedRichTextBox(this); //make sure the RichTextBox is linked to all of the other RichTextBoxes that this RichTextBox is linked to for (int i = 0; i < linkedRichTextBoxes.Count; i++) { //get the linked richtextbox var linkedRichTextBox = linkedRichTextBoxes[i]; //link the richtextboxes together if (linkedRichTextBox != richTextBox) { linkedRichTextBox.AddLinkedRichTextBox(richTextBox); } } } }
private void compareTexts(MyRichTextBox newRichTextBox, string newText, MyRichTextBox oldRichTextBox, string oldText) { ISideBySideDiffBuilder diffBuilder = new SideBySideDiffBuilder(new Differ()); SideBySideDiffModel sideBySideModel = diffBuilder.BuildDiffModel(oldText, newText); colorRichTextBox(newRichTextBox, sideBySideModel.NewText.Lines, true); colorRichTextBox(oldRichTextBox, sideBySideModel.OldText.Lines, false); newRichTextBox.AddLinkedRichTextBox(oldRichTextBox); }