private void Result_RebuildRequested(object sender, RebuildRequestEventArgs e) { if (Root == sender) { Root = e.First; } (sender as ResultBlock).RebuildRequested -= Result_RebuildRequested; RebuildRequested?.Invoke(sender, e); }
private void Comparison_RebuildRequested(object sender, RebuildRequestEventArgs e) { var prevBlock = sender as ResultBlock; int start = Comparison.GetOffsetToBlock(e.First, Side.Left); int length = prevBlock.Length(Side.Left); string text = e.First[Side.Left]; if (e.Second != null) { text += e.Second[Side.Left]; } LeftDocument.Replace(start, length, text); start = Comparison.GetOffsetToBlock(e.First, Side.Right); length = prevBlock.Length(Side.Right); text = e.First[Side.Right]; if (e.Second != null) { text += e.Second[Side.Right]; } RightDocument.Replace(start, length, text); start = Comparison.GetOffsetToBlock(e.First, Side.Result); length = prevBlock.Length(Side.Result); text = e.First[Side.Result]; if (e.Second != null) { text += e.Second[Side.Result]; } ResultDocument.Changed -= _resultDocument_Changed; ResultDocument.Replace(start, length, text); ResultDocument.Changed += _resultDocument_Changed; _canSaveMerge.OnNext(AreAllConflictsResolved()); }
public void ResolveAs(Side first, Side second) { RebuildRequestEventArgs args; ResultBlock firstBlock = null; ResultBlock secondBlock = null; var current = this; if (HasSide(first)) { ResultBlock result; if (first == Side.Left) { result = new ResultBlock(left, PrevBlock); } else { result = new ResultBlock(right, PrevBlock); } result.NextBlock = NextBlock; if (NextBlock != null) { current.NextBlock.PrevBlock = result; } firstBlock = current = result; } if (HasSide(second)) { ResultBlock result; var prev = HasSide(first) ? current : PrevBlock; if (second == Side.Left) { result = new ResultBlock(left, prev); } else { result = new ResultBlock(right, prev); } result.NextBlock = NextBlock; if (NextBlock != null) { current.NextBlock.PrevBlock = result; } if (current == this) { firstBlock = current = result; } else { secondBlock = result; } } args = new RebuildRequestEventArgs(firstBlock, secondBlock); RebuildRequested?.Invoke(this, args); RebuildRequested = null; }