From 9f56959c67970f168c284577a30995cb78f0af83 Mon Sep 17 00:00:00 2001
From: Serge <5920850+seerge@users.noreply.github.com>
Date: Sat, 20 May 2023 21:51:02 +0200
Subject: [PATCH] Some OSD notifications
---
app/Program.cs | 15 +++----
app/Properties/Resources.Designer.cs | 50 ++++++++++++++++-----
app/Properties/Resources.resx | 21 ++++++---
app/Resources/Brightness.bmp | Bin 0 -> 3382 bytes
app/Resources/icons8-brightness-96.png | Bin 0 -> 1061 bytes
app/Resources/icons8-microphone-96.png | Bin 0 -> 784 bytes
app/Resources/icons8-sunset-96.png | Bin 0 -> 1059 bytes
app/Resources/icons8-touchpad-96.png | Bin 0 -> 377 bytes
app/Settings.cs | 4 +-
app/ToastForm.cs | 60 +++++++++++++++++++++----
10 files changed, 115 insertions(+), 35 deletions(-)
create mode 100644 app/Resources/Brightness.bmp
create mode 100644 app/Resources/icons8-brightness-96.png
create mode 100644 app/Resources/icons8-microphone-96.png
create mode 100644 app/Resources/icons8-sunset-96.png
create mode 100644 app/Resources/icons8-touchpad-96.png
diff --git a/app/Program.cs b/app/Program.cs
index 69673564..697674c3 100644
--- a/app/Program.cs
+++ b/app/Program.cs
@@ -1,6 +1,5 @@
using Microsoft.Win32;
using NAudio.CoreAudioApi;
-using OSD;
using System.Diagnostics;
using System.Globalization;
using System.Management;
@@ -106,7 +105,7 @@ namespace GHelper
SettingsToggle(action);
}
- if (!isOptimizationRunning) AsusUSB.RunListener(HandleEvent);
+ if (!isOptimizationRunning) AsusUSB.RunListener(HandleEvent);
Application.Run();
@@ -265,7 +264,7 @@ namespace GHelper
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
commDevice.AudioEndpointVolume.Mute = muteStatus;
- settingsForm.BeginInvoke(settingsForm.RunToast, muteStatus ? "Mic Muted" : "Mic Unmuted");
+ settingsForm.BeginInvoke(settingsForm.RunToast, muteStatus ? "Muted" : "Unmuted", ToastIcon.Microphone);
}
break;
@@ -324,25 +323,25 @@ namespace GHelper
brightness = Math.Max(0, brightness - 1);
config.setConfig("keyboard_brightness", brightness);
AsusUSB.ApplyBrightness(brightness);
- settingsForm.BeginInvoke(settingsForm.RunToast, "Backlight -");
+ settingsForm.BeginInvoke(settingsForm.RunToast, "Down", ToastIcon.Backlight);
break;
case 196: // FN+F3
brightness = Math.Min(3, brightness + 1);
config.setConfig("keyboard_brightness", brightness);
AsusUSB.ApplyBrightness(brightness);
- settingsForm.BeginInvoke(settingsForm.RunToast, "Backlight +");
+ settingsForm.BeginInvoke(settingsForm.RunToast, "Up", ToastIcon.Backlight);
break;
case 16: // FN+F7
ScreenBrightness.Adjust(-10);
- settingsForm.BeginInvoke(settingsForm.RunToast, "Brightness -");
+ settingsForm.BeginInvoke(settingsForm.RunToast, "Down", ToastIcon.Brightness);
break;
case 32: // FN+F8
ScreenBrightness.Adjust(+10);
- settingsForm.BeginInvoke(settingsForm.RunToast, "Brightness +");
+ settingsForm.BeginInvoke(settingsForm.RunToast, "Up", ToastIcon.Brightness);
break;
case 107: // FN+F10
AsusUSB.TouchpadToggle();
- settingsForm.BeginInvoke(settingsForm.RunToast, "Touchpad");
+ settingsForm.BeginInvoke(settingsForm.RunToast, "Toggle", ToastIcon.Touchpad);
break;
case 108: // FN+F11
Application.SetSuspendState(PowerState.Suspend, true, true);
diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs
index c7831a70..81274350 100644
--- a/app/Properties/Resources.Designer.cs
+++ b/app/Properties/Resources.Designer.cs
@@ -70,16 +70,6 @@ namespace GHelper.Properties {
}
}
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap everything_is_fine_itsfine {
- get {
- object obj = ResourceManager.GetObject("everything-is-fine-itsfine", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -100,6 +90,16 @@ namespace GHelper.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_brightness_96 {
+ get {
+ object obj = ResourceManager.GetObject("icons8_brightness_96", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -230,6 +230,16 @@ namespace GHelper.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_microphone_96 {
+ get {
+ object obj = ResourceManager.GetObject("icons8_microphone_96", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -330,6 +340,26 @@ namespace GHelper.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_sunset_96 {
+ get {
+ object obj = ResourceManager.GetObject("icons8_sunset_96", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap icons8_touchpad_96 {
+ get {
+ object obj = ResourceManager.GetObject("icons8_touchpad_96", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx
index 7d70d000..8e92f0e6 100644
--- a/app/Properties/Resources.resx
+++ b/app/Properties/Resources.resx
@@ -133,9 +133,6 @@
..\Resources\icons8-fiat-500-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -205,13 +202,25 @@
..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\itsfine.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Resources\icons8-help-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\icons8-brightness-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\icons8-sunset-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\icons8-microphone-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\icons8-touchpad-96.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/Brightness.bmp b/app/Resources/Brightness.bmp
new file mode 100644
index 0000000000000000000000000000000000000000..55516c7aaa3591604865d4cd18379f8f650c3104
GIT binary patch
literal 3382
zcmeIwA#&YN425B3CLjUbgJ57$uqM1+gO+lZkut%6E<(#F6wORPc)-i=r?4!c_Vwp;
zZ3Fx2>gm_x54#?Zw`LE_etx;JyM1xL@%<_@PLnpcGPUluKQDjn-|L&12NJySLSxLr
z;9wF7q0kt!G&lm>q)=$g*LR%^B!og^%$Qm^0tune7=F^=2qc6;W6U^h9D#&TXpDvN
zo8~x1LMSw5m*!3e5<;OdyXkPr%u*^;D_frLmI06Zw(3st}a59h(3XRzqWFR3F8nf*xCj$wg(3oxIax#z*3XRz|Zzlr@q3r$RV$Z*g8j2NO
iuBTlt#|(_)(Q$tsX9dm*oE11La8}@~z*&L+tOB3FDm>c&
literal 0
HcmV?d00001
diff --git a/app/Resources/icons8-brightness-96.png b/app/Resources/icons8-brightness-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..ed8e942e93c83a4dbd32a5c00369e2470d65179e
GIT binary patch
literal 1061
zcmV+=1ls$FP)v!4ExVs)cJO6
z#AV<&@D(`cA^{izJ_CP%D`kscB?=SxCw`UUP1r&FC`{mg@ryU1hWMsUV0ZD0GXa>$
z5Pz!)g-y%_O}PFuW#P4%XlFxC1M77(#7s{h`^qo&!i&iSq>0}^m#j8y&?y5L%=sCM
z9ddJ+a3APs;yhj9T-Sj);2BT}SLQEZGyGl&|CU=kguLR910N`!_rUoEOpqsj6=0xV@qu1omh$nU_U15Qz-b3K2E0NJ
zFM%U22EzUI8|3j0IO!|{oB~#n%L;J9Sp+x=EF+(fz;S1ZFyTrX^Rrk2dYl!6-0kG$
zp0hw$Qqan%(+tq3WZbXyWv%XS%;E^k3)-1+8Ugx&ALwTz?*g6(fLqw%hSNk?&u_<)
za#^f3vY${Iz(wpa=ClxYvaGS-G!XW1{Z^ngz5tz0Iz9{qyPR>-2@wfax$2|?Ji;!s
z?GP*%bsXp1I$U-2lyNKUq{X7*KEAs7BT_7~n$%t@1M&P%bJANJCH#(j;tf
z5>B_FEz~nNAwJ(K51n*?YuIJdNhd@}TV=>eCoM+{AfyFZW8P^&c`%m#AT5KN@~c3%
z(?m#!v%-|qMheUlK*&ba&a~4?3eFXPPX$FUBhCWA1N3p%8B0;}si0bTVJbz*zQON@c}tn(DT42CtFFviU^qZNt$Lvc`P`Xy2Gm3ksPjjpC~*&WB;H+f>oM0?Sr*0%v`4M5sBj2)qpuc$?v8J^bxyc+I5G
zW@#p+NOalCRJgU=s<|@D`NmMDIVSN%nvlxZmt4L+#{(SHU-=F61QAcsFe!c=CWv^B
zjA`*}m>}XwN>PZvg9+t{zojwhL2fZY24%O;JR}2>0Z~Kh0m*=*Bi_3*-Z00000NkvXXu0mjfoDJc#
literal 0
HcmV?d00001
diff --git a/app/Resources/icons8-microphone-96.png b/app/Resources/icons8-microphone-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..f76031d00154639664bf79f2cda0d984f8874104
GIT binary patch
literal 784
zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGooCO|{#S9GG!XV7ZFl&wk0|V0`
zPZ!6KiaBrZ9L)E16gmEJp{Df44X@j7T&Q=7NYYH|59!+PdTGl)=8Y2{#B1~l)lQtU
z-{H3C-3xj*ewa-@BfKy@&LscdoXXF?*WBOxeU9b#Gjq#tn=5v}KnTMe205nu#@b`)
z_H#cw?rH0){_)^EBlD^5>obA{|Ly(E?sJaKV6~D;=B=4qejk2a&R-F}km2=R{yzd6
zfQ=&$g*3Q{qxq?B<;d%i33Wiu`*#%4`yrm6X7fi1(5+mqvm+@#M=%qIn>F7|)fC%JKsncaWoElf8|C+&Ff
zH+|Is*Td!4U-0sO<
zaNWZ0S&`WmmWo`J&ADsavbqczt=-P7UTAt??HSphLKbp!82T8`8-2XTv9^<$r{!_FEIn{?3zKB3_S%E%89zUM(^Ini{PJS^b2_H~x0snq|6xpbv*F+KQzDt~vWjS;
z?Eh=a@;>~Z)feVwGb6jxP}leDmdVU9g=VU`X8UhhKKkA=`@m{1S;6%?rS_+o?mj0k
z{y?Tce_x?bzH7O0{T0iuigoK>-uWoSeRl8dk1Wn_ckF89LWEd(ZU22WQ%mvv4FO#m+DV`l&W
literal 0
HcmV?d00001
diff --git a/app/Resources/icons8-sunset-96.png b/app/Resources/icons8-sunset-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..23531509a9f8462f46c0cf57da698f0702d0152e
GIT binary patch
literal 1059
zcmV+;1l;?HP)XpD%6h=_=YNC>b381Rf0!7t0~0h{sLtR8n53Lq^MfC6YV
zGy@bsqoEm~02&R=00q!!Xa+pfjHSRkO$`9p1uW_2I;XCDG4KQM1lZrShjG9MZrgtX
zUhLL-r#F96S3^i`O7kamFN7JI->49HzWLn?0ayfF3LJxNVIP{B0`_^DKgsrHaVHDt
z0Zs)9sO?O^zvoXi0?g@jA&m=xT$-Ol2*4a*8PE%CaHH4#t*7?Q?`8;0tm8G{Bj6nH
z3-BPYKKpN1-Dmf^aC&Oj{AqjRnSuiU2i8U|cN6eAaEIBu4GaStBWqaeY7aS+tobEp
z!eijwh~>NuT&8n=2DX=-6~K-_2@`Z1dkM@tv1|
zG19Qd_R%trFQ$c%U-PG(6TSp?miX)&z)jM#HT0FJcPH>ww#|*Y
z>|FDE3!YqlZ8G8RZhh?GbB(DQ;B3LvUSu)>EOd{$eZDbO0=yh}ifHdTH<-)-ue;i2
zVz*_rsS4nWz}_@uGR4F@2%lk71@@`|_{*~q_v{l;lPO?1@UN%#KY{rsckZQ%&oPrZ
z;6$MQw@igkzV@2G*JKWOCGZ}2#N-b6!&CevQxQ!3%55e$Oa=BHpJaEuv4Det?Z|f)
zyT`shQNKz^so*E@{U%qypr`1EReGkv#Fd<_c_s(jy|UAhV=%C+Z#_ldb?;NFH15Wp
zh}{kt)ld7SSmS{LzN7xm2eyAac46%f;7983`^ud
zfdWR|EU5Ds4Q&5dY(IU=5)ly*5qo*n-@@f;(?@^Xb{+RWkw}~Y1(22kNK64FrU2>`
zKwk^5E}K63+7^I_h=_=UwDMBAg7STjs{j&H0EsDp#1uec3LuYHmjg8){i*vbA|fIp
dA|j@BPXRsFkbWZxoe%&3002ovPDHLkV1ii-?+pL|
literal 0
HcmV?d00001
diff --git a/app/Resources/icons8-touchpad-96.png b/app/Resources/icons8-touchpad-96.png
new file mode 100644
index 0000000000000000000000000000000000000000..66e48f14cd8405846fe3c443364d25a23d9a0fc2
GIT binary patch
literal 377
zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGooCO|{#S9GG!XV7ZFl&wk0|TSB
zr;B4q#hkZy9lZ_*h&WvADS6t|v^(Ur(L9zp9DGs9)uxu|jFo41Unu+Xe-qFU28Ova
zcg~;re5U2uy18l3GSl9z+cUlUxz2p&zDFP3sx7O}S-q(3dt9=3?;P87*%B3f@i(cL
z!#6S9uil|>;Bk(^f$;UOKh=Lw-s4s=Tj{_}ev2J~3sfC^8fGvUGA1z{Vd>x$5LQql
zU*MZmLoULQ8*l%)#om1L_w(C-tm|=F^2U_mHiv-l19{dPpRcOc|C`rz_W6^|Z($S@
d$kz!!YvmWU$UVQl>ODjKlx{
literal 0
HcmV?d00001
diff --git a/app/Settings.cs b/app/Settings.cs
index 595f24bf..66c04072 100644
--- a/app/Settings.cs
+++ b/app/Settings.cs
@@ -152,9 +152,9 @@ namespace GHelper
}
- public void RunToast(string text)
+ public void RunToast(string text, ToastIcon? icon = null)
{
- toast.RunToast(text);
+ toast.RunToast(text, icon);
}
public void SetContextMenu()
diff --git a/app/ToastForm.cs b/app/ToastForm.cs
index 170a013a..f532ee83 100644
--- a/app/ToastForm.cs
+++ b/app/ToastForm.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.Drawing;
using System.Drawing.Drawing2D;
using OSD;
@@ -42,10 +43,20 @@ namespace GHelper
}
}
+ public enum ToastIcon
+ {
+ Brightness,
+ Backlight,
+ Touchpad,
+ Microphone
+ }
+
public class ToastForm : OSDNativeForm
{
protected static string toastText = "Balanced";
+ protected static ToastIcon? toastIcon = null;
+
protected static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
public ToastForm()
@@ -64,18 +75,49 @@ namespace GHelper
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
- e.Graphics.DrawString(toastText,
- new Font("Segoe UI", 16f, FontStyle.Bold),
- new SolidBrush(Color.White),
- new PointF(this.Bound.Width/2, this.Bound.Height / 2),
- format);
+ Bitmap? icon = null;
+
+ switch (toastIcon)
+ {
+ case ToastIcon.Brightness:
+ icon = Properties.Resources.icons8_brightness_96;
+ break;
+ case ToastIcon.Backlight:
+ icon = Properties.Resources.icons8_sunset_96;
+ break;
+ case ToastIcon.Microphone:
+ icon = Properties.Resources.icons8_microphone_96;
+ break;
+ case ToastIcon.Touchpad:
+ icon = Properties.Resources.icons8_touchpad_96;
+ break;
+
+ }
+
+ int shiftX = 0;
+
+ if (icon is not null)
+ {
+ e.Graphics.DrawImage(icon, 18, 18, 64, 64);
+ shiftX = 40;
+ }
+
+ e.Graphics.DrawString(toastText,
+ new Font("Segoe UI", 36f, FontStyle.Bold, GraphicsUnit.Pixel),
+ new SolidBrush(Color.White),
+ new PointF(this.Bound.Width / 2 + shiftX, this.Bound.Height / 2),
+ format);
+
}
- public void RunToast(string text)
+ public void RunToast(string text, ToastIcon? icon = null)
{
Hide();
+ timer.Stop();
toastText = text;
+ toastIcon = icon;
+
Screen screen1 = Screen.FromHandle(base.Handle);
Width = 300;
@@ -84,15 +126,15 @@ namespace GHelper
Y = screen1.Bounds.Height - 300 - this.Height;
Show();
-
- timer.Enabled = true;
+ timer.Start();
}
private void timer_Tick(object? sender, EventArgs e)
{
Debug.WriteLine("Toast end");
- timer.Enabled = false;
+
Hide();
+ timer.Stop();
}
}
}