mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #499 from rmterra/issue_495
Fix MainWindow.xaml preview
This commit is contained in:
commit
b7948c5344
7 changed files with 108 additions and 117 deletions
|
|
@ -1,30 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
17
Wox/Extensions/VisibilityExtensions.cs
Normal file
17
Wox/Extensions/VisibilityExtensions.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace Wox.Extensions
|
||||
{
|
||||
public static class VisibilityExtensions
|
||||
{
|
||||
public static bool IsVisible(this Visibility visibility)
|
||||
{
|
||||
return visibility == Visibility.Visible;
|
||||
}
|
||||
|
||||
public static bool IsNotVisible(this Visibility visibility)
|
||||
{
|
||||
return !visibility.IsVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,13 +18,12 @@
|
|||
Style="{DynamicResource WindowStyle}"
|
||||
Icon="Images\app.png"
|
||||
AllowsTransparency="True"
|
||||
Visibility="{Binding IsVisible,Converter={converters:VisibilityConverter}}"
|
||||
Visibility="{Binding WindowVisibility}"
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
|||
using MessageBox = System.Windows.MessageBox;
|
||||
using Wox.ViewModel;
|
||||
using Wox.Plugin;
|
||||
using Wox.Extensions;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
|
@ -76,7 +77,7 @@ namespace Wox
|
|||
}
|
||||
else if(eve.PropertyName == "IsVisible")
|
||||
{
|
||||
if (vm.IsVisible)
|
||||
if (vm.WindowVisibility.IsVisible())
|
||||
{
|
||||
tbQuery.Focus();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using Wox.Helper;
|
|||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Plugin;
|
||||
using Wox.ViewModel;
|
||||
using Wox.Extensions;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
|
@ -127,12 +128,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)
|
||||
|
|
@ -201,13 +202,13 @@ namespace Wox
|
|||
{
|
||||
UserSettingStorage.Instance.WindowLeft = MainVM.Left;
|
||||
UserSettingStorage.Instance.WindowTop = MainVM.Top;
|
||||
MainVM.IsVisible = false;
|
||||
MainVM.WindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ShowWox(bool selectAll = true)
|
||||
{
|
||||
UserSettingStorage.Instance.IncreaseActivateTimes();
|
||||
MainVM.IsVisible = true;
|
||||
MainVM.WindowVisibility = Visibility.Visible;
|
||||
MainVM.SelectAllText = true;
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +278,7 @@ namespace Wox
|
|||
|
||||
private void ToggleWox()
|
||||
{
|
||||
if (!MainVM.IsVisible)
|
||||
if (MainVM.WindowVisibility.IsNotVisible())
|
||||
{
|
||||
ShowWox();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using Wox.Infrastructure;
|
|||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
using Wox.Extensions;
|
||||
|
||||
namespace Wox.ViewModel
|
||||
{
|
||||
|
|
@ -22,16 +23,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 _windowVisibility;
|
||||
|
||||
private bool _queryHasReturn;
|
||||
private Query _lastQuery = new Query();
|
||||
private bool _ignoreTextChange;
|
||||
|
|
@ -100,63 +103,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
|
||||
|
|
@ -196,6 +142,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 WindowVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _windowVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
_windowVisibility = value;
|
||||
OnPropertyChanged("WindowVisibility");
|
||||
|
||||
if (value.IsNotVisible() && ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand EscCommand { get; set; }
|
||||
|
||||
public ICommand SelectNextItemCommand { get; set; }
|
||||
|
|
@ -225,13 +228,13 @@ namespace Wox.ViewModel
|
|||
EscCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsVisible = false;
|
||||
WindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -239,7 +242,7 @@ namespace Wox.ViewModel
|
|||
SelectNextItemCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
ContextMenu.SelectNextResult();
|
||||
}
|
||||
|
|
@ -253,7 +256,7 @@ namespace Wox.ViewModel
|
|||
SelectPrevItemCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
ContextMenu.SelectPrevResult();
|
||||
}
|
||||
|
|
@ -267,7 +270,7 @@ namespace Wox.ViewModel
|
|||
CtrlOCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
BackToSearchMode();
|
||||
}
|
||||
|
|
@ -315,7 +318,7 @@ namespace Wox.ViewModel
|
|||
ShiftEnterCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (!IsContextMenuVisible && null != Results.SelectedResult)
|
||||
if (ContextMenuVisibility.IsNotVisible() && null != Results.SelectedResult)
|
||||
{
|
||||
ShowContextMenu(Results.SelectedResult.RawResult);
|
||||
}
|
||||
|
|
@ -350,7 +353,7 @@ namespace Wox.ViewModel
|
|||
private void InitializeResultListBox()
|
||||
{
|
||||
Results = new ResultsViewModel();
|
||||
IsResultListBoxVisible = false;
|
||||
ResultListBoxVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void ShowContextMenu(Result result)
|
||||
|
|
@ -381,8 +384,8 @@ namespace Wox.ViewModel
|
|||
ContextMenu.AddResults(actions, pluginID);
|
||||
CurrentContextMenus = actions;
|
||||
|
||||
IsContextMenuVisible = true;
|
||||
IsResultListBoxVisible = false;
|
||||
ContextMenuVisibility = Visibility.Visible;
|
||||
ResultListBoxVisibility = Visibility.Collapsed;
|
||||
|
||||
QueryText = "";
|
||||
}
|
||||
|
|
@ -420,7 +423,7 @@ namespace Wox.ViewModel
|
|||
private void InitializeContextMenu()
|
||||
{
|
||||
ContextMenu = new ResultsViewModel();
|
||||
IsContextMenuVisible = false;
|
||||
ContextMenuVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void HandleQueryTextUpdated()
|
||||
|
|
@ -428,7 +431,7 @@ namespace Wox.ViewModel
|
|||
if (_ignoreTextChange) { _ignoreTextChange = false; return; }
|
||||
|
||||
IsProgressBarTooltipVisible = false;
|
||||
if (IsContextMenuVisible)
|
||||
if (ContextMenuVisibility.IsVisible())
|
||||
{
|
||||
QueryContextMenu();
|
||||
}
|
||||
|
|
@ -540,8 +543,8 @@ namespace Wox.ViewModel
|
|||
private void BackToSearchMode()
|
||||
{
|
||||
QueryText = _textBeforeEnterContextMenuMode;
|
||||
IsContextMenuVisible = false;
|
||||
IsResultListBoxVisible = true;
|
||||
ContextMenuVisibility = Visibility.Collapsed;
|
||||
ResultListBoxVisibility = Visibility.Visible;
|
||||
CaretIndex = QueryText.Length;
|
||||
}
|
||||
|
||||
|
|
@ -600,7 +603,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="Extensions\VisibilityExtensions.cs" />
|
||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||
<Compile Include="NotifyIconManager.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue