Ejemplo n.º 1
0
        public override void SetIconFromStream(Stream stream)
        {
            if (WindowInfo.Handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Window must be created before an icon can be set.");
            }

            iconGroup = new IconGroup(stream);

            smallIcon = iconGroup.CreateIcon(24, 24);
            largeIcon = iconGroup.CreateIcon(256, 256);

            SendMessage(WindowInfo.Handle, seticon_message, (IntPtr)0, smallIcon.Handle);
            SendMessage(WindowInfo.Handle, seticon_message, (IntPtr)1, largeIcon.Handle);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// On Windows, SDL will use the same image for both large and small icons (scaled as necessary).
        /// This can look bad if scaling down a large image, so we use the Windows API directly so as
        /// to get a cleaner icon set than SDL can provide.
        /// If called before the window has been created, or we do not find two separate icon sizes, we fall back to the base method.
        /// </summary>
        internal override void SetIconFromGroup(IconGroup iconGroup)
        {
            smallIcon = iconGroup.CreateIcon(small_icon_size, small_icon_size);
            largeIcon = iconGroup.CreateIcon(large_icon_size, large_icon_size);

            var windowHandle = WindowHandle;

            if (windowHandle == IntPtr.Zero || largeIcon == null || smallIcon == null)
            {
                base.SetIconFromGroup(iconGroup);
            }
            else
            {
                SendMessage(windowHandle, seticon_message, (IntPtr)icon_small, smallIcon.Handle);
                SendMessage(windowHandle, seticon_message, (IntPtr)icon_big, largeIcon.Handle);
            }
        }
Ejemplo n.º 3
0
        public override void SetIconFromStream(Stream stream)
        {
            if (WindowInfo.Handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Window must be created before an icon can be set.");
            }

            iconGroup = new IconGroup(stream);

            smallIcon = iconGroup.CreateIcon(24, 24);
            largeIcon = iconGroup.CreateIcon(256, 256);

            // CreateIcon was changed to return null rather than throwing exceptions
            // Since we have no fallback method of generating icons, we skip if the icon can't be found
            if (smallIcon != null)
            {
                SendMessage(WindowInfo.Handle, seticon_message, (IntPtr)0, smallIcon.Handle);
            }

            if (largeIcon != null)
            {
                SendMessage(WindowInfo.Handle, seticon_message, (IntPtr)1, largeIcon.Handle);
            }
        }