Skip to content

Commit 64fd400

Browse files
committed
PortScanner - Tabs added
1 parent 5bede7b commit 64fd400

17 files changed

Lines changed: 1110 additions & 756 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Dragablz;
2+
using System.Windows;
3+
4+
namespace NETworkManager.Controls
5+
{
6+
public class DragablzPortScannerInterTabClient : IInterTabClient
7+
{
8+
public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
9+
{
10+
DragablzPortScannerTabHostWindow dragablzPortScannerTabHostWindow = new DragablzPortScannerTabHostWindow();
11+
return new NewTabHost<DragablzPortScannerTabHostWindow>(dragablzPortScannerTabHostWindow, dragablzPortScannerTabHostWindow.TabsContainer);
12+
}
13+
14+
public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
15+
{
16+
return TabEmptiedResponse.DoNothing;
17+
}
18+
}
19+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Controls:MetroWindow x:Class="NETworkManager.Controls.DragablzPortScannerTabHostWindow"
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>
14+
<dragablz:TabablzControl Name="TabsContainer" ClosingItemCallback="{Binding CloseItemCommand}">
15+
<dragablz:TabablzControl.InterTabController>
16+
<dragablz:InterTabController Partition="E6BFC741-E391-43D3-92D7-0227277D256E" />
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+
<Setter Property="ContentTemplate">
23+
<Setter.Value>
24+
<DataTemplate>
25+
<ContentPresenter Content="{Binding View}" />
26+
</DataTemplate>
27+
</Setter.Value>
28+
</Setter>
29+
</Style>
30+
</dragablz:TabablzControl.Style>
31+
</dragablz:TabablzControl>
32+
</Grid>
33+
</Controls:MetroWindow>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Dragablz;
2+
using MahApps.Metro.Controls;
3+
using NETworkManager.Views;
4+
5+
namespace NETworkManager.Controls
6+
{
7+
/// <summary>
8+
/// Interaktionslogik für Settings.xaml
9+
/// </summary>
10+
public partial class DragablzPortScannerTabHostWindow : MetroWindow
11+
{
12+
public DragablzPortScannerTabHostWindow()
13+
{
14+
InitializeComponent();
15+
DataContext = this;
16+
}
17+
18+
#region ICommand & Actions
19+
public ItemActionCallback CloseItemCommand
20+
{
21+
get { return CloseItemAction; }
22+
}
23+
24+
private void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
25+
{
26+
((args.DragablzItem.Content as DragablzPortScannerTabItem).View as PortScannerView).CloseTab();
27+
}
28+
#endregion
29+
}
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using NETworkManager.Utilities;
2+
using NETworkManager.Views;
3+
4+
namespace NETworkManager.Controls
5+
{
6+
public class DragablzPortScannerTabItem : ViewModelBase
7+
{
8+
private string _header;
9+
public string Header
10+
{
11+
get { return _header; }
12+
set
13+
{
14+
if (value == _header)
15+
return;
16+
17+
_header = value;
18+
OnPropertyChanged();
19+
}
20+
}
21+
22+
public PortScannerView View { get; set; }
23+
public int ID { get; set; }
24+
25+
public DragablzPortScannerTabItem(string header, PortScannerView view, int id)
26+
{
27+
Header = header;
28+
View = view;
29+
ID = id;
30+
}
31+
}
32+
}

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
400400
#region Application Views
401401
NetworkInterfaceView networkInterfaceView;
402402
IPScannerHostView ipScannerHostView;
403-
PortScannerView portScannerView;
403+
PortScannerHostView portScannerHostView;
404404
PingHostView pingHostView;
405405
TracerouteHostView tracerouteHostView;
406406
DNSLookupView dnsLookupView;
@@ -435,10 +435,10 @@ private void ChangeApplicationView(ApplicationViewManager.Name name)
435435
contentControlApplication.Content = ipScannerHostView;
436436
break;
437437
case ApplicationViewManager.Name.PortScanner:
438-
if (portScannerView == null)
439-
portScannerView = new PortScannerView();
438+
if (portScannerHostView == null)
439+
portScannerHostView = new PortScannerHostView();
440440

441-
contentControlApplication.Content = portScannerView;
441+
contentControlApplication.Content = portScannerHostView;
442442
break;
443443
case ApplicationViewManager.Name.Ping:
444444
if (pingHostView == null)

Source/NETworkManager/NETworkManager.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,15 @@
212212
<Compile Include="3rdParty\Heijden.DNS\Response.cs" />
213213
<Compile Include="3rdParty\Heijden.DNS\RR.cs" />
214214
<Compile Include="3rdParty\Heijden.DNS\Structs.cs" />
215+
<Compile Include="Controls\DragablzPortScannerInterTabClient.cs" />
215216
<Compile Include="Controls\DragablzIPScannerInterTabClient.cs" />
217+
<Compile Include="Controls\DragablzPortScannerTabHostWindow.xaml.cs">
218+
<DependentUpon>DragablzPortScannerTabHostWindow.xaml</DependentUpon>
219+
</Compile>
216220
<Compile Include="Controls\DragablzIPScannerTabHostWindow.xaml.cs">
217221
<DependentUpon>DragablzIPScannerTabHostWindow.xaml</DependentUpon>
218222
</Compile>
223+
<Compile Include="Controls\DragablzPortScannerTabItem.cs" />
219224
<Compile Include="Controls\DragablzIPScannerTabItem.cs" />
220225
<Compile Include="Controls\DragablzTracerouteInterTabClient.cs" />
221226
<Compile Include="Controls\DragablzTracerouteTabHostWindow.xaml.cs">
@@ -286,6 +291,7 @@
286291
<Compile Include="Validators\MultipleHostsValidator.cs" />
287292
<Compile Include="Validators\HttpAndHttpsUriValidator.cs" />
288293
<Compile Include="Validators\SubnetCalculatorSubnetValidator.cs" />
294+
<Compile Include="ViewModels\PortScannerHostViewModel.cs" />
289295
<Compile Include="ViewModels\IPScannerHostViewModel.cs" />
290296
<Compile Include="ViewModels\TracerouteProfileViewModel.cs" />
291297
<Compile Include="ViewModels\TracerouteHostViewModel.cs" />
@@ -340,6 +346,9 @@
340346
<DependentUpon>RemoteDesktopControl.xaml</DependentUpon>
341347
</Compile>
342348
<Compile Include="ViewModels\SettingsUpdateViewModel.cs" />
349+
<Compile Include="Views\PortScannerHostView.xaml.cs">
350+
<DependentUpon>PortScannerHostView.xaml</DependentUpon>
351+
</Compile>
343352
<Compile Include="Views\IPScannerHostView.xaml.cs">
344353
<DependentUpon>IPScannerHostView.xaml</DependentUpon>
345354
</Compile>
@@ -459,6 +468,10 @@
459468
</Compile>
460469
<Compile Include="WpfHelper\PasswordBoxBindingBehavior.cs" />
461470
<Compile Include="WpfHelper\ProtocolSettingsLayout.cs" />
471+
<Page Include="Controls\DragablzPortScannerTabHostWindow.xaml">
472+
<Generator>MSBuild:Compile</Generator>
473+
<SubType>Designer</SubType>
474+
</Page>
462475
<Page Include="Controls\DragablzIPScannerTabHostWindow.xaml">
463476
<Generator>MSBuild:Compile</Generator>
464477
<SubType>Designer</SubType>
@@ -594,6 +607,10 @@
594607
<SubType>Designer</SubType>
595608
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
596609
</None>
610+
<Page Include="Views\PortScannerHostView.xaml">
611+
<Generator>MSBuild:Compile</Generator>
612+
<SubType>Designer</SubType>
613+
</Page>
597614
<Page Include="Views\IPScannerHostView.xaml">
598615
<Generator>MSBuild:Compile</Generator>
599616
<SubType>Designer</SubType>

Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.ComponentModel;
99
using System;
1010
using System.Windows.Data;
11-
using System.Linq;
1211
using MahApps.Metro.Controls.Dialogs;
1312

1413
namespace NETworkManager.ViewModels
@@ -354,7 +353,7 @@ private void AddIPScannerTab(string host = null)
354353
{
355354
_tabId++;
356355

357-
TabItems.Add(new DragablzIPScannerTabItem(host ?? LocalizationManager.GetStringByKey("String_Header_NewTab"), new IPScannerView(_tabId, host), _tabId));
356+
TabItems.Add(new DragablzIPScannerTabItem(LocalizationManager.GetStringByKey("String_Header_NewTab"), new IPScannerView(_tabId, host), _tabId));
358357

359358
SelectedTabIndex = TabItems.Count - 1;
360359
}

Source/NETworkManager/ViewModels/IPScannerViewModel.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,7 @@ public IPScannerViewModel(int tabId, string ipRange)
277277
// Result view
278278
_ipScanResultView = CollectionViewSource.GetDefaultView(IPScanResult);
279279
_ipScanResultView.SortDescriptions.Add(new SortDescription(nameof(IPScannerHostInfo.PingInfo) + "." + nameof(PingInfo.IPAddressInt32), ListSortDirection.Ascending));
280-
281-
// Load profiles
282-
if (IPScannerProfileManager.Profiles == null)
283-
IPScannerProfileManager.Load();
284-
280+
285281
LoadSettings();
286282

287283
// Detect if settings have changed...

Source/NETworkManager/ViewModels/PingHostViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ private void AddPingTab(string host = null)
367367
{
368368
_tabId++;
369369

370-
TabItems.Add(new DragablzPingTabItem(host ?? LocalizationManager.GetStringByKey("String_Header_NewTab"), new PingView(_tabId, host), _tabId));
370+
TabItems.Add(new DragablzPingTabItem(LocalizationManager.GetStringByKey("String_Header_NewTab"), new PingView(_tabId, host), _tabId));
371371

372372
SelectedTabIndex = TabItems.Count - 1;
373373
}

0 commit comments

Comments
 (0)