diff --git a/Plugins/WinAlfred.Plugin.Fanyi/Main.cs b/Plugins/WinAlfred.Plugin.Fanyi/Main.cs
index 66559b8be..cdbbc4167 100644
--- a/Plugins/WinAlfred.Plugin.Fanyi/Main.cs
+++ b/Plugins/WinAlfred.Plugin.Fanyi/Main.cs
@@ -5,7 +5,9 @@ using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
+using System.Threading;
using System.Windows.Forms;
+using System.Windows.Forms.VisualStyles;
using Newtonsoft.Json;
namespace WinAlfred.Plugin.Fanyi
diff --git a/WinAlfred.Plugin.System/Sys.cs b/WinAlfred.Plugin.System/Sys.cs
index 2494cfc6d..69db348fe 100644
--- a/WinAlfred.Plugin.System/Sys.cs
+++ b/WinAlfred.Plugin.System/Sys.cs
@@ -70,7 +70,7 @@ namespace WinAlfred.Plugin.System
Title = "Exit",
SubTitle = "Close this app",
Score = 110,
- IcoPath = "Images\\exit.png",
+ IcoPath = "Images\\ico.png",
Action = () => context.CloseApp()
});
}
diff --git a/WinAlfred/App.xaml b/WinAlfred/App.xaml
index 1a43596b7..43657b441 100644
--- a/WinAlfred/App.xaml
+++ b/WinAlfred/App.xaml
@@ -10,7 +10,7 @@
-
+
@@ -53,6 +53,7 @@
+
diff --git a/WinAlfred/Commands/BaseCommand.cs b/WinAlfred/Commands/BaseCommand.cs
index aa3dfbdb7..fd16c8ab5 100644
--- a/WinAlfred/Commands/BaseCommand.cs
+++ b/WinAlfred/Commands/BaseCommand.cs
@@ -20,10 +20,7 @@ namespace WinAlfred.Commands
protected void UpdateResultView(List results)
{
- if (results.Count > 0)
- {
- window.OnUpdateResultView(results);
- }
+ window.OnUpdateResultView(results);
}
}
}
diff --git a/WinAlfred/Commands/SystemCommand.cs b/WinAlfred/Commands/SystemCommand.cs
index 52ff2d5d6..7ecad9820 100644
--- a/WinAlfred/Commands/SystemCommand.cs
+++ b/WinAlfred/Commands/SystemCommand.cs
@@ -31,7 +31,7 @@ namespace WinAlfred.Commands
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
result.OriginQuery = query;
}
- UpdateResultView(results);
+ if(results.Count > 0) UpdateResultView(results);
});
}
}
diff --git a/WinAlfred/DispatcherExtensions.cs b/WinAlfred/DispatcherExtensions.cs
index 72f5be8ed..15a56bfa7 100644
--- a/WinAlfred/DispatcherExtensions.cs
+++ b/WinAlfred/DispatcherExtensions.cs
@@ -13,7 +13,14 @@ namespace WinAlfred
private static readonly object syncRoot = new object();
public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation,
- Action action, TimeSpan delay,
+ Action action, TimeSpan delay,
+ DispatcherPriority priority = DispatcherPriority.Normal)
+ {
+ return DelayInvoke(dispatcher, namedInvocation, action, delay, string.Empty, priority);
+ }
+
+ public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation,
+ Action action, TimeSpan delay, string arg,
DispatcherPriority priority = DispatcherPriority.Normal)
{
lock (syncRoot)
@@ -29,7 +36,7 @@ namespace WinAlfred
var timer = new DispatcherTimer(delay, priority, (s, e) =>
{
RemoveTimer(namedInvocation);
- action();
+ action(arg);
}, dispatcher);
timer.Start();
timers.Add(namedInvocation, timer);
diff --git a/WinAlfred/Helper/SelectedRecords.cs b/WinAlfred/Helper/SelectedRecords.cs
new file mode 100644
index 000000000..8e773cfcb
--- /dev/null
+++ b/WinAlfred/Helper/SelectedRecords.cs
@@ -0,0 +1,38 @@
+using WinAlfred.Plugin;
+
+namespace WinAlfred.Helper
+{
+ public class SelectedRecords
+ {
+ private int hasAddedCount = 0;
+
+ public void LoadSelectedRecords()
+ {
+
+ }
+
+ public void AddSelect(Result result)
+ {
+ hasAddedCount++;
+ if (hasAddedCount == 10)
+ {
+ SaveSelectedRecords();
+ hasAddedCount = 0;
+ }
+
+
+
+
+ }
+
+ public int GetSelectedCount(Result result)
+ {
+ return 0;
+ }
+
+ public void SaveSelectedRecords()
+ {
+
+ }
+ }
+}
diff --git a/WinAlfred/Images/enter.png b/WinAlfred/Images/enter.png
new file mode 100644
index 000000000..0999b37cd
Binary files /dev/null and b/WinAlfred/Images/enter.png differ
diff --git a/WinAlfred/Images/exit.png b/WinAlfred/Images/exit.png
index 523c3d519..af7c73824 100644
Binary files a/WinAlfred/Images/exit.png and b/WinAlfred/Images/exit.png differ
diff --git a/WinAlfred/Images/lock.png b/WinAlfred/Images/lock.png
index 5a1593aaf..3eaa9abaa 100644
Binary files a/WinAlfred/Images/lock.png and b/WinAlfred/Images/lock.png differ
diff --git a/WinAlfred/MainWindow.xaml b/WinAlfred/MainWindow.xaml
index d07aa89fd..02da826d8 100644
--- a/WinAlfred/MainWindow.xaml
+++ b/WinAlfred/MainWindow.xaml
@@ -19,7 +19,7 @@
-
+
diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs
index 00e00e86c..35fd1f299 100644
--- a/WinAlfred/MainWindow.xaml.cs
+++ b/WinAlfred/MainWindow.xaml.cs
@@ -26,6 +26,8 @@ namespace WinAlfred
private NotifyIcon notifyIcon;
private Command cmdDispatcher;
Storyboard progressBarStoryboard = new Storyboard();
+ private bool queryHasReturn = false;
+ SelectedRecords selectedRecords = new SelectedRecords();
public MainWindow()
{
@@ -40,10 +42,10 @@ namespace WinAlfred
private void InitProgressbarAnimation()
{
- DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0,0,1600)));
- DoubleAnimation da1 = new DoubleAnimation(progressBar.X1, Width, new Duration(new TimeSpan(0, 0, 0, 0,1600)));
- Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X1)"));
- Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X2)"));
+ DoubleAnimation da = new DoubleAnimation(progressBar.X2, Width + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
+ DoubleAnimation da1 = new DoubleAnimation(progressBar.X1, Width, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
+ Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
+ Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
progressBarStoryboard.Children.Add(da);
progressBarStoryboard.Children.Add(da1);
progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
@@ -81,20 +83,45 @@ namespace WinAlfred
}
}
+ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseLeftButtonDown(e);
+
+ // Begin dragging the window
+ this.DragMove();
+ }
+
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
resultCtrl.Dirty = true;
Dispatcher.DelayInvoke("UpdateSearch",
- () =>
+ o =>
{
- resultCtrl.Clear();
+ Dispatcher.DelayInvoke("ClearResults", i =>
+ {
+ // first try to use clear method inside resultCtrl, which is more closer to the add new results
+ // and this will not bring splash issues.After waiting 30ms, if there still no results added, we
+ // must clear the result. otherwise, it will be confused why the query changed, but the results
+ // didn't.
+ if (resultCtrl.Dirty) resultCtrl.Clear();
+ }, TimeSpan.FromMilliseconds(30), null);
var q = new Query(tbQuery.Text);
cmdDispatcher.DispatchCommand(q);
+ queryHasReturn = false;
+ if (Plugins.HitThirdpartyKeyword(q))
+ {
+ Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
+ {
+ if (!queryHasReturn && originQuery == tbQuery.Text)
+ {
+ StartProgress();
+ }
+ }, TimeSpan.FromSeconds(1), tbQuery.Text);
+ }
+
}, TimeSpan.FromMilliseconds(300));
-
}
-
private void StartProgress()
{
progressBar.Visibility = Visibility.Visible;
@@ -124,7 +151,7 @@ namespace WinAlfred
}
}
- public void SetAutoStart(bool IsAtuoRun)
+ private void SetAutoStart(bool IsAtuoRun)
{
string LnkPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//WinAlfred.lnk";
if (IsAtuoRun)
@@ -148,10 +175,10 @@ namespace WinAlfred
Plugins.Init(this);
cmdDispatcher = new Command(this);
InitialTray();
+ selectedRecords.LoadSelectedRecords();
SetAutoStart(true);
//var engine = new Jurassic.ScriptEngine();
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
- StartProgress();
}
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
@@ -174,7 +201,15 @@ namespace WinAlfred
break;
case Key.Enter:
- if (resultCtrl.AcceptSelect()) HideWinAlfred();
+ Result result = resultCtrl.AcceptSelect();
+ if (result != null)
+ {
+ selectedRecords.AddSelect(result);
+ if (!result.DontHideWinAlfredAfterAction)
+ {
+ HideWinAlfred();
+ }
+ }
e.Handled = true;
break;
}
@@ -182,11 +217,20 @@ namespace WinAlfred
public void OnUpdateResultView(List list)
{
- resultCtrl.Dispatcher.Invoke(new Action(() =>
+ queryHasReturn = true;
+ progressBar.Dispatcher.Invoke(new Action(StopProgress));
+ if (list.Count > 0)
{
- List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).OrderByDescending(o => o.Score).ToList();
- resultCtrl.AddResults(l);
- }));
+ list.ForEach(o =>
+ {
+ o.Score += selectedRecords.GetSelectedCount(o);
+ });
+ resultCtrl.Dispatcher.Invoke(new Action(() =>
+ {
+ List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).OrderByDescending(o => o.Score).ToList();
+ resultCtrl.AddResults(l);
+ }));
+ }
}
#region Public API
diff --git a/WinAlfred/PluginLoader/Plugins.cs b/WinAlfred/PluginLoader/Plugins.cs
index 42f527bf0..06bbceb65 100644
--- a/WinAlfred/PluginLoader/Plugins.cs
+++ b/WinAlfred/PluginLoader/Plugins.cs
@@ -24,9 +24,9 @@ namespace WinAlfred.PluginLoader
Plugins = plugins,
ChangeQuery = s => window.ChangeQuery(s),
CloseApp = window.CloseApp,
- HideApp = window.HideApp,
+ HideApp = window.HideApp,
ShowApp = window.ShowApp,
- ShowMsg = (title,subTitle,iconPath) => window.ShowMsg(title,subTitle,iconPath)
+ ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath)
}));
}
}
@@ -35,5 +35,12 @@ namespace WinAlfred.PluginLoader
{
get { return plugins; }
}
+
+ public static bool HitThirdpartyKeyword(Query query)
+ {
+ if (string.IsNullOrEmpty(query.ActionName)) return false;
+
+ return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
+ }
}
}
diff --git a/WinAlfred/ResultItem.xaml b/WinAlfred/ResultItem.xaml
index 50235dc9a..34d3ef4d2 100644
--- a/WinAlfred/ResultItem.xaml
+++ b/WinAlfred/ResultItem.xaml
@@ -22,8 +22,8 @@
sdfdsf
-
-
+
+
diff --git a/WinAlfred/ResultItem.xaml.cs b/WinAlfred/ResultItem.xaml.cs
index 63cdba567..389ee3af3 100644
--- a/WinAlfred/ResultItem.xaml.cs
+++ b/WinAlfred/ResultItem.xaml.cs
@@ -27,6 +27,15 @@ namespace WinAlfred
selected = value;
BrushConverter bc = new BrushConverter();
Background = selected ? (Brush)(bc.ConvertFrom("#d1d1d1")) : (Brush)(bc.ConvertFrom("#ebebeb"));
+ if (selected)
+ {
+ img.Visibility = Visibility.Visible;
+ img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory()+"\\Images\\enter.png"));
+ }
+ else
+ {
+ img.Visibility = Visibility.Hidden;
+ }
}
}
diff --git a/WinAlfred/ResultPanel.xaml.cs b/WinAlfred/ResultPanel.xaml.cs
index 35af12e2a..26aa8f959 100644
--- a/WinAlfred/ResultPanel.xaml.cs
+++ b/WinAlfred/ResultPanel.xaml.cs
@@ -192,10 +192,10 @@ namespace WinAlfred
Select(0);
}
- public bool AcceptSelect()
+ public Result AcceptSelect()
{
int index = GetCurrentSelectedResultIndex();
- if (index < 0) return false;
+ if (index < 0) return null;
var resultItemControl = pnlContainer.Children[index] as ResultItem;
if (resultItemControl != null)
@@ -205,10 +205,10 @@ namespace WinAlfred
resultItemControl.Result.Action();
}
- return !resultItemControl.Result.DontHideWinAlfredAfterAction;
+ return resultItemControl.Result;
}
- return true;
+ return null;
}
public ResultPanel()
diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj
index 197c21d9e..66418b728 100644
--- a/WinAlfred/WinAlfred.csproj
+++ b/WinAlfred/WinAlfred.csproj
@@ -112,6 +112,7 @@
ResultItem.xaml
+
MSBuild:Compile
Designer