mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-05-20 20:28:05 -05:00
Refresh a tab when it switches in
This commit is contained in:
parent
0af3c364df
commit
602bf280ba
|
|
@ -208,6 +208,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
if (TryUpdate(ref selectedIndex, value)) {
|
||||
findPrevious.CanExecuteChanged.Invoke(findPrevious, EventArgs.Empty);
|
||||
findNext.CanExecuteChanged.Invoke(findNext, EventArgs.Empty);
|
||||
if (selectedIndex >= 0 && selectedIndex < tabs.Count) tabs[selectedIndex].Refresh();
|
||||
UpdateGotoViewModel();
|
||||
foreach (var edit in QuickEdits) edit.TabChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
event EventHandler<ITabContent> RequestTabChange;
|
||||
event EventHandler<Action> RequestDelayedWork;
|
||||
event EventHandler RequestMenuClose;
|
||||
|
||||
void Refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
}) { ShortcutText = "Ctrl+Click" } };
|
||||
}
|
||||
|
||||
public void Refresh() { }
|
||||
|
||||
private void NotifyCollectionChanged() {
|
||||
if (children.Count == 0) return;
|
||||
UpdateHeaders();
|
||||
|
|
|
|||
|
|
@ -446,6 +446,20 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
Assert.Equal(0x100, newTab.DataOffset); // the new tab is scrolled to the desired location
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TabGetsRefreshedWhenSwitchedIn() {
|
||||
int count = 0;
|
||||
var tab1 = new StubTabContent { Refresh = () => count++ };
|
||||
var tab2 = new StubTabContent();
|
||||
editor.Add(tab1);
|
||||
count = 0;
|
||||
|
||||
tab1.RequestTabChange?.Invoke(tab1, tab2);
|
||||
editor.SelectedIndex = 0;
|
||||
|
||||
Assert.Equal(1, count);
|
||||
}
|
||||
|
||||
private StubTabContent CreateClosableTab() {
|
||||
var tab = new StubTabContent();
|
||||
var close = new StubCommand { CanExecute = arg => true };
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user