-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
358 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
FluentTerminal.App.ViewModels/Settings/MousePageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
using FluentTerminal.App.Services; | ||
using FluentTerminal.Models; | ||
using FluentTerminal.Models.Enums; | ||
using GalaSoft.MvvmLight; | ||
using GalaSoft.MvvmLight.Command; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FluentTerminal.App.ViewModels.Settings | ||
{ | ||
public class MousePageViewModel : ViewModelBase | ||
{ | ||
private readonly ISettingsService _settingsService; | ||
private readonly IDialogService _dialogService; | ||
private readonly IDefaultValueProvider _defaultValueProvider; | ||
private readonly ApplicationSettings _applicationSettings; | ||
private bool _editingMouseRightClickAction; | ||
private bool _editingMouseMiddleClickAction; | ||
|
||
public MousePageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) | ||
{ | ||
_settingsService = settingsService; | ||
_dialogService = dialogService; | ||
_defaultValueProvider = defaultValueProvider; | ||
_applicationSettings = _settingsService.GetApplicationSettings(); | ||
|
||
RestoreDefaultsCommand = new RelayCommand(async () => await RestoreDefaults().ConfigureAwait(false)); | ||
} | ||
|
||
public bool CopyOnSelect | ||
{ | ||
get => _applicationSettings.CopyOnSelect; | ||
set | ||
{ | ||
if (_applicationSettings.CopyOnSelect != value) | ||
{ | ||
_applicationSettings.CopyOnSelect = value; | ||
_settingsService.SaveApplicationSettings(_applicationSettings); | ||
RaisePropertyChanged(); | ||
} | ||
} | ||
} | ||
|
||
public MouseAction MouseRightClickAction | ||
{ | ||
get => _applicationSettings.MouseRightClickAction; | ||
set | ||
{ | ||
if (_applicationSettings.MouseRightClickAction != value && !_editingMouseRightClickAction) | ||
{ | ||
_editingMouseRightClickAction = true; | ||
_applicationSettings.MouseRightClickAction = value; | ||
_settingsService.SaveApplicationSettings(_applicationSettings); | ||
RaisePropertyChanged(); | ||
RaisePropertyChanged(nameof(MouseRightClickNoneIsSelected)); | ||
RaisePropertyChanged(nameof(MouseRightClickContextMenuIsSelected)); | ||
RaisePropertyChanged(nameof(MouseRightClickPasteIsSelected)); | ||
_editingMouseRightClickAction = false; | ||
} | ||
} | ||
} | ||
|
||
public bool MouseRightClickNoneIsSelected | ||
{ | ||
get => MouseRightClickAction == MouseAction.None; | ||
set => MouseRightClickAction = MouseAction.None; | ||
} | ||
|
||
public bool MouseRightClickContextMenuIsSelected | ||
{ | ||
get => MouseRightClickAction == MouseAction.ContextMenu; | ||
set => MouseRightClickAction = MouseAction.ContextMenu; | ||
} | ||
|
||
public bool MouseRightClickPasteIsSelected | ||
{ | ||
get => MouseRightClickAction == MouseAction.Paste; | ||
set => MouseRightClickAction = MouseAction.Paste; | ||
} | ||
|
||
public MouseAction MouseMiddleClickAction | ||
{ | ||
get => _applicationSettings.MouseMiddleClickAction; | ||
set | ||
{ | ||
if (_applicationSettings.MouseMiddleClickAction != value && !_editingMouseMiddleClickAction) | ||
{ | ||
_editingMouseMiddleClickAction = true; | ||
_applicationSettings.MouseMiddleClickAction = value; | ||
_settingsService.SaveApplicationSettings(_applicationSettings); | ||
RaisePropertyChanged(); | ||
RaisePropertyChanged(nameof(MouseMiddleClickNoneIsSelected)); | ||
RaisePropertyChanged(nameof(MouseMiddleClickContextMenuIsSelected)); | ||
RaisePropertyChanged(nameof(MouseMiddleClickPasteIsSelected)); | ||
_editingMouseMiddleClickAction = false; | ||
} | ||
} | ||
} | ||
|
||
public bool MouseMiddleClickNoneIsSelected | ||
{ | ||
get => MouseMiddleClickAction == MouseAction.None; | ||
set => MouseMiddleClickAction = MouseAction.None; | ||
} | ||
|
||
public bool MouseMiddleClickContextMenuIsSelected | ||
{ | ||
get => MouseMiddleClickAction == MouseAction.ContextMenu; | ||
set => MouseMiddleClickAction = MouseAction.ContextMenu; | ||
} | ||
|
||
public bool MouseMiddleClickPasteIsSelected | ||
{ | ||
get => MouseMiddleClickAction == MouseAction.Paste; | ||
set => MouseMiddleClickAction = MouseAction.Paste; | ||
} | ||
|
||
public RelayCommand RestoreDefaultsCommand { get; } | ||
|
||
private async Task RestoreDefaults() | ||
{ | ||
var result = await _dialogService.ShowMessageDialogAsnyc("Please confirm", "Are you sure you want to restore the mouse settings?", DialogButton.OK, DialogButton.Cancel).ConfigureAwait(true); | ||
|
||
if (result == DialogButton.OK) | ||
{ | ||
var defaults = _defaultValueProvider.GetDefaultApplicationSettings(); | ||
CopyOnSelect = defaults.CopyOnSelect; | ||
MouseMiddleClickAction = defaults.MouseMiddleClickAction; | ||
MouseRightClickAction = defaults.MouseRightClickAction; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<Page | ||
x:Class="FluentTerminal.App.Views.SettingsPages.MouseSettings" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="32" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
<Grid Grid.Row="1" Margin="24,00,0,24"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock | ||
Margin="0,10,0,0" | ||
VerticalAlignment="Center" | ||
FontSize="28" | ||
Style="{StaticResource TitleTextBlockStyle}" | ||
Text="Mouse" /> | ||
<CommandBar | ||
Grid.Column="1" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Top" | ||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}" | ||
DefaultLabelPosition="Right"> | ||
<AppBarButton | ||
Command="{x:Bind ViewModel.RestoreDefaultsCommand}" | ||
Icon="Undo" | ||
Label="Restore Defaults" /> | ||
</CommandBar> | ||
</Grid> | ||
<StackPanel Grid.Row="2" Margin="24,0,0,0"> | ||
<ToggleSwitch | ||
Margin="0,0,0,24" | ||
Header="Copy on select" | ||
IsOn="{x:Bind ViewModel.CopyOnSelect, Mode=TwoWay}" /> | ||
<TextBlock Margin="0,0,0,8" Text="Middle button action" /> | ||
<RadioButton | ||
Content="Nothing" | ||
GroupName="MiddleButton" | ||
IsChecked="{x:Bind ViewModel.MouseMiddleClickNoneIsSelected, Mode=TwoWay}" /> | ||
<RadioButton | ||
Content="Context menu" | ||
GroupName="MiddleButton" | ||
IsChecked="{x:Bind ViewModel.MouseMiddleClickContextMenuIsSelected, Mode=TwoWay}" /> | ||
<RadioButton | ||
Margin="0,0,0,24" | ||
Content="Paste" | ||
GroupName="MiddleButton" | ||
IsChecked="{x:Bind ViewModel.MouseMiddleClickPasteIsSelected, Mode=TwoWay}" /> | ||
<TextBlock Margin="0,0,0,8" Text="Right button action" /> | ||
<RadioButton | ||
Content="Nothing" | ||
GroupName="RightButton" | ||
IsChecked="{x:Bind ViewModel.MouseRightClickNoneIsSelected, Mode=TwoWay}" /> | ||
<RadioButton | ||
Content="Context menu" | ||
GroupName="RightButton" | ||
IsChecked="{x:Bind ViewModel.MouseRightClickContextMenuIsSelected, Mode=TwoWay}" /> | ||
<RadioButton | ||
Margin="0,0,0,24" | ||
Content="Paste" | ||
GroupName="RightButton" | ||
IsChecked="{x:Bind ViewModel.MouseRightClickPasteIsSelected, Mode=TwoWay}" /> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
24 changes: 24 additions & 0 deletions
24
FluentTerminal.App/Views/SettingsPages/MouseSettings.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using FluentTerminal.App.ViewModels.Settings; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
namespace FluentTerminal.App.Views.SettingsPages | ||
{ | ||
public sealed partial class MouseSettings : Page | ||
{ | ||
public MouseSettings() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public MousePageViewModel ViewModel { get; private set; } | ||
|
||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
{ | ||
if (e.Parameter is MousePageViewModel viewModel) | ||
{ | ||
ViewModel = viewModel; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.