mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 11:09:28 +08:00
merge dev
This commit is contained in:
commit
bdca59b3d7
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
namespace Wox.Converters
|
||||
{
|
||||
class VisibilityConverter : ConvertorBase<VisibilityConverter>
|
||||
{
|
||||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || value == DependencyProperty.UnsetValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return bool.Parse(value.ToString()) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
12
Wox/Helper/VisibilityExtensions.cs
Normal file
12
Wox/Helper/VisibilityExtensions.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public static class VisibilityExtensions
|
||||
{
|
||||
public static bool IsVisible(this Visibility visibility)
|
||||
{
|
||||
return visibility == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,13 +18,12 @@
|
||||
Style="{DynamicResource WindowStyle}"
|
||||
Icon="Images\app.png"
|
||||
AllowsTransparency="True"
|
||||
Visibility="{Binding IsVisible,Converter={converters:VisibilityConverter}}"
|
||||
Visibility="{Binding MainWindowVisibility}"
|
||||
PreviewKeyDown="Window_PreviewKeyDown" d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
|
||||
<Window.Resources>
|
||||
<DataTemplate DataType="{x:Type vm:ResultsViewModel}">
|
||||
<wox:ResultListBox></wox:ResultListBox>
|
||||
</DataTemplate>
|
||||
<converters:VisibilityConverter x:Key="VisibilityConverter" />
|
||||
</Window.Resources>
|
||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
|
||||
<StackPanel Orientation="Vertical">
|
||||
@ -32,14 +31,14 @@
|
||||
PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True"
|
||||
x:Name="tbQuery" />
|
||||
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Height="2" StrokeThickness="1"
|
||||
Visibility="{Binding IsProgressBarVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
Visibility="{Binding ProgressBarVisibility}">
|
||||
<Line.ToolTip>
|
||||
<ToolTip IsOpen="{Binding IsProgressBarTooltipVisible}"></ToolTip>
|
||||
</Line.ToolTip>
|
||||
</Line>
|
||||
<ContentControl Content="{Binding Results}" Visibility="{Binding IsResultListBoxVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
<ContentControl Content="{Binding Results}" Visibility="{Binding ResultListBoxVisibility}">
|
||||
</ContentControl>
|
||||
<ContentControl Content="{Binding ContextMenu}" Visibility="{Binding IsContextMenuVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
<ContentControl Content="{Binding ContextMenu}" Visibility="{Binding ContextMenuVisibility}">
|
||||
</ContentControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
@ -75,7 +75,7 @@ namespace Wox
|
||||
}
|
||||
else if(eve.PropertyName == "IsVisible")
|
||||
{
|
||||
if (vm.IsVisible)
|
||||
if (vm.MainWindowVisibility.IsVisible())
|
||||
{
|
||||
tbQuery.Focus();
|
||||
}
|
||||
|
@ -119,12 +119,12 @@ namespace Wox
|
||||
|
||||
public void StartLoadingBar()
|
||||
{
|
||||
MainVM.IsProgressBarVisible = true;
|
||||
MainVM.ProgressBarVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void StopLoadingBar()
|
||||
{
|
||||
MainVM.IsProgressBarVisible = false;
|
||||
MainVM.ProgressBarVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public void InstallPlugin(string path)
|
||||
@ -193,13 +193,13 @@ namespace Wox
|
||||
{
|
||||
UserSettingStorage.Instance.WindowLeft = MainVM.Left;
|
||||
UserSettingStorage.Instance.WindowTop = MainVM.Top;
|
||||
MainVM.IsVisible = false;
|
||||
MainVM.MainWindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ShowWox(bool selectAll = true)
|
||||
{
|
||||
UserSettingStorage.Instance.IncreaseActivateTimes();
|
||||
MainVM.IsVisible = true;
|
||||
MainVM.MainWindowVisibility = Visibility.Visible;
|
||||
MainVM.SelectAllText = true;
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ namespace Wox
|
||||
|
||||
private void ToggleWox()
|
||||
{
|
||||
if (!MainVM.IsVisible)
|
||||
if (!MainVM.MainWindowVisibility.IsVisible())
|
||||
{
|
||||
ShowWox();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
@ -18,16 +19,18 @@ namespace Wox.ViewModel
|
||||
#region Private Fields
|
||||
|
||||
private string _queryText;
|
||||
private bool _isVisible;
|
||||
private bool _isResultListBoxVisible;
|
||||
private bool _isContextMenuVisible;
|
||||
private bool _isProgressBarVisible;
|
||||
|
||||
private bool _isProgressBarTooltipVisible;
|
||||
private bool _selectAllText;
|
||||
private int _caretIndex;
|
||||
private double _left;
|
||||
private double _top;
|
||||
|
||||
private Visibility _contextMenuVisibility;
|
||||
private Visibility _progressBarVisibility;
|
||||
private Visibility _resultListBoxVisibility;
|
||||
private Visibility _mainWindowVisibility;
|
||||
|
||||
private bool _queryHasReturn;
|
||||
private Query _lastQuery = new Query();
|
||||
private bool _ignoreTextChange;
|
||||
@ -96,63 +99,6 @@ namespace Wox.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isVisible = value;
|
||||
OnPropertyChanged("IsVisible");
|
||||
|
||||
if (!value && IsContextMenuVisible)
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsResultListBoxVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isResultListBoxVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isResultListBoxVisible = value;
|
||||
OnPropertyChanged("IsResultListBoxVisible");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsContextMenuVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isContextMenuVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isContextMenuVisible = value;
|
||||
OnPropertyChanged("IsContextMenuVisible");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsProgressBarVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isProgressBarVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isProgressBarVisible = value;
|
||||
OnPropertyChanged("IsProgressBarVisible");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsProgressBarTooltipVisible
|
||||
{
|
||||
get
|
||||
@ -192,6 +138,63 @@ namespace Wox.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility ContextMenuVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _contextMenuVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
_contextMenuVisibility = value;
|
||||
OnPropertyChanged("ContextMenuVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility ProgressBarVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _progressBarVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
_progressBarVisibility = value;
|
||||
OnPropertyChanged("ProgressBarVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility ResultListBoxVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resultListBoxVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
_resultListBoxVisibility = value;
|
||||
OnPropertyChanged("ResultListBoxVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility MainWindowVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mainWindowVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
_mainWindowVisibility = value;
|
||||
OnPropertyChanged("MainWindowVisibility");
|
||||
|
||||
if (!value.IsVisible() && ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand EscCommand { get; set; }
|
||||
public ICommand SelectNextItemCommand { get; set; }
|
||||
public ICommand SelectPrevItemCommand { get; set; }
|
||||
@ -212,19 +215,19 @@ namespace Wox.ViewModel
|
||||
{
|
||||
EscCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsVisible = false;
|
||||
MainWindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
});
|
||||
|
||||
SelectNextItemCommand = new RelayCommand(o =>
|
||||
{
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
ContextMenu.SelectNextResult();
|
||||
}
|
||||
@ -236,7 +239,7 @@ namespace Wox.ViewModel
|
||||
|
||||
SelectPrevItemCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
ContextMenu.SelectPrevResult();
|
||||
}
|
||||
@ -248,7 +251,7 @@ namespace Wox.ViewModel
|
||||
|
||||
CtrlOCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
@ -287,7 +290,7 @@ namespace Wox.ViewModel
|
||||
|
||||
ShiftEnterCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if (!IsContextMenuVisible && Results.SelectedResult != null)
|
||||
if (!ContextMenuVisibility.IsVisible() && null != Results.SelectedResult)
|
||||
{
|
||||
ShowContextMenu(Results.SelectedResult.RawResult);
|
||||
}
|
||||
@ -312,7 +315,7 @@ namespace Wox.ViewModel
|
||||
private void InitializeResultListBox()
|
||||
{
|
||||
Results = new ResultsViewModel();
|
||||
IsResultListBoxVisible = false;
|
||||
ResultListBoxVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ShowContextMenu(Result result)
|
||||
@ -343,8 +346,8 @@ namespace Wox.ViewModel
|
||||
ContextMenu.AddResults(actions, pluginID);
|
||||
_currentContextMenus = actions;
|
||||
|
||||
IsContextMenuVisible = true;
|
||||
IsResultListBoxVisible = false;
|
||||
ContextMenuVisibility = Visibility.Visible;
|
||||
ResultListBoxVisibility = Visibility.Collapsed;
|
||||
|
||||
QueryText = "";
|
||||
}
|
||||
@ -382,7 +385,7 @@ namespace Wox.ViewModel
|
||||
private void InitializeContextMenu()
|
||||
{
|
||||
ContextMenu = new ResultsViewModel();
|
||||
IsContextMenuVisible = false;
|
||||
ContextMenuVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void HandleQueryTextUpdated()
|
||||
@ -390,7 +393,7 @@ namespace Wox.ViewModel
|
||||
if (_ignoreTextChange) { _ignoreTextChange = false; return; }
|
||||
|
||||
IsProgressBarTooltipVisible = false;
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
QueryContextMenu();
|
||||
}
|
||||
@ -502,8 +505,8 @@ namespace Wox.ViewModel
|
||||
private void BackToSearchMode()
|
||||
{
|
||||
QueryText = _textBeforeEnterContextMenuMode;
|
||||
IsContextMenuVisible = false;
|
||||
IsResultListBoxVisible = true;
|
||||
ContextMenuVisibility = Visibility.Collapsed;
|
||||
ResultListBoxVisibility = Visibility.Visible;
|
||||
CaretIndex = QueryText.Length;
|
||||
}
|
||||
|
||||
@ -562,7 +565,7 @@ namespace Wox.ViewModel
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
IsResultListBoxVisible = true;
|
||||
ResultListBoxVisibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@
|
||||
<Compile Include="Converters\OpacityModeConverter.cs" />
|
||||
<Compile Include="Converters\StringEmptyConverter.cs" />
|
||||
<Compile Include="Converters\StringNullOrEmptyToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\VisibilityConverter.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\
|
||||
|
Loading…
Reference in New Issue
Block a user