mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-17 15:06:36 +08:00
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Threading;
|
|
using Dragablz.Core;
|
|
|
|
namespace Dragablz
|
|
{
|
|
public class DefaultInterTabClient : IInterTabClient
|
|
{
|
|
public virtual INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
|
|
{
|
|
if (source == null) throw new ArgumentNullException("source");
|
|
var sourceWindow = Window.GetWindow(source);
|
|
if (sourceWindow == null) throw new ApplicationException("Unable to ascertain source window.");
|
|
var newWindow = (Window)Activator.CreateInstance(sourceWindow.GetType());
|
|
|
|
newWindow.Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.DataBind);
|
|
|
|
var newTabablzControl = newWindow.LogicalTreeDepthFirstTraversal().OfType<TabablzControl>().FirstOrDefault();
|
|
if (newTabablzControl == null) throw new ApplicationException("Unable to ascertain tab control.");
|
|
|
|
if (newTabablzControl.ItemsSource == null)
|
|
newTabablzControl.Items.Clear();
|
|
|
|
return new NewTabHost<Window>(newWindow, newTabablzControl);
|
|
}
|
|
|
|
public virtual TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
|
|
{
|
|
return TabEmptiedResponse.CloseWindowOrLayoutBranch;
|
|
}
|
|
}
|
|
} |