Fixed Image Errors + Handing Bad ShellRun

This commit is contained in:
Aaron Campf
2014-05-08 15:58:38 -07:00
parent 0b70c5225d
commit 7c2e2a01c2
7 changed files with 144 additions and 150 deletions

View File

@@ -15,70 +15,65 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Timer = System.Threading.Timer;
namespace Wox
{
public partial class Msg : Window
{
Storyboard fadeOutStoryboard = new Storyboard();
private bool closing = false;
namespace Wox {
public partial class Msg : Window {
Storyboard fadeOutStoryboard = new Storyboard();
private bool closing = false;
public Msg()
{
InitializeComponent();
public Msg() {
InitializeComponent();
Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
Top = Screen.PrimaryScreen.Bounds.Bottom;
showAnimation.From = Screen.PrimaryScreen.Bounds.Bottom;
showAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom - Height;
Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
Top = Screen.PrimaryScreen.Bounds.Bottom;
showAnimation.From = Screen.PrimaryScreen.Bounds.Bottom;
showAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom - Height;
// Create the fade out storyboard
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
DoubleAnimation fadeOutAnimation = new DoubleAnimation(Screen.PrimaryScreen.WorkingArea.Bottom - Height, Screen.PrimaryScreen.Bounds.Bottom, new Duration(TimeSpan.FromSeconds(0.3)))
{
AccelerationRatio = 0.2
};
Storyboard.SetTarget(fadeOutAnimation, this);
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
fadeOutStoryboard.Children.Add(fadeOutAnimation);
// Create the fade out storyboard
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
DoubleAnimation fadeOutAnimation = new DoubleAnimation(Screen.PrimaryScreen.WorkingArea.Bottom - Height, Screen.PrimaryScreen.Bounds.Bottom, new Duration(TimeSpan.FromSeconds(0.3))) {
AccelerationRatio = 0.2
};
Storyboard.SetTarget(fadeOutAnimation, this);
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
fadeOutStoryboard.Children.Add(fadeOutAnimation);
imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
imgClose.MouseUp += imgClose_MouseUp;
}
void imgClose_MouseUp(object sender, MouseButtonEventArgs e)
{
if (!closing)
{
closing = true;
fadeOutStoryboard.Begin();
}
}
imgClose.Source = new BitmapImage(new Uri("Images\\close.pn", UriKind.Relative));
//imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
imgClose.MouseUp += imgClose_MouseUp;
}
private void fadeOutStoryboard_Completed(object sender, EventArgs e)
{
Close();
}
void imgClose_MouseUp(object sender, MouseButtonEventArgs e) {
if (!closing) {
closing = true;
fadeOutStoryboard.Begin();
}
}
public void Show(string title, string subTitle, string icopath)
{
tbTitle.Text = title;
tbSubTitle.Text = subTitle;
if (!File.Exists(icopath))
{
icopath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\app.png");
}
imgIco.Source = new BitmapImage(new Uri(icopath));
Show();
private void fadeOutStoryboard_Completed(object sender, EventArgs e) {
Close();
}
Dispatcher.DelayInvoke("ShowMsg",
o =>
{
if (!closing)
{
closing = true;
Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin));
}
}, TimeSpan.FromSeconds(3));
}
}
public void Show(string title, string subTitle, string icopath) {
tbTitle.Text = title;
tbSubTitle.Text = subTitle;
if (!File.Exists(icopath)) {
//icopath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\app.png");
imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative));
}
else {
imgIco.Source = new BitmapImage(new Uri(icopath));
}
Show();
Dispatcher.DelayInvoke("ShowMsg",
o => {
if (!closing) {
closing = true;
Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin));
}
}, TimeSpan.FromSeconds(3));
}
}
}