mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
UI staff
This commit is contained in:
BIN
WinAlfred/Images/ctrl.png
Normal file
BIN
WinAlfred/Images/ctrl.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
WinAlfred/Images/ico.png
Normal file
BIN
WinAlfred/Images/ico.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -3,17 +3,19 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:winAlfred="clr-namespace:WinAlfred"
|
xmlns:winAlfred="clr-namespace:WinAlfred"
|
||||||
Title="WinAlfred" Height="80" Width="525"
|
Title="WinAlfred" Height="80" Width="525"
|
||||||
Background="Cornsilk"
|
Background="#ebebeb"
|
||||||
|
Topmost="True"
|
||||||
Loaded="MainWindow_OnLoaded"
|
Loaded="MainWindow_OnLoaded"
|
||||||
SizeToContent="Height"
|
SizeToContent="Height"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
|
Icon="Images\ico.png"
|
||||||
>
|
>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<TextBox DockPanel.Dock="Top" Margin="10" VerticalContentAlignment="Center" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" Height="26.965" />
|
<TextBox DockPanel.Dock="Top" Margin="10" VerticalContentAlignment="Center" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" Height="26.965" />
|
||||||
<winAlfred:ResultPanel x:Name="resultCtrl" />
|
<winAlfred:ResultPanel x:Name="resultCtrl" Margin="10 0 10 0" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace WinAlfred
|
|||||||
private KeyboardHook hook = new KeyboardHook();
|
private KeyboardHook hook = new KeyboardHook();
|
||||||
public List<PluginPair> plugins = new List<PluginPair>();
|
public List<PluginPair> plugins = new List<PluginPair>();
|
||||||
private List<Result> results = new List<Result>();
|
private List<Result> results = new List<Result>();
|
||||||
|
private NotifyIcon notifyIcon = null;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@@ -27,9 +28,26 @@ namespace WinAlfred
|
|||||||
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
|
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()
|
private void resultCtrl_resultItemChangedEvent()
|
||||||
{
|
{
|
||||||
Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
|
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)
|
private void OnHotKey(object sender, KeyPressedEventArgs e)
|
||||||
@@ -92,6 +110,7 @@ namespace WinAlfred
|
|||||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||||
|
|
||||||
ShowWinAlfred();
|
ShowWinAlfred();
|
||||||
|
InitialTray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
|||||||
10
WinAlfred/Properties/Resources.Designer.cs
generated
10
WinAlfred/Properties/Resources.Designer.cs
generated
@@ -59,5 +59,15 @@ namespace WinAlfred.Properties {
|
|||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon app {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("app", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:choice maxOccurs="unbounded">
|
<xsd:choice maxOccurs="unbounded">
|
||||||
@@ -68,9 +69,10 @@
|
|||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="assembly">
|
<xsd:element name="assembly">
|
||||||
@@ -85,9 +87,10 @@
|
|||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="resheader">
|
<xsd:element name="resheader">
|
||||||
@@ -114,4 +117,8 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="app" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\app.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
BIN
WinAlfred/Resources/app.ico
Normal file
BIN
WinAlfred/Resources/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
WinAlfred/Resources/ctrl.png
Normal file
BIN
WinAlfred/Resources/ctrl.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -4,22 +4,26 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="60.233" d:DesignWidth="436.064">
|
d:DesignWidth="400"
|
||||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
|
Height="50">
|
||||||
|
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="66"></ColumnDefinition>
|
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition Width="73.064"></ColumnDefinition>
|
<ColumnDefinition Width="73.064"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Image x:Name="imgIco" Width="32" Height="32" ></Image>
|
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" ></Image>
|
||||||
<Grid HorizontalAlignment="Stretch" Grid.Column="1" VerticalAlignment="Stretch">
|
<Grid HorizontalAlignment="Stretch" Margin="5 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="33"></RowDefinition>
|
<RowDefinition Height="23"></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock x:Name="tbTitle">Title</TextBlock>
|
<TextBlock x:Name="tbTitle" FontSize="16" Foreground="#37392c" FontWeight="Medium">Title</TextBlock>
|
||||||
<TextBlock Grid.Row="1" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
<TextBlock Grid.Row="1" Foreground="#8e94a4" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button Grid.Column="2" />
|
<DockPanel Grid.Column="2" >
|
||||||
|
<Image Source="Images\ctrl.png" VerticalAlignment="Center"/>
|
||||||
|
<TextBlock x:Name="tbIndex" FontSize="16" Foreground="#5c1f87" Margin="0 5 0 0" Text="1" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||||
|
</DockPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -21,10 +21,16 @@ namespace WinAlfred
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
selected = value;
|
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)
|
public ResultItem(Result result)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ namespace WinAlfred
|
|||||||
public void AddResults(List<Result> results)
|
public void AddResults(List<Result> results)
|
||||||
{
|
{
|
||||||
pnlContainer.Children.Clear();
|
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);
|
ResultItem control = new ResultItem(result);
|
||||||
|
control.SetIndex(i+1);
|
||||||
pnlContainer.Children.Add(control);
|
pnlContainer.Children.Add(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
pnlContainer.UpdateLayout();
|
pnlContainer.UpdateLayout();
|
||||||
|
|
||||||
double resultItemHeight = 0;
|
double resultItemHeight = 0;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -144,6 +145,18 @@
|
|||||||
<Name>WinAlfred.Plugin</Name>
|
<Name>WinAlfred.Plugin</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Images\ico.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\app.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\ctrl.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Images\ctrl.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
Reference in New Issue
Block a user