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