mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
parent
fc3a369d3d
commit
7e7b41cd8c
@ -22,7 +22,7 @@
|
||||
PreviewKeyDown="Window_PreviewKeyDown" d:DataContext="{d:DesignInstance vm:MainViewModel, IsDesignTimeCreatable=True}">
|
||||
<Window.Resources>
|
||||
<DataTemplate DataType="{x:Type vm:ResultPanelViewModel}">
|
||||
<wox:ResultPanel></wox:ResultPanel>
|
||||
<wox:ResultListBox></wox:ResultListBox>
|
||||
</DataTemplate>
|
||||
<converters:VisibilityConverter x:Key="VisibilityConverter" />
|
||||
</Window.Resources>
|
||||
@ -37,7 +37,7 @@
|
||||
<ToolTip IsOpen="{Binding IsProgressBarTooltipVisible}"></ToolTip>
|
||||
</Line.ToolTip>
|
||||
</Line>
|
||||
<ContentControl Content="{Binding SearchResultPanel}" Visibility="{Binding IsSearchResultPanelVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
<ContentControl Content="{Binding Results}" Visibility="{Binding IsResultListBoxVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
</ContentControl>
|
||||
<ContentControl Content="{Binding ActionPanel}" Visibility="{Binding IsActionPanelVisible,Converter={StaticResource VisibilityConverter}}">
|
||||
</ContentControl>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="Wox.ResultPanel"
|
||||
<UserControl x:Class="Wox.ResultListBox"
|
||||
x:Name="Results"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -15,7 +15,7 @@ using Wox.ViewModel;
|
||||
namespace Wox
|
||||
{
|
||||
[Synchronization]
|
||||
public partial class ResultPanel : UserControl
|
||||
public partial class ResultListBox
|
||||
{
|
||||
public void AddResults(List<Result> newResults, string resultId)
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace Wox
|
||||
}
|
||||
|
||||
|
||||
public ResultPanel()
|
||||
public ResultListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
@ -149,7 +149,7 @@
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Text="{DynamicResource helloWox}" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/>
|
||||
<wox:ResultPanel Grid.Row="1" x:Name="resultPanelPreview"/>
|
||||
<wox:ResultListBox Grid.Row="1" x:Name="ResultListBoxPreview"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
@ -37,7 +37,7 @@ namespace Wox
|
||||
{
|
||||
this._api = api;
|
||||
InitializeComponent();
|
||||
this.resultPanelPreview.DataContext = new ResultPanelViewModel();
|
||||
this.ResultListBoxPreview.DataContext = new ResultPanelViewModel();
|
||||
Loaded += Setting_Loaded;
|
||||
}
|
||||
|
||||
@ -387,7 +387,7 @@ namespace Wox
|
||||
));
|
||||
}
|
||||
|
||||
resultPanelPreview.AddResults(new List<Result>
|
||||
ResultListBoxPreview.AddResults(new List<Result>
|
||||
{
|
||||
new Result
|
||||
{
|
||||
|
@ -21,11 +21,10 @@ namespace Wox.ViewModel
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private ResultPanelViewModel _searchResultPanel;
|
||||
private ResultPanelViewModel _actionPanel;
|
||||
private string _queryText;
|
||||
private bool _isVisible;
|
||||
private bool _isSearchResultPanelVisible;
|
||||
private bool _isResultListBoxVisible;
|
||||
private bool _isActionPanelVisible;
|
||||
private bool _isProgressBarVisible;
|
||||
private bool _isProgressBarTooltipVisible;
|
||||
@ -46,7 +45,7 @@ namespace Wox.ViewModel
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
this.InitializeResultPanel();
|
||||
this.InitializeResultListBox();
|
||||
this.InitializeActionPanel();
|
||||
this.InitializeKeyCommands();
|
||||
|
||||
@ -57,13 +56,7 @@ namespace Wox.ViewModel
|
||||
|
||||
#region ViewModel Properties
|
||||
|
||||
public ResultPanelViewModel SearchResultPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._searchResultPanel;
|
||||
}
|
||||
}
|
||||
public ResultPanelViewModel Results { get; private set; }
|
||||
|
||||
public ResultPanelViewModel ActionPanel
|
||||
{
|
||||
@ -132,16 +125,16 @@ namespace Wox.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSearchResultPanelVisible
|
||||
public bool IsResultListBoxVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._isSearchResultPanelVisible;
|
||||
return this._isResultListBoxVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._isSearchResultPanelVisible = value;
|
||||
OnPropertyChanged("IsSearchResultPanelVisible");
|
||||
this._isResultListBoxVisible = value;
|
||||
OnPropertyChanged("IsResultListBoxVisible");
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +304,7 @@ namespace Wox.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
this._searchResultPanel.SelectNextResult();
|
||||
this.Results.SelectNextResult();
|
||||
}
|
||||
|
||||
});
|
||||
@ -325,7 +318,7 @@ namespace Wox.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
this._searchResultPanel.SelectPrevResult();
|
||||
this.Results.SelectPrevResult();
|
||||
}
|
||||
|
||||
});
|
||||
@ -339,7 +332,7 @@ namespace Wox.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActionPanel(this._searchResultPanel.SelectedResult.RawResult);
|
||||
ShowActionPanel(this.Results.SelectedResult.RawResult);
|
||||
}
|
||||
});
|
||||
|
||||
@ -362,14 +355,14 @@ namespace Wox.ViewModel
|
||||
this.SelectNextPageCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
this._searchResultPanel.SelectNextPage();
|
||||
this.Results.SelectNextPage();
|
||||
|
||||
});
|
||||
|
||||
this.SelectPrevPageCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
this._searchResultPanel.SelectPrevPage();
|
||||
this.Results.SelectPrevPage();
|
||||
|
||||
});
|
||||
|
||||
@ -381,9 +374,9 @@ namespace Wox.ViewModel
|
||||
this.ShiftEnterCommand = new RelayCommand((parameter) =>
|
||||
{
|
||||
|
||||
if (!this.IsActionPanelVisible && null != this._searchResultPanel.SelectedResult)
|
||||
if (!this.IsActionPanelVisible && null != this.Results.SelectedResult)
|
||||
{
|
||||
this.ShowActionPanel(this._searchResultPanel.SelectedResult.RawResult);
|
||||
this.ShowActionPanel(this.Results.SelectedResult.RawResult);
|
||||
}
|
||||
|
||||
});
|
||||
@ -394,12 +387,12 @@ namespace Wox.ViewModel
|
||||
if (null != parameter)
|
||||
{
|
||||
var index = int.Parse(parameter.ToString());
|
||||
this._searchResultPanel.SelectResult(index);
|
||||
this.Results.SelectResult(index);
|
||||
}
|
||||
|
||||
if (null != this._searchResultPanel.SelectedResult)
|
||||
if (null != this.Results.SelectedResult)
|
||||
{
|
||||
this._searchResultPanel.SelectedResult.OpenResultCommand.Execute(null);
|
||||
this.Results.SelectedResult.OpenResultCommand.Execute(null);
|
||||
}
|
||||
});
|
||||
|
||||
@ -413,10 +406,10 @@ namespace Wox.ViewModel
|
||||
});
|
||||
}
|
||||
|
||||
private void InitializeResultPanel()
|
||||
private void InitializeResultListBox()
|
||||
{
|
||||
this._searchResultPanel = new ResultPanelViewModel();
|
||||
this.IsSearchResultPanelVisible = false;
|
||||
this.Results = new ResultPanelViewModel();
|
||||
this.IsResultListBoxVisible = false;
|
||||
}
|
||||
|
||||
private void ShowActionPanel(Result result)
|
||||
@ -448,7 +441,7 @@ namespace Wox.ViewModel
|
||||
CurrentContextMenus = actions;
|
||||
|
||||
this.IsActionPanelVisible = true;
|
||||
this.IsSearchResultPanelVisible = false;
|
||||
this.IsResultListBoxVisible = false;
|
||||
|
||||
this.QueryText = "";
|
||||
}
|
||||
@ -509,7 +502,7 @@ namespace Wox.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
this._searchResultPanel.Clear();
|
||||
this.Results.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -551,18 +544,18 @@ namespace Wox.ViewModel
|
||||
{
|
||||
if (!string.IsNullOrEmpty(keyword))
|
||||
{
|
||||
this._searchResultPanel.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
this.Results.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyword))
|
||||
{
|
||||
this._searchResultPanel.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
|
||||
this.Results.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
|
||||
}
|
||||
else if (lastKeyword != keyword)
|
||||
{
|
||||
this._searchResultPanel.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
this.Results.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
|
||||
}
|
||||
}
|
||||
_lastQuery = query;
|
||||
@ -593,21 +586,21 @@ namespace Wox.ViewModel
|
||||
|
||||
private void ResetQueryHistoryIndex()
|
||||
{
|
||||
this._searchResultPanel.RemoveResultsFor(QueryHistoryStorage.MetaData);
|
||||
this.Results.RemoveResultsFor(QueryHistoryStorage.MetaData);
|
||||
QueryHistoryStorage.Instance.Reset();
|
||||
}
|
||||
|
||||
private void UpdateResultViewInternal(List<Result> list, PluginMetadata metadata)
|
||||
{
|
||||
Infrastructure.Stopwatch.Normal($"UI update cost for {metadata.Name}",
|
||||
() => { this._searchResultPanel.AddResults(list, metadata.ID); });
|
||||
() => { this.Results.AddResults(list, metadata.ID); });
|
||||
}
|
||||
|
||||
private void BackToSearchMode()
|
||||
{
|
||||
this.QueryText = _textBeforeEnterContextMenuMode;
|
||||
this.IsActionPanelVisible = false;
|
||||
this.IsSearchResultPanelVisible = true;
|
||||
this.IsResultListBoxVisible = true;
|
||||
this.CaretIndex = this.QueryText.Length;
|
||||
}
|
||||
|
||||
@ -622,7 +615,7 @@ namespace Wox.ViewModel
|
||||
|
||||
var executeQueryHistoryTitle = InternationalizationManager.Instance.GetTranslation("executeQuery");
|
||||
var lastExecuteTime = InternationalizationManager.Instance.GetTranslation("lastExecuteTime");
|
||||
this._searchResultPanel.RemoveResultsExcept(historyMetadata);
|
||||
this.Results.RemoveResultsExcept(historyMetadata);
|
||||
UpdateResultViewInternal(new List<Result>
|
||||
{
|
||||
new Result
|
||||
@ -666,7 +659,7 @@ namespace Wox.ViewModel
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
this.IsSearchResultPanelVisible = true;
|
||||
this.IsResultListBoxVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user