Migrate to WCT MVVM
This commit is contained in:
1 parent
5fd7b00778
commit
823205fa69
60 files changed
+488
-663
No files matched your search
@@ -1,9 +1,9 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class EnvironmentVariableViewModel : ViewModelBase
|
||||
public class EnvironmentVariableViewModel : ObservableObject
|
||||
{
|
||||
private string _name;
|
||||
private string _value;
|
||||
@@ -13,13 +13,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => Set(ref _name, value);
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get => _value;
|
||||
set => Set(ref _value, value);
|
||||
set => SetProperty(ref _value, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
using FluentTerminal.App.ViewModels.Utilities;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Infrastructure
|
||||
{
|
||||
public class AsyncCommand : IAsyncCommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
private bool _isExecuting;
|
||||
private readonly Func<Task> _execute;
|
||||
private readonly Func<bool> _canExecute;
|
||||
private readonly IErrorHandler _errorHandler;
|
||||
|
||||
public AsyncCommand(
|
||||
Func<Task> execute,
|
||||
Func<bool> canExecute = null,
|
||||
IErrorHandler errorHandler = null)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
_errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public bool CanExecute()
|
||||
{
|
||||
return !_isExecuting && (_canExecute?.Invoke() ?? true);
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync()
|
||||
{
|
||||
if (CanExecute())
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: If we're using class field _isExecuting, maybe we should introduce some locking?
|
||||
_isExecuting = true;
|
||||
await _execute();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isExecuting = false;
|
||||
}
|
||||
}
|
||||
|
||||
RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#region Explicit implementations
|
||||
bool ICommand.CanExecute(object parameter)
|
||||
{
|
||||
return CanExecute();
|
||||
}
|
||||
|
||||
void ICommand.Execute(object parameter)
|
||||
{
|
||||
ExecuteAsync().FireAndForgetSafeAsync(_errorHandler);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class AsyncCommand<T> : IAsyncCommand<T>
|
||||
{
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
private bool _isExecuting;
|
||||
private readonly Func<T, Task> _execute;
|
||||
private readonly Func<T, bool> _canExecute;
|
||||
private readonly IErrorHandler _errorHandler;
|
||||
|
||||
public AsyncCommand(Func<T, Task> execute, Func<T, bool> canExecute = null, IErrorHandler errorHandler = null)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
_errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public bool CanExecute(T parameter)
|
||||
{
|
||||
return !_isExecuting && (_canExecute?.Invoke(parameter) ?? true);
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync(T parameter)
|
||||
{
|
||||
if (CanExecute(parameter))
|
||||
{
|
||||
try
|
||||
{
|
||||
_isExecuting = true;
|
||||
await _execute(parameter);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isExecuting = false;
|
||||
}
|
||||
}
|
||||
|
||||
RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#region Explicit implementations
|
||||
bool ICommand.CanExecute(object parameter)
|
||||
{
|
||||
return CanExecute((T)parameter);
|
||||
}
|
||||
|
||||
void ICommand.Execute(object parameter)
|
||||
{
|
||||
ExecuteAsync((T)parameter).FireAndForgetSafeAsync(_errorHandler);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// based on: https://github.com/johnthiriet/AsyncVoid
|
||||
/// </summary>
|
||||
public interface IAsyncCommand : ICommand
|
||||
{
|
||||
Task ExecuteAsync();
|
||||
bool CanExecute();
|
||||
}
|
||||
|
||||
public interface IAsyncCommand<in T> : ICommand
|
||||
{
|
||||
Task ExecuteAsync(T parameter);
|
||||
bool CanExecute(T parameter);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using FluentTerminal.App.Services.EventArgs;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -14,13 +13,22 @@ using System.Threading.Tasks;
|
||||
using Windows.UI.Core;
|
||||
using FluentTerminal.App.ViewModels.Menu;
|
||||
using FluentTerminal.Models.Messages;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Messaging;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
public class MainViewModel : ObservableObject,
|
||||
IRecipient<ApplicationSettingsChangedMessage>,
|
||||
IRecipient<ShellProfileAddedMessage>,
|
||||
IRecipient<ShellProfileDeletedMessage>,
|
||||
IRecipient<ShellProfileChangedMessage>,
|
||||
IRecipient<DefaultShellProfileChangedMessage>,
|
||||
IRecipient<TerminalOptionsChangedMessage>,
|
||||
IRecipient<CommandHistoryChangedMessage>,
|
||||
IRecipient<KeyBindingsChangedMessage>
|
||||
{
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IDialogService _dialogService;
|
||||
@@ -39,15 +47,6 @@ namespace FluentTerminal.App.ViewModels
|
||||
public MainViewModel(ISettingsService settingsService, ITrayProcessCommunicationService trayProcessCommunicationService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService,
|
||||
IApplicationView applicationView, IClipboardService clipboardService, ICommandHistoryService commandHistoryService)
|
||||
{
|
||||
MessengerInstance.Register<ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);
|
||||
MessengerInstance.Register<ShellProfileAddedMessage>(this, OnShellProfileAdded);
|
||||
MessengerInstance.Register<ShellProfileDeletedMessage>(this, OnShellProfileDeleted);
|
||||
MessengerInstance.Register<ShellProfileChangedMessage>(this, OnShellProfileChanged);
|
||||
MessengerInstance.Register<DefaultShellProfileChangedMessage>(this, OnDefaultShellProfileChanged);
|
||||
MessengerInstance.Register<TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);
|
||||
MessengerInstance.Register<CommandHistoryChangedMessage>(this, OnCommandHistoryChanged);
|
||||
MessengerInstance.Register<KeyBindingsChangedMessage>(this, OnKeyBindingChanged);
|
||||
|
||||
_settingsService = settingsService;
|
||||
|
||||
_trayProcessCommunicationService = trayProcessCommunicationService;
|
||||
@@ -69,7 +68,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), async () => await SelectedTerminal.EditTitleAsync());
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab);
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.DuplicateTab), async () => await AddTabAsync(SelectedTerminal.ShellProfile.Clone()));
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ReconnectTab), async () => { if (SelectedTerminal.ReconnectTabCommand.CanExecute()) await SelectedTerminal.ReconnectTabAsync(); });
|
||||
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ReconnectTab), async () => { if (SelectedTerminal.ReconnectTabCommand.CanExecute(null)) await SelectedTerminal.ReconnectTabAsync(); });
|
||||
|
||||
// empty command handlers for copy and paste so that the main window does not execute these when copy keyboard shortcut is used in a popup search panel
|
||||
// in such a case an exception would be thrown if no handlers are available so these empty ones mitigate that. Also there is no need for these on the main window anyway
|
||||
@@ -126,8 +125,8 @@ namespace FluentTerminal.App.ViewModels
|
||||
_newQuickLaunchWindowCommand = new RelayCommand(async () => await AddQuickLaunchProfileAsync(NewTerminalLocation.Window));
|
||||
|
||||
_settingsCommand = new RelayCommand(ShowSettings);
|
||||
_aboutCommand = new RelayCommand(async () => await _dialogService.ShowAboutDialogAsync());
|
||||
_quitCommand = new AsyncCommand(() => _trayProcessCommunicationService.QuitApplicationAsync());
|
||||
_aboutCommand = new AsyncRelayCommand(_dialogService.ShowAboutDialogAsync);
|
||||
_quitCommand = new AsyncRelayCommand(_trayProcessCommunicationService.QuitApplicationAsync);
|
||||
|
||||
_defaultProfile = _settingsService.GetDefaultShellProfile();
|
||||
|
||||
@@ -156,7 +155,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
private void OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
MessengerInstance.Unregister(this);
|
||||
//MessengerInstance.Unregister(this); todo do we still need this?
|
||||
|
||||
ApplicationView.CloseRequested -= OnCloseRequest;
|
||||
ApplicationView.Closed -= OnClosed;
|
||||
@@ -171,41 +170,10 @@ namespace FluentTerminal.App.ViewModels
|
||||
Closed?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnShellProfileDeleted(ShellProfileDeletedMessage message)
|
||||
{
|
||||
_keyboardCommandService.DeregisterCommandHandler(message.ProfileId.ToString());
|
||||
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
private void OnShellProfileChanged(ShellProfileChangedMessage message)
|
||||
{
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
private void OnShellProfileAdded(ShellProfileAddedMessage message)
|
||||
{
|
||||
_keyboardCommandService.RegisterCommandHandler(message.ShellProfile.Id.ToString(),
|
||||
async () => await AddProfileByGuidAsync(message.ShellProfile.Id));
|
||||
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
private void OnDefaultShellProfileChanged(DefaultShellProfileChangedMessage message)
|
||||
{
|
||||
UpdateDefaultShellProfile();
|
||||
}
|
||||
|
||||
private void OnTerminalsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
RaisePropertyChanged(nameof(ShowTabsOnTop));
|
||||
RaisePropertyChanged(nameof(ShowTabsOnBottom));
|
||||
OnPropertyChanged(nameof(ShowTabsOnTop));
|
||||
OnPropertyChanged(nameof(ShowTabsOnBottom));
|
||||
}
|
||||
|
||||
public event EventHandler Closed;
|
||||
@@ -228,14 +196,14 @@ namespace FluentTerminal.App.ViewModels
|
||||
ActivatedMv?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public RelayCommand AddDefaultTabCommand { get; private set; }
|
||||
public ICommand AddDefaultTabCommand { get; private set; }
|
||||
|
||||
public string WindowTitle
|
||||
{
|
||||
get => _windowTitle;
|
||||
set
|
||||
{
|
||||
if (Set(ref _windowTitle, value))
|
||||
if (SetProperty(ref _windowTitle, value))
|
||||
{
|
||||
ApplicationView.Title = value;
|
||||
}
|
||||
@@ -255,13 +223,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool UseAcrylicBackground
|
||||
{
|
||||
get => _useAcrylicBackground;
|
||||
set => Set(ref _useAcrylicBackground, value);
|
||||
set => SetProperty(ref _useAcrylicBackground, value);
|
||||
}
|
||||
|
||||
public double BackgroundOpacity
|
||||
{
|
||||
get => _backgroundOpacity;
|
||||
set => Set(ref _backgroundOpacity, value);
|
||||
set => SetProperty(ref _backgroundOpacity, value);
|
||||
}
|
||||
|
||||
public TerminalViewModel SelectedTerminal
|
||||
@@ -271,7 +239,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
var oldValue = _selectedTerminal;
|
||||
|
||||
if (Set(ref _selectedTerminal, value))
|
||||
if (SetProperty(ref _selectedTerminal, value))
|
||||
{
|
||||
if (oldValue != null)
|
||||
{
|
||||
@@ -292,7 +260,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public TabsPosition TabsPosition
|
||||
{
|
||||
get => _tabsPosition;
|
||||
set => Set(ref _tabsPosition, value);
|
||||
set => SetProperty(ref _tabsPosition, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<TerminalViewModel> Terminals { get; } = new ObservableCollection<TerminalViewModel>();
|
||||
@@ -428,7 +396,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
await Task.WhenAll(Terminals.Where(t => t != terminal).Select(t =>
|
||||
{
|
||||
Logger.Instance.Debug("Terminal with Id: {@id} closed.", t.Terminal.Id);
|
||||
return t.CloseCommand.ExecuteAsync();
|
||||
return t.CloseAsync();
|
||||
})).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -442,7 +410,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
await Task.WhenAll(toRemove.Select(t =>
|
||||
{
|
||||
Logger.Instance.Debug("Terminal with Id: {@id} closed.", t.Terminal.Id);
|
||||
return t.CloseCommand.ExecuteAsync();
|
||||
return t.CloseAsync();
|
||||
})).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -456,7 +424,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
await Task.WhenAll(toRemove.Select(t =>
|
||||
{
|
||||
Logger.Instance.Debug("Terminal with Id: {@id} closed.", t.Terminal.Id);
|
||||
return t.CloseCommand.ExecuteAsync();
|
||||
return t.CloseAsync();
|
||||
})).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -477,33 +445,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
private void CloseCurrentTab()
|
||||
{
|
||||
SelectedTerminal?.CloseCommand.ExecuteAsync();
|
||||
}
|
||||
|
||||
private void OnApplicationSettingsChanged(ApplicationSettingsChangedMessage message)
|
||||
{
|
||||
var updateMenu = _applicationSettings != null &&
|
||||
(_applicationSettings.TabWindowCascadingAppMenu !=
|
||||
message.ApplicationSettings.TabWindowCascadingAppMenu ||
|
||||
!message.ApplicationSettings.TabWindowCascadingAppMenu &&
|
||||
_applicationSettings.NewTerminalLocation !=
|
||||
message.ApplicationSettings.NewTerminalLocation);
|
||||
|
||||
_applicationSettings = message.ApplicationSettings;
|
||||
|
||||
SetWindowTitle(SelectedTerminal);
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() =>
|
||||
{
|
||||
TabsPosition = message.ApplicationSettings.TabsPosition;
|
||||
RaisePropertyChanged(nameof(ShowTabsOnTop));
|
||||
RaisePropertyChanged(nameof(ShowTabsOnBottom));
|
||||
});
|
||||
|
||||
if (updateMenu)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
SelectedTerminal?.CloseAsync();
|
||||
}
|
||||
|
||||
private async Task OnCloseRequest(object sender, CancelableEventArgs e)
|
||||
@@ -561,7 +503,64 @@ namespace FluentTerminal.App.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
private void OnTerminalOptionsChanged(TerminalOptionsChangedMessage message)
|
||||
public void Receive(ShellProfileDeletedMessage message)
|
||||
{
|
||||
_keyboardCommandService.DeregisterCommandHandler(message.ProfileId.ToString());
|
||||
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
public void Receive(ShellProfileChangedMessage message)
|
||||
{
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
public void Receive(ShellProfileAddedMessage message)
|
||||
{
|
||||
_keyboardCommandService.RegisterCommandHandler(message.ShellProfile.Id.ToString(),
|
||||
async () => await AddProfileByGuidAsync(message.ShellProfile.Id));
|
||||
|
||||
UpdateDefaultShellProfile();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
public void Receive(DefaultShellProfileChangedMessage message)
|
||||
{
|
||||
UpdateDefaultShellProfile();
|
||||
}
|
||||
|
||||
public void Receive(ApplicationSettingsChangedMessage message)
|
||||
{
|
||||
var updateMenu = _applicationSettings != null &&
|
||||
(_applicationSettings.TabWindowCascadingAppMenu !=
|
||||
message.ApplicationSettings.TabWindowCascadingAppMenu ||
|
||||
!message.ApplicationSettings.TabWindowCascadingAppMenu &&
|
||||
_applicationSettings.NewTerminalLocation !=
|
||||
message.ApplicationSettings.NewTerminalLocation);
|
||||
|
||||
_applicationSettings = message.ApplicationSettings;
|
||||
|
||||
SetWindowTitle(SelectedTerminal);
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() =>
|
||||
{
|
||||
TabsPosition = message.ApplicationSettings.TabsPosition;
|
||||
OnPropertyChanged(nameof(ShowTabsOnTop));
|
||||
OnPropertyChanged(nameof(ShowTabsOnBottom));
|
||||
});
|
||||
|
||||
if (updateMenu)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(TerminalOptionsChangedMessage message)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() =>
|
||||
{
|
||||
@@ -570,14 +569,14 @@ namespace FluentTerminal.App.ViewModels
|
||||
}, CoreDispatcherPriority.Low);
|
||||
}
|
||||
|
||||
private void OnKeyBindingChanged(KeyBindingsChangedMessage message)
|
||||
public void Receive(KeyBindingsChangedMessage message)
|
||||
{
|
||||
LoadKeyBindings();
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
private void OnCommandHistoryChanged(CommandHistoryChangedMessage message)
|
||||
public void Receive(CommandHistoryChangedMessage message)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(CreateMenuViewModel, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
@@ -631,20 +630,20 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
private MenuViewModel _menuViewModel;
|
||||
|
||||
private readonly RelayCommand _newDefaultTabCommand;
|
||||
private readonly RelayCommand _newDefaultWindowCommand;
|
||||
private readonly RelayCommand _newRemoteTabCommand;
|
||||
private readonly RelayCommand _newRemoteWindowCommand;
|
||||
private readonly RelayCommand _newQuickLaunchTabCommand;
|
||||
private readonly RelayCommand _newQuickLaunchWindowCommand;
|
||||
private readonly RelayCommand _settingsCommand;
|
||||
private readonly RelayCommand _aboutCommand;
|
||||
private readonly ICommand _newDefaultTabCommand;
|
||||
private readonly ICommand _newDefaultWindowCommand;
|
||||
private readonly ICommand _newRemoteTabCommand;
|
||||
private readonly ICommand _newRemoteWindowCommand;
|
||||
private readonly ICommand _newQuickLaunchTabCommand;
|
||||
private readonly ICommand _newQuickLaunchWindowCommand;
|
||||
private readonly ICommand _settingsCommand;
|
||||
private readonly ICommand _aboutCommand;
|
||||
private readonly ICommand _quitCommand;
|
||||
|
||||
public MenuViewModel AppMenuViewModel
|
||||
{
|
||||
get => _menuViewModel;
|
||||
private set => Set(ref _menuViewModel, value);
|
||||
private set => SetProperty(ref _menuViewModel, value);
|
||||
}
|
||||
|
||||
private void CreateMenuViewModel()
|
||||
@@ -787,7 +786,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
foreach (var profile in _settingsService.GetShellProfiles().Concat(_settingsService.GetSshProfiles()).OrderBy(x => x.Name))
|
||||
{
|
||||
items.Add(new MenuItemViewModel(profile.Name, new AsyncCommand(() => AddProfileAsync(profile, location))));
|
||||
items.Add(new MenuItemViewModel(profile.Name, new AsyncRelayCommand(() => AddProfileAsync(profile, location))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,8 +796,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
private MenuItemViewModel CommandToMenuItem(ExecutedCommand command)
|
||||
{
|
||||
var itemCommand = new RelayCommand(async () => await AddProfileAsync(command.ShellProfile),
|
||||
keepTargetAlive: true);
|
||||
var itemCommand = new AsyncRelayCommand(() => AddProfileAsync(command.ShellProfile));
|
||||
var keyBinding = command.ShellProfile.KeyBindings?.FirstOrDefault() is KeyBinding kb
|
||||
? new MenuItemKeyBindingViewModel(kb)
|
||||
: null;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Menu
|
||||
namespace FluentTerminal.App.ViewModels.Menu
|
||||
{
|
||||
public sealed class Mdl2Icon
|
||||
{
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.System;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Menu
|
||||
{
|
||||
public class MenuItemKeyBindingViewModel : ViewModelBase
|
||||
public class MenuItemKeyBindingViewModel : ObservableObject
|
||||
{
|
||||
private int _key;
|
||||
|
||||
public int Key
|
||||
{
|
||||
get => _key;
|
||||
set => Set(ref _key, value);
|
||||
set => SetProperty(ref _key, value);
|
||||
}
|
||||
|
||||
private int _keyModifiers;
|
||||
@@ -24,7 +24,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
public int KeyModifiers
|
||||
{
|
||||
get => _keyModifiers;
|
||||
private set => Set(ref _keyModifiers, value);
|
||||
private set => SetProperty(ref _keyModifiers, value);
|
||||
}
|
||||
|
||||
private bool _ctrl;
|
||||
@@ -34,7 +34,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
get => _ctrl;
|
||||
set
|
||||
{
|
||||
if (Set(ref _ctrl, value))
|
||||
if (SetProperty(ref _ctrl, value))
|
||||
{
|
||||
SetKeyModifiers();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
get => _alt;
|
||||
set
|
||||
{
|
||||
if (Set(ref _alt, value))
|
||||
if (SetProperty(ref _alt, value))
|
||||
{
|
||||
SetKeyModifiers();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
get => _shift;
|
||||
set
|
||||
{
|
||||
if (Set(ref _shift, value))
|
||||
if (SetProperty(ref _shift, value))
|
||||
{
|
||||
SetKeyModifiers();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
get => _windows;
|
||||
set
|
||||
{
|
||||
if (Set(ref _windows, value))
|
||||
if (SetProperty(ref _windows, value))
|
||||
{
|
||||
SetKeyModifiers();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
public MenuItemKeyBindingViewModel KeyBinding
|
||||
{
|
||||
get => _keyBinding;
|
||||
set => Set(ref _keyBinding, value);
|
||||
set => SetProperty(ref _keyBinding, value);
|
||||
}
|
||||
|
||||
public ICommand Command { get; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Menu
|
||||
{
|
||||
public class MenuItemViewModelBase : ViewModelBase
|
||||
public class MenuItemViewModelBase : ObservableObject
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
public string Text
|
||||
{
|
||||
get => _text;
|
||||
set => Set(ref _text, value);
|
||||
set => SetProperty(ref _text, value);
|
||||
}
|
||||
|
||||
private string _description;
|
||||
@@ -20,7 +20,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => Set(ref _description, value);
|
||||
set => SetProperty(ref _description, value);
|
||||
}
|
||||
|
||||
private Mdl2Icon _icon;
|
||||
@@ -28,7 +28,7 @@ namespace FluentTerminal.App.ViewModels.Menu
|
||||
public Mdl2Icon Icon
|
||||
{
|
||||
get => _icon;
|
||||
set => Set(ref _icon, value);
|
||||
set => SetProperty(ref _icon, value);
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Menu
|
||||
{
|
||||
public class MenuViewModel : ViewModelBase
|
||||
public class MenuViewModel : ObservableObject
|
||||
{
|
||||
public ObservableCollection<MenuItemViewModelBase> Items { get; }
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class OverlayViewModel : ViewModelBase
|
||||
public class OverlayViewModel : ObservableObject
|
||||
{
|
||||
private readonly DispatcherTimer _overlayTimer;
|
||||
private bool _showOverlay;
|
||||
@@ -19,13 +19,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool ShowOverlay
|
||||
{
|
||||
get => _showOverlay;
|
||||
set => Set(ref _showOverlay, value);
|
||||
set => SetProperty(ref _showOverlay, value);
|
||||
}
|
||||
|
||||
public string OverlayContent
|
||||
{
|
||||
get => _overlayContent;
|
||||
set => Set(ref _overlayContent, value);
|
||||
set => SetProperty(ref _overlayContent, value);
|
||||
}
|
||||
|
||||
public void Show(string message)
|
||||
|
||||
@@ -3,21 +3,21 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.App.ViewModels.Profiles;
|
||||
using FluentTerminal.App.ViewModels.Settings;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all profile view models. Implements logic for saving, editing, resetting, etc.
|
||||
/// </summary>
|
||||
public abstract class ProfileViewModelBase<T> : ViewModelBase where T : ProfileProviderViewModelBase
|
||||
public abstract class ProfileViewModelBase<T> : ObservableObject where T : ProfileProviderViewModelBase
|
||||
{
|
||||
#region Fields
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool InEditMode
|
||||
{
|
||||
get => _inEditMode;
|
||||
set => Set(ref _inEditMode, value);
|
||||
set => SetProperty(ref _inEditMode, value);
|
||||
}
|
||||
|
||||
private string _name;
|
||||
@@ -49,7 +49,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => Set(ref _name, value);
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
public KeyBindingsViewModel KeyBindings { get; }
|
||||
@@ -69,15 +69,15 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
#region Commands
|
||||
|
||||
public IAsyncCommand CancelEditCommand { get; }
|
||||
public ICommand CancelEditCommand { get; }
|
||||
|
||||
public IAsyncCommand DeleteCommand { get; }
|
||||
public ICommand DeleteCommand { get; }
|
||||
|
||||
public RelayCommand EditCommand { get; }
|
||||
public ICommand EditCommand { get; }
|
||||
|
||||
public IAsyncCommand SaveChangesCommand { get; }
|
||||
public ICommand SaveChangesCommand { get; }
|
||||
|
||||
public IAsyncCommand AddKeyboardShortcutCommand { get; }
|
||||
public ICommand AddKeyboardShortcutCommand { get; }
|
||||
|
||||
#endregion Commands
|
||||
|
||||
@@ -102,11 +102,11 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
Initialize(shellProfile);
|
||||
|
||||
DeleteCommand = new AsyncCommand(DeleteAsync, CanDelete);
|
||||
DeleteCommand = new AsyncRelayCommand(DeleteAsync, CanDelete);
|
||||
EditCommand = new RelayCommand(Edit);
|
||||
CancelEditCommand = new AsyncCommand(CancelEditAsync);
|
||||
SaveChangesCommand = new AsyncCommand(SaveChangesAsync);
|
||||
AddKeyboardShortcutCommand = new AsyncCommand(AddKeyboardShortcut);
|
||||
CancelEditCommand = new AsyncRelayCommand(CancelEditAsync);
|
||||
SaveChangesCommand = new AsyncRelayCommand(SaveChangesAsync);
|
||||
AddKeyboardShortcutCommand = new AsyncRelayCommand(AddKeyboardShortcutAsync);
|
||||
}
|
||||
|
||||
#endregion Constructor
|
||||
@@ -248,7 +248,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
IsNew = false;
|
||||
}
|
||||
|
||||
private Task AddKeyboardShortcut()
|
||||
private Task AddKeyboardShortcutAsync()
|
||||
{
|
||||
return KeyBindings.ShowAddKeyBindingDialogAsync();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Profiles
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string Location
|
||||
{
|
||||
get => _location;
|
||||
set => Set(ref _location, value);
|
||||
set => SetProperty(ref _location, value);
|
||||
}
|
||||
|
||||
private string _workingDirectory;
|
||||
@@ -34,7 +35,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string WorkingDirectory
|
||||
{
|
||||
get => _workingDirectory;
|
||||
set => Set(ref _workingDirectory, value);
|
||||
set => SetProperty(ref _workingDirectory, value);
|
||||
}
|
||||
|
||||
private string _arguments;
|
||||
@@ -42,16 +43,16 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string Arguments
|
||||
{
|
||||
get => _arguments;
|
||||
set => Set(ref _arguments, value);
|
||||
set => SetProperty(ref _arguments, value);
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Commands
|
||||
|
||||
public IAsyncCommand BrowseForCustomShellCommand { get; }
|
||||
public ICommand BrowseForCustomShellCommand { get; }
|
||||
|
||||
public IAsyncCommand BrowseForWorkingDirectoryCommand { get; }
|
||||
public ICommand BrowseForWorkingDirectoryCommand { get; }
|
||||
|
||||
#endregion Commands
|
||||
|
||||
@@ -63,8 +64,8 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
{
|
||||
_fileSystemService = fileSystemService;
|
||||
|
||||
BrowseForCustomShellCommand = new AsyncCommand(BrowseForCustomShell);
|
||||
BrowseForWorkingDirectoryCommand = new AsyncCommand(BrowseForWorkingDirectory);
|
||||
BrowseForCustomShellCommand = new AsyncRelayCommand(BrowseForCustomShell);
|
||||
BrowseForWorkingDirectoryCommand = new AsyncRelayCommand(BrowseForWorkingDirectory);
|
||||
|
||||
Initialize(Model);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ using Windows.UI.Core;
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Messages;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Messaging;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Profiles
|
||||
{
|
||||
@@ -16,7 +17,9 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
/// Base class for all profile view model classes. It contains properties shared by all other view models
|
||||
/// (theme-related properties, line-ending translation, and WinPTY/ConPTY selection).
|
||||
/// </summary>
|
||||
public abstract class ProfileProviderViewModelBase : ViewModelBase
|
||||
public abstract class ProfileProviderViewModelBase : ObservableObject,
|
||||
IRecipient<ThemeAddedMessage>,
|
||||
IRecipient<ThemeDeletedMessage>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
@@ -78,7 +81,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
? value
|
||||
: TabThemes.FirstOrDefault(t => t.Id == value.Id) ?? TabThemes.First();
|
||||
|
||||
if (Set(ref _selectedTabTheme, theme))
|
||||
if (SetProperty(ref _selectedTabTheme, theme))
|
||||
{
|
||||
_tabThemeId = theme.Id;
|
||||
}
|
||||
@@ -92,7 +95,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
get => _tabThemeId;
|
||||
set
|
||||
{
|
||||
if (Set(ref _tabThemeId, value))
|
||||
if (SetProperty(ref _tabThemeId, value))
|
||||
{
|
||||
SelectedTabTheme = TabThemes.FirstOrDefault(t => t.Id.Equals(value));
|
||||
}
|
||||
@@ -119,7 +122,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
theme = TerminalThemes.FirstOrDefault(t => t.Id.Equals(theme.Id)) ?? TerminalThemes.First();
|
||||
}
|
||||
|
||||
if (Set(ref _selectedTerminalTheme, theme))
|
||||
if (SetProperty(ref _selectedTerminalTheme, theme))
|
||||
{
|
||||
_terminalThemeId = theme.Id;
|
||||
}
|
||||
@@ -133,7 +136,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
get => _terminalThemeId;
|
||||
set
|
||||
{
|
||||
if (Set(ref _terminalThemeId, value))
|
||||
if (SetProperty(ref _terminalThemeId, value))
|
||||
{
|
||||
SelectedTerminalTheme = TerminalThemes.FirstOrDefault(t => t.Id.Equals(value));
|
||||
}
|
||||
@@ -145,7 +148,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public bool UseConPty
|
||||
{
|
||||
get => _useConPty;
|
||||
set => Set(ref _useConPty, value);
|
||||
set => SetProperty(ref _useConPty, value);
|
||||
}
|
||||
|
||||
private bool _useBuffer;
|
||||
@@ -153,7 +156,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public bool UseBuffer
|
||||
{
|
||||
get => _useBuffer;
|
||||
set => Set(ref _useBuffer, value);
|
||||
set => SetProperty(ref _useBuffer, value);
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
@@ -179,9 +182,6 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
|
||||
SelectedTerminalTheme = TerminalThemes.First();
|
||||
|
||||
MessengerInstance.Register<ThemeAddedMessage>(this, OnThemeAdded);
|
||||
MessengerInstance.Register<ThemeDeletedMessage>(this, OnThemeDeleted);
|
||||
|
||||
Initialize(Model);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
|
||||
#region Methods
|
||||
|
||||
private void OnThemeDeleted(ThemeDeletedMessage message)
|
||||
public void Receive(ThemeDeletedMessage message)
|
||||
{
|
||||
var theme = TerminalThemes.FirstOrDefault(t => t.Id.Equals(message.ThemeId));
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
}, CoreDispatcherPriority.Low, true);
|
||||
}
|
||||
|
||||
private void OnThemeAdded(ThemeAddedMessage message)
|
||||
public void Receive(ThemeAddedMessage message)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() => TerminalThemes.Add(message.Theme), CoreDispatcherPriority.Low);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Windows.Input;
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Profiles
|
||||
{
|
||||
@@ -59,7 +60,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string Host
|
||||
{
|
||||
get => _host;
|
||||
set => Set(ref _host, value);
|
||||
set => SetProperty(ref _host, value);
|
||||
}
|
||||
|
||||
private ushort _sshPort;
|
||||
@@ -67,7 +68,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public ushort SshPort
|
||||
{
|
||||
get => _sshPort;
|
||||
set => Set(ref _sshPort, value);
|
||||
set => SetProperty(ref _sshPort, value);
|
||||
}
|
||||
|
||||
private string _username;
|
||||
@@ -75,7 +76,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string Username
|
||||
{
|
||||
get => _username;
|
||||
set => Set(ref _username, value);
|
||||
set => SetProperty(ref _username, value);
|
||||
}
|
||||
|
||||
private string _identityFile;
|
||||
@@ -83,7 +84,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public string IdentityFile
|
||||
{
|
||||
get => _identityFile;
|
||||
set => Set(ref _identityFile, value);
|
||||
set => SetProperty(ref _identityFile, value);
|
||||
}
|
||||
|
||||
private bool _useMosh;
|
||||
@@ -91,7 +92,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public bool UseMosh
|
||||
{
|
||||
get => _useMosh;
|
||||
set => Set(ref _useMosh, value);
|
||||
set => SetProperty(ref _useMosh, value);
|
||||
}
|
||||
|
||||
private ushort _moshPortFrom;
|
||||
@@ -99,7 +100,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public ushort MoshPortFrom
|
||||
{
|
||||
get => _moshPortFrom;
|
||||
set => Set(ref _moshPortFrom, value);
|
||||
set => SetProperty(ref _moshPortFrom, value);
|
||||
}
|
||||
|
||||
private ushort _moshPortTo;
|
||||
@@ -107,14 +108,14 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
public ushort MoshPortTo
|
||||
{
|
||||
get => _moshPortTo;
|
||||
set => Set(ref _moshPortTo, value);
|
||||
set => SetProperty(ref _moshPortTo, value);
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Commands
|
||||
|
||||
public IAsyncCommand BrowseForIdentityFileCommand { get; }
|
||||
public ICommand BrowseForIdentityFileCommand { get; }
|
||||
|
||||
#endregion Commands
|
||||
|
||||
@@ -132,7 +133,7 @@ namespace FluentTerminal.App.ViewModels.Profiles
|
||||
|
||||
Initialize((SshProfile)Model);
|
||||
|
||||
BrowseForIdentityFileCommand = new AsyncCommand(BrowseForIdentityFileAsync);
|
||||
BrowseForIdentityFileCommand = new AsyncRelayCommand(BrowseForIdentityFileAsync);
|
||||
}
|
||||
|
||||
#endregion Constructor
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class AboutPageViewModel : ViewModelBase
|
||||
public class AboutPageViewModel : ObservableObject
|
||||
{
|
||||
private const string BaseUrl = "https://github.com/felixse/FluentTerminal/releases/tag/";
|
||||
private readonly IUpdateService _updateService;
|
||||
@@ -17,10 +18,10 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_updateService = updateService;
|
||||
_applicationView = applicationView;
|
||||
|
||||
CheckForUpdatesCommand = new AsyncCommand(() => CheckForUpdateAsync(true));
|
||||
CheckForUpdatesCommand = new AsyncRelayCommand(() => CheckForUpdateAsync(true));
|
||||
}
|
||||
|
||||
public IAsyncCommand CheckForUpdatesCommand { get; }
|
||||
public ICommand CheckForUpdatesCommand { get; }
|
||||
|
||||
public string CurrentVersion
|
||||
{
|
||||
@@ -38,12 +39,12 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
get => _latestVersion;
|
||||
set
|
||||
{
|
||||
if (Set(ref _latestVersion, value))
|
||||
if (SetProperty(ref _latestVersion, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LatestVersionFound));
|
||||
RaisePropertyChanged(nameof(LatestVersionLoading));
|
||||
RaisePropertyChanged(nameof(LatestVersionNotFound));
|
||||
RaisePropertyChanged(nameof(LatestVersionReleaseNotesURL));
|
||||
OnPropertyChanged(nameof(LatestVersionFound));
|
||||
OnPropertyChanged(nameof(LatestVersionLoading));
|
||||
OnPropertyChanged(nameof(LatestVersionNotFound));
|
||||
OnPropertyChanged(nameof(LatestVersionReleaseNotesURL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class GeneralPageViewModel : ViewModelBase
|
||||
public class GeneralPageViewModel : ObservableObject
|
||||
{
|
||||
private readonly ApplicationSettings _applicationSettings;
|
||||
private readonly IDefaultValueProvider _defaultValueProvider;
|
||||
@@ -39,8 +40,8 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
|
||||
_applicationSettings = _settingsService.GetApplicationSettings();
|
||||
|
||||
RestoreDefaultsCommand = new AsyncCommand(RestoreDefaultsAsync);
|
||||
BrowseLogDirectoryCommand = new AsyncCommand(BrowseLogDirectoryAsync);
|
||||
RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);
|
||||
BrowseLogDirectoryCommand = new AsyncRelayCommand(BrowseLogDirectoryAsync);
|
||||
}
|
||||
|
||||
public IEnumerable<string> Languages => _applicationLanguageService.Languages;
|
||||
@@ -48,7 +49,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public bool NeedsToRestart
|
||||
{
|
||||
get => _needsToRestart;
|
||||
set => Set(ref _needsToRestart, value);
|
||||
set => SetProperty(ref _needsToRestart, value);
|
||||
}
|
||||
|
||||
public string SelectedLanguage
|
||||
@@ -78,7 +79,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.ShowCustomTitleInTitlebar = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +93,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.EnableTrayIcon = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
|
||||
// Toggle message telling user to restart the program
|
||||
ShouldRestartForTrayMessage = !ShouldRestartForTrayMessage;
|
||||
@@ -103,7 +104,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public bool ShouldRestartForTrayMessage
|
||||
{
|
||||
get => _shouldRestartForTrayMessage;
|
||||
set => Set(ref _shouldRestartForTrayMessage, value);
|
||||
set => SetProperty(ref _shouldRestartForTrayMessage, value);
|
||||
}
|
||||
|
||||
public bool ShowNewOutputIndicator
|
||||
@@ -115,7 +116,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.ShowNewOutputIndicator = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +130,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.UseMoshByDefault = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +144,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.AutoFallbackToWindowsUsernameInLinks = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +158,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.RTrimCopiedLines = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +172,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.MuteTerminalBeeps = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
|
||||
_trayProcessCommunicationService.MuteTerminalAsync(value);
|
||||
}
|
||||
@@ -186,7 +187,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.EnableLogging = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +201,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.PrintableOutputOnly = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +215,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.LogDirectoryPath = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,7 +229,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.UseConPty = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public bool CanEnableStartupTask
|
||||
{
|
||||
get => _canEnableStartupTask;
|
||||
set => Set(ref _canEnableStartupTask, value);
|
||||
set => SetProperty(ref _canEnableStartupTask, value);
|
||||
}
|
||||
|
||||
public bool ConfirmClosingTabs
|
||||
@@ -254,7 +255,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.ConfirmClosingTabs = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +269,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.ConfirmClosingWindows = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,8 +283,8 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.NewTerminalLocation = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged(nameof(TabIsSelected));
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(TabIsSelected));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,21 +298,21 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.TabWindowCascadingAppMenu = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IAsyncCommand RestoreDefaultsCommand { get; }
|
||||
public ICommand RestoreDefaultsCommand { get; }
|
||||
|
||||
public IAsyncCommand BrowseLogDirectoryCommand { get; }
|
||||
public ICommand BrowseLogDirectoryCommand { get; }
|
||||
|
||||
public bool StartupTaskEnabled
|
||||
{
|
||||
get => _startupTaskEnabled;
|
||||
set
|
||||
{
|
||||
if (Set(ref _startupTaskEnabled, value))
|
||||
if (SetProperty(ref _startupTaskEnabled, value))
|
||||
{
|
||||
// ReSharper disable once AssignmentIsFullyDiscarded
|
||||
_ = SetStartupTaskStateAsync(value);
|
||||
@@ -322,7 +323,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public string StartupTaskErrorMessage
|
||||
{
|
||||
get => _startupTaskErrorMessage;
|
||||
set => Set(ref _startupTaskErrorMessage, value);
|
||||
set => SetProperty(ref _startupTaskErrorMessage, value);
|
||||
}
|
||||
|
||||
public bool TabIsSelected
|
||||
@@ -340,7 +341,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.TabsPosition = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,7 +361,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.UnderlineSelectedTab = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -386,7 +387,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.InactiveTabColorMode = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +401,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.ShowTextCopied = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class KeyBindingViewModel : ViewModelBase
|
||||
public class KeyBindingViewModel : ObservableObject
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
|
||||
@@ -17,8 +18,8 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
Model = keyBinding;
|
||||
Parent = parent;
|
||||
_dialogService = dialogService;
|
||||
EditCommand = new AsyncCommand(EditAsync);
|
||||
DeleteCommand = new AsyncCommand(DeleteAsync);
|
||||
EditCommand = new AsyncRelayCommand(EditAsync);
|
||||
DeleteCommand = new AsyncRelayCommand(DeleteAsync);
|
||||
}
|
||||
|
||||
// Needs to be triggered from the UI thread
|
||||
@@ -36,7 +37,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
if (Model.Meta != value)
|
||||
{
|
||||
Model.Meta = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +50,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
if (Model.Alt != value)
|
||||
{
|
||||
Model.Alt = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,13 +63,13 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
if (Model.Ctrl != value)
|
||||
{
|
||||
Model.Ctrl = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IAsyncCommand DeleteCommand { get; }
|
||||
public IAsyncCommand EditCommand { get; }
|
||||
public ICommand DeleteCommand { get; }
|
||||
public ICommand EditCommand { get; }
|
||||
|
||||
public int Key
|
||||
{
|
||||
@@ -78,7 +79,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
if (Model.Key != value)
|
||||
{
|
||||
Model.Key = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +94,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
if (Model.Shift != value)
|
||||
{
|
||||
Model.Shift = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class KeyBindingsPageViewModel : ViewModelBase
|
||||
public class KeyBindingsPageViewModel : ObservableObject
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@@ -23,15 +24,15 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_settingsService = settingsService;
|
||||
_dialogService = dialogService;
|
||||
_trayProcessCommunicationService = trayProcessCommunicationService;
|
||||
RestoreDefaultsCommand = new RelayCommand(async () => await RestoreDefaultsAsync().ConfigureAwait(false));
|
||||
AddCommand = new RelayCommand<string>(async command => await AddAsync(command).ConfigureAwait(false));
|
||||
RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);
|
||||
AddCommand = new AsyncRelayCommand<string>(AddAsync);
|
||||
|
||||
Initialize(_settingsService.GetCommandKeyBindings());
|
||||
}
|
||||
|
||||
public RelayCommand<string> AddCommand { get; }
|
||||
public ICommand AddCommand { get; }
|
||||
public ObservableCollection<KeyBindingsViewModel> KeyBindings { get; } = new ObservableCollection<KeyBindingsViewModel>();
|
||||
public RelayCommand RestoreDefaultsCommand { get; }
|
||||
public ICommand RestoreDefaultsCommand { get; }
|
||||
|
||||
private Task AddAsync(string command)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class KeyBindingsViewModel : ViewModelBase
|
||||
public class KeyBindingsViewModel : ObservableObject
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private bool _editable;
|
||||
@@ -37,7 +37,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public bool Editable
|
||||
{
|
||||
get => _editable;
|
||||
set => Set(ref _editable, value);
|
||||
set => SetProperty(ref _editable, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<KeyBindingViewModel> KeyBindings { get; } = new ObservableCollection<KeyBindingViewModel>();
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class MousePageViewModel : ViewModelBase
|
||||
public class MousePageViewModel : ObservableObject
|
||||
{
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IDialogService _dialogService;
|
||||
@@ -22,7 +23,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_defaultValueProvider = defaultValueProvider;
|
||||
_applicationSettings = _settingsService.GetApplicationSettings();
|
||||
|
||||
RestoreDefaultsCommand = new RelayCommand(async () => await RestoreDefaultsAsync().ConfigureAwait(false));
|
||||
RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);
|
||||
}
|
||||
|
||||
public bool CopyOnSelect
|
||||
@@ -34,7 +35,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.CopyOnSelect = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +49,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.MouseRightClickAction = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +87,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_applicationSettings.MouseMiddleClickAction = value;
|
||||
_settingsService.SaveApplicationSettings(_applicationSettings);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +116,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
set { if (value) MouseMiddleClickAction = MouseAction.CopySelectionOrPaste; }
|
||||
}
|
||||
|
||||
public RelayCommand RestoreDefaultsCommand { get; }
|
||||
public ICommand RestoreDefaultsCommand { get; }
|
||||
|
||||
// Requires UI thread
|
||||
private async Task RestoreDefaultsAsync()
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class ProfilesPageViewModel : ViewModelBase
|
||||
public class ProfilesPageViewModel : ObservableObject
|
||||
{
|
||||
private readonly IDefaultValueProvider _defaultValueProvider;
|
||||
private readonly IDialogService _dialogService;
|
||||
@@ -79,9 +80,9 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand CreateShellProfileCommand { get; }
|
||||
public ICommand CreateShellProfileCommand { get; }
|
||||
|
||||
public RelayCommand<ShellProfileViewModel> CloneCommand { get; }
|
||||
public ICommand CloneCommand { get; }
|
||||
|
||||
private void CreateShellProfile()
|
||||
{
|
||||
@@ -122,7 +123,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public ShellProfileViewModel SelectedShellProfile
|
||||
{
|
||||
get => _selectedShellProfile;
|
||||
set => Set(ref _selectedShellProfile, value);
|
||||
set => SetProperty(ref _selectedShellProfile, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<ShellProfileViewModel> ShellProfiles { get; } = new ObservableCollection<ShellProfileViewModel>();
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class SshProfilesPageViewModel: ViewModelBase
|
||||
public class SshProfilesPageViewModel: ObservableObject
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@@ -63,9 +64,9 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand CreateSshProfileCommand { get; }
|
||||
public ICommand CreateSshProfileCommand { get; }
|
||||
|
||||
public RelayCommand<SshProfileViewModel> CloneCommand { get; }
|
||||
public ICommand CloneCommand { get; }
|
||||
|
||||
public void CreateSshProfile()
|
||||
{
|
||||
@@ -112,7 +113,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
public SshProfileViewModel SelectedSshProfile
|
||||
{
|
||||
get => _selectedShellProfile;
|
||||
set => Set(ref _selectedShellProfile, value);
|
||||
set => SetProperty(ref _selectedShellProfile, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<SshProfileViewModel> SshProfiles { get; } = new ObservableCollection<SshProfileViewModel>();
|
||||
|
||||
@@ -3,15 +3,16 @@ using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Utilities;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class TerminalPageViewModel : ViewModelBase
|
||||
public class TerminalPageViewModel : ObservableObject
|
||||
{
|
||||
private readonly TerminalOptions _terminalOptions;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@@ -63,7 +64,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.CursorBlink = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +78,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.UseAcrylicBackground = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.FontFamily = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +106,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.FontWeight = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +120,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.BackgroundOpacity = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +134,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.Padding = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,12 +154,12 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.ScrollBackLimit = intValue;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,7 +174,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.WordSeparator = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,14 +190,14 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.FontSize = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<int> Sizes { get; }
|
||||
|
||||
public RelayCommand RestoreDefaultsCommand { get; }
|
||||
public ICommand RestoreDefaultsCommand { get; }
|
||||
|
||||
private CursorStyle CursorStyle
|
||||
{
|
||||
@@ -207,7 +208,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.CursorStyle = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +222,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
_terminalOptions.ScrollBarStyle = value;
|
||||
_settingsService.SaveTerminalOptions(_terminalOptions);
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +256,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_dialogService = dialogService;
|
||||
_defaultValueProvider = defaultValueProvider;
|
||||
|
||||
RestoreDefaultsCommand = new RelayCommand(async () => await RestoreDefaultsAsync().ConfigureAwait(false));
|
||||
RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);
|
||||
|
||||
Fonts = systemFontService.GetSystemFontFamilies().OrderBy(s => s.Name);
|
||||
Sizes = Enumerable.Range(2, 72);
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FluentTerminal.Models.Messages;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using Microsoft.Toolkit.Mvvm.Messaging;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels.Settings
|
||||
{
|
||||
public class ThemesPageViewModel : ViewModelBase
|
||||
public class ThemesPageViewModel : ObservableObject,
|
||||
IRecipient<TerminalOptionsChangedMessage>
|
||||
{
|
||||
private readonly IDefaultValueProvider _defaultValueProvider;
|
||||
private readonly IDialogService _dialogService;
|
||||
@@ -42,11 +44,9 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_imageFileSystemService = imageFileSystemService;
|
||||
|
||||
CreateThemeCommand = new RelayCommand(CreateTheme);
|
||||
ImportThemeCommand = new AsyncCommand(ImportThemeAsync);
|
||||
ImportThemeCommand = new AsyncRelayCommand(ImportThemeAsync);
|
||||
CloneCommand = new RelayCommand<ThemeViewModel>(CloneTheme);
|
||||
|
||||
MessengerInstance.Register<TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);
|
||||
|
||||
BackgroundOpacity = _settingsService.GetTerminalOptions().BackgroundOpacity;
|
||||
|
||||
var activeThemeId = _settingsService.GetCurrentThemeId();
|
||||
@@ -66,14 +66,14 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
SelectedTheme = Themes.First(t => t.IsActive);
|
||||
}
|
||||
|
||||
public RelayCommand CreateThemeCommand { get; }
|
||||
public IAsyncCommand ImportThemeCommand { get; }
|
||||
public RelayCommand<ThemeViewModel> CloneCommand { get; set; }
|
||||
public ICommand CreateThemeCommand { get; }
|
||||
public ICommand ImportThemeCommand { get; }
|
||||
public ICommand CloneCommand { get; set; }
|
||||
|
||||
public double BackgroundOpacity
|
||||
{
|
||||
get => _backgroundOpacity;
|
||||
set => Set(ref _backgroundOpacity, value);
|
||||
set => SetProperty(ref _backgroundOpacity, value);
|
||||
}
|
||||
|
||||
public ThemeViewModel SelectedTheme
|
||||
@@ -87,7 +87,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
_selectedTheme.BackgroundImageChanged -= OnSelectedThemeBackgroundImageChanged;
|
||||
}
|
||||
|
||||
Set(ref _selectedTheme, value);
|
||||
SetProperty(ref _selectedTheme, value);
|
||||
SelectedThemeChanged?.Invoke(this, _selectedTheme);
|
||||
|
||||
if (value != null)
|
||||
@@ -218,7 +218,7 @@ namespace FluentTerminal.App.ViewModels.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTerminalOptionsChanged(TerminalOptionsChangedMessage message)
|
||||
public void Receive(TerminalOptionsChangedMessage message)
|
||||
{
|
||||
BackgroundOpacity = message.TerminalOptions.BackgroundOpacity;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.ViewModels.Settings;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
public class SettingsViewModel : ObservableObject
|
||||
{
|
||||
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
|
||||
ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FluentTerminal.App.ViewModels.Profiles;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool IsDefault
|
||||
{
|
||||
get => _isDefault;
|
||||
set => Set(ref _isDefault, value);
|
||||
set => SetProperty(ref _isDefault, value);
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
@@ -41,9 +41,9 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
#region Commands
|
||||
|
||||
public RelayCommand SetDefaultCommand { get; }
|
||||
public ICommand SetDefaultCommand { get; }
|
||||
|
||||
public IAsyncCommand RestoreDefaultsCommand { get; }
|
||||
public ICommand RestoreDefaultsCommand { get; }
|
||||
|
||||
#endregion Commands
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
shellProfile);
|
||||
|
||||
SetDefaultCommand = new RelayCommand(SetDefault);
|
||||
RestoreDefaultsCommand = new AsyncCommand(RestoreDefaultsAsync);
|
||||
RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync);
|
||||
}
|
||||
|
||||
#endregion Constrcutor
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class TabThemeViewModel : ViewModelBase
|
||||
public class TabThemeViewModel : ObservableObject
|
||||
{
|
||||
private bool _isSelected;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (Set(ref _isSelected, value) && value)
|
||||
if (SetProperty(ref _isSelected, value) && value)
|
||||
{
|
||||
Terminal.TabTheme = this;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using FluentTerminal.Models.Enums;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -15,14 +12,18 @@ using Windows.UI.Core;
|
||||
using FluentTerminal.Models.Messages;
|
||||
using System.Windows.Input;
|
||||
using FluentTerminal.App.ViewModels.Menu;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Messaging;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class TerminalViewModel : ViewModelBase
|
||||
public class TerminalViewModel : ObservableObject,
|
||||
IRecipient<ApplicationSettingsChangedMessage>,
|
||||
IRecipient<CurrentThemeChangedMessage>,
|
||||
IRecipient<TerminalOptionsChangedMessage>,
|
||||
IRecipient<KeyBindingsChangedMessage>
|
||||
{
|
||||
#region Static
|
||||
|
||||
@@ -126,11 +127,6 @@ namespace FluentTerminal.App.ViewModels
|
||||
IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, ShellProfile shellProfile,
|
||||
IApplicationView applicationView, IClipboardService clipboardService, string terminalState = null)
|
||||
{
|
||||
MessengerInstance.Register<ApplicationSettingsChangedMessage>(this, OnApplicationSettingsChanged);
|
||||
MessengerInstance.Register<CurrentThemeChangedMessage>(this, OnCurrentThemeChanged);
|
||||
MessengerInstance.Register<TerminalOptionsChangedMessage>(this, OnTerminalOptionsChanged);
|
||||
MessengerInstance.Register<KeyBindingsChangedMessage>(this, OnKeyBindingsChanged);
|
||||
|
||||
SettingsService = settingsService;
|
||||
|
||||
_terminalOptions = SettingsService.GetTerminalOptions();
|
||||
@@ -147,19 +143,19 @@ namespace FluentTerminal.App.ViewModels
|
||||
TerminalTheme = shellProfile.TerminalThemeId == Guid.Empty ? SettingsService.GetCurrentTheme() : SettingsService.GetTheme(shellProfile.TerminalThemeId);
|
||||
|
||||
TabThemes = new ObservableCollection<TabThemeViewModel>(SettingsService.GetTabThemes().Select(theme => new TabThemeViewModel(theme, this)));
|
||||
CloseCommand = new AsyncCommand(TryCloseAsync, CanExecuteCommand);
|
||||
CloseCommand = new AsyncRelayCommand(TryCloseAsync, CanExecuteCommand);
|
||||
CloseLeftTabsCommand = new RelayCommand(CloseLeftTabs, CanExecuteCommand);
|
||||
CloseRightTabsCommand = new RelayCommand(CloseRightTabs, CanExecuteCommand);
|
||||
CloseOtherTabsCommand = new RelayCommand(CloseOtherTabs, CanExecuteCommand);
|
||||
FindNextCommand = new RelayCommand(FindNext, CanExecuteCommand);
|
||||
FindPreviousCommand = new RelayCommand(FindPrevious, CanExecuteCommand);
|
||||
CloseSearchPanelCommand = new RelayCommand(CloseSearchPanel, CanExecuteCommand);
|
||||
EditTitleCommand = new AsyncCommand(EditTitleAsync, CanExecuteCommand);
|
||||
EditTitleCommand = new AsyncRelayCommand(EditTitleAsync, CanExecuteCommand);
|
||||
DuplicateTabCommand = new RelayCommand(DuplicateTab, CanExecuteCommand);
|
||||
ReconnectTabCommand = new AsyncCommand(ReconnectTabAsync, () => CanExecuteCommand() && HasExitedWithError);
|
||||
CopyCommand = new AsyncCommand(Copy, () => HasSelection);
|
||||
PasteCommand = new AsyncCommand(Paste);
|
||||
CopyLinkCommand = new AsyncCommand(() => CopyTextAsync(HoveredUri), () => !string.IsNullOrWhiteSpace(HoveredUri));
|
||||
ReconnectTabCommand = new AsyncRelayCommand(ReconnectTabAsync, () => CanExecuteCommand() && HasExitedWithError);
|
||||
CopyCommand = new AsyncRelayCommand(Copy, () => HasSelection);
|
||||
PasteCommand = new AsyncRelayCommand(Paste);
|
||||
CopyLinkCommand = new AsyncRelayCommand(() => CopyTextAsync(HoveredUri), () => !string.IsNullOrWhiteSpace(HoveredUri));
|
||||
ShowSearchPanelCommand = new RelayCommand(() => ShowSearchPanel = true, () => !ShowSearchPanel);
|
||||
|
||||
FontSize = _terminalOptions.FontSize;
|
||||
@@ -191,13 +187,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public MenuViewModel ContextMenu
|
||||
{
|
||||
get => _contextMenu;
|
||||
set => Set(ref _contextMenu, value);
|
||||
set => SetProperty(ref _contextMenu, value);
|
||||
}
|
||||
|
||||
public MenuViewModel TabContextMenu
|
||||
{
|
||||
get => _tabContextMenu;
|
||||
set => Set(ref _tabContextMenu, value);
|
||||
set => SetProperty(ref _tabContextMenu, value);
|
||||
}
|
||||
|
||||
private bool _disposalRequested;
|
||||
@@ -241,27 +237,27 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
public string XtermBufferState { get; private set; }
|
||||
|
||||
public AsyncCommand CloseCommand { get; private set; }
|
||||
public ICommand CloseCommand { get; private set; }
|
||||
|
||||
public RelayCommand CloseRightTabsCommand { get; }
|
||||
public ICommand CloseRightTabsCommand { get; }
|
||||
|
||||
public RelayCommand CloseLeftTabsCommand { get; }
|
||||
public ICommand CloseLeftTabsCommand { get; }
|
||||
|
||||
public RelayCommand CloseOtherTabsCommand { get; }
|
||||
public ICommand CloseOtherTabsCommand { get; }
|
||||
|
||||
public RelayCommand CloseSearchPanelCommand { get; }
|
||||
public ICommand CloseSearchPanelCommand { get; }
|
||||
|
||||
public IDialogService DialogService { get; }
|
||||
|
||||
public IAsyncCommand EditTitleCommand { get; }
|
||||
public ICommand EditTitleCommand { get; }
|
||||
|
||||
public RelayCommand FindNextCommand { get; }
|
||||
public ICommand FindNextCommand { get; }
|
||||
|
||||
public RelayCommand FindPreviousCommand { get; }
|
||||
public ICommand FindPreviousCommand { get; }
|
||||
|
||||
public RelayCommand DuplicateTabCommand { get; }
|
||||
public ICommand DuplicateTabCommand { get; }
|
||||
|
||||
public AsyncCommand ReconnectTabCommand { get; }
|
||||
public AsyncRelayCommand ReconnectTabCommand { get; }
|
||||
|
||||
public ICommand CopyLinkCommand { get; private set; }
|
||||
|
||||
@@ -278,7 +274,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (Set(ref _isSelected, value))
|
||||
if (SetProperty(ref _isSelected, value))
|
||||
{
|
||||
if (IsSelected)
|
||||
{
|
||||
@@ -291,9 +287,9 @@ namespace FluentTerminal.App.ViewModels
|
||||
_keyboardCommandService.DeregisterCommandHandler(nameof(Command.Search));
|
||||
_keyboardCommandService.DeregisterCommandHandler(nameof(Command.CloseSearch));
|
||||
}
|
||||
RaisePropertyChanged(nameof(IsUnderlined));
|
||||
RaisePropertyChanged(nameof(BackgroundTabTheme));
|
||||
RaisePropertyChanged(nameof(ShowCloseButton));
|
||||
OnPropertyChanged(nameof(IsUnderlined));
|
||||
OnPropertyChanged(nameof(BackgroundTabTheme));
|
||||
OnPropertyChanged(nameof(ShowCloseButton));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,7 +297,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool HasSelection
|
||||
{
|
||||
get => _hasSelection;
|
||||
set => Set(ref _hasSelection, value);
|
||||
set => SetProperty(ref _hasSelection, value);
|
||||
}
|
||||
|
||||
public string HoveredUri
|
||||
@@ -309,7 +305,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _hoveredUri;
|
||||
set
|
||||
{
|
||||
if (Set(ref _hoveredUri, value))
|
||||
if (SetProperty(ref _hoveredUri, value))
|
||||
{
|
||||
ContextMenu = BuidContextMenu();
|
||||
}
|
||||
@@ -321,9 +317,9 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _isHovered;
|
||||
set
|
||||
{
|
||||
if (Set(ref _isHovered, value))
|
||||
if (SetProperty(ref _isHovered, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(ShowCloseButton));
|
||||
OnPropertyChanged(nameof(ShowCloseButton));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +335,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool HasNewOutput
|
||||
{
|
||||
get => _hasNewOutput;
|
||||
set => Set(ref _hasNewOutput, value);
|
||||
set => SetProperty(ref _hasNewOutput, value);
|
||||
}
|
||||
|
||||
public bool HasExitedWithError
|
||||
@@ -347,36 +343,36 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _hasExitedWithError;
|
||||
set
|
||||
{
|
||||
if (Set(ref _hasExitedWithError, value) && value)
|
||||
if (SetProperty(ref _hasExitedWithError, value) && value)
|
||||
{
|
||||
HasNewOutput = false;
|
||||
}
|
||||
ReconnectTabCommand.RaiseCanExecuteChanged();
|
||||
ReconnectTabCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set => Set(ref _searchText, value);
|
||||
set => SetProperty(ref _searchText, value);
|
||||
}
|
||||
|
||||
public bool SearchMatchCase
|
||||
{
|
||||
get => _searchMatchCase;
|
||||
set => Set(ref _searchMatchCase, value);
|
||||
set => SetProperty(ref _searchMatchCase, value);
|
||||
}
|
||||
|
||||
public bool SearchWholeWord
|
||||
{
|
||||
get => _searchWholeWord;
|
||||
set => Set(ref _searchWholeWord, value);
|
||||
set => SetProperty(ref _searchWholeWord, value);
|
||||
}
|
||||
|
||||
public bool SearchWithRegex
|
||||
{
|
||||
get => _searchWithRegex;
|
||||
set => Set(ref _searchWithRegex, value);
|
||||
set => SetProperty(ref _searchWithRegex, value);
|
||||
}
|
||||
|
||||
public ISettingsService SettingsService { get; }
|
||||
@@ -386,7 +382,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool ShowSearchPanel
|
||||
{
|
||||
get => _showSearchPanel;
|
||||
set => Set(ref _showSearchPanel, value);
|
||||
set => SetProperty(ref _showSearchPanel, value);
|
||||
}
|
||||
|
||||
public bool SearchHasFocus { get; set; }
|
||||
@@ -396,9 +392,9 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _tabTheme;
|
||||
set
|
||||
{
|
||||
Set(ref _tabTheme, value);
|
||||
RaisePropertyChanged(nameof(IsUnderlined));
|
||||
RaisePropertyChanged(nameof(BackgroundTabTheme));
|
||||
SetProperty(ref _tabTheme, value);
|
||||
OnPropertyChanged(nameof(IsUnderlined));
|
||||
OnPropertyChanged(nameof(BackgroundTabTheme));
|
||||
|
||||
// necessary to update this constantly so that duplicated tabs will also carry over the color
|
||||
ShellProfile.TabThemeId = value.Theme.Id;
|
||||
@@ -414,7 +410,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public TerminalTheme TerminalTheme
|
||||
{
|
||||
get => _terminalTheme;
|
||||
set => Set(ref _terminalTheme, value);
|
||||
set => SetProperty(ref _terminalTheme, value);
|
||||
}
|
||||
|
||||
public bool Initialized { get; set; }
|
||||
@@ -445,7 +441,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
Set(ref _tabTitle, title);
|
||||
SetProperty(ref _tabTitle, title);
|
||||
ShellProfile.Name = title;
|
||||
}
|
||||
}
|
||||
@@ -455,7 +451,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _shellTitle;
|
||||
set
|
||||
{
|
||||
if (Set(ref _shellTitle, value) && !_hasCustomTitle)
|
||||
if (SetProperty(ref _shellTitle, value) && !_hasCustomTitle)
|
||||
{
|
||||
TabTitle = value;
|
||||
}
|
||||
@@ -475,7 +471,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
|
||||
public Task CloseAsync()
|
||||
{
|
||||
MessengerInstance.Unregister(this);
|
||||
//MessengerInstance.Unregister(this); // todo necessary?
|
||||
|
||||
return Terminal.CloseAsync();
|
||||
}
|
||||
@@ -579,18 +575,18 @@ namespace FluentTerminal.App.ViewModels
|
||||
await TerminalView?.ReconnectAsync();
|
||||
}
|
||||
|
||||
private void OnApplicationSettingsChanged(ApplicationSettingsChangedMessage message)
|
||||
public void Receive(ApplicationSettingsChangedMessage message)
|
||||
{
|
||||
ApplicationSettings = message.ApplicationSettings;
|
||||
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() =>
|
||||
{
|
||||
RaisePropertyChanged(nameof(IsUnderlined));
|
||||
RaisePropertyChanged(nameof(BackgroundTabTheme));
|
||||
OnPropertyChanged(nameof(IsUnderlined));
|
||||
OnPropertyChanged(nameof(BackgroundTabTheme));
|
||||
});
|
||||
}
|
||||
|
||||
private void OnCurrentThemeChanged(CurrentThemeChangedMessage message)
|
||||
public void Receive(CurrentThemeChangedMessage message)
|
||||
{
|
||||
// only change theme if not overwritten by profile
|
||||
if (ShellProfile.TerminalThemeId == Guid.Empty)
|
||||
@@ -605,13 +601,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTerminalOptionsChanged(TerminalOptionsChangedMessage message)
|
||||
public void Receive(TerminalOptionsChangedMessage message)
|
||||
{
|
||||
_terminalOptions = message.TerminalOptions;
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() => RaisePropertyChanged(nameof(BackgroundOpacity)), CoreDispatcherPriority.Low);
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() => OnPropertyChanged(nameof(BackgroundOpacity)), CoreDispatcherPriority.Low);
|
||||
}
|
||||
|
||||
private void OnKeyBindingsChanged(KeyBindingsChangedMessage message)
|
||||
public void Receive(KeyBindingsChangedMessage message)
|
||||
{
|
||||
ApplicationView.ExecuteOnUiThreadAsync(() =>
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using FluentTerminal.App.Services;
|
||||
using FluentTerminal.App.Services.Utilities;
|
||||
using FluentTerminal.App.ViewModels.Infrastructure;
|
||||
using FluentTerminal.Models;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Toolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
@@ -11,7 +10,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace FluentTerminal.App.ViewModels
|
||||
{
|
||||
public class ThemeViewModel : ViewModelBase
|
||||
public class ThemeViewModel : ObservableObject
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@@ -95,13 +94,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
BackgroundThemeFile = Model.BackgroundImage;
|
||||
|
||||
SetActiveCommand = new RelayCommand(SetActive);
|
||||
DeleteCommand = new AsyncCommand(DeleteAsync, NotPreInstalled);
|
||||
DeleteCommand = new AsyncRelayCommand(DeleteAsync, NotPreInstalled);
|
||||
EditCommand = new RelayCommand(Edit, NotPreInstalled);
|
||||
CancelEditCommand = new AsyncCommand(CancelEditAsync);
|
||||
SaveChangesCommand = new AsyncCommand(SaveChangesAsync);
|
||||
ExportCommand = new AsyncCommand(Export, NotPreInstalled);
|
||||
ChooseBackgroundImageCommand = new AsyncCommand(ChooseBackgroundImageAsync, NotPreInstalled);
|
||||
DeleteBackgroundImageCommand = new AsyncCommand(DeleteBackgroundImageAsync, NotPreInstalled);
|
||||
CancelEditCommand = new AsyncRelayCommand(CancelEditAsync);
|
||||
SaveChangesCommand = new AsyncRelayCommand(SaveChangesAsync);
|
||||
ExportCommand = new AsyncRelayCommand(Export, NotPreInstalled);
|
||||
ChooseBackgroundImageCommand = new AsyncRelayCommand(ChooseBackgroundImageAsync, NotPreInstalled);
|
||||
DeleteBackgroundImageCommand = new AsyncRelayCommand(DeleteBackgroundImageAsync, NotPreInstalled);
|
||||
}
|
||||
|
||||
public event EventHandler Activated;
|
||||
@@ -113,7 +112,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Author
|
||||
{
|
||||
get => _author;
|
||||
set => Set(ref _author, value);
|
||||
set => SetProperty(ref _author, value);
|
||||
}
|
||||
|
||||
public string Background
|
||||
@@ -121,7 +120,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _background;
|
||||
set
|
||||
{
|
||||
Set(ref _background, value);
|
||||
SetProperty(ref _background, value);
|
||||
BackgroundChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
@@ -129,67 +128,67 @@ namespace FluentTerminal.App.ViewModels
|
||||
public double BackgroundOpacity
|
||||
{
|
||||
get => _backgroundOpacity;
|
||||
set => Set(ref _backgroundOpacity, value);
|
||||
set => SetProperty(ref _backgroundOpacity, value);
|
||||
}
|
||||
|
||||
public string Black
|
||||
{
|
||||
get => _black;
|
||||
set => Set(ref _black, value);
|
||||
set => SetProperty(ref _black, value);
|
||||
}
|
||||
|
||||
public string Blue
|
||||
{
|
||||
get => _blue;
|
||||
set => Set(ref _blue, value);
|
||||
set => SetProperty(ref _blue, value);
|
||||
}
|
||||
|
||||
public string BrightBlack
|
||||
{
|
||||
get => _brightBlack;
|
||||
set => Set(ref _brightBlack, value);
|
||||
set => SetProperty(ref _brightBlack, value);
|
||||
}
|
||||
|
||||
public string BrightBlue
|
||||
{
|
||||
get => _brightBlue;
|
||||
set => Set(ref _brightBlue, value);
|
||||
set => SetProperty(ref _brightBlue, value);
|
||||
}
|
||||
|
||||
public string BrightCyan
|
||||
{
|
||||
get => _brightCyan;
|
||||
set => Set(ref _brightCyan, value);
|
||||
set => SetProperty(ref _brightCyan, value);
|
||||
}
|
||||
|
||||
public string BrightGreen
|
||||
{
|
||||
get => _brightGreen;
|
||||
set => Set(ref _brightGreen, value);
|
||||
set => SetProperty(ref _brightGreen, value);
|
||||
}
|
||||
|
||||
public string BrightMagenta
|
||||
{
|
||||
get => _brightMagenta;
|
||||
set => Set(ref _brightMagenta, value);
|
||||
set => SetProperty(ref _brightMagenta, value);
|
||||
}
|
||||
|
||||
public string BrightRed
|
||||
{
|
||||
get => _brightRed;
|
||||
set => Set(ref _brightRed, value);
|
||||
set => SetProperty(ref _brightRed, value);
|
||||
}
|
||||
|
||||
public string BrightWhite
|
||||
{
|
||||
get => _brightWhite;
|
||||
set => Set(ref _brightWhite, value);
|
||||
set => SetProperty(ref _brightWhite, value);
|
||||
}
|
||||
|
||||
public string BrightYellow
|
||||
{
|
||||
get => _brightYellow;
|
||||
set => Set(ref _brightYellow, value);
|
||||
set => SetProperty(ref _brightYellow, value);
|
||||
}
|
||||
|
||||
public ICommand CancelEditCommand { get; }
|
||||
@@ -197,19 +196,19 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Cursor
|
||||
{
|
||||
get => _cursor;
|
||||
set => Set(ref _cursor, value);
|
||||
set => SetProperty(ref _cursor, value);
|
||||
}
|
||||
|
||||
public string CursorAccent
|
||||
{
|
||||
get => _cursorAccent;
|
||||
set => Set(ref _cursorAccent, value);
|
||||
set => SetProperty(ref _cursorAccent, value);
|
||||
}
|
||||
|
||||
public string Cyan
|
||||
{
|
||||
get => _cyan;
|
||||
set => Set(ref _cyan, value);
|
||||
set => SetProperty(ref _cyan, value);
|
||||
}
|
||||
|
||||
public ICommand DeleteCommand { get; }
|
||||
@@ -219,13 +218,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Foreground
|
||||
{
|
||||
get => _foreground;
|
||||
set => Set(ref _foreground, value);
|
||||
set => SetProperty(ref _foreground, value);
|
||||
}
|
||||
|
||||
public string Green
|
||||
{
|
||||
get => _green;
|
||||
set => Set(ref _green, value);
|
||||
set => SetProperty(ref _green, value);
|
||||
}
|
||||
|
||||
public Guid Id { get; }
|
||||
@@ -233,31 +232,31 @@ namespace FluentTerminal.App.ViewModels
|
||||
public bool InEditMode
|
||||
{
|
||||
get => _inEditMode;
|
||||
set => Set(ref _inEditMode, value);
|
||||
set => SetProperty(ref _inEditMode, value);
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => _isActive;
|
||||
set => Set(ref _isActive, value);
|
||||
set => SetProperty(ref _isActive, value);
|
||||
}
|
||||
|
||||
public string Magenta
|
||||
{
|
||||
get => _magenta;
|
||||
set => Set(ref _magenta, value);
|
||||
set => SetProperty(ref _magenta, value);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => Set(ref _name, value);
|
||||
set => SetProperty(ref _name, value);
|
||||
}
|
||||
|
||||
public string Red
|
||||
{
|
||||
get => _red;
|
||||
set => Set(ref _red, value);
|
||||
set => SetProperty(ref _red, value);
|
||||
}
|
||||
|
||||
public ICommand SaveChangesCommand { get; }
|
||||
@@ -265,7 +264,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string Selection
|
||||
{
|
||||
get => _selection;
|
||||
set => Set(ref _selection, value);
|
||||
set => SetProperty(ref _selection, value);
|
||||
}
|
||||
|
||||
public ICommand SetActiveCommand { get; }
|
||||
@@ -273,13 +272,13 @@ namespace FluentTerminal.App.ViewModels
|
||||
public string White
|
||||
{
|
||||
get => _white;
|
||||
set => Set(ref _white, value);
|
||||
set => SetProperty(ref _white, value);
|
||||
}
|
||||
|
||||
public string Yellow
|
||||
{
|
||||
get => _yellow;
|
||||
set => Set(ref _yellow, value);
|
||||
set => SetProperty(ref _yellow, value);
|
||||
}
|
||||
|
||||
public ImageFile BackgroundThemeFile
|
||||
@@ -287,7 +286,7 @@ namespace FluentTerminal.App.ViewModels
|
||||
get => _backgroundThemeFile;
|
||||
set
|
||||
{
|
||||
Set(ref _backgroundThemeFile, value);
|
||||
SetProperty(ref _backgroundThemeFile, value);
|
||||
BackgroundImageChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user