mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
parent
cb6160f1e4
commit
6814130570
@ -22,7 +22,7 @@ namespace Wox.Plugin.Folder
|
|||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
|
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
|
||||||
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
|
this.context.API.ResultItemDropEvent += ResultDropEvent;
|
||||||
InitialDriverList();
|
InitialDriverList();
|
||||||
if (FolderStorage.Instance.FolderLinks == null)
|
if (FolderStorage.Instance.FolderLinks == null)
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ namespace Wox.Plugin.Folder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
|
void ResultDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (dropObject.GetDataPresent(DataFormats.FileDrop))
|
if (dropObject.GetDataPresent(DataFormats.FileDrop))
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace Wox.Plugin.Program
|
|||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
|
this.context.API.ResultItemDropEvent += ResultDropEvent;
|
||||||
Stopwatch.Debug("Preload programs", () =>
|
Stopwatch.Debug("Preload programs", () =>
|
||||||
{
|
{
|
||||||
programs = ProgramCacheStorage.Instance.Programs;
|
programs = ProgramCacheStorage.Instance.Programs;
|
||||||
@ -70,7 +70,7 @@ namespace Wox.Plugin.Program
|
|||||||
Stopwatch.Debug("Program Index", IndexPrograms);
|
Stopwatch.Debug("Program Index", IndexPrograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
|
void ResultDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
@ -87,10 +87,10 @@ namespace Wox.Core.Resource
|
|||||||
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
|
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
|
||||||
if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
|
if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
|
||||||
{
|
{
|
||||||
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
|
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultFont));
|
||||||
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
|
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultFontStyle));
|
||||||
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
|
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultFontWeight));
|
||||||
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));
|
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultFontStretch));
|
||||||
|
|
||||||
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
|
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
|
||||||
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
|
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
|
||||||
|
@ -44,16 +44,16 @@ namespace Wox.Core.UserSettings
|
|||||||
public string QueryBoxFontStretch { get; set; }
|
public string QueryBoxFontStretch { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string ResultItemFont { get; set; }
|
public string ResultFont { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string ResultItemFontStyle { get; set; }
|
public string ResultFontStyle { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string ResultItemFontWeight { get; set; }
|
public string ResultFontWeight { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string ResultItemFontStretch { get; set; }
|
public string ResultFontStretch { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public double WindowLeft { get; set; }
|
public double WindowLeft { get; set; }
|
||||||
@ -126,7 +126,7 @@ namespace Wox.Core.UserSettings
|
|||||||
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
||||||
Hotkey = "Alt + Space";
|
Hotkey = "Alt + Space";
|
||||||
QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
||||||
ResultItemFont = FontFamily.GenericSansSerif.Name;
|
ResultFont = FontFamily.GenericSansSerif.Name;
|
||||||
Opacity = 1;
|
Opacity = 1;
|
||||||
OpacityMode = OpacityMode.Normal;
|
OpacityMode = OpacityMode.Normal;
|
||||||
LeaveCmdOpen = false;
|
LeaveCmdOpen = false;
|
||||||
@ -147,9 +147,9 @@ namespace Wox.Core.UserSettings
|
|||||||
{
|
{
|
||||||
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
||||||
}
|
}
|
||||||
if (storage.ResultItemFont == null)
|
if (storage.ResultFont == null)
|
||||||
{
|
{
|
||||||
storage.ResultItemFont = FontFamily.GenericSansSerif.Name;
|
storage.ResultFont = FontFamily.GenericSansSerif.Name;
|
||||||
}
|
}
|
||||||
if (storage.Language == null)
|
if (storage.Language == null)
|
||||||
{
|
{
|
||||||
|
@ -119,6 +119,7 @@ namespace Wox.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired after drop to result item of current plugin
|
/// Fired after drop to result item of current plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// todo: ResultItem -> Result
|
||||||
event ResultItemDropEventHandler ResultItemDropEvent;
|
event ResultItemDropEventHandler ResultItemDropEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<DataTemplate.DataType>
|
<DataTemplate.DataType>
|
||||||
<x:Type TypeName="vm:ResultItemViewModel" />
|
<x:Type TypeName="vm:ResultViewModel" />
|
||||||
</DataTemplate.DataType>
|
</DataTemplate.DataType>
|
||||||
<Button Command="{Binding OpenResultListBoxItemCommand}">
|
<Button Command="{Binding OpenResultListBoxItemCommand}">
|
||||||
<Button.InputBindings>
|
<Button.InputBindings>
|
||||||
|
@ -177,10 +177,10 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="2">
|
<StackPanel Orientation="Horizontal" Margin="2">
|
||||||
<TextBlock Text="{DynamicResource resultItemFont}" />
|
<TextBlock Text="{DynamicResource resultItemFont}" />
|
||||||
<ComboBox Margin="5 -2 5 0" x:Name="cbResultItemFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbResultItemFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
|
<ComboBox Margin="5 -2 5 0" x:Name="ResultFontComboBox" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="OnResultFontSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
|
||||||
<ComboBox Margin="0 -2 0 0"
|
<ComboBox Margin="0 -2 0 0"
|
||||||
x:Name="cbResultItemFontFaces"
|
x:Name="ResultFontFacesComboBox"
|
||||||
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=cbResultItemFont}" SelectionChanged="CbResultItemFontFaces_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
|
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=ResultFontComboBox}" SelectionChanged="OnResultFontFacesSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
|
||||||
|
@ -375,15 +375,15 @@ namespace Wox
|
|||||||
UserSettingStorage.Instance.QueryBoxFontStretch
|
UserSettingStorage.Instance.QueryBoxFontStretch
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultItemFont) &&
|
if (!string.IsNullOrEmpty(UserSettingStorage.Instance.ResultFont) &&
|
||||||
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultItemFont)) > 0)
|
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(UserSettingStorage.Instance.ResultFont)) > 0)
|
||||||
{
|
{
|
||||||
cbResultItemFont.Text = UserSettingStorage.Instance.ResultItemFont;
|
ResultFontComboBox.Text = UserSettingStorage.Instance.ResultFont;
|
||||||
|
|
||||||
cbResultItemFontFaces.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)cbResultItemFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
ResultFontFacesComboBox.SelectedItem = SyntaxSugars.CallOrRescueDefault(() => ((FontFamily)ResultFontComboBox.SelectedItem).ConvertFromInvariantStringsOrNormal(
|
||||||
UserSettingStorage.Instance.ResultItemFontStyle,
|
UserSettingStorage.Instance.ResultFontStyle,
|
||||||
UserSettingStorage.Instance.ResultItemFontWeight,
|
UserSettingStorage.Instance.ResultFontWeight,
|
||||||
UserSettingStorage.Instance.ResultItemFontStretch
|
UserSettingStorage.Instance.ResultFontStretch
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,30 +502,30 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CbResultItemFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnResultFontSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!settingsLoaded) return;
|
if (!settingsLoaded) return;
|
||||||
string resultItemFont = cbResultItemFont.SelectedItem.ToString();
|
string resultItemFont = ResultFontComboBox.SelectedItem.ToString();
|
||||||
UserSettingStorage.Instance.ResultItemFont = resultItemFont;
|
UserSettingStorage.Instance.ResultFont = resultItemFont;
|
||||||
cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface();
|
ResultFontFacesComboBox.SelectedItem = ((FontFamily)ResultFontComboBox.SelectedItem).ChooseRegularFamilyTypeface();
|
||||||
UserSettingStorage.Instance.Save();
|
UserSettingStorage.Instance.Save();
|
||||||
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnResultFontFacesSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!settingsLoaded) return;
|
if (!settingsLoaded) return;
|
||||||
FamilyTypeface typeface = (FamilyTypeface)cbResultItemFontFaces.SelectedItem;
|
FamilyTypeface typeface = (FamilyTypeface)ResultFontFacesComboBox.SelectedItem;
|
||||||
if (typeface == null)
|
if (typeface == null)
|
||||||
{
|
{
|
||||||
if (cbResultItemFontFaces.Items.Count > 0)
|
if (ResultFontFacesComboBox.Items.Count > 0)
|
||||||
cbResultItemFontFaces.SelectedIndex = 0;
|
ResultFontFacesComboBox.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserSettingStorage.Instance.ResultItemFontStretch = typeface.Stretch.ToString();
|
UserSettingStorage.Instance.ResultFontStretch = typeface.Stretch.ToString();
|
||||||
UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString();
|
UserSettingStorage.Instance.ResultFontWeight = typeface.Weight.ToString();
|
||||||
UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString();
|
UserSettingStorage.Instance.ResultFontStyle = typeface.Style.ToString();
|
||||||
UserSettingStorage.Instance.Save();
|
UserSettingStorage.Instance.Save();
|
||||||
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ using Wox.Storage;
|
|||||||
|
|
||||||
namespace Wox.ViewModel
|
namespace Wox.ViewModel
|
||||||
{
|
{
|
||||||
public class ResultItemViewModel : BaseViewModel
|
public class ResultViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
public ResultItemViewModel(Result result)
|
public ResultViewModel(Result result)
|
||||||
{
|
{
|
||||||
if (null != result)
|
if (null != result)
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
ResultItemViewModel r = obj as ResultItemViewModel;
|
ResultViewModel r = obj as ResultViewModel;
|
||||||
if (r != null)
|
if (r != null)
|
||||||
{
|
{
|
||||||
return _result.Equals(r.RawResult);
|
return _result.Equals(r.RawResult);
|
||||||
|
@ -17,7 +17,7 @@ namespace Wox.ViewModel
|
|||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private ResultItemViewModel _selectedResult;
|
private ResultViewModel _selectedResult;
|
||||||
private ResultCollection _results;
|
private ResultCollection _results;
|
||||||
private bool _isVisible;
|
private bool _isVisible;
|
||||||
private Thickness _margin;
|
private Thickness _margin;
|
||||||
@ -53,7 +53,7 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultItemViewModel SelectedResult
|
public ResultViewModel SelectedResult
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -104,7 +104,7 @@ namespace Wox.ViewModel
|
|||||||
return TopMostRecordStorage.Instance.IsTopMost(result);
|
return TopMostRecordStorage.Instance.IsTopMost(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int InsertIndexOf(int newScore, IList<ResultItemViewModel> list)
|
private int InsertIndexOf(int newScore, IList<ResultViewModel> list)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (; index < list.Count; index++)
|
for (; index < list.Count; index++)
|
||||||
@ -211,8 +211,8 @@ namespace Wox.ViewModel
|
|||||||
{
|
{
|
||||||
lock (_resultsUpdateLock)
|
lock (_resultsUpdateLock)
|
||||||
{
|
{
|
||||||
var newResults = new List<ResultItemViewModel>();
|
var newResults = new List<ResultViewModel>();
|
||||||
newRawResults.ForEach((re) => { newResults.Add(new ResultItemViewModel(re)); });
|
newRawResults.ForEach((re) => { newResults.Add(new ResultViewModel(re)); });
|
||||||
// todo use async to do new result calculation
|
// todo use async to do new result calculation
|
||||||
var resultsCopy = _results.ToList();
|
var resultsCopy = _results.ToList();
|
||||||
var oldResults = resultsCopy.Where(r => r.RawResult.PluginID == resultId).ToList();
|
var oldResults = resultsCopy.Where(r => r.RawResult.PluginID == resultId).ToList();
|
||||||
@ -275,19 +275,18 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public class ResultCollection : ObservableCollection<ResultItemViewModel>
|
public class ResultCollection : ObservableCollection<ResultViewModel>
|
||||||
// todo implement custom moveItem,removeItem,insertItem for better performance
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public ResultCollection()
|
public ResultCollection()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveAll(Predicate<ResultItemViewModel> predicate)
|
public void RemoveAll(Predicate<ResultViewModel> predicate)
|
||||||
{
|
{
|
||||||
CheckReentrancy();
|
CheckReentrancy();
|
||||||
|
|
||||||
List<ResultItemViewModel> itemsToRemove = Items.Where(x => predicate(x)).ToList();
|
List<ResultViewModel> itemsToRemove = Items.Where(x => predicate(x)).ToList();
|
||||||
if (itemsToRemove.Count > 0)
|
if (itemsToRemove.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -309,22 +308,22 @@ namespace Wox.ViewModel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(List<ResultItemViewModel> newItems)
|
public void Update(List<ResultViewModel> newItems)
|
||||||
{
|
{
|
||||||
int newCount = newItems.Count;
|
int newCount = newItems.Count;
|
||||||
int oldCount = Items.Count;
|
int oldCount = Items.Count;
|
||||||
int location = newCount > oldCount ? oldCount : newCount;
|
int location = newCount > oldCount ? oldCount : newCount;
|
||||||
for (int i = 0; i < location; i++)
|
for (int i = 0; i < location; i++)
|
||||||
{
|
{
|
||||||
ResultItemViewModel oldItem = Items[i];
|
ResultViewModel oldResult = Items[i];
|
||||||
ResultItemViewModel newItem = newItems[i];
|
ResultViewModel newResult = newItems[i];
|
||||||
if (!oldItem.Equals(newItem))
|
if (!oldResult.Equals(newResult))
|
||||||
{
|
{
|
||||||
this[i] = newItem;
|
this[i] = newResult;
|
||||||
}
|
}
|
||||||
else if (oldItem.RawResult.Score != newItem.RawResult.Score)
|
else if (oldResult.RawResult.Score != newResult.RawResult.Score)
|
||||||
{
|
{
|
||||||
this[i].RawResult.Score = newItem.RawResult.Score;
|
this[i].RawResult.Score = newResult.RawResult.Score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user