Skip to content

Commit

Permalink
add some LG actions, fix IP address edit box
Browse files Browse the repository at this point in the history
  • Loading branch information
Maassoft committed Sep 26, 2021
1 parent 7779533 commit e1800b8
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ColorControl/ColorControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>4.4.0.0</ApplicationVersion>
<ApplicationVersion>4.5.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
12 changes: 12 additions & 0 deletions ColorControl/LgDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public LgDevice(string name, string ipAddress, string macAddress, bool isCustom
AddGenericPictureAction("gameOptimizationHDMI2", typeof(OffToOn), category: "other");
AddGenericPictureAction("gameOptimizationHDMI3", typeof(OffToOn), category: "other");
AddGenericPictureAction("gameOptimizationHDMI4", typeof(OffToOn), category: "other");
//AddGenericPictureAction("freesyncOLEDHDMI4", typeof(OffToOn), category: "other");
//AddGenericPictureAction("freesyncSupport", typeof(OffToOn), category: "other");
AddGenericPictureAction("hdmiPcMode_hdmi1", typeof(FalseToTrue), category: "other");
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);
AddInvokableAction("turnScreenOff", new Func<Dictionary<string, object>, bool>(TurnScreenOffAction));
AddInvokableAction("turnScreenOn", new Func<Dictionary<string, object>, bool>(TurnScreenOnAction));
Expand Down Expand Up @@ -321,6 +327,12 @@ public async Task<bool> ExecutePreset(LgPreset preset, bool reconnect, LgService
{
@params = new { mode = "user", flagUpdate = true };
}

if (preset.appId.Equals("com.webos.app.factorywin"))
{
@params = new { id = "executeFactory", irKey = "inStart" };
}

await _lgTvApi.LaunchApp(preset.appId, @params);
}
catch (Exception ex)
Expand Down
5 changes: 4 additions & 1 deletion ColorControl/LgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public LgDevice SelectedDevice
private int _poweredOffByScreenSaverProcessId;
private Task _monitorTask;
private int _monitorTaskCounter;
private LgPreset _lastTriggeredPreset;

public LgService(string dataPath, bool allowPowerOn) : base(dataPath, "LgPresets.json")
{
Expand Down Expand Up @@ -781,9 +782,11 @@ private async Task ExecuteProcessPresets(ProcessMonitorContext context)
toApplyPreset = toApplyPresets.First();
}

if (_lastAppliedPreset != toApplyPreset)
if (_lastTriggeredPreset != toApplyPreset)
{
await ApplyPreset(toApplyPreset);

_lastTriggeredPreset = toApplyPreset;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ColorControl/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ private void InitLgTab()
chkLgRemoteControlShow.Checked = _lgService.Config.ShowRemoteControl;
scLgController.Panel2Collapsed = !_lgService.Config.ShowRemoteControl;

Utils.BuildComboBox<PresetTriggerType>(cbxLgPresetTrigger, PresetTriggerType.Resume, PresetTriggerType.Screensaver, PresetTriggerType.Shutdown, PresetTriggerType.Standby, PresetTriggerType.Startup);
Utils.BuildComboBox<PresetTriggerType>(cbxLgPresetTrigger, PresetTriggerType.Resume, PresetTriggerType.Shutdown, PresetTriggerType.Standby, PresetTriggerType.Startup, PresetTriggerType.Reserved5, PresetTriggerType.ScreensaverStart, PresetTriggerType.ScreensaverStop);
}

private void InitOptionsTab()
Expand Down Expand Up @@ -1776,7 +1776,7 @@ private void miLgAddAction_Click(object sender, EventArgs e)
var dropDownValues = new List<string>();
foreach (var enumValue in Enum.GetValues(action.EnumType))
{
dropDownValues.Add(enumValue.ToString());
dropDownValues.Add(enumValue.ToString().Replace("_", ""));
}

var values = MessageForms.ShowDialog("Choose value", new[] {
Expand Down
4 changes: 2 additions & 2 deletions ColorControl/MessageForms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public static List<FieldDefinition> ShowDialog(string caption, IEnumerable<Field

if (label.Contains("Ip-address"))
{
textBox.Mask = "###.###.###.###";
textBox.ValidatingType = typeof(System.Net.IPAddress);
//textBox.Mask = "990.990.990.990";
//textBox.ValidatingType = typeof(System.Net.IPAddress);
textBox.Culture = CultureInfo.InvariantCulture;
}
else if (label.Contains("MAC-address"))
Expand Down
8 changes: 6 additions & 2 deletions ColorControl/PresetBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ enum PresetTriggerType
Shutdown = 3,
[Description("Standby")]
Standby = 4,
[Description("Screensaver")]
Screensaver = 5,
[Description("Reserved5")]
Reserved5 = 5,
[Description("Process switch")]
ProcessSwitch = 6,
[Description("Screensaver start")]
ScreensaverStart = 7,
[Description("Screensaver stop")]
ScreensaverStop = 8,
}

[Flags]
Expand Down
4 changes: 2 additions & 2 deletions ColorControl/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.4.0.0")]
[assembly: AssemblyFileVersion("4.4.0.0")]
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
19 changes: 18 additions & 1 deletion ColorControl/lgtv/LgTvApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public enum TruMotionMode
user
}

public enum FalseToTrue
{
false_,
true_
}

public class LgTvApi:IDisposable
{
public bool ConnectionClosed { get => _connection?.ConnectionClosed ?? true; }
Expand Down Expand Up @@ -501,7 +507,18 @@ public async Task SetSystemSettings(string key, object value, string category =
}
else
{
jsonValue = $"\"{value}\"";
if (key.Contains("_"))
{
var keys = key.Split('_');
key = keys[0];
var childKey = keys[1];

jsonValue = @"{ """ + childKey + @""": " + value + " }";
}
else
{
jsonValue = $"\"{value}\"";
}
}

var lunauri = "luna://com.webos.settingsservice/setSystemSettings";
Expand Down

0 comments on commit e1800b8

Please sign in to comment.