mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Search result thumbnail for PowerLauncher (#2124)
* Replace WPF Imaging library with UWP * Removed UWP and WPF namespace conflicting files from Wox * Removed Image hashing as it wasn't used anywhere * Updated formatting
This commit is contained in:
committed by
GitHub
parent
37a551ecd3
commit
367cb41121
@@ -1,41 +0,0 @@
|
||||
<Window x:Class="PowerLauncher.Msg"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Background="#ebebeb"
|
||||
Topmost="True"
|
||||
SizeToContent="Height"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
ShowInTaskbar="False"
|
||||
Title="Msg" Height="60" Width="420">
|
||||
<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="Window.Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation x:Name="showAnimation" Duration="0:0:0.3" Storyboard.TargetProperty="Top"
|
||||
AccelerationRatio="0.2" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
|
||||
</Window.Triggers>
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="2.852" />
|
||||
<ColumnDefinition Width="13.148"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" Margin="0,9" />
|
||||
<Grid HorizontalAlignment="Stretch" Margin="5 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="tbTitle" FontSize="16" Foreground="#37392c" FontWeight="Medium">Title</TextBlock>
|
||||
<TextBlock Grid.Row="1" Foreground="#8e94a4" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||
</Grid>
|
||||
<Image x:Name="imgClose" Grid.Column="2" Cursor="Hand" Width="16" VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right" Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,87 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Image;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
public partial class Msg : Window
|
||||
{
|
||||
Storyboard fadeOutStoryboard = new Storyboard();
|
||||
private bool closing;
|
||||
|
||||
public Msg()
|
||||
{
|
||||
InitializeComponent();
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dipWorkingArea = WindowsInteropHelper.TransformPixelsToDIP(this,
|
||||
screen.WorkingArea.Width,
|
||||
screen.WorkingArea.Height);
|
||||
Left = dipWorkingArea.X - Width;
|
||||
Top = dipWorkingArea.Y;
|
||||
showAnimation.From = dipWorkingArea.Y;
|
||||
showAnimation.To = dipWorkingArea.Y - Height;
|
||||
|
||||
// Create the fade out storyboard
|
||||
fadeOutStoryboard.Completed += fadeOutStoryboard_Completed;
|
||||
DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(5)))
|
||||
{
|
||||
AccelerationRatio = 0.2
|
||||
};
|
||||
Storyboard.SetTarget(fadeOutAnimation, this);
|
||||
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
||||
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
||||
|
||||
imgClose.Source = ImageLoader.Load(Path.Combine(Wox.Infrastructure.Constant.ProgramDirectory, "Images\\close.png"));
|
||||
imgClose.MouseUp += imgClose_MouseUp;
|
||||
}
|
||||
|
||||
void imgClose_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!closing)
|
||||
{
|
||||
closing = true;
|
||||
fadeOutStoryboard.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
private void fadeOutStoryboard_Completed(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public void Show(string title, string subTitle, string iconPath)
|
||||
{
|
||||
tbTitle.Text = title;
|
||||
tbSubTitle.Text = subTitle;
|
||||
if (string.IsNullOrEmpty(subTitle))
|
||||
{
|
||||
tbSubTitle.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
if (!File.Exists(iconPath))
|
||||
{
|
||||
imgIco.Source = ImageLoader.Load(Path.Combine(Wox.Infrastructure.Constant.ProgramDirectory, "Images\\app.png"));
|
||||
}
|
||||
else {
|
||||
imgIco.Source = ImageLoader.Load(iconPath);
|
||||
}
|
||||
|
||||
Show();
|
||||
|
||||
Dispatcher.InvokeAsync(async () =>
|
||||
{
|
||||
if (!closing)
|
||||
{
|
||||
closing = true;
|
||||
await Dispatcher.InvokeAsync(fadeOutStoryboard.Begin);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user