mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<DiffViewer>: 新增同步高亮选中行
This commit is contained in:
parent
58e690e1dc
commit
cc661d3226
1 changed files with 16 additions and 0 deletions
|
@ -318,10 +318,12 @@ namespace SourceGit.Views.Widgets {
|
||||||
oldEditor = CreateTextEditor(new string[] { "OldLine" });
|
oldEditor = CreateTextEditor(new string[] { "OldLine" });
|
||||||
oldEditor.SetValue(Grid.ColumnProperty, 0);
|
oldEditor.SetValue(Grid.ColumnProperty, 0);
|
||||||
oldEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
|
oldEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
|
||||||
|
oldEditor.SelectionChanged += new SelectionChangedEventHandler(OnTextDiffSyncSelected);
|
||||||
|
|
||||||
newEditor = CreateTextEditor(new string[] { "NewLine" });
|
newEditor = CreateTextEditor(new string[] { "NewLine" });
|
||||||
newEditor.SetValue(Grid.ColumnProperty, 1);
|
newEditor.SetValue(Grid.ColumnProperty, 1);
|
||||||
newEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
|
newEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTextDiffSyncScroll));
|
||||||
|
newEditor.SelectionChanged += new SelectionChangedEventHandler(OnTextDiffSyncSelected);
|
||||||
|
|
||||||
editors.Add(oldEditor);
|
editors.Add(oldEditor);
|
||||||
editors.Add(newEditor);
|
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) {
|
private void OnTextDiffBringIntoView(object sender, RequestBringIntoViewEventArgs e) {
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue