diff --git a/WinAlfred/Images/ctrl.png b/WinAlfred/Images/ctrl.png
new file mode 100644
index 0000000000..0e16903098
Binary files /dev/null and b/WinAlfred/Images/ctrl.png differ
diff --git a/WinAlfred/Images/ico.png b/WinAlfred/Images/ico.png
new file mode 100644
index 0000000000..64196dec7c
Binary files /dev/null and b/WinAlfred/Images/ico.png differ
diff --git a/WinAlfred/MainWindow.xaml b/WinAlfred/MainWindow.xaml
index 8e8e63c774..0dd71cf62d 100644
--- a/WinAlfred/MainWindow.xaml
+++ b/WinAlfred/MainWindow.xaml
@@ -3,17 +3,19 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:winAlfred="clr-namespace:WinAlfred"
Title="WinAlfred" Height="80" Width="525"
- Background="Cornsilk"
+ Background="#ebebeb"
+ Topmost="True"
Loaded="MainWindow_OnLoaded"
SizeToContent="Height"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
ShowInTaskbar="False"
+ Icon="Images\ico.png"
>
-
+
diff --git a/WinAlfred/MainWindow.xaml.cs b/WinAlfred/MainWindow.xaml.cs
index 4a5758887b..ea1489f472 100644
--- a/WinAlfred/MainWindow.xaml.cs
+++ b/WinAlfred/MainWindow.xaml.cs
@@ -18,6 +18,7 @@ namespace WinAlfred
private KeyboardHook hook = new KeyboardHook();
public List plugins = new List();
private List results = new List();
+ private NotifyIcon notifyIcon = null;
public MainWindow()
{
@@ -27,9 +28,26 @@ namespace WinAlfred
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
}
+ private void InitialTray()
+ {
+ notifyIcon = new NotifyIcon {Text = "WinAlfred", Icon = Properties.Resources.app, Visible = true};
+ notifyIcon.Click += (o, e) => ShowWinAlfred();
+ System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open");
+ open.Click += (o, e) => ShowWinAlfred();
+ System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit");
+ exit.Click += (o, e) =>
+ {
+ notifyIcon.Visible = false;
+ Close();
+ };
+ System.Windows.Forms.MenuItem[] childen = { open, exit };
+ notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);
+ }
+
private void resultCtrl_resultItemChangedEvent()
{
Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
+ resultCtrl.Margin = results.Count > 0 ? new Thickness{ Bottom = 10,Left = 10,Right = 10} : new Thickness { Bottom = 0,Left = 10,Right = 10 };
}
private void OnHotKey(object sender, KeyPressedEventArgs e)
@@ -92,6 +110,7 @@ namespace WinAlfred
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
ShowWinAlfred();
+ InitialTray();
}
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
diff --git a/WinAlfred/Properties/Resources.Designer.cs b/WinAlfred/Properties/Resources.Designer.cs
index 39a831b8c2..5b4270b0d5 100644
--- a/WinAlfred/Properties/Resources.Designer.cs
+++ b/WinAlfred/Properties/Resources.Designer.cs
@@ -59,5 +59,15 @@ namespace WinAlfred.Properties {
resourceCulture = value;
}
}
+
+ ///
+ /// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
+ ///
+ internal static System.Drawing.Icon app {
+ get {
+ object obj = ResourceManager.GetObject("app", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
}
}
diff --git a/WinAlfred/Properties/Resources.resx b/WinAlfred/Properties/Resources.resx
index af7dbebbac..3ae43d89b0 100644
--- a/WinAlfred/Properties/Resources.resx
+++ b/WinAlfred/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -114,4 +117,8 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/WinAlfred/Resources/app.ico b/WinAlfred/Resources/app.ico
new file mode 100644
index 0000000000..f457725eea
Binary files /dev/null and b/WinAlfred/Resources/app.ico differ
diff --git a/WinAlfred/Resources/ctrl.png b/WinAlfred/Resources/ctrl.png
new file mode 100644
index 0000000000..0e16903098
Binary files /dev/null and b/WinAlfred/Resources/ctrl.png differ
diff --git a/WinAlfred/ResultItem.xaml b/WinAlfred/ResultItem.xaml
index 6b8f6bedf3..c20bdecc65 100644
--- a/WinAlfred/ResultItem.xaml
+++ b/WinAlfred/ResultItem.xaml
@@ -4,22 +4,26 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
- d:DesignHeight="60.233" d:DesignWidth="436.064">
-
+ d:DesignWidth="400"
+ Height="50">
+
-
+
-
-
+
+
-
+
- Title
- sdfdsf
+ Title
+ sdfdsf
-
+
+
+
+
diff --git a/WinAlfred/ResultItem.xaml.cs b/WinAlfred/ResultItem.xaml.cs
index 541d79c7f6..ec251335d1 100644
--- a/WinAlfred/ResultItem.xaml.cs
+++ b/WinAlfred/ResultItem.xaml.cs
@@ -21,10 +21,16 @@ namespace WinAlfred
set
{
selected = value;
- Background = selected ? Brushes.Gray : Brushes.White;
+ BrushConverter bc = new BrushConverter();
+ Background = selected ? (Brush)(bc.ConvertFrom("#d1d1d1")) : (Brush)(bc.ConvertFrom("#ebebeb"));
}
}
+ public void SetIndex(int index)
+ {
+ tbIndex.Text = index.ToString();
+ }
+
public ResultItem(Result result)
{
diff --git a/WinAlfred/ResultPanel.xaml.cs b/WinAlfred/ResultPanel.xaml.cs
index 69c32fe2f2..fe07367545 100644
--- a/WinAlfred/ResultPanel.xaml.cs
+++ b/WinAlfred/ResultPanel.xaml.cs
@@ -22,11 +22,14 @@ namespace WinAlfred
public void AddResults(List results)
{
pnlContainer.Children.Clear();
- foreach (Result result in results)
+ for (int i = 0; i < results.Count; i++)
{
+ Result result = results[i];
ResultItem control = new ResultItem(result);
+ control.SetIndex(i+1);
pnlContainer.Children.Add(control);
}
+
pnlContainer.UpdateLayout();
double resultItemHeight = 0;
diff --git a/WinAlfred/WinAlfred.csproj b/WinAlfred/WinAlfred.csproj
index d026ff5f6b..541734e7ec 100644
--- a/WinAlfred/WinAlfred.csproj
+++ b/WinAlfred/WinAlfred.csproj
@@ -65,6 +65,7 @@
+
@@ -144,6 +145,18 @@
WinAlfred.Plugin
+
+
+
+
+
+
+
+
+
+
+
+