From 267cf6387fd968a71ef5d2ad276ef587d270753a Mon Sep 17 00:00:00 2001
From: Serge <5920850+seerge@users.noreply.github.com>
Date: Tue, 21 Nov 2023 13:07:03 +0100
Subject: [PATCH] Icons cleanup
---
app/Properties/Resources.Designer.cs | 18 ++++++++--------
app/Properties/Resources.resx | 6 +++---
app/Resources/dot-eco.ico | Bin 16958 -> 0 bytes
app/Resources/dot-eco.png | Bin 0 -> 730 bytes
app/Resources/dot-standard.ico | Bin 16958 -> 0 bytes
app/Resources/dot-standard.png | Bin 0 -> 735 bytes
app/Resources/dot-ultimate.ico | Bin 16958 -> 0 bytes
app/Resources/dot-ultimate.png | Bin 0 -> 551 bytes
app/Settings.cs | 31 +++------------------------
app/UI/IconHelper.cs | 24 +++++++++++++++++++++
10 files changed, 39 insertions(+), 40 deletions(-)
delete mode 100644 app/Resources/dot-eco.ico
create mode 100644 app/Resources/dot-eco.png
delete mode 100644 app/Resources/dot-standard.ico
create mode 100644 app/Resources/dot-standard.png
delete mode 100644 app/Resources/dot-ultimate.ico
create mode 100644 app/Resources/dot-ultimate.png
create mode 100644 app/UI/IconHelper.cs
diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs
index 4d557b78..c68924a0 100644
--- a/app/Properties/Resources.Designer.cs
+++ b/app/Properties/Resources.Designer.cs
@@ -111,32 +111,32 @@ namespace GHelper.Properties {
}
///
- /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
///
- 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));
}
}
///
- /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
///
- 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));
}
}
///
- /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
///
- 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));
}
}
diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx
index 29c0043f..3242cd04 100644
--- a/app/Properties/Resources.resx
+++ b/app/Properties/Resources.resx
@@ -293,12 +293,12 @@
..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- ..\Resources\dot-eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\Resources\dot-eco.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\Resources\dot-standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\Resources\dot-standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
- ..\Resources\dot-ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+ ..\Resources\dot-ultimate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
\ No newline at end of file
diff --git a/app/Resources/dot-eco.ico b/app/Resources/dot-eco.ico
deleted file mode 100644
index 972ddc275cf5b90f9e9aa4d6016717b7ef1a971c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 16958
zcmeI4!EVAZ3_v|?Et7T_(xhF-k>mbgXg@}8&~g}m0Dn-4!WsT#{6TlzVH&ejQmO)j
zrfyS&nTko9IQDbmrU4D$2LF0J!1oSx-vOQhpo<5d0uK*5uUf)|_*V2ibG#5TXXcy1#+7~lP{h5wa
z?shzRzBmW!m)n=3`Y87Gjr)B@wJZ*k|r9lcF)>tZy^+#K2}ApmlmC4!gDd(Y4(E
z_~mFnvh=(VM9!GQ{<1oTXb0z*K35lx{bgC(Ioi{6@2MX(*AAv
zo#~e|uIK6!|EtO8CS1>r8E3s~pZ}8oulxRg?dw0vB@M^{F=tLIs>`1_Q{9luc2e29-rBGI(f<7?vy|avK03PPp$c`q{Q(a5IK=<}
diff --git a/app/Resources/dot-eco.png b/app/Resources/dot-eco.png
new file mode 100644
index 0000000000000000000000000000000000000000..b2947573f61b6abd5e84fbbccfeab6c985ef9544
GIT binary patch
literal 730
zcmV<00ww*4P)%%I~()^aCiAGX1W*u>MvWmvgogm&%Q#5ZUDkgeoHk7dI4~0
zAII%4fhWJUT&?p%jdEx~iLd#JChv8MHO4Kp5K;+1a(8*5y5Q}?-7jgsJ%y0G1pJC0
zN8eBnR|-G&F-n&xNt^+3)JjpGjx-Cz0U)9y)QRW>0-^x4XOmv#wf|hl?=eu4C;)_L
zhz2M&SS86yfam~CAQ*=%1N@e@0f?!Kl7tyhd;LEVj6>~7@PB0ifP~wlqX`7#5CwpV
z7HELtEU_eE2Ji!#Krjwj1|XlJ0sJX4N)qn|feB4J#^34!$Zcrzp
zIRwN3SY^pIgG%qmrCPpkAh{k=qxZ|&vVeK~C_EQbc@Xkh;A;_8daC^tLOM@^E(==O
zre9SlusaI#_k#kpN8utBiGv5hPu~4^^&gcwMCzTP*fmEGs5!Eoyk=)eeKX_-7p=2H
z^)h9p>W-t4By%ZdO|4s1s1Kzm4!Nwn*6OLRk
zy1QN%dg5CZzacW|MWEs4A8&}X+{PvcPqV@K9L5-9j4{R-V~h#m7d)c$$DuJDNdN!<
M07*qoM6N<$f^t(e!TNfC(@GCcp%k025#WOn{oe+8;Xct2>DU_bmzBFbTXg-`o((@jTX}zPBlT
z8-Li3efOp4@2>B~@A2G=*1k7RXHL(Q?T6kM?a$*|^s&ylW8{D_ZyN7v7H)`o4~>cL
z>*IxYm&~7{YJZxy2W$(dU$+l!_3QLq@wAnJZ1bApu6$P#8Q9bpqSxSv
zPN}b>$nz?;jieY~sC{XwPsYBZc3;NEbU!c_`~2B)+B9aA^>vMPWw9qE}tXk*!iC)!chX3BcP*1b8bF&0Li1=_?)*EN)J
zt*c9yFKzVJwVASB8#{GfL+MvtUBZ`>?*FHr|4)7VKlSH7%oE0QfLIHuo3C`#%htAy
zJ@=%E;WdCruJs!7U&KDL;Qc@{_eQ$L^*{9*j{RbzDoUXa;9jaFmA~B&?UME^b1Cgz
ZZS7b7DF42sS<-McUpTtuArHFR{Q$-#`l$c_
diff --git a/app/Resources/dot-standard.png b/app/Resources/dot-standard.png
new file mode 100644
index 0000000000000000000000000000000000000000..bb9f95825d9d04d2366cfd46ccd2123b60d5f296
GIT binary patch
literal 735
zcmV<50wDc~P)K$7eNoXWw|)prbJayl8D
zyJq74Md!^J1&AKN{-;T^(O5qs%#WF=`HY`t@)nj2Y8bH*>uLKSu
zSOC84*OJ1!&Gg`4pI6qY7jp6*;K_aEv}Gz^@`BC-rRbIDZ-^LUj4{R-V~jDc&~Ip5?*=)DPRhi0;Yf|U<#N5
zrhqA63YY?>fGLn$0q3?Jm;(*a0^1JQWVIT9cvYBgYxQnx*pmYaad1hUSp!e_-xWmm)O)cdq%N
z>K?gA%Q!BzPPykHmkH1UF~2cvo0~_fKk(*#Y7EZDG3wNubIk*9)_$yYf6Sk4my1h^
zAH>(Hebi!+l6S5-%C)BkYUcoAdmz?9)B0TX?BfUA`B_DicZ@ynlXtGM;NBF%zsbd^
zj~{Sv3*oPF1{A_Q?14UY%Qe>c7jgD!*8kS`e^baF&^rHb{r-Q`fB*45g7vR`25fTO
z&rlQlQZ)C@I^bT&eIC%Ci!n;K$d%8fGJ=Km;z-hu+@95?{~39
zD*o~<@=E(D@4WHAkI)$F@&oR~CT{=$
diff --git a/app/Resources/dot-ultimate.png b/app/Resources/dot-ultimate.png
new file mode 100644
index 0000000000000000000000000000000000000000..6df369ed4371358ccb64b2776e1205283b1b0268
GIT binary patch
literal 551
zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=oCO|{#S9GG!XV7ZFl&wkP>``W
z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eBxjmjPjv*C{Z*RTNJ!Bxj`oUd2fyJ0HwP_mf
zjh4KC8x47f*ixFOalYc6#d~XWlJ{DXl}F3B1wZ|(qCKDCci}mCYX(6uID4K+wASjo
zM*G|?TTR5HA0_Yhvew`8KEUxKL&^nj%Qs7HJ)`e^2-IIYxonDo4VR`^L(+p}KA}T`
ztRkEaZ10~G96T>{{nMpw*RCeWHSqkCJN#hl|6eoYoH_ChlB66S9#mhZID=K-^gq#5
z_W3OWW@48g@|Ai0|9rpo{>~%9Yr8xdE=^3oG4I2_Ly0>Mtyr<#LFaGz7QtnQyp}oj
z`-q7aI9MlgtypzHseygV*7hc?hKl_67p@t7Q|{izR5qjSOqw#BgC}5?JOzPv(ht?ME*^V1Koix##02lO0ZK-K!69-+HwmLGS?Q
z;o?f|RZojb843*-g^I2)_w^BTeS9k>LZEboyXkk~$<_xWSfj7Z=6d=4%9*^@WX)?F
zif_3qBp#d-;QHZT-RwG#%~}01=cy$3?fv&RM~d7~TmP}H;qZnMxv>7byz;)&uTM_9
l``>(Xy>m+k7-Y2VW9aqkR4F=?WDbm122WQ%mvv4FO#mQ!=9B;c
literal 0
HcmV?d00001
diff --git a/app/Settings.cs b/app/Settings.cs
index 4d547da4..88e9a709 100644
--- a/app/Settings.cs
+++ b/app/Settings.cs
@@ -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;
}
diff --git a/app/UI/IconHelper.cs b/app/UI/IconHelper.cs
new file mode 100644
index 00000000..4daad6f2
--- /dev/null
+++ b/app/UI/IconHelper.cs
@@ -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);
+ }
+
+ }
+}