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 -