mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-22 16:42:21 -05:00
fixed process monitor issue, improve shortcuts and Chrome fix
This commit is contained in:
1 parent
dd9ce932fc
commit
b85d929890
5 files changed
+60
-16
No files matched your search
@@ -21,6 +21,8 @@
|
||||
|
||||
public int AmdPresetId_ApplyOnStartup { get; set; }
|
||||
|
||||
public bool FixChromeFonts { get; set; }
|
||||
|
||||
public Config()
|
||||
{
|
||||
DisplaySettingsDelay = 1000;
|
||||
@@ -29,6 +31,7 @@
|
||||
FormHeight = 600;
|
||||
MinimizeToTray = true;
|
||||
CheckForUpdates = true;
|
||||
FixChromeFonts = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,7 +560,7 @@ namespace ColorControl
|
||||
|
||||
if (!applicableDevices.Any())
|
||||
{
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_poweredOffByScreenSaver && !UserSessionInfo.UserLocalSession)
|
||||
|
||||
@@ -96,6 +96,11 @@ namespace ColorControl
|
||||
chkFixChromeFonts.Enabled = Utils.IsChromeInstalled();
|
||||
if (chkFixChromeFonts.Enabled)
|
||||
{
|
||||
var fixInstalled = Utils.IsChromeFixInstalled();
|
||||
if (_config.FixChromeFonts && !fixInstalled)
|
||||
{
|
||||
Utils.ExecuteElevated(StartUpParams.ActivateChromeFontFixParam);
|
||||
}
|
||||
chkFixChromeFonts.Checked = Utils.IsChromeFixInstalled();
|
||||
}
|
||||
|
||||
@@ -558,9 +563,8 @@ namespace ColorControl
|
||||
{
|
||||
var shortcut = edtShortcut.Text.Trim();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(shortcut) && !shortcut.Contains("+"))
|
||||
if (!Utils.ValidateShortcut(shortcut))
|
||||
{
|
||||
MessageForms.WarningOk("Invalid shortcut. The shortcut should have modifiers and a normal key.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1176,9 +1180,8 @@ namespace ColorControl
|
||||
private void btnSetShortcutLg_Click(object sender, EventArgs e)
|
||||
{
|
||||
var shortcut = edtShortcutLg.Text.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(shortcut) && !shortcut.Contains("+"))
|
||||
if (!Utils.ValidateShortcut(shortcut))
|
||||
{
|
||||
MessageForms.WarningOk("Invalid shortcut. The shortcut should have modifiers and a normal key.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1891,6 +1894,7 @@ See Options to test this functionality."
|
||||
{
|
||||
if (_initialized)
|
||||
{
|
||||
_config.FixChromeFonts = chkFixChromeFonts.Checked;
|
||||
if (chkFixChromeFonts.Checked)
|
||||
{
|
||||
Utils.ExecuteElevated(StartUpParams.ActivateChromeFontFixParam);
|
||||
@@ -1929,9 +1933,8 @@ Do you want to continue?";
|
||||
{
|
||||
var shortcut = edtBlankScreenSaverShortcut.Text.Trim();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(shortcut) && !shortcut.Contains("+"))
|
||||
if (!Utils.ValidateShortcut(shortcut))
|
||||
{
|
||||
MessageForms.WarningOk("Invalid shortcut. The shortcut should have modifiers and a normal key.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2242,9 +2245,8 @@ Do you want to continue?";
|
||||
{
|
||||
var shortcut = edtAmdShortcut.Text.Trim();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(shortcut) && !shortcut.Contains("+"))
|
||||
if (!Utils.ValidateShortcut(shortcut))
|
||||
{
|
||||
MessageForms.WarningOk("Invalid shortcut. The shortcut should have modifiers and a normal key.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+35
-6
@@ -68,7 +68,7 @@ namespace ColorControl
|
||||
|
||||
public static bool ConsoleOpened { get; private set; }
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
@@ -108,6 +108,7 @@ namespace ColorControl
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private static bool WinKeyDown = false;
|
||||
private static UserNotificationState LastNotificationState;
|
||||
private static Keys[] KeysWithoutModifiers = new[] { Keys.F13, Keys.F14, Keys.F15, Keys.F16, Keys.F17, Keys.F18, Keys.F19, Keys.F20, Keys.F21, Keys.F22, Keys.F23, Keys.F24 };
|
||||
|
||||
public static Bitmap SubPixelShift(Bitmap bitmap)
|
||||
{
|
||||
@@ -527,7 +528,7 @@ namespace ColorControl
|
||||
}
|
||||
}
|
||||
|
||||
public static void RegisterShortcut(IntPtr handle, int id, string shortcut, bool clear = false)
|
||||
public static bool RegisterShortcut(IntPtr handle, int id, string shortcut, bool clear = false)
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
@@ -537,8 +538,17 @@ namespace ColorControl
|
||||
if (!string.IsNullOrEmpty(shortcut))
|
||||
{
|
||||
var (mods, key) = ParseShortcut(shortcut);
|
||||
RegisterHotKey(handle, id, mods, key);
|
||||
var result = RegisterHotKey(handle, id, mods, key);
|
||||
if (!result)
|
||||
{
|
||||
var errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
|
||||
Logger.Error($"Could not register shortcut {shortcut}: {errorMessage}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void BuildDropDownMenuEx(ContextMenuStrip mnuParent, string name, Type enumType, EventHandler clickEvent, object tag = null)
|
||||
@@ -671,6 +681,8 @@ namespace ColorControl
|
||||
|
||||
//Debug.WriteLine("KD: " + e.Modifiers + ", " + e.KeyCode);
|
||||
|
||||
var keysWithoutModifiers = new[] { Keys.F12 };
|
||||
|
||||
var shortcutString = (pressedModifiers > 0 ? pressedModifiers.ToString() : "");
|
||||
if (keyEvent.KeyCode == Keys.LWin || WinKeyDown)
|
||||
{
|
||||
@@ -682,12 +694,17 @@ namespace ColorControl
|
||||
shortcutString += "Win";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(shortcutString) && keyEvent.KeyCode != Keys.ControlKey && keyEvent.KeyCode != Keys.ShiftKey && keyEvent.KeyCode != Keys.Menu && keyEvent.KeyCode != Keys.LWin)
|
||||
var empty = string.IsNullOrEmpty(shortcutString);
|
||||
if ((!empty || keysWithoutModifiers.Contains(keyEvent.KeyCode)) && keyEvent.KeyCode != Keys.ControlKey && keyEvent.KeyCode != Keys.ShiftKey && keyEvent.KeyCode != Keys.Menu && keyEvent.KeyCode != Keys.LWin)
|
||||
{
|
||||
shortcutString += " + " + keyEvent.KeyCode.ToString();
|
||||
if (!empty)
|
||||
{
|
||||
shortcutString += " + ";
|
||||
}
|
||||
shortcutString += keyEvent.KeyCode.ToString();
|
||||
}
|
||||
|
||||
if (pressedModifiers == 0 && !WinKeyDown)
|
||||
if (string.IsNullOrEmpty(shortcutString))
|
||||
{
|
||||
keyEvent.SuppressKeyPress = true;
|
||||
}
|
||||
@@ -695,6 +712,18 @@ namespace ColorControl
|
||||
return shortcutString;
|
||||
}
|
||||
|
||||
public static bool ValidateShortcut(string shortcut)
|
||||
{
|
||||
var valid = string.IsNullOrWhiteSpace(shortcut) || shortcut.Contains("+") || shortcut.Contains("F12");
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
MessageForms.WarningOk("Invalid shortcut. The shortcut should have modifiers and a normal key.");
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public static void HandleKeyboardShortcutUp(KeyEventArgs keyEvent)
|
||||
{
|
||||
if (keyEvent.KeyCode == Keys.LWin)
|
||||
|
||||
@@ -172,7 +172,17 @@ namespace LgTv
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var dr = args.GetDataReader())
|
||||
var task = new Task<DataReader>(new Func<DataReader>(args.GetDataReader));
|
||||
task.Start();
|
||||
var result = task.Wait(5000);
|
||||
|
||||
var dr = result ? task.Result : null;
|
||||
if (!result)
|
||||
{
|
||||
throw new Exception("Timeout while reading response, possible disconnect");
|
||||
}
|
||||
|
||||
using (dr)
|
||||
{
|
||||
dr.UnicodeEncoding = UnicodeEncoding.Utf8;
|
||||
var message = dr.ReadString(dr.UnconsumedBufferLength);
|
||||
|
||||
Reference in new issue
Block a user