Some OSD notifications

This commit is contained in:
Serge
2023-05-20 21:51:02 +02:00
parent 09e6676b7c
commit 9f56959c67
10 changed files with 115 additions and 35 deletions

View File

@@ -1,6 +1,5 @@
using Microsoft.Win32;
using NAudio.CoreAudioApi;
using OSD;
using System.Diagnostics;
using System.Globalization;
using System.Management;
@@ -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);

View File

@@ -70,16 +70,6 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap everything_is_fine_itsfine {
get {
object obj = ResourceManager.GetObject("everything-is-fine-itsfine", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -100,6 +90,16 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_brightness_96 {
get {
object obj = ResourceManager.GetObject("icons8_brightness_96", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -230,6 +230,16 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_microphone_96 {
get {
object obj = ResourceManager.GetObject("icons8_microphone_96", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -330,6 +340,26 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_sunset_96 {
get {
object obj = ResourceManager.GetObject("icons8_sunset_96", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_touchpad_96 {
get {
object obj = ResourceManager.GetObject("icons8_touchpad_96", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -133,9 +133,6 @@
<data name="icons8-fiat-500-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-fiat-500-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-project-management-48 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-bicycle-48 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -205,13 +202,25 @@
<data name="icons8-speed-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="everything-is-fine-itsfine" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\itsfine.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-help-64" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-help-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_video_48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-project-management-48 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_brightness_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-brightness-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_sunset_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-sunset-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_microphone_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-microphone-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_touchpad_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-touchpad-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

View File

@@ -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()

View File

@@ -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;
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", 16f, FontStyle.Bold),
new Font("Segoe UI", 36f, FontStyle.Bold, GraphicsUnit.Pixel),
new SolidBrush(Color.White),
new PointF(this.Bound.Width/2, this.Bound.Height / 2),
format);
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();
}
}
}