Skip to content

Commit 388d52b

Browse files
authored
Merge pull request #45 from 0xf005ba11/better-rdp-connect
change rdp connect to drop down flyout
2 parents e744080 + 664cf36 commit 388d52b

File tree

5 files changed

+43
-121
lines changed

5 files changed

+43
-121
lines changed

VMPlex/UI/ManagerPage.xaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,32 @@
105105
<ui:AppBarButton x:Name="vmAdd" Icon="Add" ToolTip="Create VM" Click="OnAddCommand" IsTabStop="False" IsCompact="True"/>
106106
<ui:AppBarButton x:Name="vmDelete" Icon="Delete" ToolTip="Delete VM" Click="OnDeleteCommand" IsTabStop="False" IsCompact="True"/>
107107
<ui:AppBarSeparator IsCompact="True"/>
108-
<ui:AppBarButton x:Name="rdpConnect" ToolTip="Remote Desktop Connection" Click="OnRdpConnect" IsTabStop="False" IsCompact="True">
109-
<ui:AppBarButton.Icon>
110-
<ui:FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE8AF;"/>
111-
</ui:AppBarButton.Icon>
112-
</ui:AppBarButton>
108+
<ui:DropDownButton Name="rdpDropDown" ToolTip="Remote Desktop Connection" IsTabStop="False" CornerRadius="0" Padding="15,11,15,10" FocusVisualMargin="0,0,0,0">
109+
<ui:DropDownButton.Style>
110+
<Style TargetType="ui:DropDownButton">
111+
<Setter Property="Background" Value="Transparent"/>
112+
<Setter Property="BorderThickness" Value="0"/>
113+
</Style>
114+
</ui:DropDownButton.Style>
115+
<ui:FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE8AF;"/>
116+
<ui:DropDownButton.Flyout>
117+
<ui:Flyout Placement="BottomEdgeAlignedRight">
118+
<ui:Flyout.FlyoutPresenterStyle>
119+
<Style TargetType="ui:FlyoutPresenter">
120+
<Setter Property="Padding" Value="2"/>
121+
<Setter Property="BorderThickness" Value="0"/>
122+
</Style>
123+
</ui:Flyout.FlyoutPresenterStyle>
124+
<ui:SimpleStackPanel Orientation="Horizontal" Margin="12 10 12 10" Spacing="20">
125+
<ComboBox Name="rdpConnectionBox" IsEditable="True" StaysOpenOnEdit="True" Width="250"
126+
ItemsSource="{Binding Source={x:Static root:UserSettings.Instance}, Path=Settings.RdpConnections, UpdateSourceTrigger=PropertyChanged}"
127+
DisplayMemberPath="DisplayText"
128+
/>
129+
<Button Name="rdpConnectButton" Content="Connect" Click="RdpConnectButton_Click"/>
130+
</ui:SimpleStackPanel>
131+
</ui:Flyout>
132+
</ui:DropDownButton.Flyout>
133+
</ui:DropDownButton>
113134
</DockPanel>
114135
</Grid>
115136
<Grid Grid.Row="1">

VMPlex/UI/ManagerPage.xaml.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,15 @@ private void RevertCheckpoint(object data)
444444
VMManager.RevertSnapshot((VirtualMachine)data);
445445
}
446446

447-
private void OnRdpConnect(object sender, RoutedEventArgs e)
447+
private void RdpConnectButton_Click(object sender, RoutedEventArgs e)
448448
{
449-
var settings = RdpConnectWindow.Show();
450-
if (settings == null)
451-
{
452-
return;
453-
}
449+
rdpDropDown.Flyout.Hide();
454450

455-
if (settings.Server.Length == 0)
451+
var strings = rdpConnectionBox.Text.Split('\\');
452+
string domain = strings.Length > 1 ? strings[0] : "";
453+
string server = strings.Length > 1 ? strings[1] : strings[0];
454+
455+
if (server.Length == 0)
456456
{
457457
MessageBox.Show(
458458
MessageBoxImage.Error,
@@ -462,6 +462,10 @@ private void OnRdpConnect(object sender, RoutedEventArgs e)
462462
return;
463463
}
464464

465+
var settings = UserSettings.Instance.Settings.RdpConnections.FirstOrDefault(
466+
c => c.Domain == domain && c.Server == server,
467+
new RdpSettings { Domain = domain, Server = server });
468+
465469
TabItem tab;
466470
try
467471
{

VMPlex/UI/RdpConnectWindow.xaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

VMPlex/UI/RdpConnectWindow.xaml.cs

Lines changed: 0 additions & 91 deletions
This file was deleted.

VMPlex/UserSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ public enum AudioRedirectionModeSetting
221221
/// </summary>
222222
[JsonInclude]
223223
public int DesktopHeight { get; set; } = 768;
224+
225+
[JsonIgnore]
226+
public string DisplayText
227+
{
228+
get { return Domain.Length > 0 ? $"{Domain}\\{Server}" : Server; }
229+
}
224230
}
225231

226232
/// <summary>

0 commit comments

Comments
 (0)