mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Refactoring for PR #499, part 2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Wox.Extensions
|
namespace Wox.Helper
|
||||||
{
|
{
|
||||||
public static class VisibilityExtensions
|
public static class VisibilityExtensions
|
||||||
{
|
{
|
||||||
@@ -8,10 +8,5 @@ namespace Wox.Extensions
|
|||||||
{
|
{
|
||||||
return visibility == Visibility.Visible;
|
return visibility == Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNotVisible(this Visibility visibility)
|
|
||||||
{
|
|
||||||
return !visibility.IsVisible();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
Style="{DynamicResource WindowStyle}"
|
Style="{DynamicResource WindowStyle}"
|
||||||
Icon="Images\app.png"
|
Icon="Images\app.png"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
Visibility="{Binding WindowVisibility}"
|
Visibility="{Binding MainWindowVisibility}"
|
||||||
PreviewKeyDown="Window_PreviewKeyDown" d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
|
PreviewKeyDown="Window_PreviewKeyDown" d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">
|
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
|||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.Extensions;
|
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -77,7 +76,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
else if(eve.PropertyName == "IsVisible")
|
else if(eve.PropertyName == "IsVisible")
|
||||||
{
|
{
|
||||||
if (vm.WindowVisibility.IsVisible())
|
if (vm.MainWindowVisibility.IsVisible())
|
||||||
{
|
{
|
||||||
tbQuery.Focus();
|
tbQuery.Focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ using Wox.Helper;
|
|||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
using Wox.Extensions;
|
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -202,13 +201,13 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
UserSettingStorage.Instance.WindowLeft = MainVM.Left;
|
UserSettingStorage.Instance.WindowLeft = MainVM.Left;
|
||||||
UserSettingStorage.Instance.WindowTop = MainVM.Top;
|
UserSettingStorage.Instance.WindowTop = MainVM.Top;
|
||||||
MainVM.WindowVisibility = Visibility.Collapsed;
|
MainVM.MainWindowVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowWox(bool selectAll = true)
|
private void ShowWox(bool selectAll = true)
|
||||||
{
|
{
|
||||||
UserSettingStorage.Instance.IncreaseActivateTimes();
|
UserSettingStorage.Instance.IncreaseActivateTimes();
|
||||||
MainVM.WindowVisibility = Visibility.Visible;
|
MainVM.MainWindowVisibility = Visibility.Visible;
|
||||||
MainVM.SelectAllText = true;
|
MainVM.SelectAllText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +277,7 @@ namespace Wox
|
|||||||
|
|
||||||
private void ToggleWox()
|
private void ToggleWox()
|
||||||
{
|
{
|
||||||
if (MainVM.WindowVisibility.IsNotVisible())
|
if (!MainVM.MainWindowVisibility.IsVisible())
|
||||||
{
|
{
|
||||||
ShowWox();
|
ShowWox();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ using System.Windows.Input;
|
|||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.Storage;
|
using Wox.Storage;
|
||||||
using Wox.Extensions;
|
|
||||||
|
|
||||||
namespace Wox.ViewModel
|
namespace Wox.ViewModel
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ namespace Wox.ViewModel
|
|||||||
private Visibility _contextMenuVisibility;
|
private Visibility _contextMenuVisibility;
|
||||||
private Visibility _progressBarVisibility;
|
private Visibility _progressBarVisibility;
|
||||||
private Visibility _resultListBoxVisibility;
|
private Visibility _resultListBoxVisibility;
|
||||||
private Visibility _windowVisibility;
|
private Visibility _mainWindowVisibility;
|
||||||
|
|
||||||
private bool _queryHasReturn;
|
private bool _queryHasReturn;
|
||||||
private Query _lastQuery = new Query();
|
private Query _lastQuery = new Query();
|
||||||
@@ -181,18 +181,18 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Visibility WindowVisibility
|
public Visibility MainWindowVisibility
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _windowVisibility;
|
return _mainWindowVisibility;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_windowVisibility = value;
|
_mainWindowVisibility = value;
|
||||||
OnPropertyChanged("WindowVisibility");
|
OnPropertyChanged("MainWindowVisibility");
|
||||||
|
|
||||||
if (value.IsNotVisible() && ContextMenuVisibility.IsVisible())
|
if (!value.IsVisible() && ContextMenuVisibility.IsVisible())
|
||||||
{
|
{
|
||||||
BackToSearchMode();
|
BackToSearchMode();
|
||||||
}
|
}
|
||||||
@@ -200,21 +200,13 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ICommand EscCommand { get; set; }
|
public ICommand EscCommand { get; set; }
|
||||||
|
|
||||||
public ICommand SelectNextItemCommand { get; set; }
|
public ICommand SelectNextItemCommand { get; set; }
|
||||||
|
|
||||||
public ICommand SelectPrevItemCommand { get; set; }
|
public ICommand SelectPrevItemCommand { get; set; }
|
||||||
|
|
||||||
public ICommand CtrlOCommand { get; set; }
|
public ICommand CtrlOCommand { get; set; }
|
||||||
|
|
||||||
public ICommand DisplayNextQueryCommand { get; set; }
|
public ICommand DisplayNextQueryCommand { get; set; }
|
||||||
|
|
||||||
public ICommand DisplayPrevQueryCommand { get; set; }
|
public ICommand DisplayPrevQueryCommand { get; set; }
|
||||||
|
|
||||||
public ICommand SelectNextPageCommand { get; set; }
|
public ICommand SelectNextPageCommand { get; set; }
|
||||||
|
|
||||||
public ICommand SelectPrevPageCommand { get; set; }
|
public ICommand SelectPrevPageCommand { get; set; }
|
||||||
|
|
||||||
public ICommand StartHelpCommand { get; set; }
|
public ICommand StartHelpCommand { get; set; }
|
||||||
public ICommand ShiftEnterCommand { get; set; }
|
public ICommand ShiftEnterCommand { get; set; }
|
||||||
public ICommand OpenResultCommand { get; set; }
|
public ICommand OpenResultCommand { get; set; }
|
||||||
@@ -234,7 +226,7 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WindowVisibility = Visibility.Collapsed;
|
MainWindowVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -318,7 +310,7 @@ namespace Wox.ViewModel
|
|||||||
ShiftEnterCommand = new RelayCommand((parameter) =>
|
ShiftEnterCommand = new RelayCommand((parameter) =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ContextMenuVisibility.IsNotVisible() && null != Results.SelectedResult)
|
if (!ContextMenuVisibility.IsVisible() && null != Results.SelectedResult)
|
||||||
{
|
{
|
||||||
ShowContextMenu(Results.SelectedResult.RawResult);
|
ShowContextMenu(Results.SelectedResult.RawResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@
|
|||||||
<Compile Include="Converters\OpacityModeConverter.cs" />
|
<Compile Include="Converters\OpacityModeConverter.cs" />
|
||||||
<Compile Include="Converters\StringEmptyConverter.cs" />
|
<Compile Include="Converters\StringEmptyConverter.cs" />
|
||||||
<Compile Include="Converters\StringNullOrEmptyToVisibilityConverter.cs" />
|
<Compile Include="Converters\StringNullOrEmptyToVisibilityConverter.cs" />
|
||||||
<Compile Include="Extensions\VisibilityExtensions.cs" />
|
<Compile Include="Helper\VisibilityExtensions.cs" />
|
||||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||||
<Compile Include="NotifyIconManager.cs" />
|
<Compile Include="NotifyIconManager.cs" />
|
||||||
@@ -375,6 +375,9 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Extensions\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\
|
<PostBuildEvent>xcopy /Y $(ProjectDir)Themes\* $(TargetDir)Themes\
|
||||||
|
|||||||
Reference in New Issue
Block a user