mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Merge pull request #1233 from Squirrel/go-back-to-wpf-for-splash
Go back to WPF instead of WinForms
This commit is contained in:
@@ -1,136 +0,0 @@
|
||||
using Microsoft.WindowsAPICodePack.Taskbar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Squirrel.Update
|
||||
{
|
||||
public class AnimatedGifWindow : Form
|
||||
{
|
||||
const int WM_NCLBUTTONDOWN = 0xA1;
|
||||
const int HT_CAPTION = 0x2;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ReleaseCapture();
|
||||
|
||||
PictureBox pictureBox;
|
||||
|
||||
AnimatedGifWindow()
|
||||
{
|
||||
var source = Path.Combine(
|
||||
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
"background.gif");
|
||||
|
||||
pictureBox = new PictureBox();
|
||||
this.Controls.Add(pictureBox);
|
||||
|
||||
if (File.Exists(source)) {
|
||||
pictureBox.ImageLocation = source;
|
||||
}
|
||||
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
Action size = () => {
|
||||
pictureBox.Width = this.Width; pictureBox.Height = this.Height;
|
||||
pictureBox.Left = 0; pictureBox.Top = 0;
|
||||
this.CenterToScreen();
|
||||
};
|
||||
|
||||
pictureBox.LoadCompleted += (o, e) => {
|
||||
if (pictureBox.Image == null) return;
|
||||
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
|
||||
this.SizeChanged += (_o, _e) => size();
|
||||
|
||||
this.Width = pictureBox.Image.Width / 2;
|
||||
this.Height = pictureBox.Image.Height / 2;
|
||||
this.CenterToScreen();
|
||||
};
|
||||
|
||||
// Enable left-mouse button to drag window
|
||||
pictureBox.MouseDown += (o, e) => {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
ReleaseCapture();
|
||||
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
|
||||
}
|
||||
};
|
||||
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
this.Width = 1;
|
||||
this.Height = 1;
|
||||
this.TopMost = true;
|
||||
}
|
||||
|
||||
public static void ShowWindow(TimeSpan initialDelay, CancellationToken token, ProgressSource progressSource)
|
||||
{
|
||||
var thread = new Thread(() => {
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
try {
|
||||
Task.Delay(initialDelay, token).ContinueWith(_ => { return true; }).Wait();
|
||||
} catch (Exception) {
|
||||
// NB: Cancellation will end up here, so we'll bail out
|
||||
return;
|
||||
}
|
||||
|
||||
var wnd = new AnimatedGifWindow();
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
try {
|
||||
wnd.Show();
|
||||
} catch (Exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
token.Register(() => wnd.Invoke(new Action(() => wnd.Close())));
|
||||
|
||||
var t = new System.Windows.Forms.Timer();
|
||||
var taskbar = TaskbarManager.Instance;
|
||||
t.Tick += (o, e) => {
|
||||
wnd.WindowState = FormWindowState.Normal;
|
||||
taskbar.SetProgressState(TaskbarProgressBarState.Normal, wnd.Handle);
|
||||
|
||||
progressSource.Progress += (_o, val) => {
|
||||
if (wnd.IsDisposed) return;
|
||||
wnd.Invoke(new Action(() => taskbar.SetProgressValue(val, 100, wnd.Handle)));
|
||||
};
|
||||
|
||||
t.Stop();
|
||||
};
|
||||
|
||||
t.Interval = 400;
|
||||
t.Start();
|
||||
|
||||
Task.Delay(TimeSpan.FromSeconds(5.0), token).ContinueWith(task => {
|
||||
if (task.IsCanceled) return;
|
||||
if (wnd.IsDisposed) return;
|
||||
wnd.Invoke(new Action(() => wnd.TopMost = false));
|
||||
});
|
||||
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
#if !DEBUG
|
||||
try {
|
||||
#endif
|
||||
Application.Run(wnd);
|
||||
#if !DEBUG
|
||||
} catch (Exception) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
});
|
||||
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ namespace Squirrel.Update
|
||||
{
|
||||
var animatedGifWindowToken = new CancellationTokenSource();
|
||||
|
||||
#if !MONO
|
||||
// Uncomment to test Gifs
|
||||
/*
|
||||
var ps = new ProgressSource();
|
||||
@@ -67,6 +68,7 @@ namespace Squirrel.Update
|
||||
AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token, ps);
|
||||
Thread.Sleep(10 * 60 * 1000);
|
||||
*/
|
||||
#endif
|
||||
|
||||
using (Disposable.Create(() => animatedGifWindowToken.Cancel())) {
|
||||
|
||||
@@ -886,4 +888,3 @@ namespace Squirrel.Update
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
//Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
[GuidAttribute("77F10CF0-3DB5-4966-B520-B7C54FD35ED6")]
|
||||
[ClassInterfaceAttribute(ClassInterfaceType.None)]
|
||||
[ComImportAttribute()]
|
||||
internal class CDestinationList { }
|
||||
|
||||
[ComImportAttribute()]
|
||||
[GuidAttribute("92CA9DCD-5622-4BBA-A805-5E9F541BD8C9")]
|
||||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IObjectArray
|
||||
{
|
||||
void GetCount(out uint cObjects);
|
||||
void GetAt(
|
||||
uint iIndex,
|
||||
ref Guid riid,
|
||||
[Out(), MarshalAs(UnmanagedType.Interface)] out object ppvObject);
|
||||
}
|
||||
|
||||
[ComImportAttribute()]
|
||||
[GuidAttribute("5632B1A4-E38A-400A-928A-D4CD63230295")]
|
||||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IObjectCollection
|
||||
{
|
||||
// IObjectArray
|
||||
[PreserveSig]
|
||||
void GetCount(out uint cObjects);
|
||||
[PreserveSig]
|
||||
void GetAt(
|
||||
uint iIndex,
|
||||
ref Guid riid,
|
||||
[Out(), MarshalAs(UnmanagedType.Interface)] out object ppvObject);
|
||||
|
||||
// IObjectCollection
|
||||
void AddObject(
|
||||
[MarshalAs(UnmanagedType.Interface)] object pvObject);
|
||||
void AddFromArray(
|
||||
[MarshalAs(UnmanagedType.Interface)] IObjectArray poaSource);
|
||||
void RemoveObject(uint uiIndex);
|
||||
void Clear();
|
||||
}
|
||||
|
||||
[GuidAttribute("2D3468C1-36A7-43B6-AC24-D3F02FD9607A")]
|
||||
[ClassInterfaceAttribute(ClassInterfaceType.None)]
|
||||
[ComImportAttribute()]
|
||||
internal class CEnumerableObjectCollection { }
|
||||
|
||||
[ComImportAttribute()]
|
||||
[GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")]
|
||||
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface ITaskbarList4
|
||||
{
|
||||
// ITaskbarList
|
||||
[PreserveSig]
|
||||
void HrInit();
|
||||
[PreserveSig]
|
||||
void AddTab(IntPtr hwnd);
|
||||
[PreserveSig]
|
||||
void DeleteTab(IntPtr hwnd);
|
||||
[PreserveSig]
|
||||
void ActivateTab(IntPtr hwnd);
|
||||
[PreserveSig]
|
||||
void SetActiveAlt(IntPtr hwnd);
|
||||
|
||||
// ITaskbarList2
|
||||
[PreserveSig]
|
||||
void MarkFullscreenWindow(
|
||||
IntPtr hwnd,
|
||||
[MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
|
||||
|
||||
// ITaskbarList3
|
||||
[PreserveSig]
|
||||
void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
|
||||
[PreserveSig]
|
||||
void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);
|
||||
[PreserveSig]
|
||||
void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
|
||||
[PreserveSig]
|
||||
void UnregisterTab(IntPtr hwndTab);
|
||||
[PreserveSig]
|
||||
void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
|
||||
[PreserveSig]
|
||||
void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);
|
||||
[PreserveSig]
|
||||
void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
|
||||
[PreserveSig]
|
||||
void SetOverlayIcon(
|
||||
IntPtr hwnd,
|
||||
IntPtr hIcon,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
|
||||
[PreserveSig]
|
||||
void SetThumbnailTooltip(
|
||||
IntPtr hwnd,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszTip);
|
||||
[PreserveSig]
|
||||
void SetThumbnailClip(
|
||||
IntPtr hwnd,
|
||||
IntPtr prcClip);
|
||||
|
||||
// ITaskbarList4
|
||||
void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);
|
||||
}
|
||||
|
||||
[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
|
||||
[ClassInterfaceAttribute(ClassInterfaceType.None)]
|
||||
[ComImportAttribute()]
|
||||
internal class CTaskbarList { }
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
//Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
|
||||
internal enum TaskbarProxyWindowType
|
||||
{
|
||||
TabbedThumbnail,
|
||||
ThumbnailToolbar,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Known category to display
|
||||
/// </summary>
|
||||
public enum JumpListKnownCategoryType
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't display either known category. You must have at least one
|
||||
/// user task or custom category link in order to not see the
|
||||
/// default 'Recent' known category
|
||||
/// </summary>
|
||||
Neither = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Display the 'Recent' known category
|
||||
/// </summary>
|
||||
Recent,
|
||||
|
||||
/// <summary>
|
||||
/// Display the 'Frequent' known category
|
||||
/// </summary>
|
||||
Frequent,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the thumbnail progress bar state.
|
||||
/// </summary>
|
||||
public enum TaskbarProgressBarState
|
||||
{
|
||||
/// <summary>
|
||||
/// No progress is displayed.
|
||||
/// </summary>
|
||||
NoProgress = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The progress is indeterminate (marquee).
|
||||
/// </summary>
|
||||
Indeterminate = 0x1,
|
||||
|
||||
/// <summary>
|
||||
/// Normal progress is displayed.
|
||||
/// </summary>
|
||||
Normal = 0x2,
|
||||
|
||||
/// <summary>
|
||||
/// An error occurred (red).
|
||||
/// </summary>
|
||||
Error = 0x4,
|
||||
|
||||
/// <summary>
|
||||
/// The operation is paused (yellow).
|
||||
/// </summary>
|
||||
Paused = 0x8
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for jump list items
|
||||
/// </summary>
|
||||
public interface IJumpListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets this item's path
|
||||
/// </summary>
|
||||
string Path { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides internal access to the functions provided by the ITaskbarList4 interface,
|
||||
/// without being forced to refer to it through another singleton.
|
||||
/// </summary>
|
||||
internal static class TaskbarList
|
||||
{
|
||||
private static object _syncLock = new object();
|
||||
|
||||
private static ITaskbarList4 _taskbarList;
|
||||
internal static ITaskbarList4 Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_taskbarList == null)
|
||||
{
|
||||
lock (_syncLock)
|
||||
{
|
||||
if (_taskbarList == null)
|
||||
{
|
||||
_taskbarList = (ITaskbarList4)new CTaskbarList();
|
||||
_taskbarList.HrInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _taskbarList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
//Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an instance of the Windows taskbar
|
||||
/// </summary>
|
||||
public class TaskbarManager
|
||||
{
|
||||
// Hide the default constructor
|
||||
private TaskbarManager()
|
||||
{
|
||||
}
|
||||
|
||||
// Best practice recommends defining a private object to lock on
|
||||
private static object _syncLock = new object();
|
||||
|
||||
private static TaskbarManager _instance;
|
||||
/// <summary>
|
||||
/// Represents an instance of the Windows Taskbar
|
||||
/// </summary>
|
||||
public static TaskbarManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (_syncLock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new TaskbarManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies an overlay to a taskbar button of the main application window to indicate application status or a notification to the user.
|
||||
/// </summary>
|
||||
/// <param name="icon">The overlay icon</param>
|
||||
/// <param name="accessibilityText">String that provides an alt text version of the information conveyed by the overlay, for accessibility purposes</param>
|
||||
public void SetOverlayIcon(System.Drawing.Icon icon, string accessibilityText)
|
||||
{
|
||||
TaskbarList.Instance.SetOverlayIcon(
|
||||
OwnerHandle,
|
||||
icon != null ? icon.Handle : IntPtr.Zero,
|
||||
accessibilityText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies an overlay to a taskbar button of the given window handle to indicate application status or a notification to the user.
|
||||
/// </summary>
|
||||
/// <param name="windowHandle">The handle of the window whose associated taskbar button receives the overlay. This handle must belong to a calling process associated with the button's application and must be a valid HWND or the call is ignored.</param>
|
||||
/// <param name="icon">The overlay icon</param>
|
||||
/// <param name="accessibilityText">String that provides an alt text version of the information conveyed by the overlay, for accessibility purposes</param>
|
||||
public void SetOverlayIcon(IntPtr windowHandle, System.Drawing.Icon icon, string accessibilityText)
|
||||
{
|
||||
TaskbarList.Instance.SetOverlayIcon(
|
||||
windowHandle,
|
||||
icon != null ? icon.Handle : IntPtr.Zero,
|
||||
accessibilityText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies an overlay to a taskbar button of the given WPF window to indicate application status or a notification to the user.
|
||||
/// </summary>
|
||||
/// <param name="window">The window whose associated taskbar button receives the overlay. This window belong to a calling process associated with the button's application and must be already loaded.</param>
|
||||
/// <param name="icon">The overlay icon</param>
|
||||
/// <param name="accessibilityText">String that provides an alt text version of the information conveyed by the overlay, for accessibility purposes</param>
|
||||
public void SetOverlayIcon(System.Windows.Window window, System.Drawing.Icon icon, string accessibilityText)
|
||||
{
|
||||
TaskbarList.Instance.SetOverlayIcon(
|
||||
(new WindowInteropHelper(window)).Handle,
|
||||
icon != null ? icon.Handle : IntPtr.Zero,
|
||||
accessibilityText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays or updates a progress bar hosted in a taskbar button of the main application window
|
||||
/// to show the specific percentage completed of the full operation.
|
||||
/// </summary>
|
||||
/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
|
||||
/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
|
||||
public void SetProgressValue(int currentValue, int maximumValue)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressValue(
|
||||
OwnerHandle,
|
||||
Convert.ToUInt32(currentValue),
|
||||
Convert.ToUInt32(maximumValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays or updates a progress bar hosted in a taskbar button of the given window handle
|
||||
/// to show the specific percentage completed of the full operation.
|
||||
/// </summary>
|
||||
/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
|
||||
/// This window belong to a calling process associated with the button's application and must be already loaded.</param>
|
||||
/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
|
||||
/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
|
||||
public void SetProgressValue(int currentValue, int maximumValue, IntPtr windowHandle)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressValue(
|
||||
windowHandle,
|
||||
Convert.ToUInt32(currentValue),
|
||||
Convert.ToUInt32(maximumValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays or updates a progress bar hosted in a taskbar button of the given WPF window
|
||||
/// to show the specific percentage completed of the full operation.
|
||||
/// </summary>
|
||||
/// <param name="window">The window whose associated taskbar button is being used as a progress indicator.
|
||||
/// This window belong to a calling process associated with the button's application and must be already loaded.</param>
|
||||
/// <param name="currentValue">An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.</param>
|
||||
/// <param name="maximumValue">An application-defined value that specifies the value currentValue will have when the operation is complete.</param>
|
||||
public void SetProgressValue(int currentValue, int maximumValue, System.Windows.Window window)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressValue(
|
||||
(new WindowInteropHelper(window)).Handle,
|
||||
Convert.ToUInt32(currentValue),
|
||||
Convert.ToUInt32(maximumValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type and state of the progress indicator displayed on a taskbar button of the main application window.
|
||||
/// </summary>
|
||||
/// <param name="state">Progress state of the progress button</param>
|
||||
public void SetProgressState(TaskbarProgressBarState state)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressState(OwnerHandle, (TaskbarProgressBarStatus)state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type and state of the progress indicator displayed on a taskbar button
|
||||
/// of the given window handle
|
||||
/// </summary>
|
||||
/// <param name="windowHandle">The handle of the window whose associated taskbar button is being used as a progress indicator.
|
||||
/// This window belong to a calling process associated with the button's application and must be already loaded.</param>
|
||||
/// <param name="state">Progress state of the progress button</param>
|
||||
public void SetProgressState(TaskbarProgressBarState state, IntPtr windowHandle)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressState(windowHandle, (TaskbarProgressBarStatus)state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type and state of the progress indicator displayed on a taskbar button
|
||||
/// of the given WPF window
|
||||
/// </summary>
|
||||
/// <param name="window">The window whose associated taskbar button is being used as a progress indicator.
|
||||
/// This window belong to a calling process associated with the button's application and must be already loaded.</param>
|
||||
/// <param name="state">Progress state of the progress button</param>
|
||||
public void SetProgressState(TaskbarProgressBarState state, System.Windows.Window window)
|
||||
{
|
||||
TaskbarList.Instance.SetProgressState(
|
||||
(new WindowInteropHelper(window)).Handle,
|
||||
(TaskbarProgressBarStatus)state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the application user model id. Use this to explicitly
|
||||
/// set the application id when generating custom jump lists
|
||||
/// </summary>
|
||||
public string ApplicationId
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCurrentProcessAppId();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
|
||||
SetCurrentProcessAppId(value);
|
||||
ApplicationIdSetProcessWide = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr _ownerHandle;
|
||||
/// <summary>
|
||||
/// Sets the handle of the window whose taskbar button will be used
|
||||
/// to display progress.
|
||||
/// </summary>
|
||||
internal IntPtr OwnerHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ownerHandle == IntPtr.Zero)
|
||||
{
|
||||
Process currentProcess = Process.GetCurrentProcess();
|
||||
|
||||
if (currentProcess == null || currentProcess.MainWindowHandle == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Valid window handle is required");
|
||||
}
|
||||
|
||||
_ownerHandle = currentProcess.MainWindowHandle;
|
||||
}
|
||||
|
||||
return _ownerHandle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current process' explicit application user model id.
|
||||
/// </summary>
|
||||
/// <param name="appId">The application id.</param>
|
||||
private void SetCurrentProcessAppId(string appId)
|
||||
{
|
||||
TaskbarNativeMethods.SetCurrentProcessExplicitAppUserModelID(appId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current process' explicit application user model id.
|
||||
/// </summary>
|
||||
/// <returns>The app id or null if no app id has been defined.</returns>
|
||||
private string GetCurrentProcessAppId()
|
||||
{
|
||||
string appId = string.Empty;
|
||||
TaskbarNativeMethods.GetCurrentProcessExplicitAppUserModelID(out appId);
|
||||
return appId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the user has set the application id for the whole process (all windows)
|
||||
/// </summary>
|
||||
internal bool ApplicationIdSetProcessWide { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this feature is supported on the current platform.
|
||||
/// </summary>
|
||||
public static bool IsPlatformSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
// We need Windows 7 onwards ...
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
//Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.WindowsAPICodePack.Taskbar
|
||||
{
|
||||
#region Enums
|
||||
internal enum KnownDestinationCategory
|
||||
{
|
||||
Frequent = 1,
|
||||
Recent
|
||||
}
|
||||
|
||||
internal enum ShellAddToRecentDocs
|
||||
{
|
||||
Pidl = 0x1,
|
||||
PathA = 0x2,
|
||||
PathW = 0x3,
|
||||
AppIdInfo = 0x4, // indicates the data type is a pointer to a SHARDAPPIDINFO structure
|
||||
AppIdInfoIdList = 0x5, // indicates the data type is a pointer to a SHARDAPPIDINFOIDLIST structure
|
||||
Link = 0x6, // indicates the data type is a pointer to an IShellLink instance
|
||||
AppIdInfoLink = 0x7, // indicates the data type is a pointer to a SHARDAPPIDINFOLINK structure
|
||||
}
|
||||
|
||||
internal enum TaskbarProgressBarStatus
|
||||
{
|
||||
NoProgress = 0,
|
||||
Indeterminate = 0x1,
|
||||
Normal = 0x2,
|
||||
Error = 0x4,
|
||||
Paused = 0x8
|
||||
}
|
||||
|
||||
internal enum TaskbarActiveTabSetting
|
||||
{
|
||||
UseMdiThumbnail = 0x1,
|
||||
UseMdiLivePreview = 0x2
|
||||
}
|
||||
|
||||
internal enum ThumbButtonMask
|
||||
{
|
||||
Bitmap = 0x1,
|
||||
Icon = 0x2,
|
||||
Tooltip = 0x4,
|
||||
THB_FLAGS = 0x8
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum ThumbButtonOptions
|
||||
{
|
||||
Enabled = 0x00000000,
|
||||
Disabled = 0x00000001,
|
||||
DismissOnClick = 0x00000002,
|
||||
NoBackground = 0x00000004,
|
||||
Hidden = 0x00000008,
|
||||
NonInteractive = 0x00000010
|
||||
}
|
||||
|
||||
internal enum SetTabPropertiesOption
|
||||
{
|
||||
None = 0x0,
|
||||
UseAppThumbnailAlways = 0x1,
|
||||
UseAppThumbnailWhenActive = 0x2,
|
||||
UseAppPeekAlways = 0x4,
|
||||
UseAppPeekWhenActive = 0x8
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Structs
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal struct ThumbButton
|
||||
{
|
||||
/// <summary>
|
||||
/// WPARAM value for a THUMBBUTTON being clicked.
|
||||
/// </summary>
|
||||
internal const int Clicked = 0x1800;
|
||||
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
internal ThumbButtonMask Mask;
|
||||
internal uint Id;
|
||||
internal uint Bitmap;
|
||||
internal IntPtr Icon;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
internal string Tip;
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
internal ThumbButtonOptions Flags;
|
||||
}
|
||||
#endregion;
|
||||
|
||||
internal static class TaskbarNativeMethods
|
||||
{
|
||||
internal static class TaskbarGuids
|
||||
{
|
||||
internal static Guid IObjectArray = new Guid("92CA9DCD-5622-4BBA-A805-5E9F541BD8C9");
|
||||
internal static Guid IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
|
||||
}
|
||||
|
||||
internal const int WmCommand = 0x0111;
|
||||
|
||||
internal const uint WmDwmSendIconThumbnail = 0x0323;
|
||||
internal const uint WmDwmSendIconicLivePreviewBitmap = 0x0326;
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
internal static extern void SetCurrentProcessExplicitAppUserModelID(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string AppID);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
internal static extern void GetCurrentProcessExplicitAppUserModelID(
|
||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] out string AppID);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
internal static extern void SHAddToRecentDocs(
|
||||
ShellAddToRecentDocs flags,
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string path);
|
||||
|
||||
internal static void SHAddToRecentDocs(string path)
|
||||
{
|
||||
SHAddToRecentDocs(ShellAddToRecentDocs.PathW, path);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thumbnail Alpha Types
|
||||
/// </summary>
|
||||
public enum ThumbnailAlphaType
|
||||
{
|
||||
/// <summary>
|
||||
/// Let the system decide.
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// No transparency
|
||||
/// </summary>
|
||||
NoAlphaChannel = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Has transparency
|
||||
/// </summary>
|
||||
HasAlphaChannel = 2,
|
||||
}
|
||||
}
|
||||
@@ -69,25 +69,20 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="WpfAnimatedGif, Version=1.4.15.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\WpfAnimatedGif.1.4.15\lib\net\WpfAnimatedGif.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AnimatedGifWindowWinForms.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AnimatedGifWindow.cs" />
|
||||
<Compile Include="AuthenticodeTools.cs" />
|
||||
<Compile Include="CopStache.cs" />
|
||||
<Compile Include="Mono.Options\Options.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TaskbarCOMInterfaces.cs" />
|
||||
<Compile Include="TaskbarEnums.cs" />
|
||||
<Compile Include="TaskbarInterfaces.cs" />
|
||||
<Compile Include="TaskbarList.cs" />
|
||||
<Compile Include="TaskbarManager.cs" />
|
||||
<Compile Include="TaskbarNativeMethods.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
@@ -124,7 +119,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) 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) WpfAnimatedGif.dll 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>
|
||||
|
||||
@@ -7,4 +7,5 @@
|
||||
<package id="SharpCompress" version="0.17.1" targetFramework="net45" />
|
||||
<package id="SimpleJson" version="0.38.0" targetFramework="net45" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="net45" />
|
||||
<package id="WpfAnimatedGif" version="1.4.15" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user