diff --git a/FluentTerminal.App.ViewModels/FluentTerminal.App.ViewModels.csproj b/FluentTerminal.App.ViewModels/FluentTerminal.App.ViewModels.csproj index ade3830..43f9702 100644 --- a/FluentTerminal.App.ViewModels/FluentTerminal.App.ViewModels.csproj +++ b/FluentTerminal.App.ViewModels/FluentTerminal.App.ViewModels.csproj @@ -7,6 +7,7 @@ + diff --git a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs index 844fbd0..7ab4759 100644 --- a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs +++ b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs @@ -1,15 +1,17 @@ using FluentTerminal.App.Services; using FluentTerminal.Models; using FluentTerminal.Models.Enums; -using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; +using ReactiveUI; +using System; using System.Collections.Generic; using System.Linq; +using System.Reactive.Linq; using System.Threading.Tasks; namespace FluentTerminal.App.ViewModels.Settings { - public class TerminalPageViewModel : ViewModelBase + public class TerminalPageViewModel : ReactiveObject { private readonly TerminalOptions _terminalOptions; private readonly ISettingsService _settingsService; @@ -63,7 +65,7 @@ namespace FluentTerminal.App.ViewModels.Settings { _terminalOptions.CursorBlink = value; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } } @@ -77,7 +79,7 @@ namespace FluentTerminal.App.ViewModels.Settings { _terminalOptions.FontFamily = value; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } } @@ -90,8 +92,7 @@ namespace FluentTerminal.App.ViewModels.Settings if (_terminalOptions.BackgroundOpacity != value) { _terminalOptions.BackgroundOpacity = value; - _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } } @@ -112,12 +113,12 @@ namespace FluentTerminal.App.ViewModels.Settings { _terminalOptions.ScrollBackLimit = intValue; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } else { - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } } @@ -133,7 +134,7 @@ namespace FluentTerminal.App.ViewModels.Settings { _terminalOptions.FontSize = value; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); + this.RaisePropertyChanged(); } } } @@ -152,10 +153,10 @@ namespace FluentTerminal.App.ViewModels.Settings _isEditingCursorStyle = true; _terminalOptions.CursorStyle = value; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); - RaisePropertyChanged(nameof(BlockIsSelected)); - RaisePropertyChanged(nameof(BarIsSelected)); - RaisePropertyChanged(nameof(UnderlineIsSelected)); + this.RaisePropertyChanged(); + this.RaisePropertyChanged(nameof(BlockIsSelected)); + this.RaisePropertyChanged(nameof(BarIsSelected)); + this.RaisePropertyChanged(nameof(UnderlineIsSelected)); _isEditingCursorStyle = false; } } @@ -171,10 +172,10 @@ namespace FluentTerminal.App.ViewModels.Settings _isEditingScrollBarStyle = true; _terminalOptions.ScrollBarStyle = value; _settingsService.SaveTerminalOptions(_terminalOptions); - RaisePropertyChanged(); - RaisePropertyChanged(nameof(HiddenIsSelected)); - RaisePropertyChanged(nameof(AutoHidingIsSelected)); - RaisePropertyChanged(nameof(VisibleIsSelected)); + this.RaisePropertyChanged(); + this.RaisePropertyChanged(nameof(HiddenIsSelected)); + this.RaisePropertyChanged(nameof(AutoHidingIsSelected)); + this.RaisePropertyChanged(nameof(VisibleIsSelected)); _isEditingScrollBarStyle = false; } } @@ -209,6 +210,11 @@ namespace FluentTerminal.App.ViewModels.Settings Sizes = Enumerable.Range(1, 72); _terminalOptions = _settingsService.GetTerminalOptions(); + + this.ObservableForProperty(x => x.BackgroundOpacity).Throttle(TimeSpan.FromMilliseconds(800)).ObserveOn(RxApp.MainThreadScheduler).Subscribe(x => + { + _settingsService.SaveTerminalOptions(_terminalOptions); + }); } } } \ No newline at end of file