merge dev

This commit is contained in:
bao-qian 2016-02-26 12:13:04 +00:00
commit bdca59b3d7
7 changed files with 104 additions and 112 deletions

View File

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

View 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;
}
}
}

View File

@ -18,13 +18,12 @@
Style="{DynamicResource WindowStyle}" Style="{DynamicResource WindowStyle}"
Icon="Images\app.png" Icon="Images\app.png"
AllowsTransparency="True" AllowsTransparency="True"
Visibility="{Binding IsVisible,Converter={converters:VisibilityConverter}}" 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}">
<wox:ResultListBox></wox:ResultListBox> <wox:ResultListBox></wox:ResultListBox>
</DataTemplate> </DataTemplate>
<converters:VisibilityConverter x:Key="VisibilityConverter" />
</Window.Resources> </Window.Resources>
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown"> <Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
@ -32,14 +31,14 @@
PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True"
x:Name="tbQuery" /> x:Name="tbQuery" />
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Height="2" StrokeThickness="1" <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> <Line.ToolTip>
<ToolTip IsOpen="{Binding IsProgressBarTooltipVisible}"></ToolTip> <ToolTip IsOpen="{Binding IsProgressBarTooltipVisible}"></ToolTip>
</Line.ToolTip> </Line.ToolTip>
</Line> </Line>
<ContentControl Content="{Binding Results}" Visibility="{Binding IsResultListBoxVisible,Converter={StaticResource VisibilityConverter}}"> <ContentControl Content="{Binding Results}" Visibility="{Binding ResultListBoxVisibility}">
</ContentControl> </ContentControl>
<ContentControl Content="{Binding ContextMenu}" Visibility="{Binding IsContextMenuVisible,Converter={StaticResource VisibilityConverter}}"> <ContentControl Content="{Binding ContextMenu}" Visibility="{Binding ContextMenuVisibility}">
</ContentControl> </ContentControl>
</StackPanel> </StackPanel>
</Border> </Border>

View File

@ -75,7 +75,7 @@ namespace Wox
} }
else if(eve.PropertyName == "IsVisible") else if(eve.PropertyName == "IsVisible")
{ {
if (vm.IsVisible) if (vm.MainWindowVisibility.IsVisible())
{ {
tbQuery.Focus(); tbQuery.Focus();
} }

View File

@ -119,12 +119,12 @@ namespace Wox
public void StartLoadingBar() public void StartLoadingBar()
{ {
MainVM.IsProgressBarVisible = true; MainVM.ProgressBarVisibility = Visibility.Visible;
} }
public void StopLoadingBar() public void StopLoadingBar()
{ {
MainVM.IsProgressBarVisible = false; MainVM.ProgressBarVisibility = Visibility.Collapsed;
} }
public void InstallPlugin(string path) public void InstallPlugin(string path)
@ -193,13 +193,13 @@ namespace Wox
{ {
UserSettingStorage.Instance.WindowLeft = MainVM.Left; UserSettingStorage.Instance.WindowLeft = MainVM.Left;
UserSettingStorage.Instance.WindowTop = MainVM.Top; UserSettingStorage.Instance.WindowTop = MainVM.Top;
MainVM.IsVisible = false; MainVM.MainWindowVisibility = Visibility.Collapsed;
} }
private void ShowWox(bool selectAll = true) private void ShowWox(bool selectAll = true)
{ {
UserSettingStorage.Instance.IncreaseActivateTimes(); UserSettingStorage.Instance.IncreaseActivateTimes();
MainVM.IsVisible = true; MainVM.MainWindowVisibility = Visibility.Visible;
MainVM.SelectAllText = true; MainVM.SelectAllText = true;
} }
@ -269,7 +269,7 @@ namespace Wox
private void ToggleWox() private void ToggleWox()
{ {
if (!MainVM.IsVisible) if (!MainVM.MainWindowVisibility.IsVisible())
{ {
ShowWox(); ShowWox();
} }

View File

@ -6,6 +6,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Resource; using Wox.Core.Resource;
using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Plugin; using Wox.Plugin;
using Wox.Storage; using Wox.Storage;
@ -18,16 +19,18 @@ namespace Wox.ViewModel
#region Private Fields #region Private Fields
private string _queryText; private string _queryText;
private bool _isVisible;
private bool _isResultListBoxVisible;
private bool _isContextMenuVisible;
private bool _isProgressBarVisible;
private bool _isProgressBarTooltipVisible; private bool _isProgressBarTooltipVisible;
private bool _selectAllText; private bool _selectAllText;
private int _caretIndex; private int _caretIndex;
private double _left; private double _left;
private double _top; private double _top;
private Visibility _contextMenuVisibility;
private Visibility _progressBarVisibility;
private Visibility _resultListBoxVisibility;
private Visibility _mainWindowVisibility;
private bool _queryHasReturn; private bool _queryHasReturn;
private Query _lastQuery = new Query(); private Query _lastQuery = new Query();
private bool _ignoreTextChange; 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 public bool IsProgressBarTooltipVisible
{ {
get 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 EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; } public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; } public ICommand SelectPrevItemCommand { get; set; }
@ -212,19 +215,19 @@ namespace Wox.ViewModel
{ {
EscCommand = new RelayCommand(_ => EscCommand = new RelayCommand(_ =>
{ {
if (IsContextMenuVisible) if (ContextMenuVisibility.IsVisible())
{ {
BackToSearchMode(); BackToSearchMode();
} }
else else
{ {
IsVisible = false; MainWindowVisibility = Visibility.Collapsed;
} }
}); });
SelectNextItemCommand = new RelayCommand(o => SelectNextItemCommand = new RelayCommand(o =>
{ {
if (IsContextMenuVisible) if (ContextMenuVisibility.IsVisible())
{ {
ContextMenu.SelectNextResult(); ContextMenu.SelectNextResult();
} }
@ -236,7 +239,7 @@ namespace Wox.ViewModel
SelectPrevItemCommand = new RelayCommand(_ => SelectPrevItemCommand = new RelayCommand(_ =>
{ {
if (IsContextMenuVisible) if (ContextMenuVisibility.IsVisible())
{ {
ContextMenu.SelectPrevResult(); ContextMenu.SelectPrevResult();
} }
@ -248,7 +251,7 @@ namespace Wox.ViewModel
CtrlOCommand = new RelayCommand(_ => CtrlOCommand = new RelayCommand(_ =>
{ {
if (IsContextMenuVisible) if (ContextMenuVisibility.IsVisible())
{ {
BackToSearchMode(); BackToSearchMode();
} }
@ -287,7 +290,7 @@ namespace Wox.ViewModel
ShiftEnterCommand = new RelayCommand(_ => ShiftEnterCommand = new RelayCommand(_ =>
{ {
if (!IsContextMenuVisible && Results.SelectedResult != null) if (!ContextMenuVisibility.IsVisible() && null != Results.SelectedResult)
{ {
ShowContextMenu(Results.SelectedResult.RawResult); ShowContextMenu(Results.SelectedResult.RawResult);
} }
@ -312,7 +315,7 @@ namespace Wox.ViewModel
private void InitializeResultListBox() private void InitializeResultListBox()
{ {
Results = new ResultsViewModel(); Results = new ResultsViewModel();
IsResultListBoxVisible = false; ResultListBoxVisibility = Visibility.Collapsed;
} }
private void ShowContextMenu(Result result) private void ShowContextMenu(Result result)
@ -343,8 +346,8 @@ namespace Wox.ViewModel
ContextMenu.AddResults(actions, pluginID); ContextMenu.AddResults(actions, pluginID);
_currentContextMenus = actions; _currentContextMenus = actions;
IsContextMenuVisible = true; ContextMenuVisibility = Visibility.Visible;
IsResultListBoxVisible = false; ResultListBoxVisibility = Visibility.Collapsed;
QueryText = ""; QueryText = "";
} }
@ -382,7 +385,7 @@ namespace Wox.ViewModel
private void InitializeContextMenu() private void InitializeContextMenu()
{ {
ContextMenu = new ResultsViewModel(); ContextMenu = new ResultsViewModel();
IsContextMenuVisible = false; ContextMenuVisibility = Visibility.Collapsed;
} }
private void HandleQueryTextUpdated() private void HandleQueryTextUpdated()
@ -390,7 +393,7 @@ namespace Wox.ViewModel
if (_ignoreTextChange) { _ignoreTextChange = false; return; } if (_ignoreTextChange) { _ignoreTextChange = false; return; }
IsProgressBarTooltipVisible = false; IsProgressBarTooltipVisible = false;
if (IsContextMenuVisible) if (ContextMenuVisibility.IsVisible())
{ {
QueryContextMenu(); QueryContextMenu();
} }
@ -502,8 +505,8 @@ namespace Wox.ViewModel
private void BackToSearchMode() private void BackToSearchMode()
{ {
QueryText = _textBeforeEnterContextMenuMode; QueryText = _textBeforeEnterContextMenuMode;
IsContextMenuVisible = false; ContextMenuVisibility = Visibility.Collapsed;
IsResultListBoxVisible = true; ResultListBoxVisibility = Visibility.Visible;
CaretIndex = QueryText.Length; CaretIndex = QueryText.Length;
} }
@ -562,7 +565,7 @@ namespace Wox.ViewModel
if (list.Count > 0) if (list.Count > 0)
{ {
IsResultListBoxVisible = true; ResultListBoxVisibility = Visibility.Visible;
} }
} }

View File

@ -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="Converters\VisibilityConverter.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\