mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Context menu
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using WinFormsSliderBar;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public static class ControlHelper
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace GHelper
|
||||
{"screenshot", Properties.Strings.PrintScreen},
|
||||
{"play", Properties.Strings.PlayPause},
|
||||
{"aura", Properties.Strings.ToggleAura},
|
||||
{"ghelper", Properties.Strings.OpenGHelper},
|
||||
{"performance", Properties.Strings.PerformanceMode},
|
||||
{"screen", Properties.Strings.ToggleScreen},
|
||||
{"miniled", Properties.Strings.ToggleMiniled},
|
||||
{"custom", Properties.Strings.Custom}
|
||||
@@ -22,7 +22,7 @@ namespace GHelper
|
||||
private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
|
||||
{
|
||||
if (name == "m4")
|
||||
customActions[""] = Properties.Strings.PerformanceMode;
|
||||
customActions[""] = Properties.Strings.OpenGHelper;
|
||||
|
||||
if (name == "fnf4")
|
||||
{
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace GHelper
|
||||
|
||||
//labelInfo.MaximumSize = new Size(280, 0);
|
||||
labelInfo.Text = Properties.Strings.PPTExperimental;
|
||||
labelFansResult.Visible = false;
|
||||
|
||||
InitFans();
|
||||
InitPower();
|
||||
@@ -283,7 +284,7 @@ namespace GHelper
|
||||
public void LabelFansResult(string text)
|
||||
{
|
||||
labelFansResult.Text = text;
|
||||
labelFansResult.Visible = (text.Length == 0);
|
||||
labelFansResult.Visible = (text.Length > 0);
|
||||
}
|
||||
|
||||
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.56</AssemblyVersion>
|
||||
<AssemblyVersion>0.57</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -3,11 +3,44 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Management;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Principal;
|
||||
using System.Windows.Forms;
|
||||
using Tools;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
|
||||
class CustomContextMenu : ContextMenuStrip
|
||||
{
|
||||
[DllImport("dwmapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
private static extern long DwmSetWindowAttribute(IntPtr hwnd,
|
||||
DWMWINDOWATTRIBUTE attribute,
|
||||
ref DWM_WINDOW_CORNER_PREFERENCE pvAttribute,
|
||||
uint cbAttribute);
|
||||
|
||||
public CustomContextMenu()
|
||||
{
|
||||
var preference = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL; //change as you want
|
||||
DwmSetWindowAttribute(Handle,
|
||||
DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE,
|
||||
ref preference,
|
||||
sizeof(uint));
|
||||
}
|
||||
|
||||
public enum DWMWINDOWATTRIBUTE
|
||||
{
|
||||
DWMWA_WINDOW_CORNER_PREFERENCE = 33
|
||||
}
|
||||
public enum DWM_WINDOW_CORNER_PREFERENCE
|
||||
{
|
||||
DWMWA_DEFAULT = 0,
|
||||
DWMWCP_DONOTROUND = 1,
|
||||
DWMWCP_ROUND = 2,
|
||||
DWMWCP_ROUNDSMALL = 3,
|
||||
}
|
||||
}
|
||||
|
||||
static class Program
|
||||
{
|
||||
public static NotifyIcon trayIcon = new NotifyIcon
|
||||
@@ -145,7 +178,6 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -173,7 +205,7 @@ namespace GHelper
|
||||
|
||||
|
||||
|
||||
public static void SetAutoModes(bool monitor = true)
|
||||
public static void SetAutoModes()
|
||||
{
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 3000) return;
|
||||
@@ -185,8 +217,7 @@ namespace GHelper
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
settingsForm.AutoPerformance();
|
||||
|
||||
bool switched = false;
|
||||
if (monitor) switched = settingsForm.AutoGPUMode();
|
||||
bool switched = settingsForm.AutoGPUMode();
|
||||
|
||||
if (!switched)
|
||||
{
|
||||
@@ -253,7 +284,7 @@ namespace GHelper
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "performance";
|
||||
action = "ghelper";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
}
|
||||
@@ -338,7 +369,7 @@ namespace GHelper
|
||||
|
||||
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
SettingsToggle();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace GHelper
|
||||
public partial class SettingsForm : RForm
|
||||
{
|
||||
|
||||
private ContextMenuStrip contextMenuStrip = new CustomContextMenu();
|
||||
private ToolStripMenuItem menuSilent, menuBalanced, menuTurbo;
|
||||
|
||||
public static System.Timers.Timer aTimer = default!;
|
||||
public static Point trayPoint;
|
||||
|
||||
@@ -140,6 +143,8 @@ namespace GHelper
|
||||
|
||||
this.TopMost = Program.config.getConfig("topmost") == 1;
|
||||
|
||||
SetContextMenu();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
@@ -147,6 +152,46 @@ namespace GHelper
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetContextMenu()
|
||||
{
|
||||
|
||||
Padding padding = new Padding(5, 5, 5, 5);
|
||||
|
||||
var menuTitle = new ToolStripMenuItem(Properties.Strings.PerformanceMode);
|
||||
menuTitle.Margin = padding;
|
||||
menuTitle.Enabled = false;
|
||||
contextMenuStrip.Items.Add(menuTitle);
|
||||
|
||||
menuSilent = new ToolStripMenuItem(Properties.Strings.Silent);
|
||||
menuSilent.Click += ButtonSilent_Click;
|
||||
menuSilent.Margin = padding;
|
||||
contextMenuStrip.Items.Add(menuSilent);
|
||||
|
||||
menuBalanced = new ToolStripMenuItem(Properties.Strings.Balanced);
|
||||
menuBalanced.Click += ButtonBalanced_Click;
|
||||
menuBalanced.Margin = padding;
|
||||
contextMenuStrip.Items.Add(menuBalanced);
|
||||
|
||||
menuTurbo = new ToolStripMenuItem(Properties.Strings.Turbo);
|
||||
menuTurbo.Click += ButtonTurbo_Click;
|
||||
menuTurbo.Checked = true;
|
||||
menuTurbo.Margin = padding;
|
||||
contextMenuStrip.Items.Add(menuTurbo);
|
||||
|
||||
contextMenuStrip.ShowCheckMargin = true;
|
||||
contextMenuStrip.RenderMode = ToolStripRenderMode.System;
|
||||
|
||||
if (CheckSystemDarkModeStatus())
|
||||
{
|
||||
contextMenuStrip.BackColor = this.BackColor;
|
||||
contextMenuStrip.ForeColor = this.ForeColor;
|
||||
}
|
||||
|
||||
Program.trayIcon.ContextMenuStrip = contextMenuStrip;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ButtonXGM_Click(object? sender, EventArgs e)
|
||||
@@ -291,7 +336,7 @@ namespace GHelper
|
||||
break;
|
||||
case 1:
|
||||
Logger.WriteLine("Monitor Power On");
|
||||
Program.SetAutoModes(false);
|
||||
Program.SetAutoModes();
|
||||
break;
|
||||
case 2:
|
||||
Logger.WriteLine("Monitor Dimmed");
|
||||
@@ -1029,18 +1074,25 @@ namespace GHelper
|
||||
buttonBalanced.Activated = false;
|
||||
buttonTurbo.Activated = false;
|
||||
|
||||
menuSilent.Checked = false;
|
||||
menuBalanced.Checked = false;
|
||||
menuTurbo.Checked = false;
|
||||
|
||||
switch (PerformanceMode)
|
||||
{
|
||||
case ASUSWmi.PerformanceSilent:
|
||||
buttonSilent.Activated = true;
|
||||
menuSilent.Checked = true;
|
||||
perfName = Properties.Strings.Silent;
|
||||
break;
|
||||
case ASUSWmi.PerformanceTurbo:
|
||||
buttonTurbo.Activated = true;
|
||||
menuTurbo.Checked = true;
|
||||
perfName = Properties.Strings.Turbo;
|
||||
break;
|
||||
default:
|
||||
buttonBalanced.Activated = true;
|
||||
menuBalanced.Checked = true;
|
||||
PerformanceMode = ASUSWmi.PerformanceBalanced;
|
||||
perfName = Properties.Strings.Balanced;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user