Remove GifWindow

This commit is contained in:
Caelan Sayler
2021-08-12 15:41:30 +01:00
parent c824f2f380
commit e35ddb89c2
3 changed files with 47 additions and 169 deletions

View File

@@ -1,103 +0,0 @@
#if false
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 executionLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var source = Path.Combine(
executionLocation,
"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;
}
var setupIcon = Path.Combine(executionLocation, "setupIcon.ico");
if (File.Exists(setupIcon)) {
Icon = BitmapFrame.Create(new Uri(setupIcon, UriKind.Relative));
}
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

View File

@@ -68,74 +68,55 @@ namespace Squirrel.Update
int executeCommandLine(string[] args)
{
var animatedGifWindowToken = new CancellationTokenSource();
this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args));
#if !MONO
// Uncomment to test Gifs
/*
var ps = new ProgressSource();
int i = 0; var t = new Timer(_ => ps.Raise(i += 10), null, 0, 1000);
AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token, ps);
Thread.Sleep(10 * 60 * 1000);
*/
#endif
using (Disposable.Create(() => animatedGifWindowToken.Cancel())) {
this.Log().Info("Starting Squirrel Updater: " + String.Join(" ", args));
if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) {
// NB: We're marked as Squirrel-aware, but we don't want to do
// anything in response to these events
return 0;
}
if (opt.updateAction == UpdateAction.Unset) {
ShowHelp();
return -1;
}
switch (opt.updateAction) {
#if !MONO
case UpdateAction.Install:
var progressSource = new ProgressSource();
//if (!opt.silentInstall) {
// AnimatedGifWindow.ShowWindow(TimeSpan.FromSeconds(4), animatedGifWindowToken.Token, progressSource);
//}
Install(opt.silentInstall, progressSource, Path.GetFullPath(opt.target)).Wait();
animatedGifWindowToken.Cancel();
break;
case UpdateAction.Uninstall:
Uninstall().Wait();
break;
case UpdateAction.Download:
Console.WriteLine(Download(opt.target).Result);
break;
case UpdateAction.Update:
Update(opt.target).Wait();
break;
case UpdateAction.CheckForUpdate:
Console.WriteLine(CheckForUpdate(opt.target).Result);
break;
case UpdateAction.UpdateSelf:
UpdateSelf().Wait();
break;
case UpdateAction.Shortcut:
Shortcut(opt.target, opt.shortcutArgs, opt.processStartArgs, opt.setupIcon, opt.onlyUpdateShortcuts);
break;
case UpdateAction.Deshortcut:
Deshortcut(opt.target, opt.shortcutArgs);
break;
case UpdateAction.ProcessStart:
ProcessStart(opt.processStart, opt.processStartArgs, opt.shouldWait);
break;
#endif
case UpdateAction.Releasify:
Releasify(opt.target, opt.releaseDir, opt.packagesDir, opt.bootstrapperExe, opt.backgroundGif, opt.signingParameters, opt.baseUrl, opt.setupIcon, !opt.noMsi, opt.packageAs64Bit, opt.frameworkVersion, !opt.noDelta);
break;
}
if (args.Any(x => x.StartsWith("/squirrel", StringComparison.OrdinalIgnoreCase))) {
// NB: We're marked as Squirrel-aware, but we don't want to do
// anything in response to these events
return 0;
}
if (opt.updateAction == UpdateAction.Unset) {
ShowHelp();
return -1;
}
switch (opt.updateAction) {
#if !MONO
case UpdateAction.Install:
var progressSource = new ProgressSource();
Install(opt.silentInstall, progressSource, Path.GetFullPath(opt.target)).Wait();
break;
case UpdateAction.Uninstall:
Uninstall().Wait();
break;
case UpdateAction.Download:
Console.WriteLine(Download(opt.target).Result);
break;
case UpdateAction.Update:
Update(opt.target).Wait();
break;
case UpdateAction.CheckForUpdate:
Console.WriteLine(CheckForUpdate(opt.target).Result);
break;
case UpdateAction.UpdateSelf:
UpdateSelf().Wait();
break;
case UpdateAction.Shortcut:
Shortcut(opt.target, opt.shortcutArgs, opt.processStartArgs, opt.setupIcon, opt.onlyUpdateShortcuts);
break;
case UpdateAction.Deshortcut:
Deshortcut(opt.target, opt.shortcutArgs);
break;
case UpdateAction.ProcessStart:
ProcessStart(opt.processStart, opt.processStartArgs, opt.shouldWait);
break;
#endif
case UpdateAction.Releasify:
Releasify(opt.target, opt.releaseDir, opt.packagesDir, opt.bootstrapperExe, opt.backgroundGif, opt.signingParameters, opt.baseUrl, opt.setupIcon, !opt.noMsi, opt.packageAs64Bit, opt.frameworkVersion, !opt.noDelta);
break;
}
this.Log().Info("Finished Squirrel Updater");
return 0;
}