using System;
using System.Runtime.InteropServices;
namespace MangaReader.Avalonia.Platform.Win.Interop
{
///
/// A struct that is submitted in order to configure
/// the taskbar icon. Provides various members that
/// can be configured partially, according to the
/// values of the
/// that were defined.
///
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NotifyIconData
{
///
/// Size of this structure, in bytes.
///
public uint cbSize;
///
/// Handle to the window that receives notification messages associated with an icon in the
/// taskbar status area. The Shell uses hWnd and uID to identify which icon to operate on
/// when Shell_NotifyIcon is invoked.
///
public IntPtr WindowHandle;
///
/// Application-defined identifier of the taskbar icon. The Shell uses hWnd and uID to identify
/// which icon to operate on when Shell_NotifyIcon is invoked. You can have multiple icons
/// associated with a single hWnd by assigning each a different uID. This feature, however
/// is currently not used.
///
public uint TaskbarIconId;
///
/// Flags that indicate which of the other members contain valid data. This member can be
/// a combination of the NIF_XXX constants.
///
public IconDataMembers ValidMembers;
///
/// Application-defined message identifier. The system uses this identifier to send
/// notifications to the window identified in hWnd.
///
public uint CallbackMessageId;
///
/// A handle to the icon that should be displayed. Just
/// Icon.Handle.
///
public IntPtr IconHandle;
///
/// String with the text for a standard ToolTip. It can have a maximum of 64 characters including
/// the terminating NULL. For Version 5.0 and later, szTip can have a maximum of
/// 128 characters, including the terminating NULL.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string ToolTipText;
///
/// State of the icon. Remember to also set the .
///
public IconState IconState;
///
/// A value that specifies which bits of the state member are retrieved or modified.
/// For example, setting this member to
/// causes only the item's hidden
/// state to be retrieved.
///
public IconState StateMask;
///
/// String with the text for a balloon ToolTip. It can have a maximum of 255 characters.
/// To remove the ToolTip, set the NIF_INFO flag in uFlags and set szInfo to an empty string.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string BalloonText;
///
/// Mainly used to set the version when is invoked
/// with . However, for legacy operations,
/// the same member is also used to set timeouts for balloon ToolTips.
///
public uint VersionOrTimeout;
///
/// String containing a title for a balloon ToolTip. This title appears in boldface
/// above the text. It can have a maximum of 63 characters.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string BalloonTitle;
///
/// Adds an icon to a balloon ToolTip, which is placed to the left of the title. If the
/// member is zero-length, the icon is not shown.
///
public BalloonFlags BalloonFlags;
///
/// Windows XP (Shell32.dll version 6.0) and later.
/// - Windows 7 and later: A registered GUID that identifies the icon.
/// This value overrides uID and is the recommended method of identifying the icon.
/// - Windows XP through Windows Vista: Reserved.
///
public Guid TaskbarIconGuid;
///
/// Windows Vista (Shell32.dll version 6.0.6) and later. The handle of a customized
/// balloon icon provided by the application that should be used independently
/// of the tray icon. If this member is non-NULL and the
/// flag is set, this icon is used as the balloon icon.
/// If this member is NULL, the legacy behavior is carried out.
///
public IntPtr CustomBalloonIconHandle;
///
/// Creates a default data structure that provides
/// a hidden taskbar icon without the icon being set.
///
///
/// NotifyIconData
public static NotifyIconData CreateDefault(IntPtr handle)
{
var data = new NotifyIconData();
//use the current size
data.cbSize = (uint) Marshal.SizeOf(data);
data.WindowHandle = handle;
data.TaskbarIconId = 0x0;
data.CallbackMessageId = WindowMessageSink.CallbackMessageId;
data.VersionOrTimeout = (uint) NotifyIconVersion.Vista;
data.IconHandle = IntPtr.Zero;
//hide initially
data.IconState = IconState.Hidden;
data.StateMask = IconState.Hidden;
//set flags
data.ValidMembers = IconDataMembers.Message | IconDataMembers.Icon | IconDataMembers.Tip | IconDataMembers.UseLegacyToolTips;
//reset strings
data.ToolTipText = data.BalloonText = data.BalloonTitle = string.Empty;
return data;
}
}
}