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