Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Source/NETworkManager.Profiles/IProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

namespace NETworkManager.Profiles
{
public interface IProfileManager
public interface IProfileManager : IProfileManagerMinimal
{
ICollectionView Profiles { get; }
void OnProfileDialogOpen();
void OnProfileDialogClose();
ICollectionView Profiles { get; }
ICommand AddProfileCommand { get; }
ICommand EditProfileCommand { get; }
ICommand CopyAsProfileCommand { get; }
Expand Down
19 changes: 19 additions & 0 deletions Source/NETworkManager.Profiles/IProfileManagerMinimal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace NETworkManager.Profiles
{
/// <summary>
/// Interface for the profile manager.
/// Minimal implementation to get the view model.
/// </summary>
public interface IProfileManagerMinimal
{
/// <summary>
/// Event is fired when the profile dialog is opened.
/// </summary>
void OnProfileDialogOpen();

/// <summary>
/// Event is fired when the profile dialog is closed.
/// </summary>
void OnProfileDialogClose();
}
}
18 changes: 9 additions & 9 deletions Source/NETworkManager/ProfileDialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace NETworkManager;
public static class ProfileDialogManager
{
#region Variables
private static string DialogResourceKey = "LargeMetroDialog";
private static string DialogResourceKey => "LargeMetroDialog";
#endregion

#region Dialog to add, edit, copy as and delete profile
public static async Task ShowAddProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, string group = null, ApplicationName applicationName = ApplicationName.None)
public static async Task ShowAddProfileDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo profile = null, string group = null, ApplicationName applicationName = ApplicationName.None)
{
CustomDialog customDialog = new()
{
Expand All @@ -36,7 +36,7 @@ public static async Task ShowAddProfileDialog(IProfileManager viewModel, IDialog
{
await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog);
viewModel.OnProfileDialogClose();
}, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, null, applicationName);
}, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, profile, applicationName);

customDialog.Content = new ProfileDialog
{
Expand All @@ -48,7 +48,7 @@ public static async Task ShowAddProfileDialog(IProfileManager viewModel, IDialog
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
}

public static async Task ShowEditProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo profile)
public static async Task ShowEditProfileDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo profile)
{
CustomDialog customDialog = new()
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public static async Task ShowEditProfileDialog(IProfileManager viewModel, IDialo
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
}

public static async Task ShowCopyAsProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo profile)
public static async Task ShowCopyAsProfileDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, ProfileInfo profile)
{
CustomDialog customDialog = new()
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public static async Task ShowCopyAsProfileDialog(IProfileManager viewModel, IDia
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
}

public static async Task ShowDeleteProfileDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, IList<ProfileInfo> profiles)
public static async Task ShowDeleteProfileDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, IList<ProfileInfo> profiles)
{
CustomDialog customDialog = new()
{
Expand Down Expand Up @@ -137,7 +137,7 @@ public static async Task ShowDeleteProfileDialog(IProfileManager viewModel, IDia
#endregion

#region Dialog to add, edit and delete group
public static async Task ShowAddGroupDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator)
public static async Task ShowAddGroupDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator)
{
CustomDialog customDialog = new()
{
Expand Down Expand Up @@ -166,7 +166,7 @@ public static async Task ShowAddGroupDialog(IProfileManager viewModel, IDialogCo
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
}

public static async Task ShowEditGroupDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, GroupInfo group)
public static async Task ShowEditGroupDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, GroupInfo group)
{
CustomDialog customDialog = new()
{
Expand Down Expand Up @@ -195,7 +195,7 @@ public static async Task ShowEditGroupDialog(IProfileManager viewModel, IDialogC
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
}

public static async Task ShowDeleteGroupDialog(IProfileManager viewModel, IDialogCoordinator dialogCoordinator, GroupInfo group)
public static async Task ShowDeleteGroupDialog(IProfileManagerMinimal viewModel, IDialogCoordinator dialogCoordinator, GroupInfo group)
{
CustomDialog customDialog = new()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void ConnectProfileExternalAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.AWSSessionManager);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.AWSSessionManager);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void LookupProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.DNSLookup);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.DNSLookup);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void ScanProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.IPScanner);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.IPScanner);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
40 changes: 15 additions & 25 deletions Source/NETworkManager/ViewModels/IPScannerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace NETworkManager.ViewModels
{
public class IPScannerViewModel : ViewModelBase
public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal
{
#region Variables
private readonly IDialogCoordinator _dialogCoordinator;
Expand Down Expand Up @@ -287,7 +287,7 @@ private void DetectSubnetAction()

private void RedirectDataToApplicationAction(object name)
{
if (!(name is string appName))
if (name is not string appName)
return;

if (!Enum.TryParse(appName, out ApplicationName applicationName))
Expand Down Expand Up @@ -321,7 +321,7 @@ private void CustomCommandAction(object guid)

public ICommand AddProfileSelectedHostCommand => new RelayCommand(p => AddProfileSelectedHostAction());

private async Task AddProfileSelectedHostAction()
private async void AddProfileSelectedHostAction()
{
ProfileInfo profileInfo = new()
{
Expand All @@ -332,27 +332,7 @@ private async Task AddProfileSelectedHostAction()
WakeOnLAN_MACAddress = SelectedResult.MACAddressString
};

var customDialog = new CustomDialog
{
Title = Localization.Resources.Strings.AddProfile
};

var profileViewModel = new ProfileViewModel(instance =>
{
_dialogCoordinator.HideMetroDialogAsync(this, customDialog);

ProfileManager.AddProfile(ProfileDialogManager.ParseProfileInfo(instance));
}, instance =>
{
_dialogCoordinator.HideMetroDialogAsync(this, customDialog);
}, ProfileManager.GetGroupNames(), null, ProfileEditMode.Add, profileInfo);

customDialog.Content = new ProfileDialog
{
DataContext = profileViewModel
};

await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
await ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, profileInfo);
}

public ICommand CopySelectedIPAddressCommand => new RelayCommand(p => CopySelectedIPAddressAction());
Expand Down Expand Up @@ -412,7 +392,7 @@ private void CopySelectedStatusAction()
}

public ICommand ExportCommand => new RelayCommand(p => ExportAction());

private void ExportAction()
{
Export();
Expand Down Expand Up @@ -693,6 +673,16 @@ private void SettingsManager_PropertyChanged(object sender, PropertyChangedEvent
break;
}
}

public void OnProfileDialogOpen()
{

}

public void OnProfileDialogClose()
{

}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ private void ApplyProfileProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator,null, ApplicationName.NetworkInterface);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.NetworkInterface);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void AddHostProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.PingMonitor);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.PingMonitor);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void ScanProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.PortScanner);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.PortScanner);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private void ConnectProfileExternalAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.PowerShell);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.PowerShell);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/ProfilesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void SetProfilesView(string groupName, ProfileInfo selectedProfileInfo =

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, SelectedGroup?.Name);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, SelectedGroup?.Name);
}

public ICommand EditProfileCommand => new RelayCommand(p => EditProfileAction(), EditProfile_CanExecute);
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private void ConnectProfileExternalAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.PuTTY);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.PuTTY);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private void ConnectProfileExternalAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator,null, ApplicationName.RemoteDesktop);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.RemoteDesktop);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void ConnectProfileExternalAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.TigerVNC);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.TigerVNC);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void TraceProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.Traceroute);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.Traceroute);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void WakeUpProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.WakeOnLAN);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.WakeOnLAN);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private void ConnectProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.WebConsole);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.WebConsole);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/ViewModels/WhoisHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void QueryProfileAction()

private void AddProfileAction()
{
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, ApplicationName.Whois);
ProfileDialogManager.ShowAddProfileDialog(this, _dialogCoordinator, null, null, ApplicationName.Whois);
}

private bool ModifyProfile_CanExecute(object obj) => SelectedProfile != null && !SelectedProfile.IsDynamic;
Expand Down