mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-21 08:09:49 -05:00
add sorting of list views, improve refresh rate/color depth apply order, fix manually turned off tv's
This commit is contained in:
1 parent
66e682ba3d
commit
c1ace0bdd5
13 files changed
+315
-48
No files matched your search
@@ -18,8 +18,8 @@
|
||||
<PublisherName>Maassoft</PublisherName>
|
||||
<Company>Maassoft</Company>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>5.7.0.0</ApplicationVersion>
|
||||
<Version>5.7.0.0</Version>
|
||||
<ApplicationVersion>5.7.1.0</ApplicationVersion>
|
||||
<Version>5.7.1.0</Version>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>false</BootstrapperEnabled>
|
||||
|
||||
+15
-1
@@ -1,5 +1,13 @@
|
||||
namespace ColorControl
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ColorControl
|
||||
{
|
||||
public class ListViewSortState
|
||||
{
|
||||
public SortOrder SortOrder { get; set; }
|
||||
public int SortIndex { get; set; }
|
||||
}
|
||||
|
||||
public class Config
|
||||
{
|
||||
public bool StartMinimized { get; set; }
|
||||
@@ -14,6 +22,9 @@
|
||||
public int AmdPresetId_ApplyOnStartup { get; set; }
|
||||
public bool FixChromeFonts { get; set; }
|
||||
public bool UseGdiScaling { get; set; }
|
||||
public ListViewSortState NvPresetsSortState { get; set; }
|
||||
public ListViewSortState AmdPresetsSortState { get; set; }
|
||||
public ListViewSortState LgPresetsSortState { get; set; }
|
||||
|
||||
public Config()
|
||||
{
|
||||
@@ -25,6 +36,9 @@
|
||||
CheckForUpdates = true;
|
||||
FixChromeFonts = false;
|
||||
UseGdiScaling = true;
|
||||
LgPresetsSortState = new ListViewSortState();
|
||||
NvPresetsSortState = new ListViewSortState();
|
||||
AmdPresetsSortState = new ListViewSortState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace ColorControl
|
||||
}
|
||||
}
|
||||
|
||||
protected bool SetRefreshRateInternal(string displayName, uint refreshRate, bool portrait, int horizontal, int vertical)
|
||||
protected bool SetRefreshRateInternal(string displayName, uint refreshRate, bool portrait, int horizontal, int vertical, bool updateRegistry = false)
|
||||
{
|
||||
uint i = 0;
|
||||
DEVMODEA devMode;
|
||||
@@ -64,7 +64,7 @@ namespace ColorControl
|
||||
{
|
||||
IntPtr bla = Marshal.AllocHGlobal(Marshal.SizeOf(devMode));
|
||||
Marshal.StructureToPtr(devMode, bla, false);
|
||||
var result = NativeMethods.ChangeDisplaySettingsExA(displayName, bla, IntPtr.Zero, 0, IntPtr.Zero);
|
||||
var result = NativeMethods.ChangeDisplaySettingsExA(displayName, bla, IntPtr.Zero, updateRegistry ? (uint)NativeConstants.CDS_UPDATEREGISTRY : 0, IntPtr.Zero);
|
||||
if (result != NativeConstants.DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
Logger.Error($"Could not set refreshrate {refreshRate} on display {displayName} because ChangeDisplaySettingsExA returned a non-zero return code: {result}");
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace ColorControl
|
||||
public string Category { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int CurrentValue { get; set; }
|
||||
public int NumberOfValues { get; set; }
|
||||
public LgPreset Preset { get; set; }
|
||||
}
|
||||
|
||||
@@ -170,7 +171,10 @@ namespace ColorControl
|
||||
AddGenericPictureAction("hdmiPcMode_hdmi2", typeof(FalseToTrue), category: "other");
|
||||
AddGenericPictureAction("hdmiPcMode_hdmi3", typeof(FalseToTrue), category: "other");
|
||||
AddGenericPictureAction("hdmiPcMode_hdmi4", typeof(FalseToTrue), category: "other");
|
||||
AddGenericPictureAction("adjustingLuminance", minValue: -50, maxValue: 50);
|
||||
AddGenericPictureAction("adjustingLuminance", minValue: -50, maxValue: 50, numberOfValues: 22);
|
||||
AddGenericPictureAction("whiteBalanceBlue", minValue: -50, maxValue: 50, numberOfValues: 22);
|
||||
AddGenericPictureAction("whiteBalanceGreen", minValue: -50, maxValue: 50, numberOfValues: 22);
|
||||
AddGenericPictureAction("whiteBalanceRed", minValue: -50, maxValue: 50, numberOfValues: 22);
|
||||
//AddGenericPictureAction("wb20PointsGammaValue", minValue: -50, maxValue: 50);
|
||||
AddInvokableAction("turnScreenOff", new Func<Dictionary<string, object>, bool>(TurnScreenOffAction));
|
||||
AddInvokableAction("turnScreenOn", new Func<Dictionary<string, object>, bool>(TurnScreenOnAction));
|
||||
@@ -212,7 +216,7 @@ namespace ColorControl
|
||||
_invokableActions.Add(action);
|
||||
}
|
||||
|
||||
private void AddGenericPictureAction(string name, Type type = null, decimal minValue = 0, decimal maxValue = 0, string category = "picture", string title = null)
|
||||
private void AddGenericPictureAction(string name, Type type = null, decimal minValue = 0, decimal maxValue = 0, string category = "picture", string title = null, int numberOfValues = 1)
|
||||
{
|
||||
var action = new InvokableAction
|
||||
{
|
||||
@@ -221,6 +225,7 @@ namespace ColorControl
|
||||
EnumType = type,
|
||||
MinValue = minValue,
|
||||
MaxValue = maxValue,
|
||||
NumberOfValues = numberOfValues,
|
||||
Category = category,
|
||||
Title = title == null ? Utils.FirstCharUpperCase(name) : title
|
||||
};
|
||||
@@ -373,6 +378,10 @@ namespace ColorControl
|
||||
PoweredOffBy = PowerOffSource.Unknown;
|
||||
_poweredOffViaAppDateTime = DateTimeOffset.MinValue;
|
||||
}
|
||||
else if (payload.processing != null && ((string)payload.processing).Equals("Request Power Off", StringComparison.Ordinal))
|
||||
{
|
||||
PoweredOffBy = PoweredOffViaApp ? PowerOffSource.App : PowerOffSource.Manually;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PoweredOffBy = PoweredOffViaApp ? PowerOffSource.App : PowerOffSource.Manually;
|
||||
|
||||
@@ -210,6 +210,7 @@ namespace ColorControl
|
||||
}
|
||||
|
||||
list.Add(GeneratePreset("Power", step: "POWER"));
|
||||
list.Add(GeneratePreset("Wol", step: "WOL"));
|
||||
list.Add(GeneratePreset("Home", appId: "com.webos.app.home", key: Keys.H));
|
||||
list.Add(GeneratePreset("Settings", appId: "com.palm.app.settings", key: Keys.S));
|
||||
list.Add(GeneratePreset("TV Guide", appId: "com.webos.app.livemenu"));
|
||||
@@ -867,14 +868,6 @@ namespace ColorControl
|
||||
sleep -= 100;
|
||||
}
|
||||
}
|
||||
else if (state == PowerOnOffState.StandBy)
|
||||
{
|
||||
var standByScript = Path.Combine(Program.DataDir, "StandByScript.bat");
|
||||
if (File.Exists(standByScript))
|
||||
{
|
||||
Utils.StartProcess(standByScript, hidden: true);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug("Powering off tv(s)...");
|
||||
var tasks = new List<Task>();
|
||||
@@ -885,6 +878,15 @@ namespace ColorControl
|
||||
tasks.Add(task);
|
||||
}
|
||||
|
||||
if (state == PowerOnOffState.StandBy)
|
||||
{
|
||||
var standByScript = Path.Combine(Program.DataDir, "StandByScript.bat");
|
||||
if (File.Exists(standByScript))
|
||||
{
|
||||
Utils.StartProcess(standByScript, hidden: true, wait: true);
|
||||
}
|
||||
}
|
||||
|
||||
var waitTask = Task.WhenAll(tasks.ToArray());
|
||||
Utils.WaitForTask(waitTask);
|
||||
Logger.Debug("Done powering off tv(s)");
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
using System.Collections;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ColorControl
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is an implementation of the 'IComparer' interface.
|
||||
/// </summary>
|
||||
public class ListViewColumnSorter : IComparer
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the column to be sorted
|
||||
/// </summary>
|
||||
private int ColumnToSort;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the order in which to sort (i.e. 'Ascending').
|
||||
/// </summary>
|
||||
private SortOrder OrderOfSort;
|
||||
|
||||
/// <summary>
|
||||
/// Case insensitive comparer object
|
||||
/// </summary>
|
||||
private CaseInsensitiveComparer ObjectCompare;
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor. Initializes various elements
|
||||
/// </summary>
|
||||
public ListViewColumnSorter()
|
||||
{
|
||||
// Initialize the column to '0'
|
||||
ColumnToSort = 0;
|
||||
|
||||
// Initialize the sort order to 'none'
|
||||
OrderOfSort = SortOrder.None;
|
||||
|
||||
// Initialize the CaseInsensitiveComparer object
|
||||
ObjectCompare = new CaseInsensitiveComparer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison.
|
||||
/// </summary>
|
||||
/// <param name="x">First object to be compared</param>
|
||||
/// <param name="y">Second object to be compared</param>
|
||||
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
int compareResult;
|
||||
ListViewItem listviewX, listviewY;
|
||||
|
||||
// Cast the objects to be compared to ListViewItem objects
|
||||
listviewX = (ListViewItem)x;
|
||||
listviewY = (ListViewItem)y;
|
||||
|
||||
if (listviewX.Tag == null)
|
||||
{
|
||||
compareResult = OrderOfSort == SortOrder.Ascending ? -1 : 1;
|
||||
}
|
||||
else if (listviewY.Tag == null)
|
||||
{
|
||||
compareResult = OrderOfSort == SortOrder.Ascending ? 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compare the two items
|
||||
compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
|
||||
}
|
||||
|
||||
// Calculate correct return value based on object comparison
|
||||
if (OrderOfSort == SortOrder.Ascending)
|
||||
{
|
||||
// Ascending sort is selected, return normal result of compare operation
|
||||
return compareResult;
|
||||
}
|
||||
else if (OrderOfSort == SortOrder.Descending)
|
||||
{
|
||||
// Descending sort is selected, return negative result of compare operation
|
||||
return (-compareResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return '0' to indicate they are equal
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0').
|
||||
/// </summary>
|
||||
public int SortColumn
|
||||
{
|
||||
set
|
||||
{
|
||||
ColumnToSort = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return ColumnToSort;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending').
|
||||
/// </summary>
|
||||
public SortOrder Order
|
||||
{
|
||||
set
|
||||
{
|
||||
OrderOfSort = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return OrderOfSort;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+3
@@ -655,6 +655,7 @@
|
||||
this.lvNvPresets.TabIndex = 0;
|
||||
this.lvNvPresets.UseCompatibleStateImageBehavior = false;
|
||||
this.lvNvPresets.View = System.Windows.Forms.View.Details;
|
||||
this.lvNvPresets.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvLgPresets_ColumnClick);
|
||||
this.lvNvPresets.SelectedIndexChanged += new System.EventHandler(this.lvNvPresets_SelectedIndexChanged);
|
||||
this.lvNvPresets.DoubleClick += new System.EventHandler(this.btnApply_Click);
|
||||
//
|
||||
@@ -966,6 +967,7 @@
|
||||
this.lvAmdPresets.TabIndex = 10;
|
||||
this.lvAmdPresets.UseCompatibleStateImageBehavior = false;
|
||||
this.lvAmdPresets.View = System.Windows.Forms.View.Details;
|
||||
this.lvAmdPresets.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvLgPresets_ColumnClick);
|
||||
this.lvAmdPresets.SelectedIndexChanged += new System.EventHandler(this.lvAmdPresets_SelectedIndexChanged);
|
||||
this.lvAmdPresets.DoubleClick += new System.EventHandler(this.btnApplyAmd_Click);
|
||||
//
|
||||
@@ -1338,6 +1340,7 @@
|
||||
this.lvLgPresets.TabIndex = 8;
|
||||
this.lvLgPresets.UseCompatibleStateImageBehavior = false;
|
||||
this.lvLgPresets.View = System.Windows.Forms.View.Details;
|
||||
this.lvLgPresets.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvLgPresets_ColumnClick);
|
||||
this.lvLgPresets.SelectedIndexChanged += new System.EventHandler(this.lvLgPresets_SelectedIndexChanged);
|
||||
this.lvLgPresets.DoubleClick += new System.EventHandler(this.lvLgPresets_DoubleClick);
|
||||
//
|
||||
|
||||
@@ -8,6 +8,7 @@ using NvAPIWrapper.Display;
|
||||
using NvAPIWrapper.Native.Display;
|
||||
using NWin32;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
@@ -140,6 +141,8 @@ namespace ColorControl
|
||||
FillNvPresets();
|
||||
Logger.Debug("Initializing NVIDIA...Done.");
|
||||
|
||||
InitSortState(lvNvPresets, _config.NvPresetsSortState);
|
||||
|
||||
_nvService.AfterApplyPreset += NvServiceAfterApplyPreset;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -162,6 +165,8 @@ namespace ColorControl
|
||||
_amdService = new AmdService(_dataDir);
|
||||
FillAmdPresets();
|
||||
|
||||
InitSortState(lvAmdPresets, _config.AmdPresetsSortState);
|
||||
|
||||
_amdService.AfterApplyPreset += AmdServiceAfterApplyPreset;
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -191,6 +196,8 @@ namespace ColorControl
|
||||
edtLgDeviceFilter.Text = _lgService.Config.DeviceSearchKey;
|
||||
chkLgShowAdvancedActions.Checked = _lgService.Config.ShowAdvancedActions;
|
||||
|
||||
InitSortState(lvLgPresets, _config.LgPresetsSortState);
|
||||
|
||||
var values = Enum.GetValues(typeof(ButtonType));
|
||||
foreach (var button in values)
|
||||
{
|
||||
@@ -229,6 +236,14 @@ namespace ColorControl
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSortState(ListView listView, ListViewSortState sortState)
|
||||
{
|
||||
var sorter = new ListViewColumnSorter();
|
||||
sorter.SortColumn = sortState.SortIndex;
|
||||
sorter.Order = sortState.SortOrder;
|
||||
listView.ListViewItemSorter = sorter;
|
||||
}
|
||||
|
||||
private void Invoke()
|
||||
{
|
||||
BeginInvoke(() => ToggleGameBar());
|
||||
@@ -494,9 +509,24 @@ namespace ColorControl
|
||||
_amdService?.GlobalSave();
|
||||
_lgService?.GlobalSave();
|
||||
|
||||
SaveSortState(lvNvPresets.ListViewItemSorter, _config.NvPresetsSortState);
|
||||
SaveSortState(lvAmdPresets.ListViewItemSorter, _config.AmdPresetsSortState);
|
||||
SaveSortState(lvLgPresets.ListViewItemSorter, _config.LgPresetsSortState);
|
||||
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
private void SaveSortState(IComparer comparer, ListViewSortState sortState)
|
||||
{
|
||||
if (!(comparer is ListViewColumnSorter sorter))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sortState.SortOrder = sorter.Order;
|
||||
sortState.SortIndex = sorter.SortColumn;
|
||||
}
|
||||
|
||||
private void lvNvPresets_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var preset = GetSelectedNvPreset();
|
||||
@@ -1879,22 +1909,46 @@ namespace ColorControl
|
||||
{
|
||||
if (action.MinValue != action.MaxValue)
|
||||
{
|
||||
var values = MessageForms.ShowDialog("Enter value", new[] {
|
||||
new MessageForms.FieldDefinition
|
||||
List<MessageForms.FieldDefinition> fields = new();
|
||||
|
||||
if (action.NumberOfValues == 1)
|
||||
{
|
||||
fields.Add(new MessageForms.FieldDefinition
|
||||
{
|
||||
Label = "Enter desired " + item.Text,
|
||||
FieldType = MessageForms.FieldType.Numeric,
|
||||
MinValue = action.MinValue,
|
||||
MaxValue = action.MaxValue
|
||||
}
|
||||
});
|
||||
MaxValue = action.MaxValue,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var array = Enumerable.Range(0, action.NumberOfValues);
|
||||
|
||||
fields.AddRange(array.Select(i => new MessageForms.FieldDefinition
|
||||
{
|
||||
Label = "Value for " + i,
|
||||
FieldType = MessageForms.FieldType.Numeric,
|
||||
MinValue = action.MinValue,
|
||||
MaxValue = action.MaxValue,
|
||||
}));
|
||||
}
|
||||
|
||||
var values = MessageForms.ShowDialog("Enter value", fields);
|
||||
|
||||
if (!values.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
value = values.First().Value.ToString();
|
||||
if (values.Count > 1)
|
||||
{
|
||||
value = string.Join("; ", values.Select(v => v.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = values.First().Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1995,7 +2049,7 @@ namespace ColorControl
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(device.PowerOnAfterResume || device.PowerOnAfterStartup || device.PowerSwitchOnScreenSaver))
|
||||
if (e.Index is 0 or 1 or 4 or 7 && !(device.PowerOnAfterResume || device.PowerOnAfterStartup || device.PowerSwitchOnScreenSaver || device.PowerByWindows))
|
||||
{
|
||||
MessageForms.InfoOk(
|
||||
@"Be sure to activate the following setting on the TV, or the app will not be able to wake the TV:
|
||||
@@ -3151,5 +3205,38 @@ The InStart and Software Update items are now visible under the Expert-button."
|
||||
|
||||
_lgService.SelectedDevice.HDMIPortNumber = cbxLgPcHdmiPort.SelectedIndex;
|
||||
}
|
||||
|
||||
private void lvLgPresets_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
var listView = (ListView)sender;
|
||||
var sorter = (ListViewColumnSorter)listView.ListViewItemSorter;
|
||||
|
||||
// Determine if clicked column is already the column that is being sorted.
|
||||
if (e.Column == sorter.SortColumn)
|
||||
{
|
||||
//if (sorter.Order == SortOrder.None)
|
||||
//{
|
||||
// sorter.Order = SortOrder.Ascending;
|
||||
//}
|
||||
// Reverse the current sort direction for this column.
|
||||
if (sorter.Order == SortOrder.Ascending)
|
||||
{
|
||||
sorter.Order = SortOrder.Descending;
|
||||
}
|
||||
else
|
||||
{
|
||||
sorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the column number that is to be sorted; default to ascending.
|
||||
sorter.SortColumn = e.Column;
|
||||
sorter.Order = SortOrder.Ascending;
|
||||
}
|
||||
|
||||
// Perform the sort with these new sort options.
|
||||
listView.Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace ColorControl
|
||||
public IEnumerable<string> Values { get; set; }
|
||||
public decimal MinValue { get; set; }
|
||||
public decimal MaxValue { get; set; }
|
||||
public int NumberOfValues { get; set; }
|
||||
public object Value { get; set; }
|
||||
}
|
||||
|
||||
|
||||
+29
-23
@@ -211,6 +211,13 @@ namespace ColorControl
|
||||
|
||||
SetCurrentDisplay(preset);
|
||||
|
||||
var display = GetCurrentDisplay();
|
||||
|
||||
if (display == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var hdrEnabled = IsHDREnabled();
|
||||
|
||||
var newHdrEnabled = preset.applyHDR && (preset.HDREnabled || (preset.toggleHDR && !hdrEnabled));
|
||||
@@ -218,17 +225,20 @@ namespace ColorControl
|
||||
|
||||
if (preset.applyColorData && (ColorDataDiffers(preset.colorData) || (!newHdrEnabled && preset.applyColorData && preset.colorData.Colorimetry != ColorDataColorimetry.Auto)))
|
||||
{
|
||||
var display = GetCurrentDisplay();
|
||||
if (display == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if (hdrEnabled)
|
||||
//{
|
||||
// SetHDRState(display, false);
|
||||
|
||||
if (hdrEnabled)
|
||||
{
|
||||
SetHDRState(display, false);
|
||||
// applyHdr = false;
|
||||
//}
|
||||
|
||||
applyHdr = false;
|
||||
if (preset.applyRefreshRate)
|
||||
{
|
||||
var timing = display.DisplayDevice.CurrentTiming;
|
||||
if (preset.refreshRate < timing.Extra.RefreshRate)
|
||||
{
|
||||
SetRefreshRate(preset.refreshRate, true);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
@@ -241,22 +251,16 @@ namespace ColorControl
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (hdrEnabled && newHdrEnabled)
|
||||
{
|
||||
SetHDRState(display, true, useSwitch: appContext.StartUpParams.NoGui);
|
||||
//if (hdrEnabled && newHdrEnabled)
|
||||
//{
|
||||
// SetHDRState(display, true, useSwitch: appContext.StartUpParams.NoGui);
|
||||
|
||||
applyHdr = false;
|
||||
}
|
||||
// applyHdr = false;
|
||||
//}
|
||||
}
|
||||
|
||||
if (applyHdr)
|
||||
{
|
||||
var display = GetCurrentDisplay();
|
||||
if (display == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var colorData = preset.applyColorData ? preset.colorData : display.DisplayDevice.CurrentColorData;
|
||||
|
||||
SetHDRState(display, newHdrEnabled, colorData, appContext.StartUpParams.NoGui);
|
||||
@@ -264,7 +268,9 @@ namespace ColorControl
|
||||
|
||||
if (preset.applyRefreshRate)
|
||||
{
|
||||
if (!SetRefreshRate(preset.refreshRate))
|
||||
var timing = display.DisplayDevice.CurrentTiming;
|
||||
|
||||
if (preset.refreshRate != timing.Extra.RefreshRate && !SetRefreshRate(preset.refreshRate, true))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
@@ -425,7 +431,7 @@ namespace ColorControl
|
||||
return dither;
|
||||
}
|
||||
|
||||
public bool SetRefreshRate(uint refreshRate)
|
||||
public bool SetRefreshRate(uint refreshRate, bool updateRegistry = false)
|
||||
{
|
||||
var display = GetCurrentDisplay();
|
||||
if (display == null)
|
||||
@@ -442,7 +448,7 @@ namespace ColorControl
|
||||
|
||||
var portrait = new[] { Rotate.Degree90, Rotate.Degree270 }.Contains(display.DisplayDevice.ScanOutInformation.SourceToTargetRotation);
|
||||
|
||||
return SetRefreshRateInternal(display.Name, refreshRate, portrait, timing.HorizontalVisible, timing.VerticalVisible);
|
||||
return SetRefreshRateInternal(display.Name, refreshRate, portrait, timing.HorizontalVisible, timing.VerticalVisible, updateRegistry);
|
||||
}
|
||||
|
||||
public List<uint> GetAvailableRefreshRates(NvPreset preset = null)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
@@ -9,6 +10,7 @@ namespace ColorControl
|
||||
partial class RemoteControlPanel : UserControl
|
||||
{
|
||||
private static int Range = 35;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private LgService _lgService;
|
||||
private List<LgPreset> _buttons;
|
||||
@@ -65,6 +67,17 @@ namespace ColorControl
|
||||
|
||||
if (preset != null)
|
||||
{
|
||||
if (preset.steps.Contains("POWER") && _lgService.SelectedDevice?.CurrentState != LgDevice.PowerState.Active)
|
||||
{
|
||||
Logger.Debug("Executing WOL instead of POWER");
|
||||
|
||||
var wolPreset = _buttons.FirstOrDefault(p => p.name.Equals("Wol"));
|
||||
if (wolPreset != null)
|
||||
{
|
||||
preset = wolPreset;
|
||||
}
|
||||
}
|
||||
|
||||
var _ = _lgService.ApplyPreset(preset);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -891,6 +891,11 @@ namespace ColorControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (listView.ListViewItemSorter is ListViewColumnSorter sorter && sorter?.Order != SortOrder.None)
|
||||
{
|
||||
listView.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool OpenConsole()
|
||||
@@ -937,9 +942,13 @@ namespace ColorControl
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void StartProcess(string fileName, string arguments = null, bool hidden = false)
|
||||
public static void StartProcess(string fileName, string arguments = null, bool hidden = false, bool wait = false)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true, WindowStyle = hidden ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal });
|
||||
var process = Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true, WindowStyle = hidden ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal });
|
||||
if (wait)
|
||||
{
|
||||
process.WaitForExit();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetResourceFile(string resourceName)
|
||||
|
||||
@@ -101,6 +101,11 @@ namespace LgTv
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_messageWriter == null)
|
||||
{
|
||||
throw new Exception("SendMessageAsync: no writer");
|
||||
}
|
||||
|
||||
_messageWriter.WriteString(message);
|
||||
|
||||
using (var cancellationTokenSource = new CancellationTokenSource(5000))
|
||||
|
||||
Reference in new issue
Block a user