Skip to content

Commit 14d7d19

Browse files
authored
Merge pull request #57 from BornToBeRoot/rdp
Remote desktop feature
2 parents 6b0e5f3 + 09dd16f commit 14d7d19

69 files changed

Lines changed: 1809 additions & 169 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
param(
2+
[Parameter(
3+
Position=0,
4+
Mandatory=$true)]
5+
[String]$OutPath
6+
)
7+
8+
# Fix wrong path
9+
# Quotation marks are required if a blank is in the path... If there is no blank space in the path, a quote will be add to the end...
10+
# VS prebuild event call: PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File "$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1" "$(TargetDir)"
11+
if(-not($OutPath.StartsWith('"')))
12+
{
13+
$OutPath = $OutPath.TrimEnd('"')
14+
}
15+
16+
# Test if files are already there...
17+
if((Test-Path -Path "$OutPath\MSTSCLib.dll") -and (Test-Path -Path "$OutPath\AxMSTSCLib.dll"))
18+
{
19+
Write-Host "MSTSCLib.dll and AxMSTSCLib.dll already created!"
20+
return
21+
}
22+
23+
# x86 or x64
24+
$ProgramFiles_Path = ${Env:ProgramFiles(x86)}
25+
26+
if([String]::IsNullOrEmpty($ProgramFiles_Path))
27+
{
28+
$ProgramFiles_Path = $Env:ProgramFiles
29+
}
30+
31+
# Get aximp from sdk
32+
$files = (Get-ChildItem -Path "$ProgramFiles_Path\Microsoft SDKs\Windows" -Recurse -Filter "aximp.exe" -File)
33+
34+
if($files.Count -eq 0)
35+
{
36+
Write-Host "Aximp.exe not found on this system!"
37+
exit 2
38+
}
39+
40+
# Change location
41+
Write-Host "Change location to: $OutPath"
42+
Set-Location -Path $OutPath
43+
44+
# Create MSTSCLib.dll and AxMSTSCLib.dll
45+
Write-Host "Creating MSTSCLib.dll and AxMSTSCLib.dll ..."
46+
Start-Process -FilePath $files[$files.Length -1].FullName -ArgumentList "$($Env:windir)\system32\mstscax.dll" -Wait -NoNewWindow

Source/NETworkManager/App.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
1515
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
1616
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatSlider.xaml" />
17+
<!-- Dragablz -->
18+
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/MahApps.xaml" />
1719
<!-- Localization -->
1820
<ResourceDictionary Source="/Resources/Localization/Resources.en-US.xaml" />
1921
<!-- Context menu (import berfore styles)-->
@@ -24,9 +26,9 @@
2426
<ResourceDictionary Source="/Resources/Styles/ButtonStyles.xaml" />
2527
<ResourceDictionary Source="/Resources/Styles/ComboBoxStyles.xaml" />
2628
<ResourceDictionary Source="/Resources/Styles/DataGridStyles.xaml" />
27-
<ResourceDictionary Source="/Resources/Styles/ExpanderStyles.xaml" />
2829
<ResourceDictionary Source="/Resources/Styles/GroupBoxStyles.xaml" />
2930
<ResourceDictionary Source="/Resources/Styles/NumericUpDownStyles.xaml" />
31+
<ResourceDictionary Source="/Resources/Styles/PasswordBoxStyles.xaml" />
3032
<ResourceDictionary Source="/Resources/Styles/ScrollBarStyles.xaml" />
3133
<ResourceDictionary Source="/Resources/Styles/ScrollViewerStyles.xaml" />
3234
<ResourceDictionary Source="/Resources/Styles/TabControlStyles.xaml" />
@@ -35,6 +37,9 @@
3537
<ResourceDictionary Source="/Resources/Styles/ToogleSwitchStyles.xaml" />
3638
<ResourceDictionary Source="/Resources/Styles/ToolTipStyles.xaml" />
3739
<ResourceDictionary Source="/Resources/Styles/WindowStyles.xaml" />
40+
<!-- Dependent styles -->
41+
<ResourceDictionary Source="/Resources/Styles/DragablzStyles.xaml" /> <!-- Requires button and textbox styles -->
42+
<ResourceDictionary Source="/Resources/Styles/ExpanderStyles.xaml" /> <!-- Required button styles -->
3843
</ResourceDictionary.MergedDictionaries>
3944
</ResourceDictionary>
4045
</Application.Resources>
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 DragablzMainInterTabClient : IInterTabClient
7+
{
8+
public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
9+
{
10+
DragablzTabHostWindow dragablzTabHostWindow = new DragablzTabHostWindow();
11+
return new NewTabHost<DragablzTabHostWindow>(dragablzTabHostWindow, dragablzTabHostWindow.TabsContainer);
12+
}
13+
14+
public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
15+
{
16+
return TabEmptiedResponse.DoNothing;
17+
}
18+
}
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace NETworkManager.Controls
2+
{
3+
public class DragablzTabContent
4+
{
5+
public string Header { get; set; }
6+
public object Content { get; set; }
7+
8+
public DragablzTabContent(string header, object content)
9+
{
10+
Header = header;
11+
Content = content;
12+
}
13+
}
14+
}
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.Controls.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.Controls
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+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<UserControl x:Class="NETworkManager.Controls.RemoteDesktopControl"
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:mstsc ="clr-namespace:AxMSTSCLib;assembly=AxMSTSCLib"
7+
mc:Ignorable="d">
8+
<UserControl.Resources>
9+
10+
</UserControl.Resources>
11+
<Grid>
12+
<WindowsFormsHost MaxWidth="{Binding ElementName=rdpClient, Path=DesktopWidth}" MaxHeight="{Binding ElementName=rdpClient, Path=DesktopHeight}" Visibility="{Binding HideRdpClient}">
13+
<mstsc:AxMsRdpClient9NotSafeForScripting x:Name="rdpClient" />
14+
</WindowsFormsHost>
15+
</Grid>
16+
</UserControl>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using NETworkManager.Models.RemoteDesktop;
2+
using System.Windows.Controls;
3+
4+
namespace NETworkManager.Controls
5+
{
6+
public partial class RemoteDesktopControl : UserControl
7+
{
8+
public RemoteDesktopControl(RemoteDesktopSessionInfo info)
9+
{
10+
InitializeComponent();
11+
12+
rdpClient.Server = info.Hostname;
13+
14+
// AdvancedSettings
15+
rdpClient.AdvancedSettings9.AuthenticationLevel = 2;
16+
rdpClient.AdvancedSettings9.EnableCredSspSupport = true;
17+
rdpClient.AdvancedSettings9.RedirectClipboard = false;
18+
rdpClient.AdvancedSettings9.RedirectDevices = false;
19+
rdpClient.AdvancedSettings9.RedirectDrives = false;
20+
rdpClient.AdvancedSettings9.RedirectPorts = false;
21+
rdpClient.AdvancedSettings9.RedirectSmartCards = false;
22+
rdpClient.AdvancedSettings9.RedirectPrinters = false;
23+
24+
// Display
25+
rdpClient.ColorDepth = 24; // 8, 15, 16, 24
26+
rdpClient.DesktopHeight = 768;
27+
rdpClient.DesktopWidth = 1280;
28+
29+
// Events
30+
rdpClient.OnDisconnected += Mstsc_OnDisconnected;
31+
32+
rdpClient.Connect();
33+
}
34+
35+
private void Mstsc_OnDisconnected(object sender, AxMSTSCLib.IMsTscAxEvents_OnDisconnectedEvent e)
36+
{
37+
38+
// Add DC reason
39+
}
40+
}
41+
}

Source/NETworkManager/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@
527527
<RowDefinition Height="*" />
528528
</Grid.RowDefinitions>
529529
<Border x:Name="HeaderBorder" Grid.Row="0" BorderBrush="{DynamicResource GrayBrush8}" BorderThickness="0,0,0,1" MouseDown="HeaderBorder_MouseDown">
530-
<TextBlock VerticalAlignment="Center" Height="48" TextAlignment="Center" Style="{StaticResource HeaderTextBlock}" Text="{Binding SelectedApplicationViewInfo.TranslatedName}" Foreground="{DynamicResource GrayBrush3}" Margin="0" />
530+
<TextBlock VerticalAlignment="Center" Height="48" TextAlignment="Center" Style="{StaticResource HeaderTextBlock}" Text="{Binding SelectedApplicationViewInfo.TranslatedName}" Foreground="{DynamicResource GrayBrush3}" Margin="0" />
531531
</Border>
532532
<ContentControl x:Name="contentControlApplication" Grid.Row="1" Focusable="False" />
533533
</Grid>

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 16 additions & 5 deletions
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();
@@ -337,7 +337,8 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
337337
WakeOnLANView wakeOnLANView;
338338
PingView pingView;
339339
TracerouteView tracerouteView;
340-
DNSLookupView DNSLookupView;
340+
DNSLookupView dnsLookupView;
341+
RemoteDesktopView remoteDesktopView;
341342
WikiView wikiView;
342343

343344
private ApplicationViewManager.Name? currentApplicationViewName = null;
@@ -392,10 +393,16 @@ private void ChangeApplicationView(ApplicationViewManager.Name name)
392393
contentControlApplication.Content = tracerouteView;
393394
break;
394395
case ApplicationViewManager.Name.DNSLookup:
395-
if (DNSLookupView == null)
396-
DNSLookupView = new DNSLookupView();
396+
if (dnsLookupView == null)
397+
dnsLookupView = new DNSLookupView();
397398

398-
contentControlApplication.Content = DNSLookupView;
399+
contentControlApplication.Content = dnsLookupView;
400+
break;
401+
case ApplicationViewManager.Name.RemoteDesktop:
402+
if (remoteDesktopView == null)
403+
remoteDesktopView = new RemoteDesktopView();
404+
405+
contentControlApplication.Content = remoteDesktopView;
399406
break;
400407
case ApplicationViewManager.Name.Wiki:
401408
if (wikiView == null)
@@ -676,11 +683,15 @@ private async void CloseSettingsAction()
676683
settings.NegativeButtonText = System.Windows.Application.Current.Resources["String_Button_OK"] as string;
677684
settings.DefaultButtonFocus = MessageDialogResult.Affirmative;
678685

686+
ConfigurationManager.Current.FixAirspace = true;
687+
679688
if (await this.ShowMessageAsync(System.Windows.Application.Current.Resources["String_RestartRequired"] as string, System.Windows.Application.Current.Resources["String_RestartRequiredAfterSettingsChanged"] as string, MessageDialogStyle.AffirmativeAndNegative, settings) == MessageDialogResult.Affirmative)
680689
{
681690
RestartApplication();
682691
return;
683692
}
693+
694+
ConfigurationManager.Current.FixAirspace = false;
684695
}
685696

686697
// Change the transparency

0 commit comments

Comments
 (0)