From d5ab4093a93b5fdaa1cc8d86c6dc343741627aae Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 26 Feb 2016 12:05:32 +0000 Subject: [PATCH] Refactoring for PR #499, part 2 --- Wox/Helper/VisibilityExtensions.cs | 7 +------ Wox/MainWindow.xaml | 2 +- Wox/MainWindow.xaml.cs | 3 +-- Wox/PublicAPIInstance.cs | 7 +++---- Wox/ViewModel/MainViewModel.cs | 26 +++++++++----------------- Wox/Wox.csproj | 5 ++++- 6 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Wox/Helper/VisibilityExtensions.cs b/Wox/Helper/VisibilityExtensions.cs index d489c0a0f6..63ecb74b47 100644 --- a/Wox/Helper/VisibilityExtensions.cs +++ b/Wox/Helper/VisibilityExtensions.cs @@ -1,6 +1,6 @@ using System.Windows; -namespace Wox.Extensions +namespace Wox.Helper { public static class VisibilityExtensions { @@ -8,10 +8,5 @@ namespace Wox.Extensions { return visibility == Visibility.Visible; } - - public static bool IsNotVisible(this Visibility visibility) - { - return !visibility.IsVisible(); - } } } diff --git a/Wox/MainWindow.xaml b/Wox/MainWindow.xaml index 361b621d20..f0a1b2843c 100644 --- a/Wox/MainWindow.xaml +++ b/Wox/MainWindow.xaml @@ -18,7 +18,7 @@ Style="{DynamicResource WindowStyle}" Icon="Images\app.png" AllowsTransparency="True" - Visibility="{Binding WindowVisibility}" + Visibility="{Binding MainWindowVisibility}" PreviewKeyDown="Window_PreviewKeyDown" d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}"> diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 481e33dcf2..ba80cd1143 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -16,7 +16,6 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs; using MessageBox = System.Windows.MessageBox; using Wox.ViewModel; using Wox.Plugin; -using Wox.Extensions; namespace Wox { @@ -77,7 +76,7 @@ namespace Wox } else if(eve.PropertyName == "IsVisible") { - if (vm.WindowVisibility.IsVisible()) + if (vm.MainWindowVisibility.IsVisible()) { tbQuery.Focus(); } diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index d4b6ab8093..c903a2851c 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -18,7 +18,6 @@ using Wox.Helper; using Wox.Infrastructure.Hotkey; using Wox.Plugin; using Wox.ViewModel; -using Wox.Extensions; namespace Wox { @@ -202,13 +201,13 @@ namespace Wox { UserSettingStorage.Instance.WindowLeft = MainVM.Left; UserSettingStorage.Instance.WindowTop = MainVM.Top; - MainVM.WindowVisibility = Visibility.Collapsed; + MainVM.MainWindowVisibility = Visibility.Collapsed; } private void ShowWox(bool selectAll = true) { UserSettingStorage.Instance.IncreaseActivateTimes(); - MainVM.WindowVisibility = Visibility.Visible; + MainVM.MainWindowVisibility = Visibility.Visible; MainVM.SelectAllText = true; } @@ -278,7 +277,7 @@ namespace Wox private void ToggleWox() { - if (MainVM.WindowVisibility.IsNotVisible()) + if (!MainVM.MainWindowVisibility.IsVisible()) { ShowWox(); } diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index c3a23e4576..29b7d053d2 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -10,11 +10,11 @@ using System.Windows.Input; using Wox.Core.Plugin; using Wox.Core.Resource; using Wox.Core.UserSettings; +using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; using Wox.Plugin; using Wox.Storage; -using Wox.Extensions; namespace Wox.ViewModel { @@ -33,7 +33,7 @@ namespace Wox.ViewModel private Visibility _contextMenuVisibility; private Visibility _progressBarVisibility; private Visibility _resultListBoxVisibility; - private Visibility _windowVisibility; + private Visibility _mainWindowVisibility; private bool _queryHasReturn; private Query _lastQuery = new Query(); @@ -181,18 +181,18 @@ namespace Wox.ViewModel } } - public Visibility WindowVisibility + public Visibility MainWindowVisibility { get { - return _windowVisibility; + return _mainWindowVisibility; } set { - _windowVisibility = value; - OnPropertyChanged("WindowVisibility"); + _mainWindowVisibility = value; + OnPropertyChanged("MainWindowVisibility"); - if (value.IsNotVisible() && ContextMenuVisibility.IsVisible()) + if (!value.IsVisible() && ContextMenuVisibility.IsVisible()) { BackToSearchMode(); } @@ -200,21 +200,13 @@ namespace Wox.ViewModel } public ICommand EscCommand { get; set; } - public ICommand SelectNextItemCommand { get; set; } - public ICommand SelectPrevItemCommand { get; set; } - public ICommand CtrlOCommand { get; set; } - public ICommand DisplayNextQueryCommand { get; set; } - public ICommand DisplayPrevQueryCommand { get; set; } - public ICommand SelectNextPageCommand { get; set; } - public ICommand SelectPrevPageCommand { get; set; } - public ICommand StartHelpCommand { get; set; } public ICommand ShiftEnterCommand { get; set; } public ICommand OpenResultCommand { get; set; } @@ -234,7 +226,7 @@ namespace Wox.ViewModel } else { - WindowVisibility = Visibility.Collapsed; + MainWindowVisibility = Visibility.Collapsed; } }); @@ -318,7 +310,7 @@ namespace Wox.ViewModel ShiftEnterCommand = new RelayCommand((parameter) => { - if (ContextMenuVisibility.IsNotVisible() && null != Results.SelectedResult) + if (!ContextMenuVisibility.IsVisible() && null != Results.SelectedResult) { ShowContextMenu(Results.SelectedResult.RawResult); } diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 35c29664b5..2bfc0d7b8a 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -123,7 +123,7 @@ - + @@ -375,6 +375,9 @@ PreserveNewest + + + xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\