Skip to content

Commit b4c38cb

Browse files
committed
Feature: PuTTY connect dialog
1 parent 252c8ea commit b4c38cb

File tree

9 files changed

+123
-102
lines changed

9 files changed

+123
-102
lines changed

Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Setter Property="TitleBarNonActiveBackground" Value="Transparent" />
1111
<Setter Property="OverlayBrush" Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray.SemiTransparent}" />
1212
<Setter Property="TitleForeground" Value="{DynamicResource ResourceKey=MahApps.Brushes.Gray3}" />
13-
<Setter Property="ChildWindowWidth" Value="450" />
13+
<Setter Property="ChildWindowWidth" Value="500" />
1414
<Setter Property="ChildWindowMaxHeight" Value="500" />
1515
</Style>
1616
</ResourceDictionary>

Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class PowerShellConnectViewModel : ViewModelBase
1818

1919
private bool _enableRemoteConsole;
2020

21-
private List<ExecutionPolicy> _executionPolicies = new();
21+
private List<ExecutionPolicy> _executionPolicies = [];
2222

2323
private ExecutionPolicy _executionPolicy;
2424

Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Dragablz;
22
using log4net;
33
using MahApps.Metro.Controls.Dialogs;
4+
using MahApps.Metro.SimpleChildWindow;
45
using NETworkManager.Controls;
56
using NETworkManager.Localization.Resources;
67
using NETworkManager.Models;
@@ -239,7 +240,7 @@ public bool IsProfileFilterSet
239240
OnPropertyChanged();
240241
}
241242
}
242-
243+
243244
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
244245
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
245246

@@ -504,7 +505,7 @@ public ICommand TextBoxSearchLostFocusCommand
504505
private void OpenProfileFilterAction()
505506
{
506507
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
507-
508+
508509
ProfileFilterIsOpen = true;
509510
}
510511

@@ -524,7 +525,7 @@ private void ClearProfileFilterAction()
524525
_searchDisabled = true;
525526
Search = string.Empty;
526527
_searchDisabled = false;
527-
528+
528529
foreach (var tag in ProfileFilterTags)
529530
tag.IsSelected = false;
530531

@@ -547,7 +548,7 @@ private void CollapseAllProfileGroupsAction()
547548
{
548549
SetIsExpandedForAllProfileGroups(false);
549550
}
550-
551+
551552
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
552553

553554
private static void OpenSettingsAction()
@@ -588,16 +589,15 @@ private void TryFindExecutable()
588589
Log.Warn("Install PuTTY or configure the path in the settings.");
589590
}
590591

591-
private async Task Connect(string host = null)
592+
private Task Connect(string host = null)
592593
{
593-
var customDialog = new CustomDialog
594-
{
595-
Title = Strings.Connect
596-
};
594+
var childWindow = new PuTTYConnectChildWindow();
597595

598-
var connectViewModel = new PuTTYConnectViewModel(async instance =>
596+
var childWindowViewModel = new PuTTYConnectViewModel(instance =>
599597
{
600-
await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
598+
childWindow.IsOpen = false;
599+
ConfigurationManager.Current.IsChildWindowOpen = false;
600+
601601
ConfigurationManager.OnDialogClose();
602602

603603
// Create profile info
@@ -630,19 +630,23 @@ private async Task Connect(string host = null)
630630
AddProfileToHistory(instance.Profile);
631631

632632
Connect(sessionInfo);
633-
}, async _ =>
634-
{
635-
await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
636-
ConfigurationManager.OnDialogClose();
637-
}, host);
633+
}, _ =>
634+
{
635+
childWindow.IsOpen = false;
636+
ConfigurationManager.Current.IsChildWindowOpen = false;
638637

639-
customDialog.Content = new PuTTYConnectDialog
640-
{
641-
DataContext = connectViewModel
642-
};
638+
ConfigurationManager.OnDialogClose();
639+
}, host);
640+
641+
childWindow.Title = Strings.Connect;
642+
643+
childWindow.DataContext = childWindowViewModel;
644+
645+
ConfigurationManager.Current.IsChildWindowOpen = true;
643646

644647
ConfigurationManager.OnDialogOpen();
645-
await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
648+
649+
return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow);
646650
}
647651

648652
private void ConnectProfile()
@@ -660,7 +664,7 @@ private void ConnectProfileExternal()
660664
ProcessStartInfo info = new()
661665
{
662666
FileName = SettingsManager.Current.PuTTY_ApplicationFilePath,
663-
Arguments = Models.PuTTY.PuTTY.BuildCommandLine(sessionInfo)
667+
Arguments = PuTTY.BuildCommandLine(sessionInfo)
664668
};
665669

666670
Process.Start(info);
@@ -761,7 +765,7 @@ private void SetIsExpandedForAllProfileGroups(bool isExpanded)
761765
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
762766
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
763767
}
764-
768+
765769
private void ResizeProfile(bool dueToChangedSize)
766770
{
767771
_canProfileWidthChange = false;
@@ -907,7 +911,7 @@ public void OnProfileFilterClosed()
907911
{
908912
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
909913
}
910-
914+
911915
public void OnProfileManagerDialogOpen()
912916
{
913917
ConfigurationManager.OnDialogOpen();

Source/NETworkManager/Views/PowerShellConnectChildWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
CloseButtonCommand="{Binding Path=CancelCommand}"
1414
Style="{StaticResource DefaultChildWindow}"
1515
Loaded="ChildWindow_OnLoaded"
16-
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:ProfileViewModel}">
16+
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:PowerShellConnectViewModel}">
1717
<simpleChildWindow:ChildWindow.Resources>
1818
<converters:BooleanReverseToVisibilityCollapsedConverter x:Key="BooleanReverseToVisibilityCollapsedConverter" />
1919
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />

0 commit comments

Comments
 (0)