From f6ae266a88d5af3031715462665a5e74e384f88e Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 5 Mar 2020 23:23:44 +1100 Subject: [PATCH] Add settings check box ui and viewmodel --- Wox/SettingWindow.xaml | 3 +++ Wox/ViewModel/SettingWindowViewModel.cs | 30 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 1eddd8ab6..b081cfbf6 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -33,6 +33,9 @@ + + + diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index 0a240aec7..197797534 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -13,7 +13,6 @@ using Wox.Core.Plugin; using Wox.Core.Resource; using Wox.Helper; using Wox.Infrastructure; -using Wox.Infrastructure.Http; using Wox.Infrastructure.Storage; using Wox.Infrastructure.UserSettings; using Wox.Plugin; @@ -39,8 +38,7 @@ namespace Wox.ViewModel OnPropertyChanged(nameof(ActivatedTimes)); } }; - - + _portableMode = Settings.PortableMode; } public Settings Settings { get; set; } @@ -50,14 +48,30 @@ namespace Wox.ViewModel await _updater.UpdateApp(false); } - public void EnablePortableMode() + private bool _portableMode; + public bool PortableMode { - _portable.EnablePortableMode(); + get { return _portableMode; } + set + { + _portableMode = value; + + Settings.PortableMode = value; + Save(); + PortabilityUpdate(value); + } } - public void DisablePortableMode() + private void PortabilityUpdate(bool enabled) { - _portable.DisablePortableMode(); + if (enabled) + { + _portable.EnablePortableMode(); + } + else + { + _portable.DisablePortableMode(); + } } public void Save()