Merge branch 'master' into dotnet45

This commit is contained in:
bao-qian
2015-11-12 22:02:40 +00:00
60 changed files with 1717 additions and 671 deletions

View File

@@ -1,34 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Wox.Core.i18n;
using Wox.Core.Plugin;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Exception;
using Wox.Plugin;
namespace Wox
{
public partial class ActionKeywords : Window
{
private PluginMetadata pluginMetadata;
private PluginPair _plugin;
public ActionKeywords(string pluginId)
{
InitializeComponent();
PluginPair plugin = PluginManager.GetPluginForId(pluginId);
if (plugin == null)
_plugin = PluginManager.GetPluginForId(pluginId);
if (_plugin == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin"));
Close();
return;
}
pluginMetadata = plugin.Metadata;
}
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
{
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, pluginMetadata.ActionKeywords.ToArray());
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, _plugin.Metadata.ActionKeywords.ToArray());
tbAction.Focus();
}
@@ -37,42 +37,23 @@ namespace Wox
Close();
}
private void btnDone_OnClick(object sender, RoutedEventArgs e)
private void btnDone_OnClick(object sender, RoutedEventArgs _)
{
if (string.IsNullOrEmpty(tbAction.Text))
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
var newActionKeyword = tbAction.Text.Trim();
try
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordCannotBeEmpty"));
// update in-memory data
PluginManager.UpdateActionKeywordForPlugin(_plugin, oldActionKeyword, newActionKeyword);
}
catch (WoxPluginException e)
{
MessageBox.Show(e.Message);
return;
}
// update persistant data
UserSettingStorage.Instance.UpdateActionKeyword(_plugin.Metadata);
var actionKeywords = tbAction.Text.Trim().Split(new[] { Query.ActionKeywordSeperater }, StringSplitOptions.RemoveEmptyEntries).ToList();
//check new action keyword didn't used by other plugin
if (actionKeywords[0] != Query.GlobalPluginWildcardSign && PluginManager.AllPlugins.
SelectMany(p => p.Metadata.ActionKeywords).
Any(k => actionKeywords.Contains(k)))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned"));
return;
}
pluginMetadata.ActionKeywords = actionKeywords;
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginMetadata.ID);
if (customizedPluginConfig == null)
{
UserSettingStorage.Instance.CustomizedPluginConfigs.Add(new CustomizedPluginConfig()
{
Disabled = false,
ID = pluginMetadata.ID,
Name = pluginMetadata.Name,
ActionKeywords = actionKeywords
});
}
else
{
customizedPluginConfig.ActionKeywords = actionKeywords;
}
UserSettingStorage.Instance.Save();
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
Close();
}

View File

@@ -1,13 +1,5 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="exceptionless" type="Exceptionless.Configuration.ExceptionlessSection, Exceptionless" />
</configSections>
<runtime>
<!--http://stackoverflow.com/questions/186854/how-to-prevent-an-exception-in-a-background-thread-from-terminating-an-application-->
<!--prevent non-ui exception crash wox-->
<legacyUnhandledExceptionPolicy enabled="1" />
</runtime>
<startup>
<supportedRuntime version="v4.0" />
</startup>

View File

@@ -42,7 +42,7 @@ namespace Wox
}
[Conditional("DEBUG")]
[Conditional("RELEASE")]
private void RegisterUnhandledException()
{
// let exception throw as normal is better for Debug

View File

@@ -1,6 +1,6 @@
using System;
using System.Windows.Threading;
using Wox.Core.Exception;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;
namespace Wox.Helper
@@ -9,7 +9,7 @@ namespace Wox.Helper
{
public static void Report(Exception e)
{
Log.Error(ExceptionFormatter.FormatExcpetion(e));
Log.Fatal(e);
new CrashReporter.CrashReporter(e).Show();
}

View File

@@ -9,6 +9,7 @@ using Wox.Plugin;
namespace Wox.Helper
{
class ListBoxItems : ObservableCollection<Result>
// todo implement custom moveItem,removeItem,insertItem for better performance
{
public void RemoveAll(Predicate<Result> predicate)
{
@@ -17,12 +18,50 @@ namespace Wox.Helper
List<Result> itemsToRemove = Items.Where(x => predicate(x)).ToList();
if (itemsToRemove.Count > 0)
{
itemsToRemove.ForEach(item => Items.Remove(item));
OnPropertyChanged(new PropertyChangedEventArgs("Count"));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, itemsToRemove));
// fuck ms
// http://blogs.msdn.com/b/nathannesbit/archive/2009/04/20/addrange-and-observablecollection.aspx
// http://geekswithblogs.net/NewThingsILearned/archive/2008/01/16/listcollectionviewcollectionview-doesnt-support-notifycollectionchanged-with-multiple-items.aspx
// PS: don't use Reset for other data updates, it will cause UI flickering
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
public void Update(List<Result> newItems)
{
int newCount = newItems.Count;
int oldCount = Items.Count;
int location = newCount > oldCount ? oldCount : newCount;
for (int i = 0; i < location; i++)
{
Result oldItem = Items[i];
Result newItem = newItems[i];
if (!Equals(oldItem, newItem))
{
this[i] = newItem;
}
}
if (newCount > oldCount)
{
for (int i = oldCount; i < newCount; i++)
{
Add(newItems[i]);
}
}
else
{
int removeIndex = newCount;
for (int i = newCount; i < oldCount; i++)
{
RemoveAt(removeIndex);
}
}
}
}
}

View File

@@ -14,9 +14,6 @@
ShowInTaskbar="False"
Style="{DynamicResource WindowStyle}"
Icon="Images\app.png">
<Window.Resources>
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
</Window.Resources>
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
<StackPanel Orientation="Vertical">
<TextBox Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True"

View File

@@ -32,6 +32,7 @@ using IDataObject = System.Windows.IDataObject;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MenuItem = System.Windows.Forms.MenuItem;
using MessageBox = System.Windows.MessageBox;
using Stopwatch = Wox.Infrastructure.Stopwatch;
using ToolTip = System.Windows.Controls.ToolTip;
namespace Wox
@@ -162,7 +163,7 @@ namespace Wox
o.PluginID = plugin.ID;
o.OriginQuery = query;
});
UpdateResultView(results);
UpdateResultView(results, plugin, query);
}
public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
@@ -176,7 +177,7 @@ namespace Wox
o.ContextMenu = null;
});
pnlContextMenu.Clear();
pnlContextMenu.AddResults(results);
pnlContextMenu.AddResults(results, plugin.ID);
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;
}
@@ -418,11 +419,12 @@ namespace Wox
private void QueryContextMenu()
{
var contextMenuId = "Context Menu Id";
pnlContextMenu.Clear();
var query = tbQuery.Text.ToLower();
if (string.IsNullOrEmpty(query))
{
pnlContextMenu.AddResults(CurrentContextMenus);
pnlContextMenu.AddResults(CurrentContextMenus, contextMenuId);
}
else
{
@@ -435,32 +437,25 @@ namespace Wox
filterResults.Add(contextMenu);
}
}
pnlContextMenu.AddResults(filterResults);
pnlContextMenu.AddResults(filterResults, contextMenuId);
}
}
private void TbQuery_OnTextChanged(object sender, TextChangedEventArgs e)
{
if (_ignoreTextChange) { _ignoreTextChange = false; return; }
toolTip.IsOpen = false;
if (IsInContextMenuMode)
{
QueryContextMenu();
return;
}
string query = tbQuery.Text.Trim();
if (!string.IsNullOrEmpty(query))
{
toolTip.IsOpen = false;
if (IsInContextMenuMode)
{
QueryContextMenu();
return;
}
Query(query);
Dispatcher.DelayInvoke("ShowProgressbar", () =>
{
if (!string.IsNullOrEmpty(query) && query != _lastQuery.RawQuery && !_queryHasReturn)
{
StartProgress();
}
}, TimeSpan.FromMilliseconds(150));
//reset query history index after user start new query
ResetQueryHistoryIndex();
}
@@ -472,10 +467,12 @@ namespace Wox
private void ResetQueryHistoryIndex()
{
pnlResult.RemoveResultsFor(QueryHistoryStorage.MetaData);
QueryHistoryStorage.Instance.Reset();
}
private void Query(string text)
{
_queryHasReturn = false;
var query = PluginManager.QueryInit(text);
if (query != null)
{
@@ -486,21 +483,28 @@ namespace Wox
{
if (!string.IsNullOrEmpty(keyword))
{
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
}
}
else
{
if (string.IsNullOrEmpty(keyword))
{
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword]);
pnlResult.RemoveResultsFor(PluginManager.NonGlobalPlugins[lastKeyword].Metadata);
}
else if (lastKeyword != keyword)
{
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword]);
pnlResult.RemoveResultsExcept(PluginManager.NonGlobalPlugins[keyword].Metadata);
}
}
_lastQuery = query;
Dispatcher.DelayInvoke("ShowProgressbar", () =>
{
if (!string.IsNullOrEmpty(query.RawQuery) && query.RawQuery == _lastQuery.RawQuery && !_queryHasReturn)
{
StartProgress();
}
}, TimeSpan.FromMilliseconds(150));
PluginManager.QueryForAllPlugins(query);
}
StopProgress();
@@ -737,9 +741,11 @@ namespace Wox
{
if (history != null)
{
var historyMetadata = QueryHistoryStorage.MetaData;
ChangeQueryText(history.Query, true);
var executeQueryHistoryTitle = GetTranslation("executeQuery");
var lastExecuteTime = GetTranslation("lastExecuteTime");
pnlResult.RemoveResultsExcept(historyMetadata);
UpdateResultViewInternal(new List<Result>()
{
new Result(){
@@ -752,7 +758,7 @@ namespace Wox
return false;
}
}
});
}, historyMetadata);
}
}
@@ -833,28 +839,27 @@ namespace Wox
}
}
private void UpdateResultView(List<Result> list)
private void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
{
_queryHasReturn = true;
progressBar.Dispatcher.Invoke(new Action(StopProgress));
if (list == null || list.Count == 0) return;
if (list.Count > 0)
list.ForEach(o =>
{
list.ForEach(o =>
{
o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
});
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == _lastQuery.RawQuery).ToList();
UpdateResultViewInternal(l);
o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
});
if (originQuery.RawQuery == _lastQuery.RawQuery)
{
UpdateResultViewInternal(list, metadata);
}
}
private void UpdateResultViewInternal(List<Result> list)
private void UpdateResultViewInternal(List<Result> list, PluginMetadata metadata)
{
Dispatcher.Invoke(new Action(() =>
{
pnlResult.AddResults(list);
Stopwatch.Normal($"UI update cost for {metadata.Name}",
() => { pnlResult.AddResults(list, metadata.ID); });
}));
}
@@ -903,7 +908,7 @@ namespace Wox
textBeforeEnterContextMenuMode = tbQuery.Text;
ChangeQueryText("");
pnlContextMenu.Clear();
pnlContextMenu.AddResults(results);
pnlContextMenu.AddResults(results, result.PluginID);
CurrentContextMenus = results;
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
@@ -21,7 +22,7 @@ namespace Wox
public event Action<Result> LeftMouseClickEvent;
public event Action<Result> RightMouseClickEvent;
public event Action<Result, IDataObject, DragEventArgs> ItemDropEvent;
private readonly ListBoxItems _results; //todo, for better performance, override the default linear search
private readonly ListBoxItems _results;
private readonly object _resultsUpdateLock = new object();
protected virtual void OnRightMouseClick(Result result)
@@ -39,75 +40,74 @@ namespace Wox
public int MaxResultsToShow { get { return UserSettingStorage.Instance.MaxResultsToShow * 50; } }
internal void RemoveResultsFor(PluginPair plugin)
internal void RemoveResultsFor(PluginMetadata metadata)
{
lock (_resultsUpdateLock)
{
_results.RemoveAll(r => r.PluginID == plugin.Metadata.ID);
_results.RemoveAll(r => r.PluginID == metadata.ID);
}
}
internal void RemoveResultsExcept(PluginPair plugin)
internal void RemoveResultsExcept(PluginMetadata metadata)
{
lock (_resultsUpdateLock)
{
_results.RemoveAll(r => r.PluginID != plugin.Metadata.ID);
_results.RemoveAll(r => r.PluginID != metadata.ID);
}
}
public void AddResults(List<Result> newResults)
public void AddResults(List<Result> newResults, string resultId)
{
if (newResults != null && newResults.Count > 0)
lock (_resultsUpdateLock)
{
lock (_resultsUpdateLock)
var resultCopy = _results.ToList();
var oldResults = resultCopy.Where(r => r.PluginID == resultId).ToList();
// intersection of A (old results) and B (new newResults)
var intersection = oldResults.Intersect(newResults).ToList();
// remove result of relative complement of B in A
foreach (var result in oldResults.Except(intersection))
{
var pluginId = newResults[0].PluginID;
var oldResults = _results.Where(r => r.PluginID == pluginId).ToList();
// intersection of A (old results) and B (new newResults)
var intersection = oldResults.Intersect(newResults).ToList();
// remove result of relative complement of B in A
foreach (var result in oldResults.Except(intersection))
{
_results.Remove(result);
}
// update scores
foreach (var result in newResults)
{
if (IsTopMostResult(result))
{
result.Score = int.MaxValue;
}
}
// update index for result in intersection of A and B
foreach (var result in intersection)
{
int oldIndex = _results.IndexOf(result);
int oldScore = _results[oldIndex].Score;
if (result.Score != oldScore)
{
int newIndex = InsertIndexOf(result.Score);
if (newIndex != oldIndex)
{
_results.Move(oldIndex, newIndex);
}
}
}
// insert result in relative complement of A in B
foreach (var result in newResults.Except(intersection))
{
int newIndex = InsertIndexOf(result.Score);
_results.Insert(newIndex, result);
}
lbResults.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 };
SelectFirst();
resultCopy.Remove(result);
}
// update scores
foreach (var result in newResults)
{
if (IsTopMostResult(result))
{
result.Score = int.MaxValue;
}
}
// update index for result in intersection of A and B
foreach (var result in intersection)
{
int oldIndex = resultCopy.IndexOf(result);
int oldScore = resultCopy[oldIndex].Score;
if (result.Score != oldScore)
{
int newIndex = InsertIndexOf(result.Score, resultCopy);
if (newIndex != oldIndex)
{
var item = resultCopy[oldIndex];
resultCopy.RemoveAt(oldIndex);
resultCopy.Insert(newIndex, item);
}
}
}
// insert result in relative complement of A in B
foreach (var result in newResults.Except(intersection))
{
int newIndex = InsertIndexOf(result.Score, resultCopy);
resultCopy.Insert(newIndex, result);
}
// update UI in one run, so it can avoid UI flickering
_results.Update(resultCopy);
lbResults.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 };
SelectFirst();
}
}
@@ -116,13 +116,13 @@ namespace Wox
return TopMostRecordStorage.Instance.IsTopMost(result);
}
private int InsertIndexOf(int newScore)
private int InsertIndexOf(int newScore, IList<Result> list)
{
int index = 0;
for (; index < lbResults.Items.Count; index++)
for (; index < list.Count; index++)
{
Result result = lbResults.Items[index] as Result;
if (newScore > result?.Score)
var result = list[index];
if (newScore > result.Score)
{
break;
}

View File

@@ -106,9 +106,7 @@
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
<TextBlock Text="{DynamicResource disable}"></TextBlock>
</CheckBox>
<TextBlock x:Name="pluginActionKeywordsTitle" Margin="20 0 0 0">
<TextBlock Text="{DynamicResource actionKeywords}"></TextBlock>
</TextBlock>
<TextBlock x:Name="pluginActionKeywordsTitle" Margin="20 0 0 0" Text="{DynamicResource actionKeywords}" />
<TextBlock Margin="5 0 0 0" ToolTip="Change Action Keywords" Cursor="Hand" MouseUp="PluginActionKeywords_OnMouseUp" Foreground="Blue" Text="keys" x:Name="pluginActionKeywords"></TextBlock>
<TextBlock Margin="10 0 0 0" Text="Init time: 0ms" x:Name="pluginInitTime"></TextBlock>
<TextBlock Margin="10 0 0 0" Text="Query time: 0ms" x:Name="pluginQueryTime"></TextBlock>
@@ -144,9 +142,6 @@
</Grid.ColumnDefinitions>
<StackPanel x:Name="PreviewPanel" Grid.Row="0" Margin="0">
<StackPanel x:Name="PreviewMainPanel" Orientation="Horizontal" Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.Resources>
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
</StackPanel.Resources>
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
<Grid>
<Grid.RowDefinitions>
@@ -231,7 +226,7 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource actionKeyword}" Width="500">
<GridViewColumn Header="{DynamicResource actionKeywords}" Width="500">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ActionKeywords}"/>

View File

@@ -17,7 +17,7 @@ using Wox.Core.Theme;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Exception;
using Wox.Plugin;
using Application = System.Windows.Forms.Application;
using Stopwatch = Wox.Infrastructure.Stopwatch;
@@ -188,23 +188,6 @@ namespace Wox
{
OnHotkeyTabSelected();
}
// save multiple action keywords settings, todo: this hack is ugly
var tab = e.RemovedItems.Count > 0 ? e.RemovedItems[0] : null;
if (ReferenceEquals(tab, tabPlugin))
{
var metadata = (lbPlugins.SelectedItem as PluginPair)?.Metadata;
if (metadata != null)
{
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
if (customizedPluginConfig != null && !customizedPluginConfig.Disabled)
{
customizedPluginConfig.ActionKeywords = metadata.ActionKeywords;
UserSettingStorage.Instance.Save();
}
}
}
}
#region General
@@ -429,7 +412,7 @@ namespace Wox
IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
}
});
}, "test id");
foreach (string theme in ThemeManager.Theme.LoadAvailableThemes())
{
@@ -535,50 +518,64 @@ namespace Wox
#region Plugin
private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
private void lbPlugins_OnSelectionChanged(object sender, SelectionChangedEventArgs _)
{
ISettingProvider provider = null;
var pair = lbPlugins.SelectedItem as PluginPair;
string pluginId = string.Empty;
if (pair != null)
List<string> actionKeywords = null;
if (pair == null) return;
actionKeywords = pair.Metadata.ActionKeywords;
pluginAuthor.Visibility = Visibility.Visible;
pluginInitTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
pluginQueryTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
if (actionKeywords.Count > 1)
{
provider = pair.Plugin as ISettingProvider;
pluginAuthor.Visibility = Visibility.Visible;
pluginInitTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
pluginQueryTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"), pair.AvgQueryTime);
if (pair.Metadata.ActionKeywords.Count > 1)
{
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
pluginActionKeywords.Visibility = Visibility.Collapsed;
}
else
{
pluginActionKeywordsTitle.Visibility = Visibility.Visible;
pluginActionKeywords.Visibility = Visibility.Visible;
}
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
pluginTitle.Text = pair.Metadata.Name;
pluginTitle.Cursor = Cursors.Hand;
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, pair.Metadata.ActionKeywords.ToArray());
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
pluginSubTitle.Text = pair.Metadata.Description;
pluginId = pair.Metadata.ID;
pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath);
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
pluginActionKeywords.Visibility = Visibility.Collapsed;
}
else
{
pluginActionKeywordsTitle.Visibility = Visibility.Visible;
pluginActionKeywords.Visibility = Visibility.Visible;
}
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
pluginTitle.Text = pair.Metadata.Name;
pluginTitle.Cursor = Cursors.Hand;
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " + pair.Metadata.Author;
pluginSubTitle.Text = pair.Metadata.Description;
pluginId = pair.Metadata.ID;
pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath);
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pluginId);
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
PluginContentPanel.Content = null;
if (provider != null)
var settingProvider = pair.Plugin as ISettingProvider;
if (settingProvider != null)
{
Control control = null;
if (!featureControls.TryGetValue(provider, out control))
featureControls.Add(provider, control = provider.CreateSettingPanel());
Control control;
if (!featureControls.TryGetValue(settingProvider, out control))
{
var multipleActionKeywordsProvider = settingProvider as IMultipleActionKeywords;
if (multipleActionKeywordsProvider != null)
{
multipleActionKeywordsProvider.ActionKeywordsChanged += (o, e) =>
{
// update in-memory data
PluginManager.UpdateActionKeywordForPlugin(pair, e.OldActionKeyword, e.NewActionKeyword);
// update persistant data
UserSettingStorage.Instance.UpdateActionKeyword(pair.Metadata);
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
};
}
featureControls.Add(settingProvider, control = settingProvider.CreateSettingPanel());
}
PluginContentPanel.Content = control;
control.HorizontalAlignment = HorizontalAlignment.Stretch;
control.VerticalAlignment = VerticalAlignment.Stretch;

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
namespace Wox.Storage
{
@@ -16,6 +17,9 @@ namespace Wox.Storage
private int MaxHistory = 300;
private int cursor = 0;
public static PluginMetadata MetaData { get; } = new PluginMetadata
{ ID = "Query history", Name = "Query history" };
protected override string ConfigFolder
{
get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }
@@ -77,7 +81,7 @@ namespace Wox.Storage
return History.OrderByDescending(o => o.ExecutedDateTime).ToList();
}
}
public class HistoryItem
{
public string Query { get; set; }

View File

@@ -48,7 +48,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Output\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;RELEASE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
@@ -295,7 +295,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -320,9 +322,6 @@
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
@@ -379,7 +378,6 @@ cd "$(TargetDir)Plugins" &amp; del /s /q NAppUpdate.Framework.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Infrastructure.dll
cd "$(TargetDir)Plugins" &amp; del /s /q Wox.Infrastructure.pdb
cd "$(TargetDir)Plugins" &amp; del /s /q Newtonsoft.Json.dll
cd "$(TargetDir)Plugins" &amp; del /s /q WindowsInput.dll
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.