Skip to content

Commit ac78c64

Browse files
committed
Feature: Migrate to simplechildwindow
1 parent 11590ce commit ac78c64

23 files changed

+4724
-42
lines changed

Source/NETworkManager.Profiles/IProfileManagerMinimal.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ public interface IProfileManagerMinimal
1111
/// </summary>
1212
public void OnProfileManagerDialogOpen()
1313
{
14+
1415
}
1516

1617
/// <summary>
1718
/// Event is fired when a dialog in the <see cref="ProfileManager" /> is closed.
1819
/// </summary>
1920
public void OnProfileManagerDialogClose()
2021
{
22+
2123
}
22-
}
24+
}

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
472472
// Show welcome dialog
473473
if (SettingsManager.Current.WelcomeDialog_Show)
474474
{
475-
476475
var childWindow = new WelcomeChildWindow();
477476

478477
var viewModel = new WelcomeViewModel(instance =>

Source/NETworkManager/ProfileDialogManager.cs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
using NETworkManager.Views;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Configuration;
1213
using System.Security;
1314
using System.Threading.Tasks;
1415
using System.Windows;
16+
using MahApps.Metro.SimpleChildWindow;
1517

1618
namespace NETworkManager;
1719

@@ -466,36 +468,36 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance)
466468

467469
#region Dialog to add, edit, copy as and delete profile
468470

469-
public static Task ShowAddProfileDialog(object context, IProfileManagerMinimal viewModel,
470-
IDialogCoordinator dialogCoordinator, ProfileInfo profile = null, string group = null,
471+
public static Task ShowAddProfileDialog(Window parentWindow,IProfileManagerMinimal viewModel,
472+
ProfileInfo profile = null, string group = null,
471473
ApplicationName applicationName = ApplicationName.None)
472474
{
473-
CustomDialog customDialog = new()
474-
{
475-
Title = Strings.AddProfile,
476-
Style = (Style)Application.Current.FindResource(DialogResourceKey)
477-
};
478475

479-
ProfileViewModel profileViewModel = new(async instance =>
476+
var childWindow = new ProfileChildWindow(parentWindow);
477+
478+
ProfileViewModel profileViewModel = new(instance =>
480479
{
481-
await dialogCoordinator.HideMetroDialogAsync(context, customDialog);
480+
childWindow.IsOpen = false;
481+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
482+
482483
viewModel.OnProfileManagerDialogClose();
483-
484+
484485
ProfileManager.AddProfile(ParseProfileInfo(instance));
485-
}, async _ =>
486+
}, _ =>
486487
{
487-
await dialogCoordinator.HideMetroDialogAsync(context, customDialog);
488+
childWindow.IsOpen = false;
489+
Settings.ConfigurationManager.Current.IsChildWindowOpen = false;
490+
488491
viewModel.OnProfileManagerDialogClose();
489492
}, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, profile, applicationName);
490493

491-
customDialog.Content = new ProfileDialog
492-
{
493-
DataContext = profileViewModel
494-
};
495-
496-
viewModel.OnProfileManagerDialogOpen();
497-
498-
return dialogCoordinator.ShowMetroDialogAsync(context, customDialog);
494+
childWindow.Title = Strings.AddProfile;
495+
496+
childWindow.DataContext = profileViewModel;
497+
498+
Settings.ConfigurationManager.Current.IsChildWindowOpen = true;
499+
500+
return parentWindow.ShowChildWindowAsync(childWindow);
499501
}
500502

501503
public static Task ShowEditProfileDialog(IProfileManagerMinimal viewModel,

Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ private void ConnectProfileExternalAction()
443443
private void AddProfileAction()
444444
{
445445
ProfileDialogManager
446-
.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.AWSSessionManager)
446+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.AWSSessionManager)
447447
.ConfigureAwait(false);
448448
}
449449

@@ -999,8 +999,8 @@ private void SetProfilesView(ProfileInfo profile = null)
999999
Profiles.Filter = o =>
10001000
{
10011001
if (string.IsNullOrEmpty(Search))
1002-
return true ;
1003-
1002+
return true;
1003+
10041004
if (o is not ProfileInfo info)
10051005
return false;
10061006

Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private void LookupProfileAction()
251251

252252
private void AddProfileAction()
253253
{
254-
ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.DNSLookup)
254+
ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.DNSLookup)
255255
.ConfigureAwait(false);
256256
}
257257

Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private void QueryProfileAction()
252252
private void AddProfileAction()
253253
{
254254
ProfileDialogManager
255-
.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.IPGeolocation)
255+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.IPGeolocation)
256256
.ConfigureAwait(false);
257257
}
258258

Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private void ScanProfileAction()
251251

252252
private void AddProfileAction()
253253
{
254-
ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.IPScanner)
254+
ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.IPScanner)
255255
.ConfigureAwait(false);
256256
}
257257

Source/NETworkManager/ViewModels/IPScannerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private async void AddProfileSelectedHostAction()
344344

345345
var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
346346

347-
await ProfileDialogManager.ShowAddProfileDialog(window, this, _dialogCoordinator, profileInfo, null,
347+
await ProfileDialogManager.ShowAddProfileDialog(window, this, profileInfo, null,
348348
ApplicationName.IPScanner);
349349
}
350350

Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ private void ApplyProfileProfileAction()
751751
private void AddProfileAction()
752752
{
753753
ProfileDialogManager
754-
.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.NetworkInterface)
754+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.NetworkInterface)
755755
.ConfigureAwait(false);
756756
}
757757

Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ private void ExportAction()
357357
private void AddProfileAction()
358358
{
359359
ProfileDialogManager
360-
.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.PingMonitor)
360+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.PingMonitor)
361361
.ConfigureAwait(false);
362362
}
363363

0 commit comments

Comments
 (0)