Icons cleanup

This commit is contained in:
Serge
2023-11-21 13:07:03 +01:00
parent 45e7e5551e
commit 267cf6387f
10 changed files with 39 additions and 40 deletions

View File

@@ -111,32 +111,32 @@ namespace GHelper.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Icon dot_eco {
internal static System.Drawing.Bitmap dot_eco {
get {
object obj = ResourceManager.GetObject("dot_eco", resourceCulture);
return ((System.Drawing.Icon)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Icon dot_standard {
internal static System.Drawing.Bitmap dot_standard {
get {
object obj = ResourceManager.GetObject("dot_standard", resourceCulture);
return ((System.Drawing.Icon)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Icon dot_ultimate {
internal static System.Drawing.Bitmap dot_ultimate {
get {
object obj = ResourceManager.GetObject("dot_ultimate", resourceCulture);
return ((System.Drawing.Icon)(obj));
return ((System.Drawing.Bitmap)(obj));
}
}

View File

@@ -293,12 +293,12 @@
<value>..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="dot_eco" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\dot-eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\dot-eco.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dot_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\dot-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\dot-standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dot_ultimate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\dot-ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\dot-ultimate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

BIN
app/Resources/dot-eco.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

View File

@@ -1150,13 +1150,6 @@ namespace GHelper
});
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private const uint WM_SETICON = 0x80u;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
public void VisualiseGPUMode(int GPUMode = -1)
{
ButtonEnabled(buttonOptimized, true);
@@ -1164,9 +1157,6 @@ namespace GHelper
ButtonEnabled(buttonStandard, true);
ButtonEnabled(buttonUltimate, true);
Bitmap? smallBmp = null;
Bitmap? bigBmp = null;
if (GPUMode == -1)
GPUMode = AppConfig.Get("gpu_mode");
@@ -1185,23 +1175,13 @@ namespace GHelper
buttonOptimized.Activated = GPUAuto;
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeEco;
Program.trayIcon.Icon = Properties.Resources.eco;
smallBmp = Properties.Resources.dot_eco.ToBitmap();
bigBmp = Properties.Resources.eco.ToBitmap();
SendMessage(this.Handle, WM_SETICON, ICON_SMALL, smallBmp.GetHicon());
SendMessage(this.Handle, WM_SETICON, ICON_BIG, bigBmp.GetHicon());
IconHelper.SetIcon(this, Properties.Resources.dot_eco);
break;
case AsusACPI.GPUModeUltimate:
buttonUltimate.Activated = true;
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeUltimate;
Program.trayIcon.Icon = Properties.Resources.ultimate;
smallBmp = Properties.Resources.dot_ultimate.ToBitmap();
bigBmp = Properties.Resources.ultimate.ToBitmap();
SendMessage(this.Handle, WM_SETICON, ICON_SMALL, smallBmp.GetHicon());
SendMessage(this.Handle, WM_SETICON, ICON_BIG, bigBmp.GetHicon());
IconHelper.SetIcon(this, Properties.Resources.dot_ultimate);
break;
default:
buttonOptimized.BorderColor = colorStandard;
@@ -1209,12 +1189,7 @@ namespace GHelper
buttonOptimized.Activated = GPUAuto;
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeStandard;
Program.trayIcon.Icon = Properties.Resources.standard;
smallBmp = Properties.Resources.dot_standard.ToBitmap();
bigBmp = Properties.Resources.standard.ToBitmap();
SendMessage(this.Handle, WM_SETICON, ICON_SMALL, smallBmp.GetHicon());
SendMessage(this.Handle, WM_SETICON, ICON_BIG, bigBmp.GetHicon());
IconHelper.SetIcon(this, Properties.Resources.dot_standard);
break;
}

24
app/UI/IconHelper.cs Normal file
View File

@@ -0,0 +1,24 @@
using System.Reflection;
using System.Runtime.InteropServices;
namespace GHelper.UI
{
public class IconHelper
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private const uint WM_SETICON = 0x80u;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
public static void SetIcon(Form form, Bitmap icon)
{
SendMessage(form.Handle, WM_SETICON, ICON_SMALL, icon.GetHicon());
SendMessage(form.Handle, WM_SETICON, ICON_BIG, Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)!.Handle);
}
}
}