mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Some OSD notifications
This commit is contained in:
@@ -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);
|
||||
|
||||
50
app/Properties/Resources.Designer.cs
generated
50
app/Properties/Resources.Designer.cs
generated
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
BIN
app/Resources/Brightness.bmp
Normal file
BIN
app/Resources/Brightness.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
app/Resources/icons8-brightness-96.png
Normal file
BIN
app/Resources/icons8-brightness-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
app/Resources/icons8-microphone-96.png
Normal file
BIN
app/Resources/icons8-microphone-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 784 B |
BIN
app/Resources/icons8-sunset-96.png
Normal file
BIN
app/Resources/icons8-sunset-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
app/Resources/icons8-touchpad-96.png
Normal file
BIN
app/Resources/icons8-touchpad-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user