fix some issues, add LG aspect ratio/zoom actions

This commit is contained in:
Vincent Maas committed 2022-07-16 15:04:07 +02:00
1 parent 5836f88ef0
commit a1121c165f
12 files changed
+304 -87

No files matched your search

+8 -8
View File
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.20348.0</TargetFramework>
<OutputType>WinExe</OutputType>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
@@ -18,8 +18,8 @@
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>7.0.0.0</ApplicationVersion>
<Version>7.0.0.0</Version>
<ApplicationVersion>7.1.0.0</ApplicationVersion>
<Version>7.1.0.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
@@ -28,7 +28,7 @@
<UseWPF>false</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>pngbarn.ico</ApplicationIcon>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
<Copyright>2020-2022 Maassoft</Copyright>
<Authors>Maassoft</Authors>
<ManifestCertificateThumbprint>CF0BC153EA664CD97AC6F234B91F45D34630958F</ManifestCertificateThumbprint>
@@ -89,11 +89,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.13" />
<PackageReference Include="NStandard" Version="0.8.28" />
<PackageReference Include="NLog" Version="5.0.1" />
<PackageReference Include="NStandard" Version="0.9.13" />
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" />
<PackageReference Include="NWin32" Version="1.2.0" />
<PackageReference Include="TaskScheduler" Version="2.9.3" />
<PackageReference Include="NWin32" Version="1.2.3" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nspector\Nspector.csproj" />
+5
View File
@@ -814,5 +814,10 @@ namespace ColorControl.Common
return null;
}
public static bool NormEquals(this string str1, string str2)
{
return str1.Trim().Replace(" ", string.Empty).Equals(str2.Trim().Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase);
}
}
}
+29 -8
View File
@@ -51,10 +51,10 @@ namespace ColorControl.Forms
t.GetMethod("UpdateIcon", hidden).Invoke(ni, new object[] { true });
}
public static ToolStripMenuItem BuildDropDownMenuEx(ContextMenuStrip mnuParent, string name, Type enumType, EventHandler clickEvent, object tag = null, int min = 0, int max = 0)
public static ToolStripMenuItem BuildDropDownMenuEx(ToolStripItemCollection items, string parentName, string name, Type enumType, EventHandler clickEvent, object tag = null, int min = 0, int max = 0, bool noSubItems = false)
{
var subMenuName = $"{mnuParent.Name}_{name}";
var subMenuItems = mnuParent.Items.Find(subMenuName, false);
var subMenuName = $"{parentName}_{name}";
var subMenuItems = items.Find(subMenuName, false);
if (subMenuItems.Length > 0)
{
@@ -62,9 +62,17 @@ namespace ColorControl.Forms
}
ToolStripMenuItem subMenuItem;
subMenuItem = (ToolStripMenuItem)mnuParent.Items.Add(name);
subMenuItem = (ToolStripMenuItem)items.Add(name);
subMenuItem.Name = subMenuName;
if (noSubItems)
{
subMenuItem.Tag = tag;
subMenuItem.Click += clickEvent;
return subMenuItem;
}
if (enumType != null)
{
foreach (var enumValue in Enum.GetValues(enumType))
@@ -81,12 +89,25 @@ namespace ColorControl.Forms
item.Click += clickEvent;
}
}
else if (min >= 0 && max > min)
else if (max > min)
{
for (var i = 0; i <= 10; i++)
{
var value = i * (max / 10);
List<int> range;
if (max - min <= 20)
{
range = Enumerable.Range(min, (max - min) + 1).ToList();
}
else
{
range = new List<int>();
for (var i = 0; i <= 10; i++)
{
range.Add(i * (max / 10));
}
}
foreach (var value in range)
{
var subSubItemName = $"{subMenuName}_{value}";
var item = subMenuItem.DropDownItems.Add(value.ToString());
+106 -31
View File
@@ -328,6 +328,10 @@ namespace ColorControl
{
return _nvService.ApplyPreset(parameters[0]);
}
if (_nvService != null && serviceName.Equals("GsyncEnabled", StringComparison.OrdinalIgnoreCase))
{
return _nvService.IsGsyncEnabled();
}
if (_amdService != null && serviceName.Equals("AmdPreset", StringComparison.OrdinalIgnoreCase))
{
return _amdService.ApplyPreset(parameters[0]);
@@ -2055,10 +2059,29 @@ namespace ColorControl
{
var filename = Path.Combine(_dataDir, "LogFile.txt");
var lines = new[] { "No log file found" };
if (File.Exists(filename))
var lines = new List<string> { "No log file found" };
try
{
lines = File.ReadAllLines(filename);
if (File.Exists(filename))
{
using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using var reader = new StreamReader(fs);
String line;
while ((line = reader.ReadLine()) != null)
{
lines.Add(line);
}
//lines = File.ReadAllLines(filename);
}
}
catch (Exception ex)
{
lines = new List<string> { $"Cannot load log file: {ex.Message}" };
}
var reversedLines = lines.ToList();
var builder = new StringBuilder();
@@ -2139,6 +2162,18 @@ namespace ColorControl
var item = sender as ToolStripItem;
var action = item.Tag as LgDevice.InvokableAction;
var value = ShowLgActionForm(action);
if (!string.IsNullOrEmpty(value))
{
var text = $"{action.Name}({value})";
FormUtils.AddStepToTextBox(edtStepsLg, text);
}
}
private string ShowLgActionForm(LgDevice.InvokableAction action)
{
var text = action.Name;
var title = action.Title ?? action.Name;
@@ -2154,7 +2189,7 @@ namespace ColorControl
{
fields.Add(new MessageForms.FieldDefinition
{
Label = "Enter desired " + item.Text,
Label = "Enter desired " + title,
FieldType = MessageForms.FieldType.Numeric,
MinValue = action.MinValue,
MaxValue = action.MaxValue,
@@ -2173,11 +2208,11 @@ namespace ColorControl
}));
}
var values = MessageForms.ShowDialog("Enter value", fields);
var values = MessageForms.ShowDialog($"Enter value for {title}", fields);
if (!values.Any())
{
return;
return null;
}
if (values.Count > 1)
@@ -2210,7 +2245,7 @@ namespace ColorControl
if (!values.Any())
{
return;
return null;
}
value = values.First().Value.ToString();
@@ -2221,12 +2256,7 @@ namespace ColorControl
}
}
if (!string.IsNullOrEmpty(value))
{
text += $"({value})";
}
FormUtils.AddStepToTextBox(edtStepsLg, text);
return value;
}
private void miLgAddNvPreset_Click(object sender, EventArgs e)
@@ -3112,31 +3142,40 @@ Do you want to continue?"
const string gameBarName = "miGameBar";
foreach (var action in actions.Where(a => !a.Name.Contains("uhd", StringComparison.OrdinalIgnoreCase) &&
var expertActions = actions.Where(a => !a.Name.Contains("uhd", StringComparison.OrdinalIgnoreCase) &&
!a.Name.Contains("gameOpt", StringComparison.OrdinalIgnoreCase) &&
!a.Name.Contains("hdmiPc", StringComparison.OrdinalIgnoreCase) &&
(a.EnumType != null || a.MinValue >= 0 && a.MaxValue > a.MinValue)))
(a.EnumType != null || a.MaxValue > a.MinValue)).ToList();
var categories = expertActions.Select(a => a.Category ?? "misc").Where(c => !string.IsNullOrEmpty(c)).Distinct();
foreach (var category in categories)
{
var menu = FormUtils.BuildDropDownMenuEx(mnuLgExpert, action.Title, action.EnumType, btnLgExpertColorGamut_Click, action, (int)action.MinValue, (int)action.MaxValue);
var catMenuItem = FormUtils.BuildDropDownMenuEx(mnuLgExpert.Items, mnuLgExpert.Name, Utils.FirstCharUpperCase(category), null, null, category);
if (!gameBarActions.Contains(action))
foreach (var action in expertActions.Where(a => (a.Category ?? "misc") == category))
{
continue;
}
var menu = FormUtils.BuildDropDownMenuEx(catMenuItem.DropDownItems, catMenuItem.Name, action.Title, action.EnumType, btnLgExpertColorGamut_Click, action, (int)action.MinValue, (int)action.MaxValue, action.NumberOfValues > 1);
var itemName = $"{menu.Name}_{gameBarName}";
var gameBarItem = (ToolStripMenuItem)menu.DropDownItems.Find(itemName, false).FirstOrDefault();
if (!gameBarActions.Contains(action))
{
continue;
}
if (gameBarItem == null)
{
var separator = new ToolStripSeparator();
menu.DropDownItems.Add(separator);
var itemName = $"{menu.Name}_{gameBarName}";
var gameBarItem = (ToolStripMenuItem)menu.DropDownItems.Find(itemName, false).FirstOrDefault();
gameBarItem = (ToolStripMenuItem)menu.DropDownItems.Add("Show in Game Bar", null, miLgGameBarToggle_Click);
gameBarItem.CheckOnClick = true;
gameBarItem.Checked = activatedGameBarActions.Contains(action);
gameBarItem.Name = itemName;
gameBarItem.Tag = action.Name;
if (gameBarItem == null)
{
var separator = new ToolStripSeparator();
menu.DropDownItems.Add(separator);
gameBarItem = (ToolStripMenuItem)menu.DropDownItems.Add("Show in Game Bar", null, miLgGameBarToggle_Click);
gameBarItem.CheckOnClick = true;
gameBarItem.Checked = activatedGameBarActions.Contains(action);
gameBarItem.Name = itemName;
gameBarItem.Tag = action.Name;
}
}
}
@@ -3157,7 +3196,7 @@ Do you want to continue?"
foreach (var presetAction in presetActions)
{
var menu = FormUtils.BuildDropDownMenuEx(mnuLgExpert, presetAction.Name, null, btnLgExpertPresetAction_Click, presetAction.Preset);
var menu = FormUtils.BuildDropDownMenuEx(mnuLgExpert.Items, mnuLgExpert.Name, presetAction.Name, null, btnLgExpertPresetAction_Click, presetAction.Preset);
}
}
@@ -3192,9 +3231,29 @@ Do you want to continue?"
var action = item.Tag as LgDevice.InvokableAction;
var value = item.AccessibleName ?? item.Text;
if (action.NumberOfValues > 1)
{
ApplyLgExpertValueRange(action);
return;
}
_lgService.SelectedDevice?.ExecuteAction(action, new[] { value });
}
private void ApplyLgExpertValueRange(LgDevice.InvokableAction action)
{
var value = ShowLgActionForm(action);
if (value == null)
{
return;
}
var values = value.Split(";");
_lgService.SelectedDevice?.ExecuteAction(action, values);
}
private void btnLgExpertPresetAction_Click(object sender, EventArgs e)
{
var item = sender as ToolStripItem;
@@ -3850,6 +3909,14 @@ The InStart and Software Update items are now visible under the Expert-button."
return;
}
var point = listView.PointToClient(Cursor.Position);
if (point.X >= 20)
{
e.Item.Checked = !e.Item.Checked;
return;
}
checkedPreset.ShowInQuickAccess = e.Item.Checked;
var preset = listView.GetSelectedItemTag<T>();
@@ -3879,6 +3946,14 @@ The InStart and Software Update items are now visible under the Expert-button."
return;
}
var point = listView.PointToClient(Cursor.Position);
if (point.X >= 20)
{
return;
}
var listItem = listView.Items[e.Index];
if (listItem.Tag == null)
+11 -4
View File
@@ -42,6 +42,10 @@ namespace ColorControl.Services.Common
FullScreen = 4,
[Description("Notifications Disabled")]
NotificationsDisabled = 8,
[Description("G-SYNC Disabled")]
GsyncDisabled = 16,
[Description("G-SYNC Enabled")]
GsyncEnabled = 32
}
class PresetTrigger
@@ -59,7 +63,9 @@ namespace ColorControl.Services.Common
public bool TriggerActive(PresetTriggerContext context)
{
var active = Conditions == PresetConditionType.None || (Conditions.HasFlag(PresetConditionType.SDR) && !context.IsHDRActive) || (Conditions.HasFlag(PresetConditionType.HDR) && context.IsHDRActive);
var active = Conditions == PresetConditionType.None ||
(Conditions.HasFlag(PresetConditionType.SDR) ? !context.IsHDRActive : true) && (Conditions.HasFlag(PresetConditionType.HDR) ? context.IsHDRActive : true) &&
(Conditions.HasFlag(PresetConditionType.GsyncDisabled) ? !context.IsGsyncActive : true) && (Conditions.HasFlag(PresetConditionType.GsyncEnabled) ? context.IsGsyncActive : true);
var allProcesses = IncludedProcesses.Contains("*");
if (Trigger == PresetTriggerType.ProcessSwitch)
@@ -68,12 +74,12 @@ namespace ColorControl.Services.Common
if (active)
{
var included = allProcesses || context.ChangedProcesses.Any(cp => IncludedProcesses.Any(ip => cp.ProcessName.Equals(ip, StringComparison.OrdinalIgnoreCase)));
var excluded = context.ChangedProcesses.Any(cp => ExcludedProcesses.Any(ep => cp.ProcessName.Equals(ep, StringComparison.OrdinalIgnoreCase)));
var included = allProcesses || context.ChangedProcesses.Any(cp => IncludedProcesses.Any(ip => cp.ProcessName.NormEquals(ip)));
var excluded = context.ChangedProcesses.Any(cp => ExcludedProcesses.Any(ep => cp.ProcessName.NormEquals(ep)));
var screenSizeCheck = (!Conditions.HasFlag(PresetConditionType.FullScreen) && !context.ForegroundProcessIsFullScreen) ||
(context.ForegroundProcess != null && context.ForegroundProcessIsFullScreen &&
(allProcesses || IncludedProcesses.Any(ip => context.ForegroundProcess.ProcessName.Equals(ip, StringComparison.OrdinalIgnoreCase))));
(allProcesses || IncludedProcesses.Any(ip => context.ForegroundProcess.ProcessName.NormEquals(ip))));
var notificationsDisabledCheck = !Conditions.HasFlag(PresetConditionType.NotificationsDisabled) || context.IsNotificationDisabled;
@@ -103,6 +109,7 @@ namespace ColorControl.Services.Common
class PresetTriggerContext
{
public bool IsHDRActive { get; set; }
public bool IsGsyncActive { get; set; }
public Process ForegroundProcess { get; set; }
public bool ForegroundProcessIsFullScreen { get; set; }
public List<Process> ChangedProcesses { get; set; }
@@ -0,0 +1,27 @@
namespace ColorControl.Services.Common
{
class ServiceManager
{
public static ServiceManager Instance
{
get
{
if (_instance == null)
{
_instance = new ServiceManager();
}
return _instance;
}
}
private static ServiceManager _instance { get; set; }
//private List<ServiceBase<PresetBase>> _services = new();
public void Initialize()
{
}
}
}
+10 -1
View File
@@ -147,6 +147,7 @@ namespace ColorControl.Services.LG
AddGenericPictureAction("colorGamut", typeof(ColorGamut), title: "Color Gamut");
AddGenericPictureAction("dynamicContrast", typeof(OffToHigh), title: "Dynamic Contrast");
AddGenericPictureAction("gamma", typeof(GammaExp));
AddGenericPictureAction("colorTemperature", minValue: 0, maxValue: 50, title: "Color Temperature");
AddGenericPictureAction("whiteBalanceColorTemperature", typeof(WhiteBalanceColorTemperature), title: "White Balance Color Temperature");
//AddGenericPictureAction("dynamicColor", typeof(OffToAuto));
//AddGenericPictureAction("superResolution", typeof(OffToAuto));
@@ -155,6 +156,14 @@ namespace ColorControl.Services.LG
AddGenericPictureAction("energySaving", typeof(EnergySaving), title: "Energy Saving");
AddGenericPictureAction("hdrDynamicToneMapping", typeof(DynamicTonemapping), title: "HDR Dynamic Tone Mapping");
AddGenericPictureAction("blackLevel", typeof(BlackLevel), title: "HDMI Black Level");
AddGenericPictureAction("arcPerApp", typeof(AspectRatio), title: "Aspect Ratio", category: "aspectRatio");
AddGenericPictureAction("justScan", typeof(OffToAuto2), title: "Just Scan", category: "aspectRatio");
AddGenericPictureAction("allDirZoomHRatio", minValue: 0, maxValue: 10, title: "All-Direction Zoom Horizontal Ratio", category: "aspectRatio");
AddGenericPictureAction("allDirZoomVRatio", minValue: 0, maxValue: 9, title: "All-Direction Zoom Verical Ratio", category: "aspectRatio");
AddGenericPictureAction("allDirZoomHPosition", minValue: -10, maxValue: 9, title: "All-Direction Zoom Horizontal Position", category: "aspectRatio");
AddGenericPictureAction("allDirZoomVPosition", minValue: -9, maxValue: 9, title: "All-Direction Zoom Vertical Position", category: "aspectRatio");
AddGenericPictureAction("vertZoomVPosition", minValue: -8, maxValue: 9, title: "Vertical Zoom Position", category: "aspectRatio");
AddGenericPictureAction("vertZoomVRatio", minValue: 0, maxValue: 9, title: "Vertical Zoom Ratio", category: "aspectRatio");
//AddGenericPictureAction("ambientLightCompensation", typeof(OffToAuto2));
AddGenericPictureAction("truMotionMode", typeof(TruMotionMode), title: "TruMotion");
AddGenericPictureAction("truMotionJudder", minValue: 0, maxValue: 10, title: "TruMotion Judder");
@@ -368,7 +377,7 @@ namespace ColorControl.Services.LG
{
Logger.Debug($"[{Name}] Power state change: {JsonConvert.SerializeObject(payload)}");
var state = ((string)payload.state).Replace(' ', '_');
var state = payload.state != null ? ((string)payload.state).Replace(' ', '_') : PowerState.Unknown.ToString();
PowerState newState;
if (Enum.TryParse(state, out newState))
+3
View File
@@ -753,9 +753,12 @@ namespace ColorControl.Services.LG
var isHDRActive = context.Devices.Any(d => d.IsUsingHDRPictureMode());
var isGsyncActive = LgDevice.ExternalServiceHandler("GsyncEnabled", new[] { "" });
var triggerContext = new PresetTriggerContext
{
IsHDRActive = isHDRActive,
IsGsyncActive = isGsyncActive,
ForegroundProcess = context.ForegroundProcess,
ForegroundProcessIsFullScreen = context.ForegroundProcessIsFullScreen,
ChangedProcesses = changedProcesses,
+1 -2
View File
@@ -93,8 +93,7 @@ namespace ColorControl.Services.NVIDIA
public static string[] GetColumnNames()
{
//return new[] { "BPC", "Format", "Dynamic range", "Toggle HDR", "Shortcut" };
return new[] { "[Quick Access] Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Driver settings|300", "Shortcut", "Apply on startup" };
return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Driver settings|300", "Shortcut", "Apply on startup" };
}
public override List<string> GetDisplayValues(Config config = null)
+53 -6
View File
@@ -13,6 +13,8 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ColorControl.Services.NVIDIA
@@ -91,6 +93,8 @@ namespace ColorControl.Services.NVIDIA
private DrsSettingsMetaService _meta;
private List<SettingItem> _settings = new List<SettingItem>();
private Semaphore _semaphore = new Semaphore(1, 1);
public const uint DRS_GSYNC_APPLICATION_MODE = 294973784;
public const uint DRS_VSYNC_CONTROL = 11041231;
//public const uint DRS_ULTRA_LOW_LATENCY = 0x10835000;
@@ -680,7 +684,7 @@ namespace ColorControl.Services.NVIDIA
public List<SettingItem> GetVisibleSettings()
{
return _settings.Where(s => _driverSettingIds.Contains(s.SettingId)).ToList();
return GetSettings().Where(s => _driverSettingIds.Contains(s.SettingId)).ToList();
}
public SettingMeta GetSettingMeta(uint settingId)
@@ -688,6 +692,38 @@ namespace ColorControl.Services.NVIDIA
return _meta.GetSettingMeta(settingId);
}
public bool IsGsyncEnabled()
{
var setting = GetSettings().FirstOrDefault(s => s.SettingId == DRS_GSYNC_APPLICATION_MODE);
if (setting == null)
{
return false;
}
var settingMeta = GetSettingMeta(setting.SettingId);
var settingValue = settingMeta.DwordValues.FirstOrDefault(s => s.ValueName == setting.ValueText);
return settingValue.Value >= 1;
}
protected List<SettingItem> GetSettings()
{
_semaphore.WaitOne();
try
{
if (!_settings.Any())
{
RefreshProfileSettings();
}
return _settings;
}
finally
{
_semaphore.Release();
}
}
protected override void Initialize()
{
NvAPIWrapper.NVIDIA.Initialize();
@@ -698,16 +734,27 @@ namespace ColorControl.Services.NVIDIA
_drs.GetProfileNames(ref _baseProfileName, false);
RefreshProfileSettings();
Task.Run(() =>
{
RefreshProfileSettings();
});
}
private void RefreshProfileSettings()
{
var applications = new Dictionary<string, string>();
var normalSettings = _drs.GetSettingsForProfile(_baseProfileName, SettingViewMode.Normal, ref applications);
_semaphore.WaitOne();
try
{
var applications = new Dictionary<string, string>();
var normalSettings = _drs.GetSettingsForProfile(_baseProfileName, SettingViewMode.Normal, ref applications);
_settings = new List<SettingItem>();
_settings.AddRange(normalSettings);
_settings = new List<SettingItem>();
_settings.AddRange(normalSettings);
}
finally
{
_semaphore.Release();
}
}
protected override void Uninitialize()
+50 -26
View File
@@ -1,5 +1,4 @@
using ColorControl;
using ColorControl.Common;
using ColorControl.Common;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -14,7 +13,7 @@ namespace LgTv
public enum ControlButtons
{
Back,Down,Left,Right,
Back, Down, Left, Right,
OK,
Exit
}
@@ -22,9 +21,9 @@ namespace LgTv
public enum PictureMode
{
cinema, eco, expert1, expert2, game, normal, photo, sports, technicolor, vivid, hdrEffect, filmMaker,
hdrCinema, hdrCinemaBright, hdrExternal, hdrGame, hdrStandard, hdrTechnicolor, hdrVivid, hdrFilmMaker,
hdrCinema, hdrCinemaBright, hdrExternal, hdrGame, hdrStandard, hdrTechnicolor, hdrVivid, hdrFilmMaker,
dolbyHdrCinema, dolbyHdrCinemaBright, dolbyHdrDarkAmazon, dolbyHdrGame, dolbyHdrStandard, dolbyHdrVivid, dolbyStandard
}
@@ -143,6 +142,26 @@ namespace LgTv
auto
}
public enum AspectRatio
{
_21x9,
_16x9,
_4x3,
_14x9,
_32x9,
_32x12,
just_scan,
original,
full_wide,
limited,
zoom,
zoom2,
cinema_zoom,
vertZoom,
allDirZoom,
twinZoom
}
public enum HdmiIcon
{
[Description("HDMI")]
@@ -225,7 +244,7 @@ namespace LgTv
wisa_speaker,
}
public class LgTvApi:IDisposable
public class LgTvApi : IDisposable
{
public bool ConnectionClosed { get => _connection?.ConnectionClosed ?? true; }
@@ -289,7 +308,7 @@ namespace LgTv
_keyStore.SaveClientKey(result.clientKey);
_keyStore.SaveHandShake(registerJson);
}
public async Task<bool> Connect()
{
@@ -303,7 +322,7 @@ namespace LgTv
var requestMessage = new RequestMessage("ssap://com.webos.service.networkinput/getPointerInputSocket", new { });
var s = await _connection.SendCommandAsync(requestMessage);
var socketPath = (string)s.socketPath;
_mouseConnection = new LgWebOsMouseService(new LgTvApiCore());
await _mouseConnection.Connect(socketPath);
return _mouseConnection;
@@ -337,10 +356,10 @@ namespace LgTv
}
public async Task ShowToast()
{
var requestMessage = new RequestMessage("ssap://system.notifications/createToast",new {message = "Co tam u Ciebie?"});
var requestMessage = new RequestMessage("ssap://system.notifications/createToast", new { message = "Co tam u Ciebie?" });
await _connection.SendCommandAsync(requestMessage);
}
//public async Task<string> LaunchApp(string appId,Uri uri)
//{
// var url = uri.ToString();
@@ -354,7 +373,7 @@ namespace LgTv
var requestMessage = new RequestMessage("volumedown", "ssap://audio/volumeDown");
await _connection.SendCommandAsync(requestMessage);
}
public async Task VolumeUp()
public async Task VolumeUp()
{
var requestMessage = new RequestMessage("volumeup", "ssap://audio/volumeUp");
await _connection.SendCommandAsync(requestMessage);
@@ -365,12 +384,12 @@ namespace LgTv
await _connection.SendCommandAsync(requestMessage);
}
public async Task SetChannel(string channelId)
public async Task SetChannel(string channelId)
{
var requestMessage = new RequestMessage("ssap://tv/openChannel", new { channelId });
await _connection.SendCommandAsync(requestMessage);
}
public async Task SetMute(bool value)
public async Task SetMute(bool value)
{
var requestMessage = new RequestMessage("ssap://audio/setMute", new { mute = value });
await _connection.SendCommandAsync(requestMessage);
@@ -386,7 +405,7 @@ namespace LgTv
return (bool)(await command).mute;
}
public async Task SetVolume(int value)
public async Task SetVolume(int value)
{
if (value >= 0 && value <= 100)
{
@@ -394,11 +413,11 @@ namespace LgTv
await _connection.SendCommandAsync(requestMessage);
}
}
public async Task TurnOff()
public async Task TurnOff()
{
await _connection.SendCommandAsync(new RequestMessage("","ssap://system/turnOff"));
await _connection.SendCommandAsync(new RequestMessage("", "ssap://system/turnOff"));
}
public async Task Play()
public async Task Play()
{
await _connection.SendCommandAsync(new RequestMessage("play", "ssap://media.controls/play"));
}
@@ -416,7 +435,7 @@ namespace LgTv
await _connection.SendCommandAsync(new RequestMessage("channelDown", "ssap://tv/channelDown"));
}
public async Task Stop()
public async Task Stop()
{
await _connection.SendCommandAsync(new RequestMessage("stop", "ssap://media.controls/stop"));
}
@@ -445,7 +464,7 @@ namespace LgTv
//Response: { returnValue: true, status3D: { status: true, pattern: ’2Dto3D’ } }
var requestMessage = new RequestMessage("status3D", "ssap://com.webos.service.tv.display/get3DStatus");
var o = await _connection.SendCommandAsync(requestMessage);
return (bool)o.status3D.status;
return (bool)o.status3D.status;
}
public async Task<int> GetVolume()
@@ -465,12 +484,12 @@ namespace LgTv
// }
var requestMessage = new RequestMessage("status", "ssap://audio/getVolume");
var o = await _connection.SendCommandAsync(requestMessage);
return( (bool)o.muted) ? -1 :(int) o.volume;
return ((bool)o.muted) ? -1 : (int)o.volume;
}
public async Task<IEnumerable<ExternalInput>> GetInputList()
{
var requestMessage = new RequestMessage("input","ssap://tv/getExternalInputList");
var results = await _connection.SendCommandAsync(requestMessage);
var requestMessage = new RequestMessage("input", "ssap://tv/getExternalInputList");
var results = await _connection.SendCommandAsync(requestMessage);
var l = new List<ExternalInput>();
foreach (var result in results)
{
@@ -482,7 +501,7 @@ namespace LgTv
return l;
}
public async Task SetInput(string id)
public async Task SetInput(string id)
{
var requestMessage = new RequestMessage("ssap://tv/switchInput", new { inputId = id });
await _connection.SendCommandAsync(requestMessage);
@@ -677,6 +696,11 @@ namespace LgTv
}
else
{
if (key.Equals("arcPerApp") && value.ToString().StartsWith("_"))
{
value = value.ToString().Substring(1);
}
jsonValue = $"\"{value}\"";
}
@@ -718,7 +742,7 @@ namespace LgTv
label = label,
icon = iconPng
};
await ExecuteRequest(lunauri, @params);
}
@@ -819,7 +843,7 @@ namespace LgTv
}
public void Dispose()
{
_connection?.Dispose();
_connection?.Dispose();
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.20348.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>