Refactoring for PR #499, part 2

This commit is contained in:
bao-qian 2016-02-26 12:05:32 +00:00
parent e6df19efbc
commit d5ab4093a9
6 changed files with 19 additions and 31 deletions

View File

@ -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();
}
}
}

View File

@ -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}">
<Window.Resources>
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -123,7 +123,7 @@
<Compile Include="Converters\OpacityModeConverter.cs" />
<Compile Include="Converters\StringEmptyConverter.cs" />
<Compile Include="Converters\StringNullOrEmptyToVisibilityConverter.cs" />
<Compile Include="Extensions\VisibilityExtensions.cs" />
<Compile Include="Helper\VisibilityExtensions.cs" />
<Compile Include="Helper\SingletonWindowOpener.cs" />
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
<Compile Include="NotifyIconManager.cs" />
@ -375,6 +375,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\