Skip to content

Commit a4f82e1

Browse files
committed
Tabs can drag out and create new windows
1 parent 45806de commit a4f82e1

7 files changed

Lines changed: 79 additions & 3 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Dragablz;
2+
using System.Windows;
3+
using NETworkManager.Views.Common;
4+
5+
namespace NETworkManager.Controls
6+
{
7+
public class DragablzMainInterTabClient : IInterTabClient
8+
{
9+
public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
10+
{
11+
DragablzTabHostWindow dragablzTabHostWindow = new DragablzTabHostWindow();
12+
return new NewTabHost<DragablzTabHostWindow>(dragablzTabHostWindow, dragablzTabHostWindow.TabsContainer);
13+
}
14+
15+
public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
16+
{
17+
return TabEmptiedResponse.DoNothing;
18+
//throw new NotImplementedException();
19+
}
20+
}
21+
}

‎Source/NETworkManager/MainWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public MainWindow()
235235

236236
Version = AssemblyManager.Current.AssemblyVersion.ToString();
237237

238-
LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(LocalizationManager.Culture.IetfLanguageTag)));
238+
// LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(LocalizationManager.Culture.IetfLanguageTag)));
239239

240240
// Load appearance
241241
AppearanceManager.Load();

‎Source/NETworkManager/NETworkManager.csproj‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
<Compile Include="3rdParty\Heijden.DNS\Response.cs" />
170170
<Compile Include="3rdParty\Heijden.DNS\RR.cs" />
171171
<Compile Include="3rdParty\Heijden.DNS\Structs.cs" />
172+
<Compile Include="Controls\DragablzMainInterTabClient.cs" />
172173
<Compile Include="Controls\DragablzTabContent.cs" />
173174
<Compile Include="Converters\TimestampToStringConverter.cs" />
174175
<Compile Include="Converters\NullableDateTimeToStringConverter.cs" />
@@ -209,6 +210,9 @@
209210
<Compile Include="Views\Applications\RemoteDesktopView.xaml.cs">
210211
<DependentUpon>RemoteDesktopView.xaml</DependentUpon>
211212
</Compile>
213+
<Compile Include="Views\Common\DragablzTabHostWindow.xaml.cs">
214+
<DependentUpon>DragablzTabHostWindow.xaml</DependentUpon>
215+
</Compile>
212216
<Compile Include="Views\Settings\UpdateView.xaml.cs">
213217
<DependentUpon>UpdateView.xaml</DependentUpon>
214218
</Compile>
@@ -310,6 +314,10 @@
310314
<SubType>Designer</SubType>
311315
<Generator>MSBuild:Compile</Generator>
312316
</Page>
317+
<Page Include="Views\Common\DragablzTabHostWindow.xaml">
318+
<Generator>MSBuild:Compile</Generator>
319+
<SubType>Designer</SubType>
320+
</Page>
313321
<Page Include="Views\Settings\UpdateView.xaml">
314322
<Generator>MSBuild:Compile</Generator>
315323
<SubType>Designer</SubType>
@@ -708,6 +716,7 @@
708716
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
709717
</None>
710718
</ItemGroup>
719+
<ItemGroup />
711720
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
712721
<PropertyGroup>
713722
<PreBuildEvent>PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File "$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1" "$(TargetDir)"</PreBuildEvent>

‎Source/NETworkManager/ViewModels/Applications/RemoteDesktopViewModel.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
using NETworkManager.Controls;
33
using System;
44
using NETworkManager.Views.Applications;
5+
using Dragablz;
56

67
namespace NETworkManager.ViewModels.Applications
78
{
89
public class RemoteDesktopViewModel : ViewModelBase
910
{
11+
public IInterTabClient InterTabClient { get; set; }
1012
public ObservableCollection<DragablzTabContent> TabContents = new ObservableCollection<DragablzTabContent>();
1113

1214
public RemoteDesktopViewModel()
1315
{
14-
16+
InterTabClient = new DragablzMainInterTabClient();
1517
}
1618

1719
public static Func<object> NewItemFactory
1820
{
19-
get { return () => new DragablzTabContent("test", new TracerouteView()); }
21+
get { return () => new DragablzTabContent("Traceroute", new TracerouteView()); }
2022
}
2123
}
2224
}

‎Source/NETworkManager/Views/Applications/RemoteDesktopView.xaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
mc:Ignorable="d">
99
<Grid>
1010
<dragablz:TabablzControl ItemsSource="{Binding TabContents}">
11+
<dragablz:TabablzControl.InterTabController>
12+
<dragablz:InterTabController InterTabClient="{Binding InterTabClient}" />
13+
</dragablz:TabablzControl.InterTabController>
1114
<dragablz:TabablzControl.Style>
1215
<Style TargetType="{x:Type dragablz:TabablzControl}" BasedOn="{StaticResource DefaultTabablzControl}">
1316
<Setter Property="NewItemFactory" Value="{x:Static ViewModel:RemoteDesktopViewModel.NewItemFactory}" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Controls:MetroWindow x:Name="MetroWindowDragablzTabHost" x:Class="NETworkManager.Views.Common.DragablzTabHostWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
7+
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
8+
mc:Ignorable="d"
9+
Title="{DynamicResource String_ProductName}" Style="{DynamicResource DefaultWindow}" MinWidth="650" MinHeight="500" Height="650" Width="1000" TitleAlignment="Left">
10+
<Controls:MetroWindow.WindowButtonCommands>
11+
<Controls:WindowButtonCommands Template="{DynamicResource MahApps.Metro.Templates.WindowButtonCommands.Win10}" />
12+
</Controls:MetroWindow.WindowButtonCommands>
13+
<Grid Margin="10">
14+
<dragablz:TabablzControl Name="TabsContainer">
15+
<dragablz:TabablzControl.InterTabController>
16+
<dragablz:InterTabController></dragablz:InterTabController>
17+
</dragablz:TabablzControl.InterTabController>
18+
<dragablz:TabablzControl.Style>
19+
<Style TargetType="{x:Type dragablz:TabablzControl}" BasedOn="{StaticResource DefaultTabablzControl}">
20+
<!-- If not null, the header suffix will be removed in the main window -->
21+
<Setter Property="HeaderSuffixContent" Value="{x:Null}" />
22+
</Style>
23+
</dragablz:TabablzControl.Style>
24+
</dragablz:TabablzControl>
25+
</Grid>
26+
</Controls:MetroWindow>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using MahApps.Metro.Controls;
2+
3+
namespace NETworkManager.Views.Common
4+
{
5+
/// <summary>
6+
/// Interaktionslogik für Settings.xaml
7+
/// </summary>
8+
public partial class DragablzTabHostWindow : MetroWindow
9+
{
10+
public DragablzTabHostWindow()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)