Skip to content

Commit 6f50b0b

Browse files
authored
Issue/767 (BornToBeRoot#768)
* Fix namespace * Fix nullreferenceexception * Return exit code on error * Changelog added, Broken link fixed Co-authored-by: BornToBeRoot <BornToBeRoot@users.noreply.github.com>
1 parent e4c0395 commit 6f50b0b

9 files changed

Lines changed: 55 additions & 50 deletions

File tree

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
1-
using NETworkManager.Profiles;
2-
using NETworkManager.Models.RemoteDesktop;
1+
using NETworkManager.Models.RemoteDesktop;
32
using NETworkManager.Settings;
43

5-
namespace NETworkManager.Models.RemoteDesktopTMP
4+
namespace NETworkManager.Profiles.Application
65
{
76
public static class RemoteDesktop
87
{
98
public static RemoteDesktopSessionInfo CreateSessionInfo(ProfileInfo profileInfo = null)
109
{
10+
if (profileInfo == null)
11+
return new RemoteDesktopSessionInfo();
12+
1113
var info = new RemoteDesktopSessionInfo
1214
{
13-
Hostname = profileInfo?.Host,
15+
// Hostname
16+
Hostname = profileInfo.Host,
1417

1518
// Display
16-
AdjustScreenAutomatically = profileInfo != null && profileInfo.RemoteDesktop_OverrideDisplay ? profileInfo.RemoteDesktop_AdjustScreenAutomatically : SettingsManager.Current.RemoteDesktop_AdjustScreenAutomatically,
17-
UseCurrentViewSize = profileInfo != null && profileInfo.RemoteDesktop_OverrideDisplay ? profileInfo.RemoteDesktop_UseCurrentViewSize : SettingsManager.Current.RemoteDesktop_UseCurrentViewSize,
18-
DesktopWidth = profileInfo != null && profileInfo.RemoteDesktop_OverrideDisplay ? (profileInfo.RemoteDesktop_UseCustomScreenSize ? profileInfo.RemoteDesktop_CustomScreenWidth : profileInfo.RemoteDesktop_ScreenWidth) : (SettingsManager.Current.RemoteDesktop_UseCustomScreenSize ? SettingsManager.Current.RemoteDesktop_CustomScreenWidth : SettingsManager.Current.RemoteDesktop_ScreenWidth),
19-
DesktopHeight = profileInfo != null && profileInfo.RemoteDesktop_OverrideDisplay ? (profileInfo.RemoteDesktop_UseCustomScreenSize ? profileInfo.RemoteDesktop_CustomScreenHeight : profileInfo.RemoteDesktop_ScreenHeight) : (SettingsManager.Current.RemoteDesktop_UseCustomScreenSize ? SettingsManager.Current.RemoteDesktop_CustomScreenHeight : SettingsManager.Current.RemoteDesktop_ScreenHeight),
20-
ColorDepth = profileInfo != null && profileInfo.RemoteDesktop_OverrideColorDepth ? profileInfo.RemoteDesktop_ColorDepth : SettingsManager.Current.RemoteDesktop_ColorDepth,
19+
AdjustScreenAutomatically = profileInfo.RemoteDesktop_OverrideDisplay ? profileInfo.RemoteDesktop_AdjustScreenAutomatically : SettingsManager.Current.RemoteDesktop_AdjustScreenAutomatically,
20+
UseCurrentViewSize = profileInfo.RemoteDesktop_OverrideDisplay ? profileInfo.RemoteDesktop_UseCurrentViewSize : SettingsManager.Current.RemoteDesktop_UseCurrentViewSize,
21+
DesktopWidth = profileInfo.RemoteDesktop_OverrideDisplay ? (profileInfo.RemoteDesktop_UseCustomScreenSize ? profileInfo.RemoteDesktop_CustomScreenWidth : profileInfo.RemoteDesktop_ScreenWidth) : (SettingsManager.Current.RemoteDesktop_UseCustomScreenSize ? SettingsManager.Current.RemoteDesktop_CustomScreenWidth : SettingsManager.Current.RemoteDesktop_ScreenWidth),
22+
DesktopHeight = profileInfo.RemoteDesktop_OverrideDisplay ? (profileInfo.RemoteDesktop_UseCustomScreenSize ? profileInfo.RemoteDesktop_CustomScreenHeight : profileInfo.RemoteDesktop_ScreenHeight) : (SettingsManager.Current.RemoteDesktop_UseCustomScreenSize ? SettingsManager.Current.RemoteDesktop_CustomScreenHeight : SettingsManager.Current.RemoteDesktop_ScreenHeight),
23+
ColorDepth = profileInfo.RemoteDesktop_OverrideColorDepth ? profileInfo.RemoteDesktop_ColorDepth : SettingsManager.Current.RemoteDesktop_ColorDepth,
2124

2225
// Network
23-
Port = profileInfo != null && profileInfo.RemoteDesktop_OverridePort ? profileInfo.RemoteDesktop_Port : SettingsManager.Current.RemoteDesktop_Port,
26+
Port = profileInfo.RemoteDesktop_OverridePort ? profileInfo.RemoteDesktop_Port : SettingsManager.Current.RemoteDesktop_Port,
2427

2528
// Authentication
26-
EnableCredSspSupport = profileInfo != null && profileInfo.RemoteDesktop_OverrideCredSspSupport ? profileInfo.RemoteDesktop_EnableCredSspSupport : SettingsManager.Current.RemoteDesktop_EnableCredSspSupport,
27-
AuthenticationLevel = profileInfo != null && profileInfo.RemoteDesktop_OverrideAuthenticationLevel ? profileInfo.RemoteDesktop_AuthenticationLevel : SettingsManager.Current.RemoteDesktop_AuthenticationLevel,
29+
EnableCredSspSupport = profileInfo.RemoteDesktop_OverrideCredSspSupport ? profileInfo.RemoteDesktop_EnableCredSspSupport : SettingsManager.Current.RemoteDesktop_EnableCredSspSupport,
30+
AuthenticationLevel = profileInfo.RemoteDesktop_OverrideAuthenticationLevel ? profileInfo.RemoteDesktop_AuthenticationLevel : SettingsManager.Current.RemoteDesktop_AuthenticationLevel,
2831

2932
// Remote audio
30-
AudioRedirectionMode = profileInfo != null && profileInfo.RemoteDesktop_OverrideAudioRedirectionMode ? profileInfo.RemoteDesktop_AudioRedirectionMode : SettingsManager.Current.RemoteDesktop_AudioRedirectionMode,
31-
AudioCaptureRedirectionMode = profileInfo != null && profileInfo.RemoteDesktop_OverrideAudioCaptureRedirectionMode ? profileInfo.RemoteDesktop_AudioCaptureRedirectionMode : SettingsManager.Current.RemoteDesktop_AudioCaptureRedirectionMode,
33+
AudioRedirectionMode = profileInfo.RemoteDesktop_OverrideAudioRedirectionMode ? profileInfo.RemoteDesktop_AudioRedirectionMode : SettingsManager.Current.RemoteDesktop_AudioRedirectionMode,
34+
AudioCaptureRedirectionMode = profileInfo.RemoteDesktop_OverrideAudioCaptureRedirectionMode ? profileInfo.RemoteDesktop_AudioCaptureRedirectionMode : SettingsManager.Current.RemoteDesktop_AudioCaptureRedirectionMode,
3235

3336
// Keyboard
34-
KeyboardHookMode = profileInfo != null && profileInfo.RemoteDesktop_OverrideApplyWindowsKeyCombinations ? profileInfo.RemoteDesktop_KeyboardHookMode : SettingsManager.Current.RemoteDesktop_KeyboardHookMode,
37+
KeyboardHookMode = profileInfo.RemoteDesktop_OverrideApplyWindowsKeyCombinations ? profileInfo.RemoteDesktop_KeyboardHookMode : SettingsManager.Current.RemoteDesktop_KeyboardHookMode,
3538

3639
// Local devices and resources
37-
RedirectClipboard = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectClipboard ? profileInfo.RemoteDesktop_RedirectClipboard : SettingsManager.Current.RemoteDesktop_RedirectClipboard,
38-
RedirectDevices = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectDevices ? profileInfo.RemoteDesktop_RedirectDevices : SettingsManager.Current.RemoteDesktop_RedirectDevices,
39-
RedirectDrives = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectDrives ? profileInfo.RemoteDesktop_RedirectDrives : SettingsManager.Current.RemoteDesktop_RedirectDrives,
40-
RedirectPorts = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectPorts ? profileInfo.RemoteDesktop_RedirectPorts : SettingsManager.Current.RemoteDesktop_RedirectPorts,
41-
RedirectSmartCards = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectSmartcards ? profileInfo.RemoteDesktop_RedirectSmartCards : SettingsManager.Current.RemoteDesktop_RedirectSmartCards,
42-
RedirectPrinters = profileInfo != null && profileInfo.RemoteDesktop_OverrideRedirectPrinters ? profileInfo.RemoteDesktop_RedirectPrinters : SettingsManager.Current.RemoteDesktop_RedirectPrinters,
40+
RedirectClipboard = profileInfo.RemoteDesktop_OverrideRedirectClipboard ? profileInfo.RemoteDesktop_RedirectClipboard : SettingsManager.Current.RemoteDesktop_RedirectClipboard,
41+
RedirectDevices = profileInfo.RemoteDesktop_OverrideRedirectDevices ? profileInfo.RemoteDesktop_RedirectDevices : SettingsManager.Current.RemoteDesktop_RedirectDevices,
42+
RedirectDrives = profileInfo.RemoteDesktop_OverrideRedirectDrives ? profileInfo.RemoteDesktop_RedirectDrives : SettingsManager.Current.RemoteDesktop_RedirectDrives,
43+
RedirectPorts = profileInfo.RemoteDesktop_OverrideRedirectPorts ? profileInfo.RemoteDesktop_RedirectPorts : SettingsManager.Current.RemoteDesktop_RedirectPorts,
44+
RedirectSmartCards = profileInfo.RemoteDesktop_OverrideRedirectSmartcards ? profileInfo.RemoteDesktop_RedirectSmartCards : SettingsManager.Current.RemoteDesktop_RedirectSmartCards,
45+
RedirectPrinters = profileInfo.RemoteDesktop_OverrideRedirectPrinters ? profileInfo.RemoteDesktop_RedirectPrinters : SettingsManager.Current.RemoteDesktop_RedirectPrinters,
4346

4447
// Experience
45-
PersistentBitmapCaching = profileInfo != null && profileInfo.RemoteDesktop_OverridePersistentBitmapCaching ? profileInfo.RemoteDesktop_PersistentBitmapCaching : SettingsManager.Current.RemoteDesktop_PersistentBitmapCaching,
46-
ReconnectIfTheConnectionIsDropped = profileInfo != null && profileInfo.RemoteDesktop_OverrideReconnectIfTheConnectionIsDropped ? profileInfo.RemoteDesktop_ReconnectIfTheConnectionIsDropped : SettingsManager.Current.RemoteDesktop_ReconnectIfTheConnectionIsDropped,
48+
PersistentBitmapCaching = profileInfo.RemoteDesktop_OverridePersistentBitmapCaching ? profileInfo.RemoteDesktop_PersistentBitmapCaching : SettingsManager.Current.RemoteDesktop_PersistentBitmapCaching,
49+
ReconnectIfTheConnectionIsDropped = profileInfo.RemoteDesktop_OverrideReconnectIfTheConnectionIsDropped ? profileInfo.RemoteDesktop_ReconnectIfTheConnectionIsDropped : SettingsManager.Current.RemoteDesktop_ReconnectIfTheConnectionIsDropped,
4750

4851
// Performance
49-
NetworkConnectionType = profileInfo != null && profileInfo.RemoteDesktop_OverrideNetworkConnectionType ? profileInfo.RemoteDesktop_NetworkConnectionType : SettingsManager.Current.RemoteDesktop_NetworkConnectionType,
50-
DesktopBackground = profileInfo != null && profileInfo.RemoteDesktop_OverrideDesktopBackground ? profileInfo.RemoteDesktop_DesktopBackground : SettingsManager.Current.RemoteDesktop_DesktopBackground,
51-
FontSmoothing = profileInfo != null && profileInfo.RemoteDesktop_OverrideFontSmoothing ? profileInfo.RemoteDesktop_FontSmoothing : SettingsManager.Current.RemoteDesktop_FontSmoothing,
52-
DesktopComposition = profileInfo != null && profileInfo.RemoteDesktop_OverrideDesktopComposition ? profileInfo.RemoteDesktop_DesktopComposition : SettingsManager.Current.RemoteDesktop_DesktopComposition,
53-
ShowWindowContentsWhileDragging = profileInfo != null && profileInfo.RemoteDesktop_OverrideShowWindowContentsWhileDragging ? profileInfo.RemoteDesktop_ShowWindowContentsWhileDragging : SettingsManager.Current.RemoteDesktop_ShowWindowContentsWhileDragging,
54-
MenuAndWindowAnimation = profileInfo != null && profileInfo.RemoteDesktop_OverrideMenuAndWindowAnimation ? profileInfo.RemoteDesktop_MenuAndWindowAnimation : SettingsManager.Current.RemoteDesktop_MenuAndWindowAnimation,
55-
VisualStyles = profileInfo != null && profileInfo.RemoteDesktop_OverrideVisualStyles ? profileInfo.RemoteDesktop_VisualStyles : SettingsManager.Current.RemoteDesktop_VisualStyles,
52+
NetworkConnectionType = profileInfo.RemoteDesktop_OverrideNetworkConnectionType ? profileInfo.RemoteDesktop_NetworkConnectionType : SettingsManager.Current.RemoteDesktop_NetworkConnectionType,
53+
DesktopBackground = profileInfo.RemoteDesktop_OverrideDesktopBackground ? profileInfo.RemoteDesktop_DesktopBackground : SettingsManager.Current.RemoteDesktop_DesktopBackground,
54+
FontSmoothing = profileInfo.RemoteDesktop_OverrideFontSmoothing ? profileInfo.RemoteDesktop_FontSmoothing : SettingsManager.Current.RemoteDesktop_FontSmoothing,
55+
DesktopComposition = profileInfo.RemoteDesktop_OverrideDesktopComposition ? profileInfo.RemoteDesktop_DesktopComposition : SettingsManager.Current.RemoteDesktop_DesktopComposition,
56+
ShowWindowContentsWhileDragging = profileInfo.RemoteDesktop_OverrideShowWindowContentsWhileDragging ? profileInfo.RemoteDesktop_ShowWindowContentsWhileDragging : SettingsManager.Current.RemoteDesktop_ShowWindowContentsWhileDragging,
57+
MenuAndWindowAnimation = profileInfo.RemoteDesktop_OverrideMenuAndWindowAnimation ? profileInfo.RemoteDesktop_MenuAndWindowAnimation : SettingsManager.Current.RemoteDesktop_MenuAndWindowAnimation,
58+
VisualStyles = profileInfo.RemoteDesktop_OverrideVisualStyles ? profileInfo.RemoteDesktop_VisualStyles : SettingsManager.Current.RemoteDesktop_VisualStyles
5659
};
5760

5861
// Set credentials
59-
if(profileInfo.RemoteDesktop_UseCredentials)
62+
if (profileInfo.RemoteDesktop_UseCredentials)
6063
{
6164
info.CustomCredentials = true;
6265

@@ -65,8 +68,6 @@ public static RemoteDesktopSessionInfo CreateSessionInfo(ProfileInfo profileInfo
6568
}
6669

6770
return info;
68-
}
69-
70-
71+
}
7172
}
7273
}

Source/NETworkManager.Profiles/Application/WakeOnLan.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using NETworkManager.Models.Network;
2-
using NETworkManager.Profiles;
32
using NETworkManager.Settings;
43
using System.Net;
54

6-
namespace NETworkManager.Models.NetworkTMP
5+
namespace NETworkManager.Profiles.Application
76
{
87
public static class WakeOnLAN
98
{
109
public static WakeOnLANInfo CreateInfo(ProfileInfo profileInfo)
1110
{
1211
var info = new WakeOnLANInfo
1312
{
14-
MagicPacket = Network.WakeOnLAN.CreateMagicPacket(profileInfo.WakeOnLAN_MACAddress),
13+
MagicPacket = Models.Network.WakeOnLAN.CreateMagicPacket(profileInfo.WakeOnLAN_MACAddress),
1514
Broadcast = IPAddress.Parse(profileInfo.WakeOnLAN_Broadcast),
1615
Port = profileInfo.WakeOnLAN_OverridePort ? profileInfo.WakeOnLAN_Port : SettingsManager.Current.WakeOnLAN_Port
1716
};

Source/NETworkManager.Profiles/Application/WebConsole.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using NETworkManager.Profiles;
2-
using NETworkManager.Models.WebConsole;
1+
using NETworkManager.Models.WebConsole;
32

4-
namespace NETworkManager.Models.WebConsoleTMP
3+
namespace NETworkManager.Profiles.Application
54
{
65
public class WebConsole
76
{

Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private static string GetDisconnectReason(int reason)
420420
case 8711:
421421
return Localization.Resources.Strings.RemoteDesktopDisconnectReason_SslErrSmartcardCardBlocked;
422422
default:
423-
return string.Empty;
423+
return "Disconnect reason code " + reason + " not found in resources!" + Environment.NewLine + "(You can report this on GitHub)";
424424
}
425425
}
426426
#endregion

Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private async Task Connect(string host = null)
371371
AddHostToHistory(instance.Host);
372372

373373
// Create new session info with default settings
374-
var sessionInfo = Models.RemoteDesktopTMP.RemoteDesktop.CreateSessionInfo();
374+
var sessionInfo = NETworkManager.Profiles.Application.RemoteDesktop.CreateSessionInfo();
375375

376376
sessionInfo.Hostname = instance.Host;
377377

@@ -407,7 +407,7 @@ private void ConnectProfile()
407407
{
408408
var profileInfo = SelectedProfile;
409409

410-
var sessionInfo = Models.RemoteDesktopTMP.RemoteDesktop.CreateSessionInfo(profileInfo);
410+
var sessionInfo = NETworkManager.Profiles.Application.RemoteDesktop.CreateSessionInfo(profileInfo);
411411

412412
Connect(sessionInfo, profileInfo.Name);
413413
}
@@ -417,7 +417,7 @@ private async Task ConnectProfileAs()
417417
{
418418
var profileInfo = SelectedProfile;
419419

420-
var sessionInfo = Models.RemoteDesktopTMP.RemoteDesktop.CreateSessionInfo(profileInfo);
420+
var sessionInfo = NETworkManager.Profiles.Application.RemoteDesktop.CreateSessionInfo(profileInfo);
421421

422422
var customDialog = new CustomDialog
423423
{

Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private void WakeUpAction()
324324

325325
private void WakeUpProfileAction()
326326
{
327-
WakeUp(Models.NetworkTMP.WakeOnLAN.CreateInfo(SelectedProfile));
327+
WakeUp(NETworkManager.Profiles.Application.WakeOnLAN.CreateInfo(SelectedProfile));
328328
}
329329

330330
public ICommand AddProfileCommand => new RelayCommand(p => AddProfileAction());

Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ private async Task Connect()
367367
}
368368

369369
private void ConnectProfile()
370-
{
371-
Connect(Models.WebConsoleTMP.WebConsole.CreateSessionInfo(SelectedProfile), SelectedProfile.Name);
370+
{
371+
Connect(NETworkManager.Profiles.Application.WebConsole.CreateSessionInfo(SelectedProfile), SelectedProfile.Name);
372372
}
373373

374374
private void Connect(WebConsoleSessionInfo sessionInfo, string header = null)

docs/01_Home.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ description: "A powerful tool for managing networks and troubleshoot network pro
66
permalink: /
77
---
88

9-
# Welcome
9+
# NETworkManager
10+
11+
A powerful tool for managing networks and troubleshoot network problems!
1012

13+
<!--
14+
15+
# Welcome
1116
NETworkManager is a powerful tool for managing networks and troubleshoot network problems! You can view and configure network interfaces, scan for wifi networks, capture lldp or cdp packages, perform an IP or port scan, ping your hosts, and troubleshoot your connection using traceroute or a DNS lookup.
1217
1318
It contains a remote desktop and PowerShell for managing Windows devices. You can use PuTTY, TigerVNC or the web console to administrate Linux or other devices (e.g. switches). And best of all... everything has tabs and you can create a profile for each of your hosts that can be used across all features. The profile files can be stored encrypted on disk and protected with a master password to provide an additional layer of security.
1419
1520
There are some more features such as a subnet calculator, a Whois lookup or a database in which you can find MAC address vendors or TCP / UDP ports with a description. The best way is to download the tool and try it yourself!
21+
-->
1622

1723
<img alt="NETworkManager" src="Preview.gif" />
1824

@@ -54,6 +60,6 @@ There are some more features such as a subnet calculator, a Whois lookup or a da
5460
<a href='https://github.com/BornToBeRoot/NETworkManager' target="_blank"><button type="button" name="button" class="btn">Github :octocat:</button></a>
5561
<a href='./Download'><button type="button" name="button" class="btn">Download :package:</button></a>
5662
<a href='./Changelog'><button type="button" name="button" class="btn">Changelog :page_with_curl:</button></a>
57-
<a href='./Application'><button type="button" name="button" class="btn">Documentation :book:</button></a>
63+
<a href='./Documentation'><button type="button" name="button" class="btn">Documentation :book:</button></a>
5864
</p>
5965
</div>

docs/04_Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Date: **xx.xx.2021**
2323
2424
2525
## Bugfixes
26-
26+
- App crash fixed when Remote Desktop is opened from a differnet view [#767](https://github.com/BornToBeRoot/NETworkManager/issues/767){:target="_blank"}
2727
2828
## Other
2929

0 commit comments

Comments
 (0)