mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-21 15:53:19 +00:00
UI staff
This commit is contained in:
parent
121db63778
commit
57b381311c
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: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"
|
||||
>
|
||||
<DockPanel>
|
||||
<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>
|
||||
</Window>
|
||||
|
||||
|
@ -18,6 +18,7 @@ namespace WinAlfred
|
||||
private KeyboardHook hook = new KeyboardHook();
|
||||
public List<PluginPair> plugins = new List<PluginPair>();
|
||||
private List<Result> results = new List<Result>();
|
||||
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)
|
||||
|
10
WinAlfred/Properties/Resources.Designer.cs
generated
10
WinAlfred/Properties/Resources.Designer.cs
generated
@ -59,5 +59,15 @@ namespace WinAlfred.Properties {
|
||||
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
|
||||
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.
|
||||
-->
|
||||
<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:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</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="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@ -85,9 +87,10 @@
|
||||
<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: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="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@ -114,4 +117,8 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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>
|
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:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="60.233" d:DesignWidth="436.064">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
|
||||
d:DesignWidth="400"
|
||||
Height="50">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="66"></ColumnDefinition>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="73.064"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="imgIco" Width="32" Height="32" ></Image>
|
||||
<Grid HorizontalAlignment="Stretch" Grid.Column="1" VerticalAlignment="Stretch">
|
||||
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" ></Image>
|
||||
<Grid HorizontalAlignment="Stretch" Margin="5 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="33"></RowDefinition>
|
||||
<RowDefinition Height="23"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="tbTitle">Title</TextBlock>
|
||||
<TextBlock Grid.Row="1" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||
<TextBlock x:Name="tbTitle" FontSize="16" Foreground="#37392c" FontWeight="Medium">Title</TextBlock>
|
||||
<TextBlock Grid.Row="1" Foreground="#8e94a4" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||
</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>
|
||||
</UserControl>
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -22,11 +22,14 @@ namespace WinAlfred
|
||||
public void AddResults(List<Result> 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;
|
||||
|
@ -65,6 +65,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -144,6 +145,18 @@
|
||||
<Name>WinAlfred.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</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="$(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.
|
||||
|
Loading…
Reference in New Issue
Block a user