feature<DiffViewer>: 新增同步高亮选中行

This commit is contained in:
ZCShou 2021-05-25 13:50:33 +08:00
parent 58e690e1dc
commit cc661d3226

View file

@ -318,10 +318,12 @@ namespace SourceGit.Views.Widgets {
oldEditor = CreateTextEditor(new string[] { "OldLine" });
oldEditor.SetValue(Grid.ColumnProperty, 0);
oldEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
oldEditor.SelectionChanged += new SelectionChangedEventHandler(OnTextDiffSyncSelected);
newEditor = CreateTextEditor(new string[] { "NewLine" });
newEditor.SetValue(Grid.ColumnProperty, 1);
newEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
newEditor.SelectionChanged += new SelectionChangedEventHandler(OnTextDiffSyncSelected);
editors.Add(oldEditor);
editors.Add(newEditor);
@ -601,6 +603,20 @@ namespace SourceGit.Views.Widgets {
}
}
private void OnTextDiffSyncSelected(object sender, SelectionChangedEventArgs e) {
DataGrid dG = sender as DataGrid;
int Index = dG.SelectedIndex;
foreach (var editor in editors) {
if (editor == sender || editor.SelectedIndex == Index) { /// 对于事件发起者不用处理
continue;
}
editor.SelectedIndex = Index; ///* 这里更改后,会导致再次进入改接口
}
}
private void OnTextDiffBringIntoView(object sender, RequestBringIntoViewEventArgs e) {
e.Handled = true;
}