Skip to content

Commit b87f45e

Browse files
committed
RemoteDesktop - ContextMenu added/MSTSCLib fixed
1 parent 942060a commit b87f45e

File tree

10 files changed

+1110
-792
lines changed

10 files changed

+1110
-792
lines changed

Scripts/PreBuildEventCommandLine.ps1

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ param(
55
[String]$OutPath
66
)
77

8+
# VS prebuild event call: PowerShell.exe -ExecutionPolicy Bypass -NoProfile -File "$(ProjectDir)..\..\Scripts\PreBuildEventCommandLine.ps1" "$(TargetDir)"
9+
810
# Fix wrong path
911
# 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)"
1112
if(-not($OutPath.StartsWith('"')))
1213
{
1314
$OutPath = $OutPath.TrimEnd('"')
@@ -16,35 +17,55 @@ if(-not($OutPath.StartsWith('"')))
1617
# Test if files are already there...
1718
if((Test-Path -Path "$OutPath\MSTSCLib.dll") -and (Test-Path -Path "$OutPath\AxMSTSCLib.dll"))
1819
{
19-
Write-Host "MSTSCLib.dll and AxMSTSCLib.dll already there!"
20+
Write-Host "MSTSCLib.dll and AxMSTSCLib.dll exist! Continue..."
2021
return
2122
}
2223

23-
# x86 or x64
24+
# Detect x86 or x64
2425
$ProgramFiles_Path = ${Env:ProgramFiles(x86)}
2526

2627
if([String]::IsNullOrEmpty($ProgramFiles_Path))
2728
{
2829
$ProgramFiles_Path = $Env:ProgramFiles
2930
}
3031

31-
# Get aximp from sdk
32-
$AximpPath = ((Get-ChildItem -Path "$ProgramFiles_Path\Microsoft SDKs\Windows" -Recurse -Filter "aximp.exe" -File) | Sort-Object FullName | Select-Object -First 1).FullName
32+
# Get aximp.exe, ildasm.exe and ilasm.exe from sdk
33+
$AximpPath = ((Get-ChildItem -Path "$ProgramFiles_Path\Microsoft SDKs\Windows" -Recurse -Filter "aximp.exe" -File) | Sort-Object CreationTime -Descending | Select-Object -First 1).FullName
34+
$IldasmPath = ((Get-ChildItem -Path "$ProgramFiles_Path\Microsoft SDKs\Windows" -Recurse -Filter "ildasm.exe" -File) | Sort-Object CreationTime | Select-Object -First 1).FullName
35+
$IlasmPath = ((Get-ChildItem -Path "$($Env:windir)\Microsoft.NET\Framework\" -Recurse -Filter "ilasm.exe" -File) | Sort-Object CreationTime | Select-Object -First 1).FullName
3336

34-
if([String]::IsNullOrEmpty($AximpPath))
37+
if([String]::IsNullOrEmpty($AximpPath) -or [String]::IsNullOrEmpty($IldasmPath) -or [String]::IsNullOrEmpty($IlasmPath))
3538
{
36-
Write-Host "Aximp.exe not found on this system!"
39+
Write-Host "Could not find sdk tools:`naximp.exe`t$AximpPath`nildasm.exe`t$IldasmPath`nilasm.exe`t$IlasmPath"
40+
3741
return
3842
}
39-
else
40-
{
41-
Write-Host "Using aximp.exe from: $AximpPath"
42-
}
4343

44-
# Change location
44+
# Change location to output folder...
4545
Write-Host "Change location to: $OutPath"
4646
Set-Location -Path $OutPath
4747

4848
# Create MSTSCLib.dll and AxMSTSCLib.dll
49-
Write-Host "Build MSTSCLib.dll and AxMSTSCLib.dll ..."
49+
Write-Host "Build MSTSCLib.dll and AxMSTSCLib.dll..."
50+
Write-Host "Using aximp.exe from: $AximpPath"
5051
Start-Process -FilePath $AximpPath -ArgumentList "$($Env:windir)\system32\mstscax.dll" -Wait -NoNewWindow
52+
53+
# Modify MSTSCLib.ddl to fix an issue with SendKeys (See: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/9095625c-4361-4e0b-bfcf-be15550b60a8/imsrdpclientnonscriptablesendkeys?forum=windowsgeneraldevelopmentissues&prof=required)
54+
Write-Host "Modify MSTSCLib.dll..."
55+
Write-Host "Using ildasm.exe from: $IldasmPath"
56+
57+
$MSTSCLibDLLPath = "$OutPath\MSTSCLib.dll"
58+
$MSTSCLibILPath = "$OutPath\MSTSCLib.il"
59+
60+
Start-Process -FilePath $IldasmPath -ArgumentList "$MSTSCLibDLLPath /out=$MSTSCLibILPath" -Wait -NoNewWindow
61+
62+
Write-Host "Replace ""[in] bool& pbArrayKeyUp"" with ""[in] bool[] marshal([+0]) pbArrayKeyUp"""
63+
(Get-Content -Path $MSTSCLibILPath).Replace("[in] bool& pbArrayKeyUp", "[in] bool[] marshal([+0]) pbArrayKeyUp") | Set-Content -Path $MSTSCLibILPath
64+
65+
Write-Host "Replace ""[in] int32& plKeyData"" with ""[in] int32[] marshal([+0]) plKeyData"""
66+
(Get-Content -Path $MSTSCLibILPath).Replace("[in] int32& plKeyData", "[in] int32[] marshal([+0]) plKeyData") | Set-Content -Path $MSTSCLibILPath
67+
68+
Start-Process -FilePath $IlasmPath -ArgumentList "/dll $MSTSCLibILPath /output:$MSTSCLibDllPath" -Wait -NoNewWindow
69+
70+
Remove-Item -Path "$MSTSCLibILPath"
71+
Remove-Item -Path "$OutPath\MSTSCLib.res"

Source/NETworkManager/Controls/DragablzTabHostWindow.xaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,113 @@
3737
</Setter.Value>
3838
</Setter>
3939
<Style.Triggers>
40+
<!-- Add ContextMenu for RemoteDesktop -->
41+
<DataTrigger Binding="{Binding ApplicationName}" Value="{x:Static networkManager:ApplicationViewManager+Name.RemoteDesktop}">
42+
<DataTrigger.Setters>
43+
<Setter Property="HeaderItemTemplate">
44+
<Setter.Value>
45+
<DataTemplate DataType="controls:DragablzTabItem">
46+
<Border BorderBrush="{DynamicResource GrayBrush8}" BorderThickness="0,0,1,0">
47+
<Grid>
48+
<Grid.ContextMenu>
49+
<ContextMenu>
50+
<MenuItem Header="{x:Static localization:Strings.Reconnect}" Command="{Binding Data.RemoteDesktop_ReconnectCommand, Source={StaticResource BindingProxy}}" CommandParameter="{Binding View}">
51+
<MenuItem.Icon>
52+
<Rectangle Width="16" Height="16" Fill="{DynamicResource GrayBrush3}">
53+
<Rectangle.OpacityMask>
54+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Restart}" />
55+
</Rectangle.OpacityMask>
56+
</Rectangle>
57+
</MenuItem.Icon>
58+
</MenuItem>
59+
<MenuItem Header="{x:Static localization:Strings.Disconnect}" Command="{Binding Data.RemoteDesktop_DisconnectCommand, Source={StaticResource BindingProxy}}" CommandParameter="{Binding View}">
60+
<MenuItem.Icon>
61+
<Rectangle Width="16" Height="16" Fill="{DynamicResource GrayBrush3}">
62+
<Rectangle.OpacityMask>
63+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Modern Kind=Disconnect}" />
64+
</Rectangle.OpacityMask>
65+
</Rectangle>
66+
</MenuItem.Icon>
67+
</MenuItem>
68+
<Separator />
69+
<MenuItem Header="{x:Static localization:Strings.Fullscreen}" Command="{Binding Data.RemoteDesktop_FullscreenCommand, Source={StaticResource BindingProxy}}" CommandParameter="{Binding View}">
70+
<MenuItem.Icon>
71+
<Rectangle Width="16" Height="16" Fill="{DynamicResource GrayBrush3}">
72+
<Rectangle.OpacityMask>
73+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Octicons Kind=ScreenFull}" />
74+
</Rectangle.OpacityMask>
75+
</Rectangle>
76+
</MenuItem.Icon>
77+
</MenuItem>
78+
<MenuItem Header="{x:Static localization:Strings.AdjustScreen}" Command="{Binding Data.RemoteDesktop_AdjustScreenCommand, Source={StaticResource BindingProxy}}" CommandParameter="{Binding View}">
79+
<MenuItem.Icon>
80+
<Rectangle Width="16" Height="16" Fill="{DynamicResource GrayBrush3}">
81+
<Rectangle.OpacityMask>
82+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Octicons Kind=ScreenNormal}" />
83+
</Rectangle.OpacityMask>
84+
</Rectangle>
85+
</MenuItem.Icon>
86+
</MenuItem>
87+
<Separator />
88+
<MenuItem Header="{x:Static localization:Strings.KeyboardShortcuts}">
89+
<MenuItem.Icon>
90+
<Rectangle Width="16" Height="16" Fill="{DynamicResource GrayBrush3}">
91+
<Rectangle.OpacityMask>
92+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=KeyboardVariant}" />
93+
</Rectangle.OpacityMask>
94+
</Rectangle>
95+
</MenuItem.Icon>
96+
<MenuItem Header="{x:Static localization:Strings.CtrlAltDel}" Command="{Binding Data.RemoteDesktop_SendCtrlAltDelCommand, Source={StaticResource BindingProxy}}" CommandParameter="{Binding View}" />
97+
</MenuItem>
98+
</ContextMenu>
99+
</Grid.ContextMenu>
100+
<Grid.InputBindings>
101+
<MouseBinding Command="dragablz:TabablzControl.CloseItemCommand" Gesture="MiddleClick" />
102+
</Grid.InputBindings>
103+
<StackPanel Orientation="Horizontal">
104+
<Grid ToolTip="{Binding Header}">
105+
<TextBlock Text="{Binding Header}" VerticalAlignment="Center" Width="150" Margin="10">
106+
<TextBlock.Style>
107+
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource HeaderTextBlock}">
108+
<Setter Property="Foreground" Value="{DynamicResource GrayBrush3}" />
109+
<Style.Triggers>
110+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dragablz:DragablzItem}}, Path=IsMouseOver}" Value="True">
111+
<Setter Property="Foreground" Value="{DynamicResource GrayBrush5}" />
112+
</DataTrigger>
113+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dragablz:DragablzItem}}, Path=IsSelected}" Value="True">
114+
<Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
115+
</DataTrigger>
116+
</Style.Triggers>
117+
</Style>
118+
</TextBlock.Style>
119+
</TextBlock>
120+
<Thumb Style="{DynamicResource InvisibleThumbStyle}" dragablz:DragablzItem.IsCustomThumb="True" />
121+
</Grid>
122+
<Button Style="{StaticResource CleanButton}" Command="dragablz:TabablzControl.CloseItemCommand" ToolTip="{x:Static localization:Strings.Close}" Margin="0,0,10,0">
123+
<Rectangle Width="16" Height="16">
124+
<Rectangle.OpacityMask>
125+
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=WindowClose}" />
126+
</Rectangle.OpacityMask>
127+
<Rectangle.Style>
128+
<Style TargetType="{x:Type Rectangle}">
129+
<Setter Property="Fill" Value="{DynamicResource GrayBrush3}" />
130+
<Style.Triggers>
131+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}" Value="True">
132+
<Setter Property="Fill" Value="{DynamicResource GrayBrush5}" />
133+
</DataTrigger>
134+
</Style.Triggers>
135+
</Style>
136+
</Rectangle.Style>
137+
</Rectangle>
138+
</Button>
139+
</StackPanel>
140+
</Grid>
141+
</Border>
142+
</DataTemplate>
143+
</Setter.Value>
144+
</Setter>
145+
</DataTrigger.Setters>
146+
</DataTrigger>
40147
<!-- Add ContextMenu for PowerShell -->
41148
<DataTrigger Binding="{Binding ApplicationName}" Value="{x:Static networkManager:ApplicationViewManager+Name.PowerShell}">
42149
<DataTrigger.Setters>

0 commit comments

Comments
 (0)