fixed several issues, add some LG settings

This commit is contained in:
Vincent Maas committed 2022-02-26 14:35:38 +01:00
1 parent b2e7c529a0
commit b8910a3b64
9 files changed
+148 -42

No files matched your search

+2 -2
View File
@@ -18,8 +18,8 @@
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>5.4.0.0</ApplicationVersion>
<Version>5.4.0.0</Version>
<ApplicationVersion>5.5.0.0</ApplicationVersion>
<Version>5.5.0.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
+3 -1
View File
@@ -138,6 +138,7 @@ namespace ColorControl
AddGenericPictureAction("colorGamut", typeof(ColorGamut), title: "Color Gamut");
AddGenericPictureAction("dynamicContrast", typeof(OffToHigh), title: "Dynamic Contrast");
AddGenericPictureAction("gamma", typeof(GammaExp));
AddGenericPictureAction("whiteBalanceColorTemperature", typeof(WhiteBalanceColorTemperature), title: "White Balance Color Temperature");
//AddGenericPictureAction("dynamicColor", typeof(OffToAuto));
//AddGenericPictureAction("superResolution", typeof(OffToAuto));
AddGenericPictureAction("peakBrightness", typeof(OffToHigh), title: "Peak Brightness");
@@ -148,6 +149,7 @@ namespace ColorControl
//AddGenericPictureAction("ambientLightCompensation", typeof(OffToAuto2));
//AddGenericPictureAction("truMotionMode", typeof(TruMotionMode));
AddGenericPictureAction("motionProOLED", typeof(OffToHigh), title: "OLED Motion Pro");
AddGenericPictureAction("motionPro", typeof(OffToOn), title: "Motion Pro");
AddGenericPictureAction("uhdDeepColorHDMI1", typeof(OffToOn), category: "other");
AddGenericPictureAction("uhdDeepColorHDMI2", typeof(OffToOn), category: "other");
AddGenericPictureAction("uhdDeepColorHDMI3", typeof(OffToOn), category: "other");
@@ -702,7 +704,7 @@ namespace ColorControl
var resumeScript = Path.Combine(Program.DataDir, "ResumeScript.bat");
if (File.Exists(resumeScript))
{
Utils.StartProcess(resumeScript);
Utils.StartProcess(resumeScript, hidden: true);
}
}
+1 -1
View File
@@ -495,7 +495,7 @@ namespace ColorControl
var standByScript = Path.Combine(Program.DataDir, "StandByScript.bat");
if (File.Exists(standByScript))
{
Utils.StartProcess(standByScript);
Utils.StartProcess(standByScript, hidden: true);
}
Logger.Debug("Powering off tv...");
+2
View File
@@ -15,10 +15,12 @@ namespace ColorControl
public string GameBarShortcut { get; set; }
public int GameBarTop { get; set; }
public int GameBarLeft { get; set; }
public int ShutdownDelay { get; set; }
public LgServiceConfig()
{
PowerOnDelayAfterResume = 5000;
ShutdownDelay = 1000;
DeviceSearchKey = "[LG]";
PowerOnRetries = 10;
Devices = new List<LgDevice>();
+56 -4
View File
@@ -172,6 +172,9 @@
this.lblFixChromeFontsDescription = new System.Windows.Forms.Label();
this.chkFixChromeFonts = new System.Windows.Forms.CheckBox();
this.grpLGOptions = new System.Windows.Forms.GroupBox();
this.lblLgOptionShutdownDelayHelp = new System.Windows.Forms.Label();
this.edtLgOptionShutdownDelay = new System.Windows.Forms.NumericUpDown();
this.lblLgOptionShutdownDelay = new System.Windows.Forms.Label();
this.chkLgShowAdvancedActions = new System.Windows.Forms.CheckBox();
this.btnLGTestPower = new System.Windows.Forms.Button();
this.lblLgMaxPowerOnRetriesDescription = new System.Windows.Forms.Label();
@@ -214,6 +217,7 @@
((System.ComponentModel.ISupportInitialize)(this.pbGradient)).BeginInit();
this.grpMiscellaneousOptions.SuspendLayout();
this.grpLGOptions.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.edtLgOptionShutdownDelay)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.edtLgMaxPowerOnRetries)).BeginInit();
this.grpHDROptions.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.edtDelayDisplaySettings)).BeginInit();
@@ -1732,7 +1736,7 @@
this.grpMiscellaneousOptions.Controls.Add(this.edtBlankScreenSaverShortcut);
this.grpMiscellaneousOptions.Controls.Add(this.lblFixChromeFontsDescription);
this.grpMiscellaneousOptions.Controls.Add(this.chkFixChromeFonts);
this.grpMiscellaneousOptions.Location = new System.Drawing.Point(7, 292);
this.grpMiscellaneousOptions.Location = new System.Drawing.Point(7, 332);
this.grpMiscellaneousOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.grpMiscellaneousOptions.Name = "grpMiscellaneousOptions";
this.grpMiscellaneousOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
@@ -1797,6 +1801,9 @@
//
// grpLGOptions
//
this.grpLGOptions.Controls.Add(this.lblLgOptionShutdownDelayHelp);
this.grpLGOptions.Controls.Add(this.edtLgOptionShutdownDelay);
this.grpLGOptions.Controls.Add(this.lblLgOptionShutdownDelay);
this.grpLGOptions.Controls.Add(this.chkLgShowAdvancedActions);
this.grpLGOptions.Controls.Add(this.btnLGTestPower);
this.grpLGOptions.Controls.Add(this.lblLgMaxPowerOnRetriesDescription);
@@ -1806,15 +1813,56 @@
this.grpLGOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.grpLGOptions.Name = "grpLGOptions";
this.grpLGOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.grpLGOptions.Size = new System.Drawing.Size(470, 149);
this.grpLGOptions.Size = new System.Drawing.Size(470, 190);
this.grpLGOptions.TabIndex = 4;
this.grpLGOptions.TabStop = false;
this.grpLGOptions.Text = "LG controller";
//
// lblLgOptionShutdownDelayHelp
//
this.lblLgOptionShutdownDelayHelp.AutoSize = true;
this.lblLgOptionShutdownDelayHelp.Location = new System.Drawing.Point(7, 94);
this.lblLgOptionShutdownDelayHelp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblLgOptionShutdownDelayHelp.Name = "lblLgOptionShutdownDelayHelp";
this.lblLgOptionShutdownDelayHelp.Size = new System.Drawing.Size(385, 15);
this.lblLgOptionShutdownDelayHelp.TabIndex = 11;
this.lblLgOptionShutdownDelayHelp.Text = "This delay may prevent the tv from powering off when restarting the pc.";
//
// edtLgOptionShutdownDelay
//
this.edtLgOptionShutdownDelay.Increment = new decimal(new int[] {
100,
0,
0,
0});
this.edtLgOptionShutdownDelay.Location = new System.Drawing.Point(349, 68);
this.edtLgOptionShutdownDelay.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.edtLgOptionShutdownDelay.Maximum = new decimal(new int[] {
5000,
0,
0,
0});
this.edtLgOptionShutdownDelay.Name = "edtLgOptionShutdownDelay";
this.edtLgOptionShutdownDelay.ReadOnly = true;
this.edtLgOptionShutdownDelay.Size = new System.Drawing.Size(86, 23);
this.edtLgOptionShutdownDelay.TabIndex = 10;
this.edtLgOptionShutdownDelay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.edtLgOptionShutdownDelay.ValueChanged += new System.EventHandler(this.edtLgOptionShutdownDelay_ValueChanged);
//
// lblLgOptionShutdownDelay
//
this.lblLgOptionShutdownDelay.AutoSize = true;
this.lblLgOptionShutdownDelay.Location = new System.Drawing.Point(7, 70);
this.lblLgOptionShutdownDelay.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblLgOptionShutdownDelay.Name = "lblLgOptionShutdownDelay";
this.lblLgOptionShutdownDelay.Size = new System.Drawing.Size(249, 15);
this.lblLgOptionShutdownDelay.TabIndex = 9;
this.lblLgOptionShutdownDelay.Text = "Delay when shutting down/restarting pc (ms):";
//
// chkLgShowAdvancedActions
//
this.chkLgShowAdvancedActions.AutoSize = true;
this.chkLgShowAdvancedActions.Location = new System.Drawing.Point(10, 112);
this.chkLgShowAdvancedActions.Location = new System.Drawing.Point(8, 155);
this.chkLgShowAdvancedActions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.chkLgShowAdvancedActions.Name = "chkLgShowAdvancedActions";
this.chkLgShowAdvancedActions.Size = new System.Drawing.Size(419, 19);
@@ -1825,7 +1873,7 @@
//
// btnLGTestPower
//
this.btnLGTestPower.Location = new System.Drawing.Point(10, 78);
this.btnLGTestPower.Location = new System.Drawing.Point(8, 121);
this.btnLGTestPower.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnLGTestPower.Name = "btnLGTestPower";
this.btnLGTestPower.Size = new System.Drawing.Size(167, 27);
@@ -2182,6 +2230,7 @@
this.grpMiscellaneousOptions.PerformLayout();
this.grpLGOptions.ResumeLayout(false);
this.grpLGOptions.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.edtLgOptionShutdownDelay)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.edtLgMaxPowerOnRetries)).EndInit();
this.grpHDROptions.ResumeLayout(false);
this.grpHDROptions.PerformLayout();
@@ -2368,6 +2417,9 @@
private System.Windows.Forms.TextBox edtLgGameBarShortcut;
private System.Windows.Forms.CheckBox chkGdiScaling;
private System.Windows.Forms.Button btnLgDeviceOptionsHelp;
private System.Windows.Forms.Label lblLgOptionShutdownDelayHelp;
private System.Windows.Forms.NumericUpDown edtLgOptionShutdownDelay;
private System.Windows.Forms.Label lblLgOptionShutdownDelay;
}
}
+51 -9
View File
@@ -16,6 +16,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -50,6 +51,7 @@ namespace ColorControl
private ToolStripMenuItem _lgTrayMenu;
private StartUpParams StartUpParams { get; }
public string _lgTabMessage { get; private set; }
private AmdService _amdService;
private bool _skipResize;
@@ -184,6 +186,7 @@ namespace ColorControl
FillLgPresets();
edtLgMaxPowerOnRetries.Value = _lgService.Config.PowerOnRetries;
edtLgOptionShutdownDelay.Value = _lgService.Config.ShutdownDelay;
edtLgDeviceFilter.Text = _lgService.Config.DeviceSearchKey;
chkLgShowAdvancedActions.Checked = _lgService.Config.ShowAdvancedActions;
@@ -478,22 +481,42 @@ namespace ColorControl
{
Logger.Debug($"MainForm_FormClosing: SystemShutdown");
if (_restartDetector != null && (_restartDetector.RestartDetected || _restartDetector.IsRebootInProgress()))
{
Logger.Debug("Not powering off because of a restart");
}
else if (NativeMethods.GetAsyncKeyState(NativeConstants.VK_CONTROL) < 0 || NativeMethods.GetAsyncKeyState(NativeConstants.VK_RCONTROL) < 0)
if (NativeMethods.GetAsyncKeyState(NativeConstants.VK_CONTROL) < 0 || NativeMethods.GetAsyncKeyState(NativeConstants.VK_RCONTROL) < 0)
{
Logger.Debug("Not powering off because CONTROL-key is down");
return;
}
else
var sleep = _lgService.Config.ShutdownDelay;
Logger.Debug($"MainForm_FormClosing: Waiting for {sleep} milliseconds...");
NativeMethods.SetThreadExecutionState(NativeConstants.ES_CONTINUOUS | NativeConstants.ES_SYSTEM_REQUIRED | NativeConstants.ES_AWAYMODE_REQUIRED);
try
{
while (sleep > 0 && _restartDetector?.PowerOffDetected == false)
{
Thread.Sleep(100);
if (_restartDetector != null && (_restartDetector.RestartDetected || _restartDetector.IsRebootInProgress()))
{
Logger.Debug("Not powering off because of a restart");
return;
}
sleep -= 100;
}
Logger.Debug("Powering off tv...");
var task = _lgService.PowerOffOnShutdownOrResume();
Utils.WaitForTask(task);
Logger.Debug("Done powering off tv");
//ExecPowerOffPreset(true);
}
finally
{
NativeMethods.SetThreadExecutionState(NativeConstants.ES_CONTINUOUS);
}
}
}
@@ -1384,7 +1407,13 @@ namespace ColorControl
chkLgRemoteControlShow.Checked = _lgService.Config.ShowRemoteControl;
scLgController.Panel2Collapsed = !_lgService.Config.ShowRemoteControl;
Utils.BuildComboBox<PresetTriggerType>(cbxLgPresetTrigger, PresetTriggerType.Resume, PresetTriggerType.Shutdown, PresetTriggerType.Standby, PresetTriggerType.Startup, PresetTriggerType.Reserved5, PresetTriggerType.ScreensaverStart, PresetTriggerType.ScreensaverStop);
Utils.BuildComboBox(cbxLgPresetTrigger, PresetTriggerType.Resume, PresetTriggerType.Shutdown, PresetTriggerType.Standby, PresetTriggerType.Startup, PresetTriggerType.Reserved5, PresetTriggerType.ScreensaverStart, PresetTriggerType.ScreensaverStop);
if (!string.IsNullOrEmpty(_lgTabMessage))
{
MessageForms.WarningOk(_lgTabMessage);
_lgTabMessage = null;
}
}
private void InitOptionsTab()
@@ -1452,7 +1481,16 @@ namespace ColorControl
if (!devices.Any())
{
MessageForms.WarningOk("It seems there's no LG TV available! Please make sure it's connected to the same network as this PC.");
var message = "It seems there's no LG TV available! Please make sure it's connected to the same network as this PC.";
if (tcMain.SelectedTab == tabLG)
{
MessageForms.WarningOk(message);
}
else
{
_lgTabMessage = message;
}
}
if (cbxLgApps.Items.Count == 0 && device != null)
@@ -2137,7 +2175,6 @@ Do you want to continue?";
preset.ditheringMode = uint.Parse(item.Tag.ToString());
AddOrUpdateItem();
}
private void btnLGRemoteControl_Click(object sender, EventArgs e)
@@ -3090,5 +3127,10 @@ The InStart and Software Update items are now visible under the Expert-button."
- power off on shutdown: because this app cannot detect a restart, restarting could also trigger this. Hold down Ctrl on restart to prevent power off.
");
}
private void edtLgOptionShutdownDelay_ValueChanged(object sender, EventArgs e)
{
_lgService.Config.ShutdownDelay = (int)edtLgOptionShutdownDelay.Value;
}
}
}
+10 -21
View File
@@ -9,7 +9,8 @@ namespace ColorControl
public class RestartDetector : IDisposable
{
public bool RestartDetected { get; private set; }
public bool PowerOffDetected { get; private set; }
private EventLogWatcher watcher = null;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@@ -17,8 +18,7 @@ namespace ColorControl
{
try
{
EventLogQuery subscriptionQuery = new EventLogQuery(
"System", PathType.LogName, "*[System[Provider[@Name='USER32'] and (EventID=1074)]]");
EventLogQuery subscriptionQuery = new EventLogQuery("System", PathType.LogName, "*[System[Provider[@Name='USER32'] and (EventID=1074)]]");
watcher = new EventLogWatcher(subscriptionQuery);
@@ -47,6 +47,7 @@ namespace ColorControl
public void EventLogEventRead(object obj, EventRecordWrittenEventArgs arg)
{
RestartDetected = false;
PowerOffDetected = false;
try
{
Logger.Debug("Logging event: " + arg);
@@ -60,26 +61,14 @@ namespace ColorControl
{
RestartDetected = true;
break;
}
}
if (x.Value.Equals("power off"))
{
PowerOffDetected = true;
break;
}
}
}
//if (arg.EventRecord != null)
//{
// String[] xPathRefs = new String[1];
// xPathRefs[0] = "Event/EventData/Data";
// IEnumerable<String> xPathEnum = xPathRefs;
// EventLogPropertySelector logPropertyContext = new EventLogPropertySelector(xPathEnum);
// IList<object> logEventProps = ((EventLogRecord)arg.EventRecord).GetPropertyValues(logPropertyContext);
// string[] eventData = (string[])logEventProps[0];
// foreach (string attribute in eventData)
// {
// if (attribute.Contains("restart")) { restart = true; break; }
// }
//}
}
catch (Exception)
{
+9 -3
View File
@@ -455,7 +455,13 @@ namespace ColorControl
{
var val = value.ToInt32(CultureInfo.InvariantCulture);
var memInfo = enumType.GetMember(enumType.GetEnumName(val));
var enumName = enumType.GetEnumName(val);
if (enumName == null)
{
return string.Empty;
}
var memInfo = enumType.GetMember(enumName);
var descriptionAttribute = memInfo[0]
.GetCustomAttributes(typeof(DescriptionAttribute), false)
.FirstOrDefault() as DescriptionAttribute;
@@ -915,9 +921,9 @@ namespace ColorControl
return null;
}
public static void StartProcess(string fileName, string arguments = null)
public static void StartProcess(string fileName, string arguments = null, bool hidden = false)
{
var process = Process.Start(fileName, arguments);
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true, WindowStyle = hidden ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal });
}
public static string GetResourceFile(string resourceName)
+14 -1
View File
@@ -77,7 +77,8 @@ namespace LgTv
auto,
extended,
wide,
srgb
srgb,
native
}
public enum EnergySaving
@@ -100,9 +101,21 @@ namespace LgTv
public enum TruMotionMode
{
off,
smooth,
clear,
clearPlus,
user
}
public enum WhiteBalanceColorTemperature
{
cool,
medium,
warm1,
warm2,
warm3
}
public enum FalseToTrue
{
[Description("Disabled")]