mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-22 00:22:18 -05:00
fix final Samsung issues
This commit is contained in:
1 parent
04d447a48b
commit
7e1eb8bfa8
15 files changed
+381
-309
No files matched your search
@@ -0,0 +1,162 @@
|
||||
using ColorControl.Common;
|
||||
using ColorControl.Forms;
|
||||
using ColorControl.Services.AMD;
|
||||
using ColorControl.Services.LG;
|
||||
using ColorControl.Services.NVIDIA;
|
||||
using ColorControl.Services.Samsung;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ColorControl
|
||||
{
|
||||
public static class CommandLineHandler
|
||||
{
|
||||
public static async Task<bool> HandleStartupParams(StartUpParams startUpParams, Process existingProcess)
|
||||
{
|
||||
if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
|
||||
{
|
||||
Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix, startUpParams.ChromeFontFixApplicationDataFolder);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.EnableAutoStart || startUpParams.DisableAutoStart)
|
||||
{
|
||||
Utils.RegisterTask(Program.TS_TASKNAME, startUpParams.EnableAutoStart, startUpParams.AutoStartRunLevel);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SetProcessAffinity)
|
||||
{
|
||||
Utils.SetProcessAffinity(startUpParams.ProcessId, startUpParams.AffinityMask);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SetProcessPriority)
|
||||
{
|
||||
Utils.SetProcessPriority(startUpParams.ProcessId, startUpParams.PriorityClass);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StartElevated)
|
||||
{
|
||||
StartElevated();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SendWol)
|
||||
{
|
||||
return WOL.WakeFunction(startUpParams.WolMacAddress, startUpParams.WolIpAddress);
|
||||
}
|
||||
if (startUpParams.InstallService)
|
||||
{
|
||||
Utils.InstallService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.UninstallService)
|
||||
{
|
||||
Utils.UninstallService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StartService)
|
||||
{
|
||||
Utils.StartService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StopService)
|
||||
{
|
||||
Utils.StopService();
|
||||
return true;
|
||||
}
|
||||
|
||||
var useConsole = startUpParams.NoGui || existingProcess != null;
|
||||
|
||||
if (!useConsole)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
startUpParams.NoGui = true;
|
||||
|
||||
var result = false;
|
||||
|
||||
if (startUpParams.ExecuteHelp)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($@"ColorControl CLI {Application.ProductVersion}
|
||||
Syntax : ColorControl command options
|
||||
Commands:
|
||||
--nvpreset <preset name or id>: execute NVIDIA-preset
|
||||
--amdpreset <preset name or id>: execute AMD-preset
|
||||
--lgpreset <preset name> : execute LG-preset
|
||||
--sampreset <preset name> : execute Samsung-preset
|
||||
--help : displays this help info
|
||||
Options:
|
||||
--nogui : starts command from the command line and will not open GUI (is forced when GUI is already running)
|
||||
--no-refresh: when using LG or Samsung-preset: skip refreshing devices (speeds up executing preset)");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteLgPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing LG-preset '{startUpParams.LgPresetName}'...");
|
||||
await LgService.ExecutePresetAsync(startUpParams.LgPresetName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteSamsungPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing Samsung-preset '{startUpParams.SamsungPresetName}'...");
|
||||
await SamsungService.ExecutePresetAsync(startUpParams.SamsungPresetName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteNvidiaPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing NVIDIA-preset '{startUpParams.NvidiaPresetIdOrName}'...");
|
||||
await NvService.ExecutePresetAsync(startUpParams.NvidiaPresetIdOrName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteAmdPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing AMD-preset '{startUpParams.AmdPresetIdOrName}'...");
|
||||
await AmdService.ExecutePresetAsync(startUpParams.AmdPresetIdOrName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void StartElevated()
|
||||
{
|
||||
try
|
||||
{
|
||||
Application.Run(new ElevatedForm());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error while initializing elevated application: " + ex.ToLogString(Environment.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ namespace ColorControl
|
||||
public ListViewSortState NvPresetsSortState { get; set; }
|
||||
public ListViewSortState AmdPresetsSortState { get; set; }
|
||||
public ListViewSortState LgPresetsSortState { get; set; }
|
||||
public ListViewSortState SamsungPresetsSortState { get; set; }
|
||||
public ListViewSortState GamePresetsSortState { get; set; }
|
||||
public string NvQuickAccessShortcut { get; set; }
|
||||
public string AmdQuickAccessShortcut { get; set; }
|
||||
@@ -66,6 +67,7 @@ namespace ColorControl
|
||||
LgPresetsSortState = new ListViewSortState();
|
||||
NvPresetsSortState = new ListViewSortState();
|
||||
AmdPresetsSortState = new ListViewSortState();
|
||||
SamsungPresetsSortState = new ListViewSortState();
|
||||
GamePresetsSortState = new ListViewSortState();
|
||||
Modules = new List<Module>();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using NWin32;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,7 +13,6 @@ namespace ColorControl.Forms
|
||||
{
|
||||
public ElevatedForm()
|
||||
{
|
||||
File.Delete("d:\\Msg.txt");
|
||||
InitializeComponent();
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
@@ -26,10 +24,9 @@ namespace ColorControl.Forms
|
||||
filterStatus.size = (uint)Marshal.SizeOf(filterStatus);
|
||||
filterStatus.info = 0;
|
||||
|
||||
var result = WinApi.ChangeWindowMessageFilterEx(Handle, NativeConstants.WM_COPYDATA, WinApi.ChangeWindowMessageFilterExAction.Allow, ref filterStatus);
|
||||
//File.AppendAllLines("d:\\Msg.txt", new[] { "ChangeWindowMessageFilterEx result: " + result });
|
||||
WinApi.ChangeWindowMessageFilterEx(Handle, NativeConstants.WM_COPYDATA, WinApi.ChangeWindowMessageFilterExAction.Allow, ref filterStatus);
|
||||
|
||||
Task.Run(() => CheckMutexAsync());
|
||||
Task.Run(CheckMutexAsync);
|
||||
}
|
||||
|
||||
private void ElevatedForm_Shown(object sender, EventArgs e)
|
||||
@@ -49,15 +46,7 @@ namespace ColorControl.Forms
|
||||
var container = (WinApi.COPYDATASTRUCT)m.GetLParam(typeof(WinApi.COPYDATASTRUCT));
|
||||
var message = Marshal.PtrToStringAnsi(container.lpData);
|
||||
|
||||
//File.AppendAllLines("d:\\Msg.txt", new[] { "Message received: " + message });
|
||||
|
||||
HandleMessage(message);
|
||||
|
||||
//Utils.StartProcess("notepad.exe");
|
||||
|
||||
//BackColor = Color.Red;
|
||||
//Text = "AHA!";
|
||||
//MessageForms.WarningOk("Received!");
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
@@ -71,7 +60,7 @@ namespace ColorControl.Forms
|
||||
|
||||
try
|
||||
{
|
||||
var _ = Program.HandleStartupParams(startUpParams, null);
|
||||
var _ = CommandLineHandler.HandleStartupParams(startUpParams, null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -82,19 +71,14 @@ namespace ColorControl.Forms
|
||||
private void CheckMutexAsync()
|
||||
{
|
||||
var mutex = new Mutex(false, Program.MutexId, out var created);
|
||||
|
||||
File.AppendAllLines("d:\\Msg.txt", new[] { "Mutex created: " + created });
|
||||
|
||||
try
|
||||
{
|
||||
mutex.WaitOne();
|
||||
File.AppendAllLines("d:\\Msg.txt", new[] { "Mutex released?" });
|
||||
}
|
||||
catch (AbandonedMutexException)
|
||||
{
|
||||
File.AppendAllLines("d:\\Msg.txt", new[] { "Mutex abandoned" });
|
||||
}
|
||||
BeginInvoke(() => Application.Exit());
|
||||
BeginInvoke(Application.Exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,6 +411,8 @@ namespace ColorControl
|
||||
lbPlugins.Items.Add("NVIDIA Profile Inspector by Orbmu2k");
|
||||
lbPlugins.Items.Add("NvidiaML wrapper by LibreHardwareMonitor");
|
||||
lbPlugins.Items.Add("Novideo sRGB by ledoge");
|
||||
lbPlugins.Items.Add("NLogViewer by dojo90");
|
||||
lbPlugins.Items.Add("WPFDarkTheme by AngryCarrot789");
|
||||
}
|
||||
|
||||
private void OpenForm(object sender, EventArgs e)
|
||||
@@ -1022,7 +1024,7 @@ NOTE: installing the service may cause a User Account Control popup.");
|
||||
BeginInvoke(() => HandleCheckForUpdates(latest));
|
||||
}
|
||||
|
||||
private void HandleCheckForUpdates(dynamit)
|
||||
private void HandleCheckForUpdates(dynamic latest)
|
||||
{
|
||||
if (latest?.tag_name == null)
|
||||
{
|
||||
|
||||
+1
-148
@@ -1,11 +1,8 @@
|
||||
using ColorControl.Common;
|
||||
using ColorControl.Forms;
|
||||
using ColorControl.Services.AMD;
|
||||
using ColorControl.Services.Common;
|
||||
using ColorControl.Services.EventDispatcher;
|
||||
using ColorControl.Services.GameLauncher;
|
||||
using ColorControl.Services.LG;
|
||||
using ColorControl.Services.NVIDIA;
|
||||
using ColorControl.Services.Samsung;
|
||||
using ColorControl.Svc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -101,7 +98,7 @@ namespace ColorControl
|
||||
|
||||
try
|
||||
{
|
||||
if (await HandleStartupParams(startUpParams, existingProcess))
|
||||
if (await CommandLineHandler.HandleStartupParams(startUpParams, existingProcess))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -223,150 +220,6 @@ namespace ColorControl
|
||||
_loggingRule.SetLoggingLevels(minLogLevel, LogLevel.Fatal);
|
||||
}
|
||||
|
||||
public static async Task<bool> HandleStartupParams(StartUpParams startUpParams, Process existingProcess)
|
||||
{
|
||||
if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
|
||||
{
|
||||
Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix, startUpParams.ChromeFontFixApplicationDataFolder);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.EnableAutoStart || startUpParams.DisableAutoStart)
|
||||
{
|
||||
Utils.RegisterTask(TS_TASKNAME, startUpParams.EnableAutoStart, startUpParams.AutoStartRunLevel);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SetProcessAffinity)
|
||||
{
|
||||
Utils.SetProcessAffinity(startUpParams.ProcessId, startUpParams.AffinityMask);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SetProcessPriority)
|
||||
{
|
||||
Utils.SetProcessPriority(startUpParams.ProcessId, startUpParams.PriorityClass);
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StartElevated)
|
||||
{
|
||||
StartElevated();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.SendWol)
|
||||
{
|
||||
return WOL.WakeFunction(startUpParams.WolMacAddress, startUpParams.WolIpAddress);
|
||||
}
|
||||
if (startUpParams.InstallService)
|
||||
{
|
||||
Utils.InstallService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.UninstallService)
|
||||
{
|
||||
Utils.UninstallService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StartService)
|
||||
{
|
||||
Utils.StartService();
|
||||
return true;
|
||||
}
|
||||
if (startUpParams.StopService)
|
||||
{
|
||||
Utils.StopService();
|
||||
return true;
|
||||
}
|
||||
|
||||
var useConsole = startUpParams.NoGui || existingProcess != null;
|
||||
|
||||
if (!useConsole)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
startUpParams.NoGui = true;
|
||||
|
||||
var result = false;
|
||||
|
||||
if (startUpParams.ExecuteHelp)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine("\nColorControl CLI");
|
||||
Console.WriteLine("Syntax : ColorControl command options");
|
||||
Console.WriteLine("Commands:");
|
||||
Console.WriteLine("--nvpreset <preset name or id>: execute NVIDIA-preset");
|
||||
Console.WriteLine("--amdpreset <preset name or id>: execute AMD-preset");
|
||||
Console.WriteLine("--lgpreset <preset name> : execute LG-preset");
|
||||
Console.WriteLine("--sampreset <preset name> : execute Samsung-preset");
|
||||
Console.WriteLine("--help : displays this help info");
|
||||
Console.WriteLine("Options:");
|
||||
Console.WriteLine("--nogui: starts command from the command line and will not open GUI (is forced when GUI is already running)");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteLgPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing LG-preset '{startUpParams.LgPresetName}'...");
|
||||
await LgService.ExecutePresetAsync(startUpParams.LgPresetName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteSamsungPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing Samsung-preset '{startUpParams.SamsungPresetName}'...");
|
||||
await SamsungService.ExecutePresetAsync(startUpParams.SamsungPresetName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteNvidiaPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing NVIDIA-preset '{startUpParams.NvidiaPresetIdOrName}'...");
|
||||
await NvService.ExecutePresetAsync(startUpParams.NvidiaPresetIdOrName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (startUpParams.ExecuteAmdPreset)
|
||||
{
|
||||
Utils.OpenConsole();
|
||||
|
||||
Console.WriteLine($"Executing AMD-preset '{startUpParams.AmdPresetIdOrName}'...");
|
||||
await AmdService.ExecutePresetAsync(startUpParams.AmdPresetIdOrName);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void StartElevated()
|
||||
{
|
||||
try
|
||||
{
|
||||
Application.Run(new ElevatedForm());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error while initializing elevated application: " + ex.ToLogString(Environment.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static IServiceProvider ServiceProvider { get; private set; }
|
||||
private static IHostBuilder CreateHostBuilder()
|
||||
{
|
||||
|
||||
@@ -277,17 +277,21 @@ namespace ColorControl.Services.LG
|
||||
public async Task RefreshDevices(bool connect = true, bool afterStartUp = false)
|
||||
{
|
||||
Devices = Config.Devices;
|
||||
var customIpAddresses = Devices.Where(d => d.IsCustom).Select(d => d.IpAddress);
|
||||
|
||||
var pnpDevices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
|
||||
if (!_appContextProvider.GetAppContext().StartUpParams.NoDeviceRefresh)
|
||||
{
|
||||
var customIpAddresses = Devices.Where(d => d.IsCustom).Select(d => d.IpAddress);
|
||||
|
||||
var autoDevices = pnpDevices.Where(p => !customIpAddresses.Contains(p.IpAddress)).Select(d => new LgDevice(d.Name, d.IpAddress, d.MacAddress, false)).ToList();
|
||||
var autoIpAddresses = pnpDevices.Select(d => d.IpAddress);
|
||||
var pnpDevices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
|
||||
|
||||
Devices.RemoveAll(d => !d.IsCustom && !autoIpAddresses.Contains(d.IpAddress));
|
||||
var autoDevices = pnpDevices.Where(p => !customIpAddresses.Contains(p.IpAddress)).Select(d => new LgDevice(d.Name, d.IpAddress, d.MacAddress, false)).ToList();
|
||||
var autoIpAddresses = pnpDevices.Select(d => d.IpAddress);
|
||||
|
||||
var newAutoDevices = autoDevices.Where(ad => ad.IpAddress != null && !Devices.Any(d => d.IpAddress != null && d.IpAddress.Equals(ad.IpAddress)));
|
||||
Devices.AddRange(newAutoDevices);
|
||||
Devices.RemoveAll(d => !d.IsCustom && !autoIpAddresses.Contains(d.IpAddress));
|
||||
|
||||
var newAutoDevices = autoDevices.Where(ad => ad.IpAddress != null && !Devices.Any(d => d.IpAddress != null && d.IpAddress.Equals(ad.IpAddress)));
|
||||
Devices.AddRange(newAutoDevices);
|
||||
}
|
||||
|
||||
if (Devices.Any())
|
||||
{
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
KEY_HDMI,
|
||||
KEY_CONTENTS,
|
||||
KEY_TV_MODE,
|
||||
KEY_PC_MODE
|
||||
KEY_PC_MODE,
|
||||
KEY_SUB_TITLE,
|
||||
KEY_AD,
|
||||
KEY_PMODE,
|
||||
KEY_ASPECT,
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace ColorControl.Services.Samsung
|
||||
public int CurrentValue { get; set; }
|
||||
public int NumberOfValues { get; set; }
|
||||
public bool Advanced { get; set; }
|
||||
public SamsungPreset Preset { get; set; }
|
||||
public List<string> ValueLabels { get; set; }
|
||||
}
|
||||
|
||||
@@ -92,6 +93,9 @@ namespace ColorControl.Services.Samsung
|
||||
[JsonIgnore]
|
||||
private TaskCompletionSource<string> _taskCompletionSource;
|
||||
|
||||
[JsonIgnore]
|
||||
private List<InvokableAction> _invokableActions = new List<InvokableAction>();
|
||||
|
||||
public SamsungDevice(string name, string ipAddress, string macAddress, bool isCustom = true, bool isDummy = false)
|
||||
{
|
||||
Options = new SamsungDeviceOptions();
|
||||
@@ -102,6 +106,10 @@ namespace ColorControl.Services.Samsung
|
||||
IsCustom = isCustom;
|
||||
IsDummy = isDummy;
|
||||
|
||||
AddInvokableAction("WOL", WakeAction);
|
||||
AddInternalPresetAction(new SamsungPreset("PictureOff", null, new[] { "KEY_AD:1200", "KEY_DOWN:300", "KEY_DOWN:300", "KEY_ENTER" }));
|
||||
AddInternalPresetAction(new SamsungPreset("PictureOn", null, new[] { "KEY_RETURN:1000", "KEY_RETURN", "KEY_RETURN" }));
|
||||
|
||||
_serviceManager = Program.ServiceProvider.GetRequiredService<ServiceManager>();
|
||||
}
|
||||
|
||||
@@ -112,7 +120,10 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
public async Task<bool> ConnectAsync(bool force = false, bool retryToken = false)
|
||||
{
|
||||
await _connectSemaphore.WaitAsync();
|
||||
if (!retryToken)
|
||||
{
|
||||
await _connectSemaphore.WaitAsync();
|
||||
}
|
||||
try
|
||||
{
|
||||
if (force)
|
||||
@@ -127,7 +138,7 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
_samTvConnection = new SamTvConnection();
|
||||
_samTvConnection.Connected += Connection_Connected;
|
||||
var b64 = Utils.Base64Encode("samsungctl");
|
||||
var b64 = Utils.Base64Encode("ColorControl");
|
||||
|
||||
var firstTime = Token == null;
|
||||
var readTimeout = firstTime ? 60000 : 5000;
|
||||
@@ -159,20 +170,6 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
_taskCompletionSource = null;
|
||||
|
||||
//if (Token != null)
|
||||
//{
|
||||
// await Task.Delay(1500);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var seconds = 60;
|
||||
// while (seconds > 0 && Token == null)
|
||||
// {
|
||||
// await Task.Delay(1000);
|
||||
// seconds--;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (firstTime && Token != null && !retryToken)
|
||||
{
|
||||
_samTvConnection.Dispose();
|
||||
@@ -193,7 +190,10 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
finally
|
||||
{
|
||||
_connectSemaphore.Release();
|
||||
if (!retryToken)
|
||||
{
|
||||
_connectSemaphore.Release();
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
@@ -322,7 +322,6 @@ namespace ColorControl.Services.Samsung
|
||||
if (MacAddress != null)
|
||||
{
|
||||
result = WOL.WakeFunctionCheckAdmin(MacAddress, IpAddress);
|
||||
//_justWokeUp = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -379,8 +378,14 @@ namespace ColorControl.Services.Samsung
|
||||
return $"{(IsDummy ? string.Empty : (IsCustom ? "Custom: " : "Auto detect: "))}{Name}{(!string.IsNullOrEmpty(IpAddress) ? ", " + IpAddress : string.Empty)}";
|
||||
}
|
||||
|
||||
internal async Task<bool> ExecutePresetAsync(SamsungPreset preset, AppContext appContext, SamsungServiceConfig config)
|
||||
internal async Task<bool> ExecutePresetAsync(SamsungPreset preset, AppContext appContext = null, SamsungServiceConfig config = null)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
var service = Program.ServiceProvider.GetRequiredService<SamsungService>();
|
||||
config = service.Config;
|
||||
}
|
||||
|
||||
var hasApp = !string.IsNullOrEmpty(preset.AppId);
|
||||
|
||||
var hasWOL = preset.Steps.Any(s => s.Equals("WOL", StringComparison.OrdinalIgnoreCase));
|
||||
@@ -430,7 +435,7 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
try
|
||||
{
|
||||
await ExecuteStepsAsync(preset, config);
|
||||
await ExecuteStepsAsync(preset, appContext, config);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -451,7 +456,7 @@ namespace ColorControl.Services.Samsung
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task ExecuteStepsAsync(SamsungPreset preset, SamsungServiceConfig config)
|
||||
private async Task ExecuteStepsAsync(SamsungPreset preset, AppContext appContext, SamsungServiceConfig config)
|
||||
{
|
||||
foreach (var step in preset.Steps)
|
||||
{
|
||||
@@ -478,6 +483,14 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
|
||||
var executeKey = true;
|
||||
var action = _invokableActions.FirstOrDefault(a => a.Name.Equals(key, StringComparison.OrdinalIgnoreCase));
|
||||
if (action != null)
|
||||
{
|
||||
await ExecuteActionAsync(action, parameters, appContext, config);
|
||||
|
||||
executeKey = false;
|
||||
}
|
||||
|
||||
if (parameters != null && await _serviceManager.HandleExternalServiceAsync(key, parameters))
|
||||
{
|
||||
executeKey = false;
|
||||
@@ -496,6 +509,16 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteActionAsync(InvokableAction action, string[] parameters, AppContext appContext, SamsungServiceConfig config)
|
||||
{
|
||||
if (action.Preset != null)
|
||||
{
|
||||
await ExecutePresetAsync(action.Preset, appContext, config);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendKeyAsync(string key)
|
||||
{
|
||||
var dynamic = new
|
||||
@@ -543,7 +566,7 @@ namespace ColorControl.Services.Samsung
|
||||
if (Options.TurnScreenOffOnScreenSaver)
|
||||
{
|
||||
Logger.Debug("Turning screen off on screen saver");
|
||||
//await _lgTvApi.TurnScreenOff();
|
||||
await TurnPictureOff();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -555,6 +578,26 @@ namespace ColorControl.Services.Samsung
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task TurnPictureOff()
|
||||
{
|
||||
var action = _invokableActions.FirstOrDefault(a => a.Name == "PictureOff");
|
||||
|
||||
if (action?.Preset != null)
|
||||
{
|
||||
await ExecutePresetAsync(action.Preset);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task TurnPictureOn()
|
||||
{
|
||||
var action = _invokableActions.FirstOrDefault(a => a.Name == "PictureOn");
|
||||
|
||||
if (action?.Preset != null)
|
||||
{
|
||||
await ExecutePresetAsync(action.Preset);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> PerformActionAfterScreenSaver(int powerOnRetries)
|
||||
{
|
||||
if (Options.TurnScreenOffOnScreenSaver && IsConnected())
|
||||
@@ -564,7 +607,7 @@ namespace ColorControl.Services.Samsung
|
||||
try
|
||||
{
|
||||
Logger.Debug("Turning screen on after screen saver");
|
||||
//await _lgTvApi.TurnScreenOn();
|
||||
await TurnPictureOn();
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
@@ -589,6 +632,40 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
return new List<SamsungApp>();
|
||||
}
|
||||
|
||||
private void AddInternalPresetAction(SamsungPreset preset)
|
||||
{
|
||||
var action = new InvokableAction
|
||||
{
|
||||
Name = preset.name,
|
||||
Preset = preset
|
||||
};
|
||||
|
||||
_invokableActions.Add(action);
|
||||
}
|
||||
|
||||
private void AddInvokableAction(string name, Func<Dictionary<string, object>, Task<bool>> function)
|
||||
{
|
||||
var action = new InvokableAction
|
||||
{
|
||||
Name = name,
|
||||
AsyncFunction = function,
|
||||
Category = "misc",
|
||||
Title = name
|
||||
};
|
||||
|
||||
_invokableActions.Add(action);
|
||||
}
|
||||
|
||||
internal IEnumerable<InvokableAction> GetInvokableActions(bool showAdvanced)
|
||||
{
|
||||
return _invokableActions;
|
||||
}
|
||||
|
||||
private async Task<bool> WakeAction(Dictionary<string, object> _)
|
||||
{
|
||||
return await WakeAndConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@
|
||||
cbxSamsungPcHdmiPort.Name = "cbxSamsungPcHdmiPort";
|
||||
cbxSamsungPcHdmiPort.Size = new System.Drawing.Size(86, 23);
|
||||
cbxSamsungPcHdmiPort.TabIndex = 62;
|
||||
cbxSamsungPcHdmiPort.Visible = false;
|
||||
cbxSamsungPcHdmiPort.SelectedIndexChanged += cbxSamsungPcHdmiPort_SelectedIndexChanged;
|
||||
//
|
||||
// lblSamsungPcHdmiPort
|
||||
@@ -213,6 +214,7 @@
|
||||
lblSamsungPcHdmiPort.Size = new System.Drawing.Size(84, 15);
|
||||
lblSamsungPcHdmiPort.TabIndex = 61;
|
||||
lblSamsungPcHdmiPort.Text = "PC HDMI port:";
|
||||
lblSamsungPcHdmiPort.Visible = false;
|
||||
//
|
||||
// edtSamsungPresetDescription
|
||||
//
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ColorControl.Services.Samsung
|
||||
private AmdService _amdService;
|
||||
private IntPtr _mainHandle;
|
||||
|
||||
private string _lgTabMessage;
|
||||
private string _tabMessage;
|
||||
private bool _disableEvents = false;
|
||||
|
||||
internal SamsungPanel(SamsungService samsungService, NvService nvService, AmdService amdService, IntPtr handle)
|
||||
@@ -43,9 +43,9 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
scSamsungController.Panel2Collapsed = true;
|
||||
|
||||
FillLgPresets();
|
||||
FillPresets();
|
||||
|
||||
FormUtils.InitSortState(lvSamsungPresets, _config.LgPresetsSortState);
|
||||
FormUtils.InitSortState(lvSamsungPresets, _config.SamsungPresetsSortState);
|
||||
|
||||
//_samsungService.AfterApplyPreset += SamsungServiceAfterApplyPreset;
|
||||
//_samsungService.SelectedDeviceChangedEvent += _samsungService_SelectedDeviceChangedEvent;
|
||||
@@ -95,15 +95,15 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
var startUpParams = AppContext.CurrentContext.StartUpParams;
|
||||
|
||||
if (startUpParams.ExecuteLgPreset)
|
||||
if (startUpParams.ExecuteSamsungPreset)
|
||||
{
|
||||
var _ = _samsungService.ApplyPreset(startUpParams.LgPresetName);
|
||||
var _ = _samsungService.ApplyPreset(startUpParams.SamsungPresetName);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Save()
|
||||
{
|
||||
FormUtils.SaveSortState(lvSamsungPresets.ListViewItemSorter, _config.LgPresetsSortState);
|
||||
FormUtils.SaveSortState(lvSamsungPresets.ListViewItemSorter, _config.SamsungPresetsSortState);
|
||||
}
|
||||
|
||||
private void edtShortcut_KeyDown(object sender, KeyEventArgs e)
|
||||
@@ -116,31 +116,31 @@ namespace ColorControl.Services.Samsung
|
||||
Utils.HandleKeyboardShortcutUp(e);
|
||||
}
|
||||
|
||||
private void FillLgPresets()
|
||||
private void FillPresets()
|
||||
{
|
||||
FormUtils.InitListView(lvSamsungPresets, SamsungPreset.GetColumnNames());
|
||||
|
||||
foreach (var preset in _samsungService.GetPresets())
|
||||
{
|
||||
AddOrUpdateItemLg(preset);
|
||||
AddOrUpdateItem(preset);
|
||||
Utils.RegisterShortcut(_mainHandle, preset.id, preset.shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddOrUpdateItemLg(SamsungPreset preset = null, ListViewItem specItem = null)
|
||||
private void AddOrUpdateItem(SamsungPreset preset = null, ListViewItem specItem = null)
|
||||
{
|
||||
FormUtils.AddOrUpdateListItem(lvSamsungPresets, _samsungService.GetPresets(), _config, preset, specItem);
|
||||
}
|
||||
|
||||
private void btnCloneLg_Click(object sender, EventArgs e)
|
||||
{
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
var newPreset = preset.Clone();
|
||||
AddOrUpdateItemLg(newPreset);
|
||||
AddOrUpdateItem(newPreset);
|
||||
}
|
||||
|
||||
private SamsungPreset GetSelectedLgPreset()
|
||||
private SamsungPreset GetSelectedPreset()
|
||||
{
|
||||
if (lvSamsungPresets.SelectedItems.Count > 0)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace ColorControl.Services.Samsung
|
||||
edtSamsungPresetIncludedProcesses.Enabled = enabled;
|
||||
edtSamsungPresetExcludedProcesses.Enabled = enabled;
|
||||
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
if (preset != null)
|
||||
{
|
||||
@@ -230,7 +230,7 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
private async void btnApplyLg_Click(object sender, EventArgs e)
|
||||
{
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
await ApplyPreset(preset);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ namespace ColorControl.Services.Samsung
|
||||
return;
|
||||
}
|
||||
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
var name = edtNameLg.Text.Trim();
|
||||
|
||||
@@ -275,8 +275,8 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
else
|
||||
{
|
||||
var lgApp = (SamsungApp)cbxSamsungApps.SelectedItem;
|
||||
preset.AppId = lgApp.AppId;
|
||||
var app = (SamsungApp)cbxSamsungApps.SelectedItem;
|
||||
preset.AppId = app.AppId;
|
||||
}
|
||||
|
||||
var triggerType = FormUtils.GetComboBoxEnumItem<PresetTriggerType>(cbxSamsungPresetTrigger);
|
||||
@@ -295,7 +295,7 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
Utils.ParseWords(preset.Steps, text);
|
||||
|
||||
AddOrUpdateItemLg();
|
||||
AddOrUpdateItem();
|
||||
|
||||
if (shortcutChanged)
|
||||
{
|
||||
@@ -326,10 +326,10 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
FormUtils.BuildComboBox(cbxSamsungPresetTrigger, PresetTriggerType.Resume, PresetTriggerType.Shutdown, PresetTriggerType.Standby, PresetTriggerType.Startup, PresetTriggerType.Reserved5, PresetTriggerType.ScreensaverStart, PresetTriggerType.ScreensaverStop);
|
||||
|
||||
if (!string.IsNullOrEmpty(_lgTabMessage))
|
||||
if (!string.IsNullOrEmpty(_tabMessage))
|
||||
{
|
||||
MessageForms.WarningOk(_lgTabMessage);
|
||||
_lgTabMessage = null;
|
||||
MessageForms.WarningOk(_tabMessage);
|
||||
_tabMessage = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,15 +354,15 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
if (!devices.Any())
|
||||
{
|
||||
var message = "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 Samsung TV available! Please make sure it's connected to the same network as this PC.";
|
||||
|
||||
if (Visible /*tcMain.SelectedTab == tabLG*/)
|
||||
if (Visible)
|
||||
{
|
||||
MessageForms.WarningOk(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
_lgTabMessage = message;
|
||||
_tabMessage = message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +406,8 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
private void FillApps(bool forced)
|
||||
{
|
||||
var lgApps = _samsungService?.GetApps();
|
||||
if (forced && (lgApps == null || !lgApps.Any()))
|
||||
var apps = _samsungService?.GetApps();
|
||||
if (forced && (apps == null || !apps.Any()))
|
||||
{
|
||||
MessageForms.WarningOk("Could not refresh the apps. Check the log for details.");
|
||||
return;
|
||||
@@ -417,30 +417,30 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
private void InitApps()
|
||||
{
|
||||
var lgApps = _samsungService?.GetApps();
|
||||
var apps = _samsungService?.GetApps();
|
||||
|
||||
cbxSamsungApps.Items.Clear();
|
||||
if (lgApps != null)
|
||||
if (apps != null)
|
||||
{
|
||||
cbxSamsungApps.Items.AddRange(lgApps.ToArray());
|
||||
cbxSamsungApps.Items.AddRange(apps.ToArray());
|
||||
}
|
||||
|
||||
for (var i = 0; i < lvSamsungPresets.Items.Count; i++)
|
||||
{
|
||||
var item = lvSamsungPresets.Items[i];
|
||||
AddOrUpdateItemLg((SamsungPreset)item.Tag, item);
|
||||
AddOrUpdateItem((SamsungPreset)item.Tag, item);
|
||||
}
|
||||
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
if (preset != null)
|
||||
{
|
||||
cbxSamsungApps.SelectedIndex = lgApps == null ? -1 : lgApps.FindIndex(x => x.AppId.Equals(preset.AppId));
|
||||
cbxSamsungApps.SelectedIndex = apps == null ? -1 : apps.FindIndex(x => x.AppId.Equals(preset.AppId));
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDeleteLg_Click(object sender, EventArgs e)
|
||||
{
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
if (preset == null)
|
||||
{
|
||||
@@ -460,7 +460,7 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
private void btnAddLg_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddOrUpdateItemLg(_samsungService.CreateNewPreset());
|
||||
AddOrUpdateItem(_samsungService.CreateNewPreset());
|
||||
}
|
||||
|
||||
internal async Task ApplyPreset(SamsungPreset preset)
|
||||
@@ -504,12 +504,12 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
private void lvSamsungPresets_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
ApplySelectedLgPreset();
|
||||
ApplySelectedPreset();
|
||||
}
|
||||
|
||||
private async void ApplySelectedLgPreset()
|
||||
private async void ApplySelectedPreset()
|
||||
{
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
await ApplyPreset(preset);
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ namespace ColorControl.Services.Samsung
|
||||
var item = sender as ToolStripItem;
|
||||
var action = item.Tag as SamsungDevice.InvokableAction;
|
||||
|
||||
var value = ShowLgActionForm(action);
|
||||
var value = ShowActionForm(action);
|
||||
|
||||
var text = action.Name;
|
||||
|
||||
@@ -542,7 +542,7 @@ namespace ColorControl.Services.Samsung
|
||||
FormUtils.AddStepToTextBox(edtStepsLg, text);
|
||||
}
|
||||
|
||||
private string ShowLgActionForm(SamsungDevice.InvokableAction action)
|
||||
private string ShowActionForm(SamsungDevice.InvokableAction action)
|
||||
{
|
||||
var text = action.Name;
|
||||
var title = action.Title ?? action.Name;
|
||||
@@ -718,7 +718,7 @@ Use 'Settings > Test power off/on' to test this functionality."
|
||||
{
|
||||
var text = edtShortcutLg.Text;
|
||||
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
FormUtils.UpdateShortcutTextBox(edtShortcutLg, preset);
|
||||
}
|
||||
@@ -786,7 +786,7 @@ Use 'Settings > Test power off/on' to test this functionality."
|
||||
{
|
||||
mnuLgActions.DropDownItems.Clear();
|
||||
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
if (preset == null)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ Use 'Settings > Test power off/on' to test this functionality."
|
||||
|
||||
var device = _samsungService.GetPresetDevice(preset);
|
||||
|
||||
BuildLgActionMenu(device, mnuLgActions.DropDownItems, mnuLgActions.Name, miLgAddAction_Click);
|
||||
BuildActionMenu(device, mnuLgActions.DropDownItems, mnuLgActions.Name, miLgAddAction_Click);
|
||||
FormUtils.BuildServicePresetsMenu(mnuLgNvPresets, _nvService, "NVIDIA", miLgAddNvPreset_Click);
|
||||
FormUtils.BuildServicePresetsMenu(mnuLgAmdPresets, _amdService, "AMD", miLgAddAmdPreset_Click);
|
||||
}
|
||||
@@ -822,49 +822,24 @@ Do you want to continue?"
|
||||
//_samsungService.Config.ShowRemoteControl = chkSamsungRemoteControlShow.Checked;
|
||||
}
|
||||
|
||||
private void BuildLgActionMenu(SamsungDevice device, ToolStripItemCollection parent, string parentName, EventHandler clickEvent, bool showAdvanced = false, bool showGameBar = false)
|
||||
private void BuildActionMenu(SamsungDevice device, ToolStripItemCollection parent, string parentName, EventHandler clickEvent, bool showAdvanced = false)
|
||||
{
|
||||
if (device == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var actions = new List<SamsungDevice.InvokableAction>();// device.GetInvokableActions(showAdvanced);
|
||||
var gameBarActions = new List<SamsungDevice.InvokableAction>();// device.GetInvokableActionsForGameBar();
|
||||
var activatedGameBarActions = new List<SamsungDevice.InvokableAction>();// device.GetActionsForGameBar();
|
||||
var actions = device.GetInvokableActions(showAdvanced);
|
||||
|
||||
var expertActions = actions.Where(a => a.EnumType != null || a.MaxValue > a.MinValue || a.AsyncFunction != null).ToList();
|
||||
|
||||
var categories = expertActions.Select(a => a.Category ?? "misc").Where(c => !string.IsNullOrEmpty(c)).Distinct();
|
||||
|
||||
foreach (var category in categories)
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var catMenuItem = FormUtils.BuildDropDownMenuEx(parent, parentName, Utils.FirstCharUpperCase(category), null, null, category);
|
||||
var text = action.Title ?? action.Name;
|
||||
|
||||
foreach (var action in expertActions.Where(a => (a.Category ?? "misc") == category))
|
||||
{
|
||||
if (!showGameBar)
|
||||
{
|
||||
var text = action.Title ?? action.Name;
|
||||
var item = parent.AddCustom(text);
|
||||
item.Tag = action;
|
||||
item.Click += clickEvent;
|
||||
|
||||
var item = catMenuItem.DropDownItems.AddCustom(text);
|
||||
item.Tag = action;
|
||||
item.Click += clickEvent;
|
||||
continue;
|
||||
}
|
||||
|
||||
var menu = FormUtils.BuildDropDownMenuEx(catMenuItem.DropDownItems, catMenuItem.Name, action.Title, action.EnumType, clickEvent, action, (int)action.MinValue, (int)action.MaxValue, action.NumberOfValues > 1);
|
||||
|
||||
if (!gameBarActions.Contains(action))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!showAdvanced)
|
||||
{
|
||||
return;
|
||||
//var menu = FormUtils.BuildDropDownMenuEx(catMenuItem.DropDownItems, catMenuItem.Name, action.Title, action.EnumType, clickEvent, action, (int)action.MinValue, (int)action.MaxValue, action.NumberOfValues > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -878,7 +853,7 @@ Do you want to continue?"
|
||||
|
||||
private void btnSamsungPresetEditTriggerConditions_Click(object sender, EventArgs e)
|
||||
{
|
||||
var preset = GetSelectedLgPreset();
|
||||
var preset = GetSelectedPreset();
|
||||
|
||||
if (preset == null)
|
||||
{
|
||||
@@ -980,8 +955,6 @@ Connection > Network > Expert Settings:
|
||||
1) Power On with Mobile
|
||||
2) IP Remote
|
||||
|
||||
It will also work over a wired connection.
|
||||
|
||||
Do you want to continue?";
|
||||
|
||||
if (MessageForms.QuestionYesNo(text) == DialogResult.Yes)
|
||||
@@ -1085,6 +1058,7 @@ Do you want to continue?";
|
||||
var turnOffField = new MessageForms.FieldDefinition
|
||||
{
|
||||
Label = "Turn screen off instead of power off",
|
||||
SubLabel = "NOTE: turning the screen off might not work correctly on all models",
|
||||
FieldType = MessageForms.FieldType.CheckBox,
|
||||
Value = device.Options.TurnScreenOffOnScreenSaver
|
||||
};
|
||||
|
||||
@@ -26,6 +26,16 @@ namespace ColorControl.Services.Samsung
|
||||
Steps.AddRange(preset.Steps);
|
||||
}
|
||||
|
||||
public SamsungPreset(string name, string appId, IEnumerable<string> steps = null) : this()
|
||||
{
|
||||
this.name = name;
|
||||
AppId = appId;
|
||||
if (steps != null)
|
||||
{
|
||||
Steps.AddRange(steps);
|
||||
}
|
||||
}
|
||||
|
||||
public SamsungPreset Clone()
|
||||
{
|
||||
var preset = new SamsungPreset(this);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using ColorControl.Common;
|
||||
using ColorControl.Services.Common;
|
||||
using ColorControl.Services.EventDispatcher;
|
||||
using ColorControl.Services.LG;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using NWin32;
|
||||
@@ -32,7 +31,6 @@ namespace ColorControl.Services.Samsung
|
||||
private readonly SessionSwitchDispatcher _sessionSwitchDispatcher;
|
||||
private readonly RestartDetector _restartDetector;
|
||||
private readonly ProcessEventDispatcher _processEventDispatcher;
|
||||
private SamTvConnection _samTvConnection;
|
||||
private string _configFilename;
|
||||
private bool _poweredOffByScreenSaver;
|
||||
private int _poweredOffByScreenSaverProcessId;
|
||||
@@ -111,17 +109,6 @@ namespace ColorControl.Services.Samsung
|
||||
}
|
||||
Config ??= new SamsungServiceConfig();
|
||||
|
||||
//if (!Config.Devices.Any())
|
||||
//{
|
||||
// var device = new SamsungDevice("S95C", "192.168.178.40", "BC-45-5B-A4-70-A4", true);
|
||||
// device.Options.PowerOffOnShutdown = true;
|
||||
// device.Options.PowerOffOnStandby = true;
|
||||
// device.Options.PowerOnAfterResume = true;
|
||||
// device.Options.PowerOnAfterStartup = true;
|
||||
|
||||
// Config.Devices.Add(device);
|
||||
//}
|
||||
|
||||
SamsungPreset.SamsungDevices = Config.Devices;
|
||||
}
|
||||
|
||||
@@ -168,17 +155,21 @@ namespace ColorControl.Services.Samsung
|
||||
public async Task RefreshDevices(bool connect = true, bool afterStartUp = false)
|
||||
{
|
||||
Devices = Config.Devices;
|
||||
var customIpAddresses = Devices.Where(d => d.IsCustom).Select(d => d.IpAddress);
|
||||
|
||||
var pnpDevices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
|
||||
if (!_appContextProvider.GetAppContext().StartUpParams.NoDeviceRefresh)
|
||||
{
|
||||
var customIpAddresses = Devices.Where(d => d.IsCustom).Select(d => d.IpAddress);
|
||||
|
||||
var autoDevices = pnpDevices.Where(p => !customIpAddresses.Contains(p.IpAddress)).Select(d => new SamsungDevice(d.Name, d.IpAddress, d.MacAddress, false)).ToList();
|
||||
var autoIpAddresses = pnpDevices.Select(d => d.IpAddress);
|
||||
var pnpDevices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
|
||||
|
||||
Devices.RemoveAll(d => !d.IsCustom && !autoIpAddresses.Contains(d.IpAddress));
|
||||
var autoDevices = pnpDevices.Where(p => !customIpAddresses.Contains(p.IpAddress)).Select(d => new SamsungDevice(d.Name, d.IpAddress, d.MacAddress, false)).ToList();
|
||||
var autoIpAddresses = pnpDevices.Select(d => d.IpAddress);
|
||||
|
||||
var newAutoDevices = autoDevices.Where(ad => ad.IpAddress != null && !Devices.Any(d => d.IpAddress != null && d.IpAddress.Equals(ad.IpAddress)));
|
||||
Devices.AddRange(newAutoDevices);
|
||||
Devices.RemoveAll(d => !d.IsCustom && !autoIpAddresses.Contains(d.IpAddress));
|
||||
|
||||
var newAutoDevices = autoDevices.Where(ad => ad.IpAddress != null && !Devices.Any(d => d.IpAddress != null && d.IpAddress.Equals(ad.IpAddress)));
|
||||
Devices.AddRange(newAutoDevices);
|
||||
}
|
||||
|
||||
if (Devices.Any())
|
||||
{
|
||||
@@ -197,7 +188,7 @@ namespace ColorControl.Services.Samsung
|
||||
{
|
||||
Logger.Debug("No device has been found, trying to wake it first...");
|
||||
|
||||
var tempDevice = new LgDevice("Test", string.Empty, Config.PreferredMacAddress);
|
||||
var tempDevice = new SamsungDevice("Test", string.Empty, Config.PreferredMacAddress);
|
||||
tempDevice.Wake();
|
||||
|
||||
await Task.Delay(4000);
|
||||
@@ -319,7 +310,7 @@ namespace ColorControl.Services.Samsung
|
||||
|
||||
internal void WakeAfterStartupOrResume(PowerOnOffState state = PowerOnOffState.StartUp, bool checkUserSession = true)
|
||||
{
|
||||
//Devices.ForEach(d => d.ClearPowerOffTask());
|
||||
Devices.ForEach(d => d.ClearPowerOffTask());
|
||||
|
||||
var wakeDevices = Devices.Where(d => state == PowerOnOffState.StartUp && d.Options.PowerOnAfterStartup ||
|
||||
state == PowerOnOffState.Resume && d.Options.PowerOnAfterResume ||
|
||||
@@ -425,11 +416,11 @@ namespace ColorControl.Services.Samsung
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (state == PowerOnOffState.ScreenSaver)
|
||||
//{
|
||||
// tasks.Add(device.PerformActionAfterScreenSaver(Config.PowerOnRetries));
|
||||
// continue;
|
||||
//}
|
||||
if (state == PowerOnOffState.ScreenSaver)
|
||||
{
|
||||
tasks.Add(device.PerformActionAfterScreenSaver(Config.PowerOnRetries));
|
||||
continue;
|
||||
}
|
||||
|
||||
var task = device.WakeAndConnectWithRetries(Config.PowerOnRetries);
|
||||
tasks.Add(task);
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace ColorControl
|
||||
public const string ExecuteAmdPresetParam = "--amdpreset";
|
||||
public const string ExecuteLgPresetParam = "--lgpreset";
|
||||
public const string ExecuteSamsungPresetParam = "--sampreset";
|
||||
public const string NoDeviceRefreshParam = "--no-refresh";
|
||||
public const string NoGuiParam = "--nogui";
|
||||
public const string EnableAutoStartParam = "--enable-auto-start";
|
||||
public const string DisableAutoStartParam = "--disable-auto-start";
|
||||
@@ -39,6 +40,7 @@ namespace ColorControl
|
||||
public string LgPresetName { get; private set; }
|
||||
public bool ExecuteSamsungPreset { get; private set; }
|
||||
public string SamsungPresetName { get; private set; }
|
||||
public bool NoDeviceRefresh { get; private set; }
|
||||
public bool NoGui { get; set; }
|
||||
public bool EnableAutoStart { get; private set; }
|
||||
public TaskRunLevel AutoStartRunLevel { get; private set; } = TaskRunLevel.LUA;
|
||||
@@ -245,6 +247,11 @@ namespace ColorControl
|
||||
settings.StopService = true;
|
||||
break;
|
||||
}
|
||||
case NoDeviceRefreshParam:
|
||||
{
|
||||
settings.NoDeviceRefresh = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace ColorControl.Svc
|
||||
|
||||
var startUpParams = StartUpParams.Parse(args);
|
||||
|
||||
return SvcResultMessage.FromResult(await Program.HandleStartupParams(startUpParams, null));
|
||||
return SvcResultMessage.FromResult(await CommandLineHandler.HandleStartupParams(startUpParams, null));
|
||||
}
|
||||
|
||||
private SvcResultMessage HandleSetLgConfigMessage(SvcMessage message)
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
mc:Ignorable="d"
|
||||
Title="Logging"
|
||||
ResizeMode="CanResize"
|
||||
Width="800"
|
||||
Height="600"
|
||||
Width="1280"
|
||||
Height="720"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
SnapsToDevicePixels="True"
|
||||
Style="{DynamicResource CustomWindowStyle}"
|
||||
d:DesignHeight="450" d:DesignWidth="800" Loaded="Window_Loaded">
|
||||
d:DesignHeight="720" d:DesignWidth="1280" Loaded="Window_Loaded">
|
||||
<DockPanel Margin="6 0 6 6" LastChildFill="True">
|
||||
<GroupBox DockPanel.Dock="Top" HorizontalAlignment="Stretch" Margin="0,6,0,0" VerticalAlignment="Bottom" Header="Log settings" Padding="6">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
Reference in new issue
Block a user