mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Keep movin'
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
#if !MONO
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shell;
|
||||
using WpfAnimatedGif;
|
||||
|
||||
namespace Squirrel.Update
|
||||
{
|
||||
public class AnimatedGifWindow : Window
|
||||
{
|
||||
public AnimatedGifWindow()
|
||||
{
|
||||
var img = new Image();
|
||||
var src = default(BitmapImage);
|
||||
|
||||
var source = Path.Combine(
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"background.gif");
|
||||
|
||||
if (File.Exists(source)) {
|
||||
src = new BitmapImage();
|
||||
src.BeginInit();
|
||||
src.StreamSource = File.OpenRead(source);
|
||||
src.EndInit();
|
||||
|
||||
ImageBehavior.SetAnimatedSource(img, src);
|
||||
this.Content = img;
|
||||
this.Width = src.Width;
|
||||
this.Height = src.Height;
|
||||
}
|
||||
|
||||
this.AllowsTransparency = true;
|
||||
this.WindowStyle = WindowStyle.None;
|
||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
this.ShowInTaskbar = true;
|
||||
this.Topmost = true;
|
||||
this.TaskbarItemInfo = new TaskbarItemInfo {
|
||||
ProgressState = TaskbarItemProgressState.Normal
|
||||
};
|
||||
this.Title = "Installing...";
|
||||
this.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public static void ShowWindow(TimeSpan initialDelay, CancellationToken token, ProgressSource progressSource)
|
||||
{
|
||||
var wnd = default(AnimatedGifWindow);
|
||||
|
||||
var thread = new Thread(() => {
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
try {
|
||||
Task.Delay(initialDelay, token).ContinueWith(t => { return true; }).Wait();
|
||||
} catch (Exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
wnd = new AnimatedGifWindow();
|
||||
wnd.Show();
|
||||
|
||||
Task.Delay(TimeSpan.FromSeconds(5.0), token).ContinueWith(t => {
|
||||
if (t.IsCanceled) return;
|
||||
wnd.Dispatcher.BeginInvoke(new Action(() => wnd.Topmost = false));
|
||||
});
|
||||
|
||||
token.Register(() => wnd.Dispatcher.BeginInvoke(new Action(wnd.Close)));
|
||||
EventHandler<int> progressSourceOnProgress = ((sender, p) =>
|
||||
wnd.Dispatcher.BeginInvoke(
|
||||
new Action(() => wnd.TaskbarItemInfo.ProgressValue = p/100.0)));
|
||||
progressSource.Progress += progressSourceOnProgress;
|
||||
try {
|
||||
(new Application()).Run(wnd);
|
||||
} finally {
|
||||
progressSource.Progress -= progressSourceOnProgress;
|
||||
}
|
||||
});
|
||||
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
this.DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,11 +12,11 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Squirrel.Update
|
||||
{
|
||||
public class AnimatedGifWindowWinForms : Form
|
||||
public class AnimatedGifWindow : Form
|
||||
{
|
||||
PictureBox pictureBox;
|
||||
|
||||
AnimatedGifWindowWinForms()
|
||||
AnimatedGifWindow()
|
||||
{
|
||||
var source = Path.Combine(
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
@@ -45,6 +45,7 @@ namespace Squirrel.Update
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
this.Width = 1;
|
||||
this.Height = 1;
|
||||
this.TopMost = true;
|
||||
}
|
||||
|
||||
public static void ShowWindow(TimeSpan initialDelay, CancellationToken token, ProgressSource progressSource)
|
||||
@@ -59,7 +60,7 @@ namespace Squirrel.Update
|
||||
return;
|
||||
}
|
||||
|
||||
var wnd = new AnimatedGifWindowWinForms();
|
||||
var wnd = new AnimatedGifWindow();
|
||||
wnd.Show();
|
||||
|
||||
token.Register(() => wnd.Invoke(new Action(() => wnd.Close())));
|
||||
@@ -80,6 +81,11 @@ namespace Squirrel.Update
|
||||
t.Interval = 400;
|
||||
t.Start();
|
||||
|
||||
Task.Delay(TimeSpan.FromSeconds(5.0), token).ContinueWith(task => {
|
||||
if (task.IsCanceled) return;
|
||||
wnd.Invoke(new Action(() => wnd.TopMost = false));
|
||||
});
|
||||
|
||||
Application.Run(wnd);
|
||||
});
|
||||
|
||||
|
||||
@@ -69,16 +69,11 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\WpfAnimatedGif.1.4.14\lib\net\WpfAnimatedGif.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AnimatedGifWindow.cs" />
|
||||
<Compile Include="AnimatedGifWindowWinForms.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -129,7 +124,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PostBuildEvent>cd "$(TargetDir)"
|
||||
"$(SolutionDir)packages\ILRepack.1.26.0\tools\ILRepack.exe" /internalize /out:$(TargetFileName).tmp $(TargetFileName) WpfAnimatedGif.dll SharpCompress.dll Microsoft.Web.XmlTransform.dll Splat.dll DeltaCompressionDotNet.dll DeltaCompressionDotNet.MsDelta.dll Squirrel.dll NuGet.Squirrel.dll Mono.Cecil.dll
|
||||
"$(SolutionDir)packages\ILRepack.1.26.0\tools\ILRepack.exe" /internalize /out:$(TargetFileName).tmp $(TargetFileName) SharpCompress.dll Microsoft.Web.XmlTransform.dll Splat.dll DeltaCompressionDotNet.dll DeltaCompressionDotNet.MsDelta.dll Squirrel.dll NuGet.Squirrel.dll Mono.Cecil.dll
|
||||
del "$(TargetFileName)"
|
||||
ren "$(TargetFileName).tmp" "$(TargetFileName)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user