mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix duplicate SetConsoleIcon method (#1044)
This commit is contained in:
parent
674bf4f635
commit
bfdfbe3009
1 changed files with 10 additions and 20 deletions
|
|
@ -15,27 +15,22 @@ namespace MinecraftClient.WinAPI
|
|||
/// Allow to set the player skin as console icon, on Windows only.
|
||||
/// See StackOverflow no. 2986853
|
||||
/// </summary>
|
||||
|
||||
public static class ConsoleIcon
|
||||
{
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool SetConsoleIcon(IntPtr hIcon);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously download the player's skin and set the head as console icon
|
||||
/// </summary>
|
||||
public enum WinMessages : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// An application sends the WM_SETICON message to associate a new large or small icon with a window.
|
||||
/// The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.
|
||||
/// </summary>
|
||||
SETICON = 0x0080,
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, IntPtr lParam);
|
||||
|
||||
/// <summary>
|
||||
/// An application sends the WM_SETICON message to associate a new large or small icon with a window.
|
||||
/// The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.
|
||||
/// </summary>
|
||||
public enum WinMessages : uint
|
||||
{
|
||||
SETICON = 0x0080,
|
||||
}
|
||||
|
||||
private static void SetWindowIcon(System.Drawing.Icon icon)
|
||||
{
|
||||
|
|
@ -44,13 +39,9 @@ namespace MinecraftClient.WinAPI
|
|||
IntPtr result02 = SendMessage(mwHandle, (int)WinMessages.SETICON, 1, icon.Handle);
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
private static extern bool SetConsoleIcon(IntPtr hIcon);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously download the player's skin and set the head as console icon
|
||||
/// </summary>
|
||||
|
||||
public static void setPlayerIconAsync(string playerName)
|
||||
{
|
||||
if (!Program.isUsingMono) //Windows Only
|
||||
|
|
@ -66,8 +57,8 @@ namespace MinecraftClient.WinAPI
|
|||
{
|
||||
Bitmap skin = new Bitmap(Image.FromStream(httpWebReponse.GetResponseStream())); //Read skin from network
|
||||
skin = skin.Clone(new Rectangle(8, 8, 8, 8), skin.PixelFormat); //Crop skin
|
||||
SetWindowIcon(Icon.FromHandle(skin.GetHicon()));
|
||||
SetConsoleIcon(skin.GetHicon()); //Set skin as icon
|
||||
SetWindowIcon(Icon.FromHandle(skin.GetHicon())); // Windows 10+ (New console)
|
||||
SetConsoleIcon(skin.GetHicon()); // Windows 8 and lower (Older console)
|
||||
}
|
||||
catch (ArgumentException) { /* Invalid image in HTTP response */ }
|
||||
}
|
||||
|
|
@ -90,7 +81,6 @@ namespace MinecraftClient.WinAPI
|
|||
/// <summary>
|
||||
/// Set the icon back to the default CMD icon
|
||||
/// </summary>
|
||||
|
||||
public static void revertToCMDIcon()
|
||||
{
|
||||
if (!Program.isUsingMono) //Windows Only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue