* Separating "SSH Info" and "Quick Launch", and updating translations. * Adding "Quick Launch" to menu. * Auto-complete, initial version. * Builds, but not finished. * Improved, but there are still some bugs... * Minor changes. * Refactroing request/response identifiers. * Improving command history. * Minor refactoring. * Deleting history by using "Del" key. * Handling mosh special case in quick commands. * SSH command handled as any other command in the path. * New resource strings. * Fixing quick command links. * Fixing after-merging bugs. * Improving filtering. * Finishing filtering. * Changing placeholder text. * Minor refactoring. * Updating resources. * Renaming NewRemoteTab back to NewSshTab.
97 lines
3.7 KiB
C#
97 lines
3.7 KiB
C#
using FluentTerminal.App.Services.Dialogs;
|
|
using FluentTerminal.Models;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FluentTerminal.App.Services.Implementation
|
|
{
|
|
public class DialogService : IDialogService
|
|
{
|
|
private readonly Func<IShellProfileSelectionDialog> _shellProfileSelectionDialogFactory;
|
|
private readonly Func<IMessageDialog> _messageDialogFactory;
|
|
private readonly Func<ICreateKeyBindingDialog> _createKeyBindingDialogFactory;
|
|
private readonly Func<IInputDialog> _inputDialogFactory;
|
|
private readonly Func<ISshConnectionInfoDialog> _sshConnectionInfoDialogFactory;
|
|
private readonly Func<ICustomCommandDialog> _customCommandDialogFactory;
|
|
private readonly Func<ISshProfileSelectionDialog> _sshProfileSelectionDialogFactory;
|
|
|
|
public DialogService(Func<IShellProfileSelectionDialog> shellProfileSelectionDialogFactory,
|
|
Func<IMessageDialog> messageDialogFactory, Func<ICreateKeyBindingDialog> createKeyBindingDialogFactory,
|
|
Func<IInputDialog> inputDialogFactory, Func<ISshConnectionInfoDialog> sshConnectionInfoDialogFactory,
|
|
Func<ICustomCommandDialog> customCommandDialogFactory,
|
|
Func<ISshProfileSelectionDialog> sshProfileSelectionDialogFactory)
|
|
{
|
|
_shellProfileSelectionDialogFactory = shellProfileSelectionDialogFactory;
|
|
_messageDialogFactory = messageDialogFactory;
|
|
_createKeyBindingDialogFactory = createKeyBindingDialogFactory;
|
|
_inputDialogFactory = inputDialogFactory;
|
|
_sshConnectionInfoDialogFactory = sshConnectionInfoDialogFactory;
|
|
_customCommandDialogFactory = customCommandDialogFactory;
|
|
_sshProfileSelectionDialogFactory = sshProfileSelectionDialogFactory;
|
|
}
|
|
|
|
public Task<KeyBinding> ShowCreateKeyBindingDialog()
|
|
{
|
|
var dialog = _createKeyBindingDialogFactory();
|
|
|
|
return dialog.CreateKeyBinding();
|
|
}
|
|
|
|
public Task<DialogButton> ShowMessageDialogAsnyc(string title, string content, params DialogButton[] buttons)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(title))
|
|
{
|
|
throw new ArgumentNullException(nameof(title));
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(content))
|
|
{
|
|
throw new ArgumentNullException(nameof(content));
|
|
}
|
|
|
|
if (buttons.Length == 0)
|
|
{
|
|
throw new ArgumentException("Must not be empty", nameof(buttons));
|
|
}
|
|
|
|
var dialog = _messageDialogFactory();
|
|
dialog.Content = content;
|
|
dialog.Title = title;
|
|
|
|
foreach (var button in buttons)
|
|
{
|
|
dialog.AddButton(button);
|
|
}
|
|
|
|
return dialog.ShowAsync();
|
|
}
|
|
|
|
public Task<string> ShowInputDialogAsync(string title)
|
|
{
|
|
var dialog = _inputDialogFactory.Invoke();
|
|
dialog.SetTitle(title);
|
|
|
|
return dialog.GetInput();
|
|
}
|
|
|
|
public Task<ShellProfile> ShowProfileSelectionDialogAsync()
|
|
{
|
|
var dialog = _shellProfileSelectionDialogFactory();
|
|
|
|
return dialog.SelectProfile();
|
|
}
|
|
|
|
public Task<SshProfile> ShowSshConnectionInfoDialogAsync(SshProfile input = null) =>
|
|
_sshConnectionInfoDialogFactory().GetSshConnectionInfoAsync(input);
|
|
|
|
public Task<ShellProfile> ShowCustomCommandDialogAsync(ShellProfile input = null) =>
|
|
_customCommandDialogFactory().GetCustomCommandAsync(input);
|
|
|
|
public Task<SshProfile> ShowSshProfileSelectionDialogAsync()
|
|
{
|
|
var dialog = _sshProfileSelectionDialogFactory();
|
|
|
|
return dialog.SelectProfile();
|
|
}
|
|
}
|
|
} |