|
|
|
@ -48,26 +48,42 @@ public abstract class DockUserControlBase : DropTargetUserControlBase
|
|
|
|
|
// Attach handlers for view state saving and loading |
|
|
|
|
if (DataContext is InferenceTabViewModelBase vm) |
|
|
|
|
{ |
|
|
|
|
vm.SaveViewStateRequested += (_, args) => |
|
|
|
|
{ |
|
|
|
|
var saveTcs = new TaskCompletionSource<ViewState>(); |
|
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(() => |
|
|
|
|
{ |
|
|
|
|
var state = new ViewState { DockLayout = SaveDockLayout() }; |
|
|
|
|
saveTcs.SetResult(state); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
args.StateTask ??= saveTcs.Task; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
vm.LoadViewStateRequested += (_, args) => |
|
|
|
|
{ |
|
|
|
|
if (args.State.DockLayout is { } layout) |
|
|
|
|
{ |
|
|
|
|
LoadDockLayout(layout); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
vm.SaveViewStateRequested += DataContext_OnSaveViewStateRequested; |
|
|
|
|
vm.LoadViewStateRequested += DataContext_OnLoadViewStateRequested; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <inheritdoc /> |
|
|
|
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) |
|
|
|
|
{ |
|
|
|
|
base.OnDetachedFromVisualTree(e); |
|
|
|
|
|
|
|
|
|
// Detach handlers for view state saving and loading |
|
|
|
|
if (DataContext is InferenceTabViewModelBase vm) |
|
|
|
|
{ |
|
|
|
|
vm.SaveViewStateRequested -= DataContext_OnSaveViewStateRequested; |
|
|
|
|
vm.LoadViewStateRequested -= DataContext_OnLoadViewStateRequested; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void DataContext_OnSaveViewStateRequested(object? sender, SaveViewStateEventArgs args) |
|
|
|
|
{ |
|
|
|
|
var saveTcs = new TaskCompletionSource<ViewState>(); |
|
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(() => |
|
|
|
|
{ |
|
|
|
|
var state = new ViewState { DockLayout = SaveDockLayout() }; |
|
|
|
|
saveTcs.SetResult(state); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
args.StateTask ??= saveTcs.Task; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void DataContext_OnLoadViewStateRequested(object? sender, LoadViewStateEventArgs args) |
|
|
|
|
{ |
|
|
|
|
if (args.State.DockLayout is { } layout) |
|
|
|
|
{ |
|
|
|
|
LoadDockLayout(layout); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|