From 6f5f7c4dd3f28c36c4525c85ab731f180f5b5248 Mon Sep 17 00:00:00 2001 From: Vincent Maas Date: Mon, 27 Dec 2021 14:37:14 +0100 Subject: [PATCH] add game bar and some other functions, upgrade to .NET 6 --- .gitignore | 3 +- ColorControl.sln | 10 +- ColorControl/.upgrade-assistant | 1 + ColorControl/AmdService.cs | 3 +- ColorControl/AnalysisReport.sarif | 317 ++++++++ ColorControl/App.config | 24 +- ColorControl/ColorControl.csproj | 308 ++------ ColorControl/ColorDataConverter.cs | 41 +- ColorControl/Config.cs | 11 +- ColorControl/LgDevice.cs | 145 +++- ColorControl/LgGameBar.Designer.cs | 134 ++++ ColorControl/LgGameBar.cs | 341 +++++++++ ColorControl/LgGameBar.resx | 123 ++++ ColorControl/LgPreset.cs | 10 + ColorControl/LgService.cs | 22 +- ColorControl/LgServiceConfig.cs | 12 +- ColorControl/MainForm.Designer.cs | 679 +++++++++++------- ColorControl/MainForm.cs | 356 ++++++--- ColorControl/MainForm.resx | 62 +- ColorControl/NvService.cs | 9 +- ColorControl/Program.cs | 17 +- ColorControl/Properties/AssemblyInfo.cs | 36 - ColorControl/Properties/Resources.Designer.cs | 25 +- ColorControl/Properties/Settings.Designer.cs | 22 +- ColorControl/ServiceBase.cs | 18 +- ColorControl/StartUpParams.cs | 14 + ColorControl/TreeNodeBuilder.cs | 28 +- ColorControl/Utils.cs | 71 +- ColorControl/WOL.cs | 77 +- ColorControl/lgtv/LgTvApi.cs | 20 +- ColorControl/lgtv/LgWebOsMouseService.cs | 25 +- ColorControl/packages.config | 17 - WakeOnLan/ArpRequest.cs | 39 - WakeOnLan/ArpRequestResult.cs | 57 -- WakeOnLan/GlobalSuppressions.cs | 62 -- WakeOnLan/IPAddressExtensions.cs | 166 ----- WakeOnLan/IPEndPointExtensions.cs | 101 --- WakeOnLan/Localization.cs | 12 - WakeOnLan/MagicPacket.cs | 171 ----- WakeOnLan/NativeMethods.cs | 14 - WakeOnLan/PhysicalAddressExtensions.cs | 148 ---- WakeOnLan/PhysicalAddressProperties.cs | 34 - WakeOnLan/Properties/AssemblyInfo.cs | 4 - WakeOnLan/SecureOnPassword.cs | 95 --- WakeOnLan/Topology/ByteArrayExtensions.cs | 287 -------- WakeOnLan/Topology/ByteExtensions.cs | 43 -- WakeOnLan/Topology/INetMask.cs | 17 - WakeOnLan/Topology/IPAddressExtensions.cs | 167 ----- WakeOnLan/Topology/NetMask.cs | 312 -------- WakeOnLan/Topology/NetMaskExtensions.cs | 36 - WakeOnLan/Topology/SiblingOptions.cs | 27 - WakeOnLan/Topology/StringExtensions.cs | 39 - WakeOnLan/Topology/UIntExtensions.cs | 41 -- WakeOnLan/WakeOnLan.csproj | 26 - 54 files changed, 2022 insertions(+), 2857 deletions(-) create mode 100644 ColorControl/.upgrade-assistant create mode 100644 ColorControl/AnalysisReport.sarif create mode 100644 ColorControl/LgGameBar.Designer.cs create mode 100644 ColorControl/LgGameBar.cs create mode 100644 ColorControl/LgGameBar.resx delete mode 100644 ColorControl/Properties/AssemblyInfo.cs delete mode 100644 ColorControl/packages.config delete mode 100644 WakeOnLan/ArpRequest.cs delete mode 100644 WakeOnLan/ArpRequestResult.cs delete mode 100644 WakeOnLan/GlobalSuppressions.cs delete mode 100644 WakeOnLan/IPAddressExtensions.cs delete mode 100644 WakeOnLan/IPEndPointExtensions.cs delete mode 100644 WakeOnLan/Localization.cs delete mode 100644 WakeOnLan/MagicPacket.cs delete mode 100644 WakeOnLan/NativeMethods.cs delete mode 100644 WakeOnLan/PhysicalAddressExtensions.cs delete mode 100644 WakeOnLan/PhysicalAddressProperties.cs delete mode 100644 WakeOnLan/Properties/AssemblyInfo.cs delete mode 100644 WakeOnLan/SecureOnPassword.cs delete mode 100644 WakeOnLan/Topology/ByteArrayExtensions.cs delete mode 100644 WakeOnLan/Topology/ByteExtensions.cs delete mode 100644 WakeOnLan/Topology/INetMask.cs delete mode 100644 WakeOnLan/Topology/IPAddressExtensions.cs delete mode 100644 WakeOnLan/Topology/NetMask.cs delete mode 100644 WakeOnLan/Topology/NetMaskExtensions.cs delete mode 100644 WakeOnLan/Topology/SiblingOptions.cs delete mode 100644 WakeOnLan/Topology/StringExtensions.cs delete mode 100644 WakeOnLan/Topology/UIntExtensions.cs delete mode 100644 WakeOnLan/WakeOnLan.csproj diff --git a/.gitignore b/.gitignore index 4ce6fdd..31a5f9d 100644 --- a/.gitignore +++ b/.gitignore @@ -337,4 +337,5 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb +*.clef diff --git a/ColorControl.sln b/ColorControl.sln index c62f64f..67a44de 100644 --- a/ColorControl.sln +++ b/ColorControl.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30128.74 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorControl", "ColorControl\ColorControl.csproj", "{A6005D08-70F0-44CB-A384-9219EBA84F21}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorControl", "ColorControl\ColorControl.csproj", "{A6005D08-70F0-44CB-A384-9219EBA84F21}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,8 +15,8 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|x64.ActiveCfg = Debug|x64 - {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|x64.Build.0 = Debug|x64 + {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|x64.ActiveCfg = Debug|Any CPU + {A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|x64.Build.0 = Debug|Any CPU {A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|Any CPU.ActiveCfg = Release|Any CPU {A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|Any CPU.Build.0 = Release|Any CPU {A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|x64.ActiveCfg = Release|x64 diff --git a/ColorControl/.upgrade-assistant b/ColorControl/.upgrade-assistant new file mode 100644 index 0000000..139ec6b --- /dev/null +++ b/ColorControl/.upgrade-assistant @@ -0,0 +1 @@ +{"Build":"0.3.261602\u002Befb3cc30a24e699e6e4337f263a2b9478f04f618","CurrentProject":"ColorControl.csproj","EntryPoints":["ColorControl.csproj"],"Properties":{}} \ No newline at end of file diff --git a/ColorControl/AmdService.cs b/ColorControl/AmdService.cs index 5eb0b12..31ede47 100644 --- a/ColorControl/AmdService.cs +++ b/ColorControl/AmdService.cs @@ -1,4 +1,5 @@ using ATI.ADL; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -49,7 +50,7 @@ namespace ColorControl { try { - var json = _JsonSerializer.Serialize(_presets); + var json = JsonConvert.SerializeObject(_presets); File.WriteAllText(_presetsFilename, json); } catch (Exception e) diff --git a/ColorControl/AnalysisReport.sarif b/ColorControl/AnalysisReport.sarif new file mode 100644 index 0000000..acfca8c --- /dev/null +++ b/ColorControl/AnalysisReport.sarif @@ -0,0 +1,317 @@ +{ + "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "Dependency Analysis", + "semanticVersion": "0.3.261602", + "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview", + "rules": [ + { + "id": "UA103", + "name": "ReferenceToBeDeleted", + "fullDescription": { + "text": "References that need to be deleted in order to upgrade the project to chosen TFM" + }, + "helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" + }, + { + "id": "UA106", + "name": "PackageToBeAdded", + "fullDescription": { + "text": "Packages that need to be added in order to upgrade the project to chosen TFM" + }, + "helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" + }, + { + "id": "UA108", + "name": "FrameworkReferenceToBeAdded", + "fullDescription": { + "text": "Framework Reference that need to be added in order to upgrade the project to chosen TFM" + }, + "helpUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" + } + ] + } + }, + "results": [ + { + "ruleId": "UA103", + "message": { + "text": "Reference to System.Configuration needs to be deleted." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA103", + "message": { + "text": "Reference to System.ServiceModel needs to be deleted." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA103", + "message": { + "text": "Reference to System.Web needs to be deleted." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA103", + "message": { + "text": "Reference to System.Web.Extensions needs to be deleted." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.Configuration.ConfigurationManager, Version=5.0.0 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.Primitives, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.Http, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.Duplex, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.NetTcp, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.Security, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package System.ServiceModel.Federation, Version=4.8.1 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers, Version=0.3.261602 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA106", + "message": { + "text": "Package Microsoft.Windows.Compatibility, Version=6.0.0 needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + }, + { + "ruleId": "UA108", + "message": { + "text": "Framework Reference to Microsoft.AspNetCore.App needs to be added." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/ColorControl.csproj" + }, + "region": {} + } + } + ] + } + ], + "columnKind": "utf16CodeUnits" + }, + { + "tool": { + "driver": { + "name": "API Upgradability", + "semanticVersion": "0.3.261602", + "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview" + } + }, + "results": [], + "columnKind": "utf16CodeUnits" + }, + { + "tool": { + "driver": { + "name": "Component Analysis", + "semanticVersion": "0.3.261602", + "informationUri": "https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview", + "rules": [ + { + "id": "UA202", + "name": "Microsoft.DotNet.UpgradeAssistant.Extensions.Windows.WinformsDpiSettingUpdater", + "fullDescription": { + "text": "Winforms Source Updater" + }, + "helpUri": "about:blank" + } + ] + } + }, + "results": [ + { + "ruleId": "UA202", + "message": { + "text": "HighDpiMode needs to set in Main() instead of app.config or app.manifest - Application.SetHighDpiMode(HighDpiMode.). It is recommended to use SystemAware as the HighDpiMode option for better results." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///C:/Users/vinni/source/repos/ColorControl/ColorControl/Program.cs" + }, + "region": {} + } + } + ] + } + ], + "columnKind": "utf16CodeUnits" + } + ] +} \ No newline at end of file diff --git a/ColorControl/App.config b/ColorControl/App.config index 1985185..4427404 100644 --- a/ColorControl/App.config +++ b/ColorControl/App.config @@ -1,29 +1,29 @@ - + - + - - + + - - + + - - + + - - + + - + - \ No newline at end of file + diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj index d344a57..3c672ed 100644 --- a/ColorControl/ColorControl.csproj +++ b/ColorControl/ColorControl.csproj @@ -1,17 +1,7 @@ - - - + - Debug - AnyCPU - {A6005D08-70F0-44CB-A384-9219EBA84F21} + net6.0-windows10.0.20348.0 WinExe - ColorControl - ColorControl - v4.7.2 - 512 - true - true false publish\ true @@ -26,271 +16,52 @@ https://www.maassoft.com/downloads/ColorControl/ ColorControl Maassoft - 0 - 4.5.0.0 - false + Maassoft + 0 + 5.0.0.0 + 5.0.0.0 + false true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + true + true + false + true + pngbarn.ico + 10.0.17763.0 + 2020-2022 Maassoft + Maassoft + CF0BC153EA664CD97AC6F234B91F45D34630958F + ColorControl_1_TemporaryKey.pfx + true + LocalIntranet + Properties\app.manifest + true + ColorControl_TemporaryKey.pfx - true bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt MinimumRecommendedRules.ruleset - true bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt MinimumRecommendedRules.ruleset - true - - - CF0BC153EA664CD97AC6F234B91F45D34630958F - - - ColorControl_1_TemporaryKey.pfx - - - true - - - LocalIntranet - - - Properties\app.manifest - - - true - - - false - - - ColorControl_TemporaryKey.pfx - - - pngbarn.ico - - ..\packages\TaskScheduler.2.9.1\lib\net452\Microsoft.Win32.TaskScheduler.dll - - - ..\packages\Native.0.1.1\lib\net46\Native.dll - - - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll - - - ..\packages\NStandard.0.8.9\lib\net46\NStandard.dll - - - ..\packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll - - - ..\packages\NWin32.1.2.0\lib\net46\NWin32.dll - - - ..\packages\PacketDotNet.1.2.0\lib\net45\PacketDotNet.dll - - - - ..\packages\SharpPcap.5.4.0\lib\netstandard2.0\SharpPcap.dll - - - - ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - - - - - - - - ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll - - - - ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll - - - - False - ..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll - - - - - - - - - - - - - - - - - ..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.18362.0\Windows.winmd - - - - - - - - - - - + + True True - True - Resources.resx + Settings.settings - + UserControl - - RemoteControlPanel.cs - - - - - - - - - - Form - - - RemoteControlForm.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - - MainForm.cs - - - - - - MainForm.cs - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - - RemoteControlForm.cs - - - RemoteControlPanel.cs - - PreserveNewest - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - False - Microsoft .NET Framework 4.7.2 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - @@ -309,5 +80,28 @@ True - + + + + + + + + + + + + + + + + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + \ No newline at end of file diff --git a/ColorControl/ColorDataConverter.cs b/ColorControl/ColorDataConverter.cs index 0872404..2dfc989 100644 --- a/ColorControl/ColorDataConverter.cs +++ b/ColorControl/ColorDataConverter.cs @@ -1,27 +1,40 @@ -using NvAPIWrapper.Display; +using Newtonsoft.Json; +using NvAPIWrapper.Display; using System; using System.Collections.Generic; -using System.Web.Script.Serialization; namespace ColorControl { - public class ColorDataConverter : JavaScriptConverter + public class ColorDataConverter : JsonConverter { - public override IEnumerable SupportedTypes + public override bool CanWrite { get { return false; } } + + public override ColorData ReadJson(JsonReader reader, Type objectType, ColorData existingValue, bool hasExistingValue, JsonSerializer serializer) { - get { return new List() { typeof(ColorData) }; } + var result = new Dictionary(); + + if (reader.TokenType == JsonToken.StartObject) + { + reader.Read(); + while (reader.TokenType == JsonToken.PropertyName) + { + var propertyName = reader.Value; + + reader.Read(); + var value = reader.Value; + + result.Add(propertyName.ToString(), value); + + reader.Read(); + } + } + + return NvPreset.GenerateColorData(result); } - public override IDictionary Serialize(object obj, JavaScriptSerializer serializer) + public override void WriteJson(JsonWriter writer, ColorData value, JsonSerializer serializer) { - Dictionary result = new Dictionary(); - if (obj == null) return result; - return result; - } - - public override object Deserialize(IDictionary dictionary, Type type, JavaScriptSerializer serializer) - { - return NvPreset.GenerateColorData(dictionary); + throw new NotImplementedException(); } } } diff --git a/ColorControl/Config.cs b/ColorControl/Config.cs index 5e024f3..1ba7865 100644 --- a/ColorControl/Config.cs +++ b/ColorControl/Config.cs @@ -3,25 +3,17 @@ public class Config { public bool StartMinimized { get; set; } - public bool MinimizeOnClose { get; set; } - public bool MinimizeToTray { get; set; } - public bool CheckForUpdates { get; set; } - public int DisplaySettingsDelay { get; set; } - public string ScreenSaverShortcut { get; set; } - public int FormWidth { get; set; } public int FormHeight { get; set; } - public int NvPresetId_ApplyOnStartup { get; set; } - public int AmdPresetId_ApplyOnStartup { get; set; } - public bool FixChromeFonts { get; set; } + public bool UseGdiScaling { get; set; } public Config() { @@ -32,6 +24,7 @@ MinimizeToTray = true; CheckForUpdates = true; FixChromeFonts = false; + UseGdiScaling = true; } } } diff --git a/ColorControl/LgDevice.cs b/ColorControl/LgDevice.cs index 2de652c..71a9bd7 100644 --- a/ColorControl/LgDevice.cs +++ b/ColorControl/LgDevice.cs @@ -19,12 +19,17 @@ namespace ColorControl public decimal MinValue { get; set; } public decimal MaxValue { get; set; } public string Category { get; set; } + public string Title { get; set; } + public int CurrentValue { get; set; } + public LgPreset Preset { get; set; } } public class LgDevicePictureSettings { public int Backlight { get; set; } public int Contrast { get; set; } + public int Brightness { get; set; } + public int Color { get; set; } } public enum PowerState @@ -46,8 +51,9 @@ namespace ColorControl protected static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); public static Func ExternalServiceHandler; + public static List DefaultActionsOnGameBar = new() { "backlight", "contrast", "brightness", "color" }; - public string Name { get; private set; } + public string Name { get; private set; } public string IpAddress { get; private set; } public string MacAddress { get; private set; } public bool IsCustom { get; private set; } @@ -60,6 +66,26 @@ namespace ColorControl public bool PowerOffOnStandby { get; set; } public bool PowerSwitchOnScreenSaver { get; set; } + private List _actionsForGameBar; + + public List ActionsOnGameBar { + get + { + return _actionsForGameBar; + } + set + { + if (value?.Any() == false) + { + _actionsForGameBar = DefaultActionsOnGameBar; + } + else + { + _actionsForGameBar = value; + } + } + } + [JsonIgnore] public PowerState CurrentState { get; set; } @@ -85,10 +111,13 @@ namespace ColorControl [JsonIgnore] public LgDevicePictureSettings PictureSettings { get; private set; } + public event EventHandler PictureSettingsChangedEvent; + [JsonConstructor] public LgDevice(string name, string ipAddress, string macAddress, bool isCustom = true, bool isDummy = false) { PictureSettings = new LgDevicePictureSettings(); + ActionsOnGameBar = new List { "backlight", "contrast", "brightness", "color" }; Name = name; IpAddress = ipAddress; @@ -101,19 +130,20 @@ namespace ColorControl AddGenericPictureAction("brightness", minValue: 0, maxValue: 100); AddGenericPictureAction("contrast", minValue: 0, maxValue: 100); AddGenericPictureAction("color", minValue: 0, maxValue: 100); - AddGenericPictureAction("pictureMode", typeof(PictureMode)); - AddGenericPictureAction("colorGamut", typeof(ColorGamut)); - AddGenericPictureAction("dynamicContrast", typeof(OffToAuto)); + AddGenericPictureAction("pictureMode", typeof(PictureMode), title: "Picture Mode"); + AddGenericPictureAction("colorGamut", typeof(ColorGamut), title: "Color Gamut"); + AddGenericPictureAction("dynamicContrast", typeof(OffToHigh), title: "Dynamic Contrast"); + AddGenericPictureAction("gamma", typeof(GammaExp)); //AddGenericPictureAction("dynamicColor", typeof(OffToAuto)); //AddGenericPictureAction("superResolution", typeof(OffToAuto)); - AddGenericPictureAction("peakBrightness", typeof(OffToAuto)); - AddGenericPictureAction("smoothGradation", typeof(OffToAuto)); - AddGenericPictureAction("energySaving", typeof(EnergySaving)); - AddGenericPictureAction("hdrDynamicToneMapping", typeof(DynamicTonemapping)); + AddGenericPictureAction("peakBrightness", typeof(OffToHigh), title: "Peak Brightness"); + AddGenericPictureAction("smoothGradation", typeof(OffToAuto), title: "Smooth Gradation"); + AddGenericPictureAction("energySaving", typeof(EnergySaving), title: "Energy Saving"); + AddGenericPictureAction("hdrDynamicToneMapping", typeof(DynamicTonemapping), title: "HDR Dynamic Tone Mapping"); //AddGenericPictureAction("blackLevel", typeof(LowToAuto)); //AddGenericPictureAction("ambientLightCompensation", typeof(OffToAuto2)); //AddGenericPictureAction("truMotionMode", typeof(TruMotionMode)); - AddGenericPictureAction("motionProOLED", typeof(OffToHigh)); + AddGenericPictureAction("motionProOLED", typeof(OffToHigh), title: "OLED Motion Pro"); AddGenericPictureAction("uhdDeepColorHDMI1", typeof(OffToOn), category: "other"); AddGenericPictureAction("uhdDeepColorHDMI2", typeof(OffToOn), category: "other"); AddGenericPictureAction("uhdDeepColorHDMI3", typeof(OffToOn), category: "other"); @@ -132,6 +162,9 @@ namespace ColorControl AddGenericPictureAction("adjustingLuminance", minValue: -50, maxValue: 50); AddInvokableAction("turnScreenOff", new Func, bool>(TurnScreenOffAction)); AddInvokableAction("turnScreenOn", new Func, bool>(TurnScreenOnAction)); + + AddInternalPresetAction(new LgPreset("InStart", "com.webos.app.factorywin", new[] { "0", "4", "1", "3" })); + AddInternalPresetAction(new LgPreset("Software Update", "com.webos.app.softwareupdate")); } private void AddInvokableAction(string name, Func, bool> function) @@ -145,7 +178,18 @@ namespace ColorControl _invokableActions.Add(action); } - private void AddGenericPictureAction(string name, Type type = null, decimal minValue = 0, decimal maxValue = 0, string category = "picture") + private void AddInternalPresetAction(LgPreset preset) + { + var action = new InvokableAction + { + Name = preset.name, + Preset = preset + }; + + _invokableActions.Add(action); + } + + private void AddGenericPictureAction(string name, Type type = null, decimal minValue = 0, decimal maxValue = 0, string category = "picture", string title = null) { var action = new InvokableAction { @@ -154,12 +198,26 @@ namespace ColorControl EnumType = type, MinValue = minValue, MaxValue = maxValue, - Category = category + Category = category, + Title = title == null ? name.Substring(0, 1).ToUpper() + name.Substring(1) : title }; _invokableActions.Add(action); } + public void AddGameBarAction(string name) + { + if (!ActionsOnGameBar.Contains(name)) + { + ActionsOnGameBar.Add(name); + } + } + + public void RemoveGameBarAction(string name) + { + ActionsOnGameBar.Remove(name); + } + public override string ToString() { //return (IsDummy ? string.Empty : (IsCustom ? "Custom: " : "Auto detect: ")) + $"{Name}" + (!string.IsNullOrEmpty(IpAddress) ? $" ({IpAddress})" : string.Empty); @@ -242,8 +300,18 @@ namespace ColorControl { PictureSettings.Contrast = Utils.ParseDynamicAsInt(settings.contrast, PictureSettings.Contrast); } + if (settings.brightness != null) + { + PictureSettings.Brightness = Utils.ParseDynamicAsInt(settings.brightness, PictureSettings.Brightness); + } + if (settings.color != null) + { + PictureSettings.Color = Utils.ParseDynamicAsInt(settings.color, PictureSettings.Color); + } } + PictureSettingsChangedEvent?.Invoke(this, EventArgs.Empty); + return true; } @@ -323,7 +391,7 @@ namespace ColorControl try { dynamic @params = null; - if (config.AllowFirmwareDowngrade && preset.appId.Equals("com.webos.app.softwareupdate")) + if (config.ShowAdvancedActions && preset.appId.Equals("com.webos.app.softwareupdate")) { @params = new { mode = "user", flagUpdate = true }; } @@ -409,10 +477,7 @@ namespace ColorControl var action = _invokableActions.FirstOrDefault(a => a.Name.Equals(key, StringComparison.OrdinalIgnoreCase)); if (action != null) { - if (!key.Equals("WOL")) - { - ExecuteAction(action, parameters); - } + ExecuteAction(action, parameters); executeKey = false; } @@ -458,7 +523,7 @@ namespace ColorControl private void SendKey(LgWebOsMouseService mouse, string key) { - if (key.Length == 1 && int.TryParse(key, out _)) + if (key.Length >= 1 && int.TryParse(key[0].ToString(), out _)) { key = "_" + key; } @@ -606,6 +671,18 @@ namespace ColorControl return _invokableActions; } + public List GetInvokableActionsForGameBar() + { + var actions = GetInvokableActions(); + return actions.Where(a => a.Category == "picture" && (a.EnumType != null && a.EnumType != typeof(PictureMode) || a.MinValue >= 0 && a.MaxValue > 0)).ToList(); + } + + public List GetActionsForGameBar() + { + var actions = GetInvokableActions(); + return actions.Where(a => ActionsOnGameBar.Contains(a.Name)).ToList(); + } + public async Task PowerOn() { var mouse = await _lgTvApi.GetMouse(); @@ -654,6 +731,11 @@ namespace ColorControl await _lgTvApi.SetSystemSettings("backlight", backlight.ToString()); } + internal async Task SetContrast(int contrast) + { + await _lgTvApi.SetSystemSettings("contrast", contrast.ToString()); + } + public async Task SetOLEDMotionPro(string mode) { await _lgTvApi.SetConfig("tv.model.motionProMode", mode); @@ -666,6 +748,8 @@ namespace ColorControl internal async Task SetSystemSettings(string name, string value) { await _lgTvApi.SetSystemSettings(name, value); + + UpdateCurrentValueOfAction(name, value); } internal async Task GetPictureSettings() @@ -710,7 +794,34 @@ namespace ColorControl var task = _lgTvApi.SetSystemSettings(settingName, value, category); Utils.WaitForTask(task); + UpdateCurrentValueOfAction(settingName, value.ToString()); + return true; } + + private void UpdateCurrentValueOfAction(string settingName, string value) + { + if (settingName != "backlight" && settingName != "contrast" && settingName != "brightness" && settingName != "color") + { + var action = _invokableActions.FirstOrDefault(a => a.Name == settingName); + if (action != null) + { + if (action.EnumType != null) + { + try + { + var enumValue = Enum.Parse(action.EnumType, value); + var intEnum = (int)enumValue; + action.CurrentValue = intEnum; + } + catch (Exception) { } + } + else + { + action.CurrentValue = 0; + } + } + } + } } } diff --git a/ColorControl/LgGameBar.Designer.cs b/ColorControl/LgGameBar.Designer.cs new file mode 100644 index 0000000..a7ecd26 --- /dev/null +++ b/ColorControl/LgGameBar.Designer.cs @@ -0,0 +1,134 @@ + +namespace ColorControl +{ + partial class LgGameBar + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.flowPanel = new System.Windows.Forms.FlowLayoutPanel(); + this.btnClose = new System.Windows.Forms.Button(); + this.lblTvName = new System.Windows.Forms.Label(); + this.tmrHide = new System.Windows.Forms.Timer(this.components); + this.lblProcessName = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // flowPanel + // + this.flowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flowPanel.Location = new System.Drawing.Point(12, 41); + this.flowPanel.Name = "flowPanel"; + this.flowPanel.Size = new System.Drawing.Size(231, 282); + this.flowPanel.TabIndex = 0; + this.flowPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RemoteControlForm_MouseDown); + this.flowPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.flowPanel_MouseMove); + this.flowPanel.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.flowPanel_PreviewKeyDown); + // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.FlatAppearance.BorderColor = System.Drawing.Color.DarkGray; + this.btnClose.FlatAppearance.BorderSize = 0; + this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnClose.ForeColor = System.Drawing.Color.White; + this.btnClose.Location = new System.Drawing.Point(240, 0); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(14, 23); + this.btnClose.TabIndex = 1; + this.btnClose.TabStop = false; + this.btnClose.Text = "x"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // lblTvName + // + this.lblTvName.AutoSize = true; + this.lblTvName.ForeColor = System.Drawing.Color.White; + this.lblTvName.Location = new System.Drawing.Point(12, 0); + this.lblTvName.Name = "lblTvName"; + this.lblTvName.Size = new System.Drawing.Size(25, 13); + this.lblTvName.TabIndex = 0; + this.lblTvName.Text = " "; + // + // tmrHide + // + this.tmrHide.Interval = 5000; + this.tmrHide.Tick += new System.EventHandler(this.tmrHide_Tick); + // + // lblProcessName + // + this.lblProcessName.AutoSize = true; + this.lblProcessName.ForeColor = System.Drawing.Color.White; + this.lblProcessName.Location = new System.Drawing.Point(12, 20); + this.lblProcessName.Name = "lblProcessName"; + this.lblProcessName.Size = new System.Drawing.Size(25, 13); + this.lblProcessName.TabIndex = 2; + this.lblProcessName.Text = " "; + // + // LgGameBar + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(255, 335); + this.Controls.Add(this.lblProcessName); + this.Controls.Add(this.lblTvName); + this.Controls.Add(this.btnClose); + this.Controls.Add(this.flowPanel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "LgGameBar"; + this.Opacity = 0.7D; + this.Text = "RemoteControlForm"; + this.TopMost = true; + this.Activated += new System.EventHandler(this.LgGameBar_Activated); + this.Deactivate += new System.EventHandler(this.LgGameBar_Deactivate); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.RemoteControlForm_FormClosed); + this.Load += new System.EventHandler(this.RemoteControlForm_Load); + this.Shown += new System.EventHandler(this.RemoteControlForm_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RemoteControlForm_KeyDown); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RemoteControlForm_KeyUp); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RemoteControlForm_MouseDown); + this.Move += new System.EventHandler(this.LgGameBar_Move); + this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.RemoteControlForm_PreviewKeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flowPanel; + private System.Windows.Forms.Button btnClose; + private System.Windows.Forms.Label lblTvName; + private System.Windows.Forms.Timer tmrHide; + private System.Windows.Forms.Label lblProcessName; + } +} \ No newline at end of file diff --git a/ColorControl/LgGameBar.cs b/ColorControl/LgGameBar.cs new file mode 100644 index 0000000..5eb4586 --- /dev/null +++ b/ColorControl/LgGameBar.cs @@ -0,0 +1,341 @@ +using NWin32; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; + +namespace ColorControl +{ + partial class LgGameBar : Form + { + private class TbSetting + { + public TrackBar TrackBar { get; set; } + public string Name { get; set; } + public Type EnumType { get; set; } + public string PropertyName { get; set; } + } + + private LgService _lgService; + private LgDevice _lgDevice; + private ToolTip _toolTip; + private bool _settingChanged = false; + private List _trackBars = new List(); + private List _lastActions = new List(); + + public LgGameBar(LgService lgService) + { + _lgService = lgService; + + _lgDevice = _lgService.SelectedDevice; + + _lgDevice.PictureSettingsChangedEvent += LgDevice_PictureSettingsChangedEvent; + + InitializeComponent(); + + _toolTip = new ToolTip(); + } + + private void GenerateComponents() + { + var actions = _lgDevice.GetActionsForGameBar(); + var actionNames = actions.Select(a => a.Name).ToList(); + + if (_lastActions.Count == actions.Count && _lastActions.All(a => actionNames.Contains(a))) { + return; + } + + flowPanel.Controls.Clear(); + _trackBars.Clear(); + + foreach (var action in actions) + { + CreateGroup(action.Title, action.Name, (int)action.MinValue, (int)action.MaxValue, action.EnumType); + } + + _lastActions.Clear(); + _lastActions.AddRange(actionNames); + + Width = 28 + (_trackBars.Count() * 56); + } + + private TrackBar CreateGroup(string title, string settingName = null, int min = 0, int max = 100, Type enumType = null) + { + if (settingName == null) + { + settingName = title.ToLowerInvariant(); + } + + var panel = new Panel(); + panel.Width = 50; + panel.Height = flowPanel.Height; + var label = new Label(); + label.Text = title; + label.ForeColor = Color.White; + label.Parent = panel; + + if (min == 0 && max == 0 && enumType != null) + { + max = Enum.GetValues(enumType).Length - 1; + } + + var trackBar = CreateTrackBar(min, max); + trackBar.Top = label.Height; + trackBar.Height = panel.Height - trackBar.Top - 4; + trackBar.Parent = panel; + trackBar.Scroll += tbTrackBar_Scroll; + var margin = trackBar.Margin; + margin.Top = 0; + margin.Bottom = 0; + trackBar.Margin = margin; + trackBar.ValueChanged += TrackBar_ValueChanged; + + var setting = new TbSetting + { + TrackBar = trackBar, + Name = settingName, + EnumType = enumType, + PropertyName = title + }; + + trackBar.Tag = setting; + + panel.Parent = flowPanel; + + _trackBars.Add(trackBar); + + return trackBar; + } + + private void TrackBar_ValueChanged(object sender, EventArgs e) + { + //var trackBar = sender as TrackBar; + + //if (_toolTip != null) + //{ + // _toolTip.SetToolTip(trackBar, trackBar.Value.ToString()); + //} + } + + private TrackBar CreateTrackBar(int min, int max) + { + var trackBar = new TrackBar(); + trackBar.BackColor = Color.Black; + trackBar.Orientation = Orientation.Vertical; + trackBar.TickFrequency = (max >= 50) ? 5 : 1; + trackBar.TickStyle = TickStyle.Both; + trackBar.Minimum = min; + trackBar.Maximum = max; + + return trackBar; + } + + private void LgDevice_PictureSettingsChangedEvent(object sender, EventArgs e) + { + if (_settingChanged) + { + _settingChanged = false; + return; + } + BeginInvoke(new Action(UpdateValues)); + } + + private void UpdateValues() + { + var dynType = _lgDevice.PictureSettings.GetType(); + var actions = _lgDevice.GetInvokableActions(); + foreach (var trackbar in _trackBars.Where(t => !t.Focused)) + { + var setting = (TbSetting)trackbar.Tag; + + if (setting.PropertyName == null) + { + continue; + } + + var prop = dynType.GetProperty(setting.PropertyName); + + if (prop != null) + { + var value = prop.GetValue(_lgDevice.PictureSettings); + + if (value is int intValue) + { + trackbar.Value = intValue; + } + } + else + { + var action = actions.FirstOrDefault(a => a.Name == setting.Name); + if (action != null) + { + trackbar.Value = action.CurrentValue; + } + } + } + } + + private void RemoteControlForm_Load(object sender, EventArgs e) + { + } + + private void ButtonClick(object sender, EventArgs e) + { + if (e is MouseEventArgs) + { + var preset = (LgPreset)(sender as Button).Tag; + + var _ = _lgService.ApplyPreset(preset); + } + } + + private void btnClose_Click(object sender, EventArgs e) + { + Hide(); + } + + private void RemoteControlForm_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + NativeMethods.ReleaseCapture(); + var intPtr = new UIntPtr(2); + NativeMethods.SendMessageW(Handle, NativeConstants.WM_NCLBUTTONDOWN, intPtr, IntPtr.Zero); + } + } + + private void RemoteControlForm_KeyDown(object sender, KeyEventArgs e) + { + //var key = e.KeyCode; + //HandleKey(key); + } + + private void flowPanel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + //HandleKey(e.KeyCode); + } + + private void HandleKey(Keys key) + { + var cvt = new KeysConverter(); + var shortcut = (string)cvt.ConvertTo(key, typeof(string)); + } + + private void RemoteControlForm_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + //HandleKey(e.KeyCode); + } + + private void RemoteControlForm_KeyUp(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.F1) + { + return; + } + + HandleKey(e.KeyCode); + } + + private void flowPanel_MouseMove(object sender, MouseEventArgs e) + { + ResetAutoHide(); + } + + private void pnlMouse_MouseEnter(object sender, EventArgs e) + { + } + + private void RemoteControlForm_FormClosed(object sender, FormClosedEventArgs e) + { + } + + private void pnlMouse_MouseUp(object sender, MouseEventArgs e) + { + } + + private void HandleMouse(MouseEventArgs e) + { + } + + private void RemoteControlForm_Shown(object sender, EventArgs e) + { + GenerateComponents(); + UpdateInfo(); + ResetAutoHide(); + } + + private void UpdateInfo() + { + lblTvName.Text = $"Device: {_lgDevice?.Name ?? "No tv selected"}"; + lblProcessName.Text = $"Current process: {_lgService.MonitorContext?.ForegroundProcess?.ProcessName ?? _lgService.MonitorContext?.LastFullScreenProcessName ?? "No full screen process"}"; + + UpdateValues(); + } + + private void pnlMouse_MouseMove(object sender, MouseEventArgs e) + { + HandleMouse(e); + } + + private void pnlMouse_MouseWheel(object sender, MouseEventArgs e) + { + } + + private void LgGameBar_Deactivate(object sender, EventArgs e) + { + Hide(); + } + + private void tmrHide_Tick(object sender, EventArgs e) + { + Hide(); + } + + private void tbTrackBar_Scroll(object sender, EventArgs e) + { + _settingChanged = true; + ResetAutoHide(); + + var trackBar = sender as TrackBar; + var setting = (TbSetting)trackBar.Tag; + + var value = string.Empty; + + if (setting.EnumType == null) + { + value = trackBar.Value.ToString(); + } + else + { + var enumValue = Enum.Parse(setting.EnumType, trackBar.Value.ToString()); + value = enumValue.ToString(); + } + + _lgDevice.SetSystemSettings(setting.Name, value).ConfigureAwait(false); + + if (_toolTip != null) + { + _toolTip.Show(value, trackBar, 10, 50, 1500); + } + } + + private void LgGameBar_Activated(object sender, EventArgs e) + { + GenerateComponents(); + UpdateInfo(); + ResetAutoHide(); + } + + private void LgGameBar_Move(object sender, EventArgs e) + { + ResetAutoHide(); + } + + private void ResetAutoHide() + { + tmrHide.Enabled = false; + tmrHide.Enabled = true; + } + } +} diff --git a/ColorControl/LgGameBar.resx b/ColorControl/LgGameBar.resx new file mode 100644 index 0000000..eb2cf17 --- /dev/null +++ b/ColorControl/LgGameBar.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ColorControl/LgPreset.cs b/ColorControl/LgPreset.cs index ffc7e41..7806577 100644 --- a/ColorControl/LgPreset.cs +++ b/ColorControl/LgPreset.cs @@ -37,6 +37,16 @@ namespace ColorControl } } + public LgPreset(string name, string appId, IEnumerable steps = null) : this() + { + this.name = name; + this.appId = appId; + if (steps != null) + { + this.steps.AddRange(steps); + } + } + public LgPreset Clone() { var preset = new LgPreset(this); diff --git a/ColorControl/LgService.cs b/ColorControl/LgService.cs index efcd824..f2cfb88 100644 --- a/ColorControl/LgService.cs +++ b/ColorControl/LgService.cs @@ -52,6 +52,7 @@ namespace ColorControl } public LgServiceConfig Config { get; private set; } + public ProcessMonitorContext MonitorContext { get; private set; } private string _configFilename; private bool _allowPowerOn; @@ -65,7 +66,7 @@ namespace ColorControl private Task _monitorTask; private int _monitorTaskCounter; private LgPreset _lastTriggeredPreset; - + public LgService(string dataPath, bool allowPowerOn) : base(dataPath, "LgPresets.json") { _allowPowerOn = allowPowerOn; @@ -137,9 +138,9 @@ namespace ColorControl { var json = File.ReadAllText(defaultPresetsFileName); - presets = _JsonDeserializer.Deserialize>(json); + presets = JsonConvert.DeserializeObject>(json); } - + return presets; } @@ -253,7 +254,7 @@ namespace ColorControl { try { - var json = _JsonSerializer.Serialize(_presets); + var json = JsonConvert.SerializeObject(_presets); File.WriteAllText(_presetsFilename, json); } catch (Exception e) @@ -547,7 +548,7 @@ namespace ColorControl var validCounter = _monitorTaskCounter; var lastProcessId = 0; - var monitorContext = new ProcessMonitorContext(); + MonitorContext = new ProcessMonitorContext(); //Process[] lastProcesses = null; while (validCounter == _monitorTaskCounter) @@ -622,8 +623,8 @@ namespace ColorControl wasConnected = true; } - monitorContext.Devices = connectedDevices; - monitorContext.RunningProcesses = processes; + MonitorContext.Devices = connectedDevices; + MonitorContext.RunningProcesses = processes; //if (lastProcesses != null) //{ // monitorContext.StartedProcesses = processes.Where(p => !lastProcesses.Any(lp => lp.Id == p.Id)).ToArray(); @@ -692,7 +693,7 @@ namespace ColorControl } else { - await ExecuteProcessPresets(monitorContext); + await ExecuteProcessPresets(MonitorContext); } } catch (Exception ex) @@ -714,6 +715,11 @@ namespace ColorControl var (processId, isFullScreen) = Utils.GetForegroundProcessIdAndIfFullScreen(); + if (processId == Process.GetCurrentProcess().Id) + { + return; + } + if (processId > 0) { context.ForegroundProcess = context.RunningProcesses.FirstOrDefault(p => p.Id == processId); diff --git a/ColorControl/LgServiceConfig.cs b/ColorControl/LgServiceConfig.cs index 070e131..5409866 100644 --- a/ColorControl/LgServiceConfig.cs +++ b/ColorControl/LgServiceConfig.cs @@ -5,22 +5,14 @@ namespace ColorControl class LgServiceConfig { public bool PowerOnAfterStartup { get; set; } - public int PowerOnDelayAfterResume { get; set; } - public int PowerOnRetries { get; set; } - public string PreferredMacAddress { get; set; } - public string DeviceSearchKey { get; set; } - - public bool UseOldNpcapWol { get; set; } - public List Devices { get; set; } - public bool ShowRemoteControl { get; set; } - - public bool AllowFirmwareDowngrade { get; set; } + public bool ShowAdvancedActions { get; set; } + public string GameBarShortcut { get; set; } public LgServiceConfig() { diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs index ffed692..70f2a95 100644 --- a/ColorControl/MainForm.Designer.cs +++ b/ColorControl/MainForm.Designer.cs @@ -104,6 +104,9 @@ this.lvAmdPresets = new System.Windows.Forms.ListView(); this.tabLG = new System.Windows.Forms.TabPage(); this.scLgController = new System.Windows.Forms.SplitContainer(); + this.lblGameBarShortcut = new System.Windows.Forms.Label(); + this.edtLgGameBarShortcut = new System.Windows.Forms.TextBox(); + this.btnLgGameBar = new System.Windows.Forms.Button(); this.btnLgPresetEditTriggerConditions = new System.Windows.Forms.Button(); this.edtLgPresetTriggerConditions = new System.Windows.Forms.TextBox(); this.lblLgPresetExcludedProcesses = new System.Windows.Forms.Label(); @@ -119,7 +122,6 @@ this.miLgEnableMotionPro = new System.Windows.Forms.ToolStripMenuItem(); this.miLgDisableMotionPro = new System.Windows.Forms.ToolStripMenuItem(); this.miLgExpertSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.mnuLgExpertBacklight = new System.Windows.Forms.ToolStripMenuItem(); this.chkLgRemoteControlShow = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); this.cbxLgDevices = new System.Windows.Forms.ComboBox(); @@ -169,7 +171,7 @@ this.lblFixChromeFontsDescription = new System.Windows.Forms.Label(); this.chkFixChromeFonts = new System.Windows.Forms.CheckBox(); this.grpLGOptions = new System.Windows.Forms.GroupBox(); - this.chkLgOldWolMechanism = new System.Windows.Forms.CheckBox(); + this.chkLgShowAdvancedActions = new System.Windows.Forms.CheckBox(); this.btnLGTestPower = new System.Windows.Forms.Button(); this.lblLgMaxPowerOnRetriesDescription = new System.Windows.Forms.Label(); this.edtLgMaxPowerOnRetries = new System.Windows.Forms.NumericUpDown(); @@ -178,6 +180,7 @@ this.edtDelayDisplaySettings = new System.Windows.Forms.NumericUpDown(); this.label6 = new System.Windows.Forms.Label(); this.grpGeneralOptions = new System.Windows.Forms.GroupBox(); + this.chkGdiScaling = new System.Windows.Forms.CheckBox(); this.chkCheckForUpdates = new System.Windows.Forms.CheckBox(); this.chkMinimizeToSystemTray = new System.Windows.Forms.CheckBox(); this.chkMinimizeOnClose = new System.Windows.Forms.CheckBox(); @@ -194,7 +197,6 @@ this.lbPlugins = new System.Windows.Forms.ListBox(); this.label7 = new System.Windows.Forms.Label(); this.lblInfo = new System.Windows.Forms.Label(); - this.chkLgAllowDowngrade = new System.Windows.Forms.CheckBox(); this.tcMain.SuspendLayout(); this.tabNVIDIA.SuspendLayout(); this.mnuNvPresets.SuspendLayout(); @@ -232,10 +234,11 @@ this.tcMain.Controls.Add(this.tabOptions); this.tcMain.Controls.Add(this.tabLog); this.tcMain.Controls.Add(this.tabInfo); - this.tcMain.Location = new System.Drawing.Point(12, 12); + this.tcMain.Location = new System.Drawing.Point(14, 14); + this.tcMain.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tcMain.Name = "tcMain"; this.tcMain.SelectedIndex = 0; - this.tcMain.Size = new System.Drawing.Size(962, 479); + this.tcMain.Size = new System.Drawing.Size(1122, 553); this.tcMain.TabIndex = 1; this.tcMain.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // @@ -253,10 +256,11 @@ this.tabNVIDIA.Controls.Add(this.btnChange); this.tabNVIDIA.Controls.Add(this.btnApply); this.tabNVIDIA.Controls.Add(this.lvNvPresets); - this.tabNVIDIA.Location = new System.Drawing.Point(4, 22); + this.tabNVIDIA.Location = new System.Drawing.Point(4, 24); + this.tabNVIDIA.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabNVIDIA.Name = "tabNVIDIA"; - this.tabNVIDIA.Padding = new System.Windows.Forms.Padding(3); - this.tabNVIDIA.Size = new System.Drawing.Size(954, 453); + this.tabNVIDIA.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabNVIDIA.Size = new System.Drawing.Size(1114, 525); this.tabNVIDIA.TabIndex = 0; this.tabNVIDIA.Text = "NVIDIA controller"; this.tabNVIDIA.UseVisualStyleBackColor = true; @@ -265,9 +269,10 @@ // this.lblNvPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblNvPresetName.AutoSize = true; - this.lblNvPresetName.Location = new System.Drawing.Point(6, 404); + this.lblNvPresetName.Location = new System.Drawing.Point(7, 466); + this.lblNvPresetName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblNvPresetName.Name = "lblNvPresetName"; - this.lblNvPresetName.Size = new System.Drawing.Size(38, 13); + this.lblNvPresetName.Size = new System.Drawing.Size(42, 15); this.lblNvPresetName.TabIndex = 22; this.lblNvPresetName.Text = "Name:"; // @@ -275,17 +280,19 @@ // this.edtNvPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtNvPresetName.Enabled = false; - this.edtNvPresetName.Location = new System.Drawing.Point(87, 401); + this.edtNvPresetName.Location = new System.Drawing.Point(102, 463); + this.edtNvPresetName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtNvPresetName.Name = "edtNvPresetName"; - this.edtNvPresetName.Size = new System.Drawing.Size(200, 20); + this.edtNvPresetName.Size = new System.Drawing.Size(233, 23); this.edtNvPresetName.TabIndex = 21; // // btnAddModesNv // this.btnAddModesNv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnAddModesNv.Location = new System.Drawing.Point(330, 372); + this.btnAddModesNv.Location = new System.Drawing.Point(385, 429); + this.btnAddModesNv.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnAddModesNv.Name = "btnAddModesNv"; - this.btnAddModesNv.Size = new System.Drawing.Size(75, 23); + this.btnAddModesNv.Size = new System.Drawing.Size(88, 27); this.btnAddModesNv.TabIndex = 9; this.btnAddModesNv.Text = "Add modes"; this.btnAddModesNv.UseVisualStyleBackColor = true; @@ -295,9 +302,10 @@ // this.btnNvPresetDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnNvPresetDelete.Enabled = false; - this.btnNvPresetDelete.Location = new System.Drawing.Point(249, 372); + this.btnNvPresetDelete.Location = new System.Drawing.Point(290, 429); + this.btnNvPresetDelete.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnNvPresetDelete.Name = "btnNvPresetDelete"; - this.btnNvPresetDelete.Size = new System.Drawing.Size(75, 23); + this.btnNvPresetDelete.Size = new System.Drawing.Size(88, 27); this.btnNvPresetDelete.TabIndex = 8; this.btnNvPresetDelete.Text = "Delete"; this.btnNvPresetDelete.UseVisualStyleBackColor = true; @@ -306,9 +314,10 @@ // lblError // this.lblError.AutoSize = true; - this.lblError.Location = new System.Drawing.Point(6, 6); + this.lblError.Location = new System.Drawing.Point(7, 7); + this.lblError.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblError.Name = "lblError"; - this.lblError.Size = new System.Drawing.Size(50, 13); + this.lblError.Size = new System.Drawing.Size(53, 15); this.lblError.TabIndex = 7; this.lblError.Text = "ErrorText"; this.lblError.Visible = false; @@ -317,9 +326,10 @@ // this.btnClone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnClone.Enabled = false; - this.btnClone.Location = new System.Drawing.Point(168, 372); + this.btnClone.Location = new System.Drawing.Point(196, 429); + this.btnClone.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnClone.Name = "btnClone"; - this.btnClone.Size = new System.Drawing.Size(75, 23); + this.btnClone.Size = new System.Drawing.Size(88, 27); this.btnClone.TabIndex = 6; this.btnClone.Text = "Clone"; this.btnClone.UseVisualStyleBackColor = true; @@ -329,9 +339,10 @@ // this.btnNvPresetSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnNvPresetSave.Enabled = false; - this.btnNvPresetSave.Location = new System.Drawing.Point(411, 372); + this.btnNvPresetSave.Location = new System.Drawing.Point(479, 429); + this.btnNvPresetSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnNvPresetSave.Name = "btnNvPresetSave"; - this.btnNvPresetSave.Size = new System.Drawing.Size(75, 23); + this.btnNvPresetSave.Size = new System.Drawing.Size(88, 27); this.btnNvPresetSave.TabIndex = 5; this.btnNvPresetSave.Text = "Save"; this.btnNvPresetSave.UseVisualStyleBackColor = true; @@ -341,9 +352,10 @@ // this.lblShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblShortcut.AutoSize = true; - this.lblShortcut.Location = new System.Drawing.Point(6, 430); + this.lblShortcut.Location = new System.Drawing.Point(7, 496); + this.lblShortcut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblShortcut.Name = "lblShortcut"; - this.lblShortcut.Size = new System.Drawing.Size(50, 13); + this.lblShortcut.Size = new System.Drawing.Size(55, 15); this.lblShortcut.TabIndex = 4; this.lblShortcut.Text = "Shortcut:"; // @@ -351,10 +363,11 @@ // this.edtShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtShortcut.Enabled = false; - this.edtShortcut.Location = new System.Drawing.Point(87, 427); + this.edtShortcut.Location = new System.Drawing.Point(102, 493); + this.edtShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtShortcut.Name = "edtShortcut"; this.edtShortcut.ReadOnly = true; - this.edtShortcut.Size = new System.Drawing.Size(200, 20); + this.edtShortcut.Size = new System.Drawing.Size(233, 23); this.edtShortcut.TabIndex = 3; this.edtShortcut.TextChanged += new System.EventHandler(this.edtShortcut_TextChanged); this.edtShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown); @@ -365,9 +378,10 @@ this.btnChange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnChange.ContextMenuStrip = this.mnuNvPresets; this.btnChange.Enabled = false; - this.btnChange.Location = new System.Drawing.Point(87, 372); + this.btnChange.Location = new System.Drawing.Point(102, 429); + this.btnChange.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnChange.Name = "btnChange"; - this.btnChange.Size = new System.Drawing.Size(75, 23); + this.btnChange.Size = new System.Drawing.Size(88, 27); this.btnChange.TabIndex = 2; this.btnChange.Text = "Change..."; this.btnChange.UseVisualStyleBackColor = true; @@ -608,9 +622,10 @@ // this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnApply.Enabled = false; - this.btnApply.Location = new System.Drawing.Point(6, 372); + this.btnApply.Location = new System.Drawing.Point(7, 429); + this.btnApply.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnApply.Name = "btnApply"; - this.btnApply.Size = new System.Drawing.Size(75, 23); + this.btnApply.Size = new System.Drawing.Size(88, 27); this.btnApply.TabIndex = 1; this.btnApply.Text = "Apply"; this.btnApply.UseVisualStyleBackColor = true; @@ -623,11 +638,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.lvNvPresets.ContextMenuStrip = this.mnuNvPresets; this.lvNvPresets.FullRowSelect = true; - this.lvNvPresets.HideSelection = false; - this.lvNvPresets.Location = new System.Drawing.Point(6, 6); + this.lvNvPresets.Location = new System.Drawing.Point(7, 7); + this.lvNvPresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lvNvPresets.MultiSelect = false; this.lvNvPresets.Name = "lvNvPresets"; - this.lvNvPresets.Size = new System.Drawing.Size(942, 360); + this.lvNvPresets.Size = new System.Drawing.Size(1098, 415); this.lvNvPresets.TabIndex = 0; this.lvNvPresets.UseCompatibleStateImageBehavior = false; this.lvNvPresets.View = System.Windows.Forms.View.Details; @@ -648,10 +663,11 @@ this.tabAMD.Controls.Add(this.btnChangeAmd); this.tabAMD.Controls.Add(this.btnApplyAmd); this.tabAMD.Controls.Add(this.lvAmdPresets); - this.tabAMD.Location = new System.Drawing.Point(4, 22); + this.tabAMD.Location = new System.Drawing.Point(4, 24); + this.tabAMD.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabAMD.Name = "tabAMD"; - this.tabAMD.Padding = new System.Windows.Forms.Padding(3); - this.tabAMD.Size = new System.Drawing.Size(954, 453); + this.tabAMD.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabAMD.Size = new System.Drawing.Size(1114, 525); this.tabAMD.TabIndex = 5; this.tabAMD.Text = "AMD controller"; this.tabAMD.UseVisualStyleBackColor = true; @@ -660,9 +676,10 @@ // this.lblAmdPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblAmdPresetName.AutoSize = true; - this.lblAmdPresetName.Location = new System.Drawing.Point(6, 404); + this.lblAmdPresetName.Location = new System.Drawing.Point(7, 466); + this.lblAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblAmdPresetName.Name = "lblAmdPresetName"; - this.lblAmdPresetName.Size = new System.Drawing.Size(38, 13); + this.lblAmdPresetName.Size = new System.Drawing.Size(42, 15); this.lblAmdPresetName.TabIndex = 24; this.lblAmdPresetName.Text = "Name:"; // @@ -670,17 +687,19 @@ // this.edtAmdPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtAmdPresetName.Enabled = false; - this.edtAmdPresetName.Location = new System.Drawing.Point(87, 401); + this.edtAmdPresetName.Location = new System.Drawing.Point(102, 463); + this.edtAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtAmdPresetName.Name = "edtAmdPresetName"; - this.edtAmdPresetName.Size = new System.Drawing.Size(200, 20); + this.edtAmdPresetName.Size = new System.Drawing.Size(233, 23); this.edtAmdPresetName.TabIndex = 23; // // btnAddAmd // this.btnAddAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnAddAmd.Location = new System.Drawing.Point(330, 372); + this.btnAddAmd.Location = new System.Drawing.Point(385, 429); + this.btnAddAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnAddAmd.Name = "btnAddAmd"; - this.btnAddAmd.Size = new System.Drawing.Size(75, 23); + this.btnAddAmd.Size = new System.Drawing.Size(88, 27); this.btnAddAmd.TabIndex = 18; this.btnAddAmd.Text = "Add"; this.btnAddAmd.UseVisualStyleBackColor = true; @@ -689,9 +708,10 @@ // lblErrorAMD // this.lblErrorAMD.AutoSize = true; - this.lblErrorAMD.Location = new System.Drawing.Point(6, 6); + this.lblErrorAMD.Location = new System.Drawing.Point(7, 7); + this.lblErrorAMD.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblErrorAMD.Name = "lblErrorAMD"; - this.lblErrorAMD.Size = new System.Drawing.Size(50, 13); + this.lblErrorAMD.Size = new System.Drawing.Size(53, 15); this.lblErrorAMD.TabIndex = 8; this.lblErrorAMD.Text = "ErrorText"; this.lblErrorAMD.Visible = false; @@ -700,9 +720,10 @@ // this.btnDeleteAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnDeleteAmd.Enabled = false; - this.btnDeleteAmd.Location = new System.Drawing.Point(249, 372); + this.btnDeleteAmd.Location = new System.Drawing.Point(290, 429); + this.btnDeleteAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnDeleteAmd.Name = "btnDeleteAmd"; - this.btnDeleteAmd.Size = new System.Drawing.Size(75, 23); + this.btnDeleteAmd.Size = new System.Drawing.Size(88, 27); this.btnDeleteAmd.TabIndex = 17; this.btnDeleteAmd.Text = "Delete"; this.btnDeleteAmd.UseVisualStyleBackColor = true; @@ -712,9 +733,10 @@ // this.btnCloneAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnCloneAmd.Enabled = false; - this.btnCloneAmd.Location = new System.Drawing.Point(168, 372); + this.btnCloneAmd.Location = new System.Drawing.Point(196, 429); + this.btnCloneAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnCloneAmd.Name = "btnCloneAmd"; - this.btnCloneAmd.Size = new System.Drawing.Size(75, 23); + this.btnCloneAmd.Size = new System.Drawing.Size(88, 27); this.btnCloneAmd.TabIndex = 16; this.btnCloneAmd.Text = "Clone"; this.btnCloneAmd.UseVisualStyleBackColor = true; @@ -724,9 +746,10 @@ // this.btnAmdPresetSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnAmdPresetSave.Enabled = false; - this.btnAmdPresetSave.Location = new System.Drawing.Point(411, 372); + this.btnAmdPresetSave.Location = new System.Drawing.Point(479, 429); + this.btnAmdPresetSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnAmdPresetSave.Name = "btnAmdPresetSave"; - this.btnAmdPresetSave.Size = new System.Drawing.Size(75, 23); + this.btnAmdPresetSave.Size = new System.Drawing.Size(88, 27); this.btnAmdPresetSave.TabIndex = 15; this.btnAmdPresetSave.Text = "Save"; this.btnAmdPresetSave.UseVisualStyleBackColor = true; @@ -736,9 +759,10 @@ // this.lblAmdShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblAmdShortcut.AutoSize = true; - this.lblAmdShortcut.Location = new System.Drawing.Point(6, 430); + this.lblAmdShortcut.Location = new System.Drawing.Point(7, 496); + this.lblAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblAmdShortcut.Name = "lblAmdShortcut"; - this.lblAmdShortcut.Size = new System.Drawing.Size(50, 13); + this.lblAmdShortcut.Size = new System.Drawing.Size(55, 15); this.lblAmdShortcut.TabIndex = 14; this.lblAmdShortcut.Text = "Shortcut:"; // @@ -746,10 +770,11 @@ // this.edtAmdShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtAmdShortcut.Enabled = false; - this.edtAmdShortcut.Location = new System.Drawing.Point(87, 427); + this.edtAmdShortcut.Location = new System.Drawing.Point(102, 493); + this.edtAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtAmdShortcut.Name = "edtAmdShortcut"; this.edtAmdShortcut.ReadOnly = true; - this.edtAmdShortcut.Size = new System.Drawing.Size(200, 20); + this.edtAmdShortcut.Size = new System.Drawing.Size(233, 23); this.edtAmdShortcut.TabIndex = 13; this.edtAmdShortcut.TextChanged += new System.EventHandler(this.edtAmdShortcut_TextChanged); this.edtAmdShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown); @@ -760,9 +785,10 @@ this.btnChangeAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnChangeAmd.ContextMenuStrip = this.mnuAmdPresets; this.btnChangeAmd.Enabled = false; - this.btnChangeAmd.Location = new System.Drawing.Point(87, 372); + this.btnChangeAmd.Location = new System.Drawing.Point(102, 429); + this.btnChangeAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnChangeAmd.Name = "btnChangeAmd"; - this.btnChangeAmd.Size = new System.Drawing.Size(75, 23); + this.btnChangeAmd.Size = new System.Drawing.Size(88, 27); this.btnChangeAmd.TabIndex = 12; this.btnChangeAmd.Text = "Change..."; this.btnChangeAmd.UseVisualStyleBackColor = true; @@ -907,9 +933,10 @@ // this.btnApplyAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnApplyAmd.Enabled = false; - this.btnApplyAmd.Location = new System.Drawing.Point(6, 372); + this.btnApplyAmd.Location = new System.Drawing.Point(7, 429); + this.btnApplyAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnApplyAmd.Name = "btnApplyAmd"; - this.btnApplyAmd.Size = new System.Drawing.Size(75, 23); + this.btnApplyAmd.Size = new System.Drawing.Size(88, 27); this.btnApplyAmd.TabIndex = 11; this.btnApplyAmd.Text = "Apply"; this.btnApplyAmd.UseVisualStyleBackColor = true; @@ -922,11 +949,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.lvAmdPresets.ContextMenuStrip = this.mnuAmdPresets; this.lvAmdPresets.FullRowSelect = true; - this.lvAmdPresets.HideSelection = false; - this.lvAmdPresets.Location = new System.Drawing.Point(6, 6); + this.lvAmdPresets.Location = new System.Drawing.Point(7, 7); + this.lvAmdPresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lvAmdPresets.MultiSelect = false; this.lvAmdPresets.Name = "lvAmdPresets"; - this.lvAmdPresets.Size = new System.Drawing.Size(942, 360); + this.lvAmdPresets.Size = new System.Drawing.Size(1098, 415); this.lvAmdPresets.TabIndex = 10; this.lvAmdPresets.UseCompatibleStateImageBehavior = false; this.lvAmdPresets.View = System.Windows.Forms.View.Details; @@ -936,10 +963,11 @@ // tabLG // this.tabLG.Controls.Add(this.scLgController); - this.tabLG.Location = new System.Drawing.Point(4, 22); + this.tabLG.Location = new System.Drawing.Point(4, 24); + this.tabLG.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabLG.Name = "tabLG"; - this.tabLG.Padding = new System.Windows.Forms.Padding(3); - this.tabLG.Size = new System.Drawing.Size(954, 453); + this.tabLG.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabLG.Size = new System.Drawing.Size(1114, 525); this.tabLG.TabIndex = 1; this.tabLG.Text = "LG controller"; this.tabLG.UseVisualStyleBackColor = true; @@ -947,11 +975,15 @@ // scLgController // this.scLgController.Dock = System.Windows.Forms.DockStyle.Fill; - this.scLgController.Location = new System.Drawing.Point(3, 3); + this.scLgController.Location = new System.Drawing.Point(4, 3); + this.scLgController.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.scLgController.Name = "scLgController"; // // scLgController.Panel1 // + this.scLgController.Panel1.Controls.Add(this.lblGameBarShortcut); + this.scLgController.Panel1.Controls.Add(this.edtLgGameBarShortcut); + this.scLgController.Panel1.Controls.Add(this.btnLgGameBar); this.scLgController.Panel1.Controls.Add(this.btnLgPresetEditTriggerConditions); this.scLgController.Panel1.Controls.Add(this.edtLgPresetTriggerConditions); this.scLgController.Panel1.Controls.Add(this.lblLgPresetExcludedProcesses); @@ -993,16 +1025,51 @@ this.scLgController.Panel1.Controls.Add(this.lblLgError); this.scLgController.Panel1MinSize = 750; this.scLgController.Panel2MinSize = 150; - this.scLgController.Size = new System.Drawing.Size(948, 447); - this.scLgController.SplitterDistance = 767; + this.scLgController.Size = new System.Drawing.Size(1106, 519); + this.scLgController.SplitterDistance = 894; + this.scLgController.SplitterWidth = 5; this.scLgController.TabIndex = 43; // + // lblGameBarShortcut + // + this.lblGameBarShortcut.AutoSize = true; + this.lblGameBarShortcut.Location = new System.Drawing.Point(597, 45); + this.lblGameBarShortcut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblGameBarShortcut.Name = "lblGameBarShortcut"; + this.lblGameBarShortcut.Size = new System.Drawing.Size(55, 15); + this.lblGameBarShortcut.TabIndex = 57; + this.lblGameBarShortcut.Text = "Shortcut:"; + // + // edtLgGameBarShortcut + // + this.edtLgGameBarShortcut.Location = new System.Drawing.Point(667, 42); + this.edtLgGameBarShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.edtLgGameBarShortcut.Name = "edtLgGameBarShortcut"; + this.edtLgGameBarShortcut.ReadOnly = true; + this.edtLgGameBarShortcut.Size = new System.Drawing.Size(128, 23); + this.edtLgGameBarShortcut.TabIndex = 56; + this.edtLgGameBarShortcut.TextChanged += new System.EventHandler(this.edtLgGameBarShortcut_TextChanged); + this.edtLgGameBarShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtLgGameBarShortcut_KeyDown); + this.edtLgGameBarShortcut.KeyUp += new System.Windows.Forms.KeyEventHandler(this.edtLgGameBarShortcut_KeyUp); + // + // btnLgGameBar + // + this.btnLgGameBar.Location = new System.Drawing.Point(478, 40); + this.btnLgGameBar.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.btnLgGameBar.Name = "btnLgGameBar"; + this.btnLgGameBar.Size = new System.Drawing.Size(88, 27); + this.btnLgGameBar.TabIndex = 55; + this.btnLgGameBar.Text = "Game Bar"; + this.btnLgGameBar.UseVisualStyleBackColor = true; + this.btnLgGameBar.Click += new System.EventHandler(this.btnLgGameBar_Click); + // // btnLgPresetEditTriggerConditions // this.btnLgPresetEditTriggerConditions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnLgPresetEditTriggerConditions.Location = new System.Drawing.Point(689, 317); + this.btnLgPresetEditTriggerConditions.Location = new System.Drawing.Point(804, 369); + this.btnLgPresetEditTriggerConditions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgPresetEditTriggerConditions.Name = "btnLgPresetEditTriggerConditions"; - this.btnLgPresetEditTriggerConditions.Size = new System.Drawing.Size(75, 23); + this.btnLgPresetEditTriggerConditions.Size = new System.Drawing.Size(88, 27); this.btnLgPresetEditTriggerConditions.TabIndex = 54; this.btnLgPresetEditTriggerConditions.Text = "Edit..."; this.btnLgPresetEditTriggerConditions.UseVisualStyleBackColor = true; @@ -1012,19 +1079,21 @@ // this.edtLgPresetTriggerConditions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtLgPresetTriggerConditions.Enabled = false; - this.edtLgPresetTriggerConditions.Location = new System.Drawing.Point(515, 319); + this.edtLgPresetTriggerConditions.Location = new System.Drawing.Point(601, 371); + this.edtLgPresetTriggerConditions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLgPresetTriggerConditions.Name = "edtLgPresetTriggerConditions"; this.edtLgPresetTriggerConditions.ReadOnly = true; - this.edtLgPresetTriggerConditions.Size = new System.Drawing.Size(167, 20); + this.edtLgPresetTriggerConditions.Size = new System.Drawing.Size(194, 23); this.edtLgPresetTriggerConditions.TabIndex = 53; // // lblLgPresetExcludedProcesses // this.lblLgPresetExcludedProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblLgPresetExcludedProcesses.AutoSize = true; - this.lblLgPresetExcludedProcesses.Location = new System.Drawing.Point(407, 375); + this.lblLgPresetExcludedProcesses.Location = new System.Drawing.Point(475, 436); + this.lblLgPresetExcludedProcesses.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgPresetExcludedProcesses.Name = "lblLgPresetExcludedProcesses"; - this.lblLgPresetExcludedProcesses.Size = new System.Drawing.Size(105, 13); + this.lblLgPresetExcludedProcesses.Size = new System.Drawing.Size(112, 15); this.lblLgPresetExcludedProcesses.TabIndex = 52; this.lblLgPresetExcludedProcesses.Text = "Excluded processes:"; // @@ -1032,18 +1101,20 @@ // this.edtLgPresetExcludedProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtLgPresetExcludedProcesses.Enabled = false; - this.edtLgPresetExcludedProcesses.Location = new System.Drawing.Point(515, 373); + this.edtLgPresetExcludedProcesses.Location = new System.Drawing.Point(601, 433); + this.edtLgPresetExcludedProcesses.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLgPresetExcludedProcesses.Name = "edtLgPresetExcludedProcesses"; - this.edtLgPresetExcludedProcesses.Size = new System.Drawing.Size(248, 20); + this.edtLgPresetExcludedProcesses.Size = new System.Drawing.Size(289, 23); this.edtLgPresetExcludedProcesses.TabIndex = 51; // // lblLgPresetIncludedProcesses // this.lblLgPresetIncludedProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblLgPresetIncludedProcesses.AutoSize = true; - this.lblLgPresetIncludedProcesses.Location = new System.Drawing.Point(407, 349); + this.lblLgPresetIncludedProcesses.Location = new System.Drawing.Point(475, 406); + this.lblLgPresetIncludedProcesses.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgPresetIncludedProcesses.Name = "lblLgPresetIncludedProcesses"; - this.lblLgPresetIncludedProcesses.Size = new System.Drawing.Size(102, 13); + this.lblLgPresetIncludedProcesses.Size = new System.Drawing.Size(110, 15); this.lblLgPresetIncludedProcesses.TabIndex = 50; this.lblLgPresetIncludedProcesses.Text = "Included processes:"; // @@ -1051,18 +1122,20 @@ // this.edtLgPresetIncludedProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtLgPresetIncludedProcesses.Enabled = false; - this.edtLgPresetIncludedProcesses.Location = new System.Drawing.Point(515, 347); + this.edtLgPresetIncludedProcesses.Location = new System.Drawing.Point(601, 403); + this.edtLgPresetIncludedProcesses.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLgPresetIncludedProcesses.Name = "edtLgPresetIncludedProcesses"; - this.edtLgPresetIncludedProcesses.Size = new System.Drawing.Size(248, 20); + this.edtLgPresetIncludedProcesses.Size = new System.Drawing.Size(289, 23); this.edtLgPresetIncludedProcesses.TabIndex = 49; // // lblLgPresetTriggerCondition // this.lblLgPresetTriggerCondition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblLgPresetTriggerCondition.AutoSize = true; - this.lblLgPresetTriggerCondition.Location = new System.Drawing.Point(407, 322); + this.lblLgPresetTriggerCondition.Location = new System.Drawing.Point(475, 375); + this.lblLgPresetTriggerCondition.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgPresetTriggerCondition.Name = "lblLgPresetTriggerCondition"; - this.lblLgPresetTriggerCondition.Size = new System.Drawing.Size(54, 13); + this.lblLgPresetTriggerCondition.Size = new System.Drawing.Size(63, 15); this.lblLgPresetTriggerCondition.TabIndex = 47; this.lblLgPresetTriggerCondition.Text = "Condition:"; // @@ -1072,27 +1145,30 @@ this.cbxLgPresetTrigger.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxLgPresetTrigger.Enabled = false; this.cbxLgPresetTrigger.FormattingEnabled = true; - this.cbxLgPresetTrigger.Location = new System.Drawing.Point(515, 292); + this.cbxLgPresetTrigger.Location = new System.Drawing.Point(601, 340); + this.cbxLgPresetTrigger.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxLgPresetTrigger.Name = "cbxLgPresetTrigger"; - this.cbxLgPresetTrigger.Size = new System.Drawing.Size(248, 21); + this.cbxLgPresetTrigger.Size = new System.Drawing.Size(289, 23); this.cbxLgPresetTrigger.TabIndex = 46; // // lblLgPresetTrigger // this.lblLgPresetTrigger.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblLgPresetTrigger.AutoSize = true; - this.lblLgPresetTrigger.Location = new System.Drawing.Point(407, 295); + this.lblLgPresetTrigger.Location = new System.Drawing.Point(475, 343); + this.lblLgPresetTrigger.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgPresetTrigger.Name = "lblLgPresetTrigger"; - this.lblLgPresetTrigger.Size = new System.Drawing.Size(43, 13); + this.lblLgPresetTrigger.Size = new System.Drawing.Size(46, 15); this.lblLgPresetTrigger.TabIndex = 45; this.lblLgPresetTrigger.Text = "Trigger:"; // // btnLgExpert // this.btnLgExpert.ContextMenuStrip = this.mnuLgExpert; - this.btnLgExpert.Location = new System.Drawing.Point(315, 34); + this.btnLgExpert.Location = new System.Drawing.Point(368, 39); + this.btnLgExpert.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgExpert.Name = "btnLgExpert"; - this.btnLgExpert.Size = new System.Drawing.Size(75, 23); + this.btnLgExpert.Size = new System.Drawing.Size(88, 27); this.btnLgExpert.TabIndex = 44; this.btnLgExpert.Text = "Expert..."; this.btnLgExpert.UseVisualStyleBackColor = true; @@ -1103,10 +1179,9 @@ this.mnuLgExpert.ImageScalingSize = new System.Drawing.Size(20, 20); this.mnuLgExpert.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mnuLgOLEDMotionPro, - this.miLgExpertSeparator1, - this.mnuLgExpertBacklight}); + this.miLgExpertSeparator1}); this.mnuLgExpert.Name = "mnuLgButtons"; - this.mnuLgExpert.Size = new System.Drawing.Size(321, 54); + this.mnuLgExpert.Size = new System.Drawing.Size(321, 32); this.mnuLgExpert.Opening += new System.ComponentModel.CancelEventHandler(this.mnuLgExpert_Opening); // // mnuLgOLEDMotionPro @@ -1137,20 +1212,15 @@ this.miLgExpertSeparator1.Name = "miLgExpertSeparator1"; this.miLgExpertSeparator1.Size = new System.Drawing.Size(317, 6); // - // mnuLgExpertBacklight - // - this.mnuLgExpertBacklight.Name = "mnuLgExpertBacklight"; - this.mnuLgExpertBacklight.Size = new System.Drawing.Size(320, 22); - this.mnuLgExpertBacklight.Text = "Backlight"; - // // chkLgRemoteControlShow // this.chkLgRemoteControlShow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chkLgRemoteControlShow.Appearance = System.Windows.Forms.Appearance.Button; this.chkLgRemoteControlShow.AutoSize = true; - this.chkLgRemoteControlShow.Location = new System.Drawing.Point(673, 7); + this.chkLgRemoteControlShow.Location = new System.Drawing.Point(788, 8); + this.chkLgRemoteControlShow.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkLgRemoteControlShow.Name = "chkLgRemoteControlShow"; - this.chkLgRemoteControlShow.Size = new System.Drawing.Size(90, 23); + this.chkLgRemoteControlShow.Size = new System.Drawing.Size(101, 25); this.chkLgRemoteControlShow.TabIndex = 43; this.chkLgRemoteControlShow.Text = "Remote Control"; this.chkLgRemoteControlShow.UseVisualStyleBackColor = true; @@ -1159,9 +1229,10 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(5, 12); + this.label3.Location = new System.Drawing.Point(6, 14); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(44, 13); + this.label3.Size = new System.Drawing.Size(45, 15); this.label3.TabIndex = 31; this.label3.Text = "Device:"; // @@ -1170,17 +1241,19 @@ this.cbxLgDevices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxLgDevices.DropDownWidth = 400; this.cbxLgDevices.FormattingEnabled = true; - this.cbxLgDevices.Location = new System.Drawing.Point(86, 8); + this.cbxLgDevices.Location = new System.Drawing.Point(100, 9); + this.cbxLgDevices.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxLgDevices.Name = "cbxLgDevices"; - this.cbxLgDevices.Size = new System.Drawing.Size(318, 21); + this.cbxLgDevices.Size = new System.Drawing.Size(370, 23); this.cbxLgDevices.TabIndex = 30; this.cbxLgDevices.SelectedIndexChanged += new System.EventHandler(this.cbxLgDevices_SelectedIndexChanged); // // btnLgDeviceConvertToCustom // - this.btnLgDeviceConvertToCustom.Location = new System.Drawing.Point(572, 7); + this.btnLgDeviceConvertToCustom.Location = new System.Drawing.Point(667, 8); + this.btnLgDeviceConvertToCustom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgDeviceConvertToCustom.Name = "btnLgDeviceConvertToCustom"; - this.btnLgDeviceConvertToCustom.Size = new System.Drawing.Size(75, 23); + this.btnLgDeviceConvertToCustom.Size = new System.Drawing.Size(88, 27); this.btnLgDeviceConvertToCustom.TabIndex = 41; this.btnLgDeviceConvertToCustom.Text = "To custom..."; this.btnLgDeviceConvertToCustom.UseVisualStyleBackColor = true; @@ -1192,9 +1265,10 @@ this.cbxLgApps.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxLgApps.Enabled = false; this.cbxLgApps.FormattingEnabled = true; - this.cbxLgApps.Location = new System.Drawing.Point(86, 346); + this.cbxLgApps.Location = new System.Drawing.Point(100, 402); + this.cbxLgApps.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxLgApps.Name = "cbxLgApps"; - this.cbxLgApps.Size = new System.Drawing.Size(200, 21); + this.cbxLgApps.Size = new System.Drawing.Size(233, 23); this.cbxLgApps.TabIndex = 26; this.cbxLgApps.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cbxLgApps_KeyPress); // @@ -1204,11 +1278,11 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lvLgPresets.FullRowSelect = true; - this.lvLgPresets.HideSelection = false; - this.lvLgPresets.Location = new System.Drawing.Point(5, 146); + this.lvLgPresets.Location = new System.Drawing.Point(6, 168); + this.lvLgPresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lvLgPresets.MultiSelect = false; this.lvLgPresets.Name = "lvLgPresets"; - this.lvLgPresets.Size = new System.Drawing.Size(758, 111); + this.lvLgPresets.Size = new System.Drawing.Size(883, 130); this.lvLgPresets.TabIndex = 8; this.lvLgPresets.UseCompatibleStateImageBehavior = false; this.lvLgPresets.View = System.Windows.Forms.View.Details; @@ -1219,9 +1293,10 @@ // this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(5, 349); + this.label5.Location = new System.Drawing.Point(6, 406); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(29, 13); + this.label5.Size = new System.Drawing.Size(32, 15); this.label5.TabIndex = 25; this.label5.Text = "App:"; // @@ -1231,18 +1306,20 @@ this.cbxLgPresetDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxLgPresetDevice.Enabled = false; this.cbxLgPresetDevice.FormattingEnabled = true; - this.cbxLgPresetDevice.Location = new System.Drawing.Point(86, 318); + this.cbxLgPresetDevice.Location = new System.Drawing.Point(100, 370); + this.cbxLgPresetDevice.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxLgPresetDevice.Name = "cbxLgPresetDevice"; - this.cbxLgPresetDevice.Size = new System.Drawing.Size(318, 21); + this.cbxLgPresetDevice.Size = new System.Drawing.Size(370, 23); this.cbxLgPresetDevice.TabIndex = 40; // // btnDeleteLg // this.btnDeleteLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnDeleteLg.Enabled = false; - this.btnDeleteLg.Location = new System.Drawing.Point(248, 263); + this.btnDeleteLg.Location = new System.Drawing.Point(289, 306); + this.btnDeleteLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnDeleteLg.Name = "btnDeleteLg"; - this.btnDeleteLg.Size = new System.Drawing.Size(75, 23); + this.btnDeleteLg.Size = new System.Drawing.Size(88, 27); this.btnDeleteLg.TabIndex = 27; this.btnDeleteLg.Text = "Delete"; this.btnDeleteLg.UseVisualStyleBackColor = true; @@ -1252,9 +1329,10 @@ // this.btnApplyLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnApplyLg.Enabled = false; - this.btnApplyLg.Location = new System.Drawing.Point(5, 263); + this.btnApplyLg.Location = new System.Drawing.Point(6, 306); + this.btnApplyLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnApplyLg.Name = "btnApplyLg"; - this.btnApplyLg.Size = new System.Drawing.Size(75, 23); + this.btnApplyLg.Size = new System.Drawing.Size(88, 27); this.btnApplyLg.TabIndex = 9; this.btnApplyLg.Text = "Apply"; this.btnApplyLg.UseVisualStyleBackColor = true; @@ -1263,9 +1341,10 @@ // lblDeviceFilter // this.lblDeviceFilter.AutoSize = true; - this.lblDeviceFilter.Location = new System.Drawing.Point(5, 39); + this.lblDeviceFilter.Location = new System.Drawing.Point(6, 45); + this.lblDeviceFilter.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblDeviceFilter.Name = "lblDeviceFilter"; - this.lblDeviceFilter.Size = new System.Drawing.Size(66, 13); + this.lblDeviceFilter.Size = new System.Drawing.Size(72, 15); this.lblDeviceFilter.TabIndex = 24; this.lblDeviceFilter.Text = "Device filter:"; // @@ -1273,18 +1352,20 @@ // this.lblLgPresetDevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblLgPresetDevice.AutoSize = true; - this.lblLgPresetDevice.Location = new System.Drawing.Point(5, 321); + this.lblLgPresetDevice.Location = new System.Drawing.Point(6, 373); + this.lblLgPresetDevice.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgPresetDevice.Name = "lblLgPresetDevice"; - this.lblLgPresetDevice.Size = new System.Drawing.Size(44, 13); + this.lblLgPresetDevice.Size = new System.Drawing.Size(45, 15); this.lblLgPresetDevice.TabIndex = 39; this.lblLgPresetDevice.Text = "Device:"; // // btnAddLg // this.btnAddLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnAddLg.Location = new System.Drawing.Point(167, 263); + this.btnAddLg.Location = new System.Drawing.Point(195, 306); + this.btnAddLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnAddLg.Name = "btnAddLg"; - this.btnAddLg.Size = new System.Drawing.Size(75, 23); + this.btnAddLg.Size = new System.Drawing.Size(88, 27); this.btnAddLg.TabIndex = 28; this.btnAddLg.Text = "Add"; this.btnAddLg.UseVisualStyleBackColor = true; @@ -1294,10 +1375,11 @@ // this.edtShortcutLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtShortcutLg.Enabled = false; - this.edtShortcutLg.Location = new System.Drawing.Point(86, 373); + this.edtShortcutLg.Location = new System.Drawing.Point(100, 433); + this.edtShortcutLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtShortcutLg.Name = "edtShortcutLg"; this.edtShortcutLg.ReadOnly = true; - this.edtShortcutLg.Size = new System.Drawing.Size(200, 20); + this.edtShortcutLg.Size = new System.Drawing.Size(233, 23); this.edtShortcutLg.TabIndex = 11; this.edtShortcutLg.TextChanged += new System.EventHandler(this.edtShortcutLg_TextChanged); this.edtShortcutLg.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown); @@ -1305,17 +1387,19 @@ // // edtLgDeviceFilter // - this.edtLgDeviceFilter.Location = new System.Drawing.Point(86, 35); + this.edtLgDeviceFilter.Location = new System.Drawing.Point(100, 40); + this.edtLgDeviceFilter.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLgDeviceFilter.Name = "edtLgDeviceFilter"; - this.edtLgDeviceFilter.Size = new System.Drawing.Size(142, 20); + this.edtLgDeviceFilter.Size = new System.Drawing.Size(165, 23); this.edtLgDeviceFilter.TabIndex = 23; this.edtLgDeviceFilter.TextChanged += new System.EventHandler(this.edtLgDeviceFilter_TextChanged); // // btnLgRemoveDevice // - this.btnLgRemoveDevice.Location = new System.Drawing.Point(491, 7); + this.btnLgRemoveDevice.Location = new System.Drawing.Point(573, 8); + this.btnLgRemoveDevice.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgRemoveDevice.Name = "btnLgRemoveDevice"; - this.btnLgRemoveDevice.Size = new System.Drawing.Size(75, 23); + this.btnLgRemoveDevice.Size = new System.Drawing.Size(88, 27); this.btnLgRemoveDevice.TabIndex = 38; this.btnLgRemoveDevice.Text = "Remove"; this.btnLgRemoveDevice.UseVisualStyleBackColor = true; @@ -1324,9 +1408,10 @@ // btnLgRefreshApps // this.btnLgRefreshApps.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnLgRefreshApps.Location = new System.Drawing.Point(292, 344); + this.btnLgRefreshApps.Location = new System.Drawing.Point(341, 400); + this.btnLgRefreshApps.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgRefreshApps.Name = "btnLgRefreshApps"; - this.btnLgRefreshApps.Size = new System.Drawing.Size(75, 23); + this.btnLgRefreshApps.Size = new System.Drawing.Size(88, 27); this.btnLgRefreshApps.TabIndex = 29; this.btnLgRefreshApps.Text = "Refresh"; this.btnLgRefreshApps.UseVisualStyleBackColor = true; @@ -1336,9 +1421,10 @@ // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(5, 376); + this.label2.Location = new System.Drawing.Point(6, 437); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(50, 13); + this.label2.Size = new System.Drawing.Size(55, 15); this.label2.TabIndex = 12; this.label2.Text = "Shortcut:"; // @@ -1346,17 +1432,19 @@ // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(5, 295); + this.label1.Location = new System.Drawing.Point(6, 343); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.Size = new System.Drawing.Size(42, 15); this.label1.TabIndex = 20; this.label1.Text = "Name:"; // // btnLgAddDevice // - this.btnLgAddDevice.Location = new System.Drawing.Point(410, 7); + this.btnLgAddDevice.Location = new System.Drawing.Point(478, 8); + this.btnLgAddDevice.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgAddDevice.Name = "btnLgAddDevice"; - this.btnLgAddDevice.Size = new System.Drawing.Size(75, 23); + this.btnLgAddDevice.Size = new System.Drawing.Size(88, 27); this.btnLgAddDevice.TabIndex = 37; this.btnLgAddDevice.Text = "Add"; this.btnLgAddDevice.UseVisualStyleBackColor = true; @@ -1366,18 +1454,20 @@ // this.edtNameLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.edtNameLg.Enabled = false; - this.edtNameLg.Location = new System.Drawing.Point(86, 292); + this.edtNameLg.Location = new System.Drawing.Point(100, 340); + this.edtNameLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtNameLg.Name = "edtNameLg"; - this.edtNameLg.Size = new System.Drawing.Size(200, 20); + this.edtNameLg.Size = new System.Drawing.Size(233, 23); this.edtNameLg.TabIndex = 19; // // btnSetShortcutLg // this.btnSetShortcutLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnSetShortcutLg.Enabled = false; - this.btnSetShortcutLg.Location = new System.Drawing.Point(329, 263); + this.btnSetShortcutLg.Location = new System.Drawing.Point(384, 306); + this.btnSetShortcutLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnSetShortcutLg.Name = "btnSetShortcutLg"; - this.btnSetShortcutLg.Size = new System.Drawing.Size(75, 23); + this.btnSetShortcutLg.Size = new System.Drawing.Size(88, 27); this.btnSetShortcutLg.TabIndex = 13; this.btnSetShortcutLg.Text = "Save"; this.btnSetShortcutLg.UseVisualStyleBackColor = true; @@ -1388,10 +1478,11 @@ this.edtStepsLg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.edtStepsLg.Enabled = false; - this.edtStepsLg.Location = new System.Drawing.Point(86, 398); + this.edtStepsLg.Location = new System.Drawing.Point(100, 462); + this.edtStepsLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtStepsLg.Multiline = true; this.edtStepsLg.Name = "edtStepsLg"; - this.edtStepsLg.Size = new System.Drawing.Size(596, 38); + this.edtStepsLg.Size = new System.Drawing.Size(694, 43); this.edtStepsLg.TabIndex = 17; // // btnLgAddButton @@ -1399,9 +1490,10 @@ this.btnLgAddButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnLgAddButton.ContextMenuStrip = this.mnuLgButtons; this.btnLgAddButton.Enabled = false; - this.btnLgAddButton.Location = new System.Drawing.Point(688, 397); + this.btnLgAddButton.Location = new System.Drawing.Point(802, 461); + this.btnLgAddButton.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgAddButton.Name = "btnLgAddButton"; - this.btnLgAddButton.Size = new System.Drawing.Size(75, 23); + this.btnLgAddButton.Size = new System.Drawing.Size(88, 27); this.btnLgAddButton.TabIndex = 32; this.btnLgAddButton.Text = "Add step"; this.btnLgAddButton.UseVisualStyleBackColor = true; @@ -1447,9 +1539,10 @@ // this.btnCloneLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnCloneLg.Enabled = false; - this.btnCloneLg.Location = new System.Drawing.Point(86, 263); + this.btnCloneLg.Location = new System.Drawing.Point(100, 306); + this.btnCloneLg.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnCloneLg.Name = "btnCloneLg"; - this.btnCloneLg.Size = new System.Drawing.Size(75, 23); + this.btnCloneLg.Size = new System.Drawing.Size(88, 27); this.btnCloneLg.TabIndex = 14; this.btnCloneLg.Text = "Clone"; this.btnCloneLg.UseVisualStyleBackColor = true; @@ -1459,17 +1552,19 @@ // this.lblStepsLg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.lblStepsLg.AutoSize = true; - this.lblStepsLg.Location = new System.Drawing.Point(5, 402); + this.lblStepsLg.Location = new System.Drawing.Point(6, 467); + this.lblStepsLg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblStepsLg.Name = "lblStepsLg"; - this.lblStepsLg.Size = new System.Drawing.Size(37, 13); + this.lblStepsLg.Size = new System.Drawing.Size(38, 15); this.lblStepsLg.TabIndex = 16; this.lblStepsLg.Text = "Steps:"; // // btnLgDeviceFilterRefresh // - this.btnLgDeviceFilterRefresh.Location = new System.Drawing.Point(234, 34); + this.btnLgDeviceFilterRefresh.Location = new System.Drawing.Point(273, 39); + this.btnLgDeviceFilterRefresh.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLgDeviceFilterRefresh.Name = "btnLgDeviceFilterRefresh"; - this.btnLgDeviceFilterRefresh.Size = new System.Drawing.Size(75, 23); + this.btnLgDeviceFilterRefresh.Size = new System.Drawing.Size(88, 27); this.btnLgDeviceFilterRefresh.TabIndex = 35; this.btnLgDeviceFilterRefresh.Text = "Refresh"; this.btnLgDeviceFilterRefresh.UseVisualStyleBackColor = true; @@ -1491,18 +1586,20 @@ ".", "Automatically power off on standby", "Automatically power off on screensaver and power on when screensaver deactivates"}); - this.clbLgPower.Location = new System.Drawing.Point(5, 61); + this.clbLgPower.Location = new System.Drawing.Point(6, 70); + this.clbLgPower.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.clbLgPower.Name = "clbLgPower"; - this.clbLgPower.Size = new System.Drawing.Size(758, 79); + this.clbLgPower.Size = new System.Drawing.Size(883, 76); this.clbLgPower.TabIndex = 34; this.clbLgPower.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbLgPower_ItemCheck); // // lblLgError // this.lblLgError.AutoSize = true; - this.lblLgError.Location = new System.Drawing.Point(5, 8); + this.lblLgError.Location = new System.Drawing.Point(6, 9); + this.lblLgError.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgError.Name = "lblLgError"; - this.lblLgError.Size = new System.Drawing.Size(50, 13); + this.lblLgError.Size = new System.Drawing.Size(53, 15); this.lblLgError.TabIndex = 15; this.lblLgError.Text = "ErrorText"; this.lblLgError.Visible = false; @@ -1514,10 +1611,11 @@ this.tabOptions.Controls.Add(this.grpLGOptions); this.tabOptions.Controls.Add(this.grpHDROptions); this.tabOptions.Controls.Add(this.grpGeneralOptions); - this.tabOptions.Location = new System.Drawing.Point(4, 22); + this.tabOptions.Location = new System.Drawing.Point(4, 24); + this.tabOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabOptions.Name = "tabOptions"; - this.tabOptions.Padding = new System.Windows.Forms.Padding(3); - this.tabOptions.Size = new System.Drawing.Size(954, 453); + this.tabOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabOptions.Size = new System.Drawing.Size(1114, 525); this.tabOptions.TabIndex = 2; this.tabOptions.Text = "Options"; this.tabOptions.UseVisualStyleBackColor = true; @@ -1533,9 +1631,11 @@ this.grpNvidiaOptions.Controls.Add(this.cbxDitheringBitDepth); this.grpNvidiaOptions.Controls.Add(this.chkDitheringEnabled); this.grpNvidiaOptions.Controls.Add(this.pbGradient); - this.grpNvidiaOptions.Location = new System.Drawing.Point(412, 6); + this.grpNvidiaOptions.Location = new System.Drawing.Point(481, 7); + this.grpNvidiaOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpNvidiaOptions.Name = "grpNvidiaOptions"; - this.grpNvidiaOptions.Size = new System.Drawing.Size(536, 304); + this.grpNvidiaOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpNvidiaOptions.Size = new System.Drawing.Size(625, 351); this.grpNvidiaOptions.TabIndex = 6; this.grpNvidiaOptions.TabStop = false; this.grpNvidiaOptions.Text = "NVIDIA options - test dithering"; @@ -1543,9 +1643,10 @@ // lblDitheringMode // this.lblDitheringMode.AutoSize = true; - this.lblDitheringMode.Location = new System.Drawing.Point(6, 70); + this.lblDitheringMode.Location = new System.Drawing.Point(7, 81); + this.lblDitheringMode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblDitheringMode.Name = "lblDitheringMode"; - this.lblDitheringMode.Size = new System.Drawing.Size(37, 13); + this.lblDitheringMode.Size = new System.Drawing.Size(41, 15); this.lblDitheringMode.TabIndex = 7; this.lblDitheringMode.Text = "Mode:"; // @@ -1553,18 +1654,20 @@ // this.cbxDitheringMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxDitheringMode.FormattingEnabled = true; - this.cbxDitheringMode.Location = new System.Drawing.Point(64, 65); + this.cbxDitheringMode.Location = new System.Drawing.Point(75, 75); + this.cbxDitheringMode.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxDitheringMode.Name = "cbxDitheringMode"; - this.cbxDitheringMode.Size = new System.Drawing.Size(117, 21); + this.cbxDitheringMode.Size = new System.Drawing.Size(136, 23); this.cbxDitheringMode.TabIndex = 6; this.cbxDitheringMode.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringMode_SelectedIndexChanged); // // lblDitheringBitDepth // this.lblDitheringBitDepth.AutoSize = true; - this.lblDitheringBitDepth.Location = new System.Drawing.Point(6, 43); + this.lblDitheringBitDepth.Location = new System.Drawing.Point(7, 50); + this.lblDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblDitheringBitDepth.Name = "lblDitheringBitDepth"; - this.lblDitheringBitDepth.Size = new System.Drawing.Size(52, 13); + this.lblDitheringBitDepth.Size = new System.Drawing.Size(60, 15); this.lblDitheringBitDepth.TabIndex = 5; this.lblDitheringBitDepth.Text = "Bit-depth:"; // @@ -1572,9 +1675,10 @@ // this.cbxDitheringBitDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxDitheringBitDepth.FormattingEnabled = true; - this.cbxDitheringBitDepth.Location = new System.Drawing.Point(64, 38); + this.cbxDitheringBitDepth.Location = new System.Drawing.Point(75, 44); + this.cbxDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.cbxDitheringBitDepth.Name = "cbxDitheringBitDepth"; - this.cbxDitheringBitDepth.Size = new System.Drawing.Size(117, 21); + this.cbxDitheringBitDepth.Size = new System.Drawing.Size(136, 23); this.cbxDitheringBitDepth.TabIndex = 4; this.cbxDitheringBitDepth.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringBitDepth_SelectedIndexChanged); // @@ -1583,9 +1687,10 @@ this.chkDitheringEnabled.AutoSize = true; this.chkDitheringEnabled.Checked = true; this.chkDitheringEnabled.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkDitheringEnabled.Location = new System.Drawing.Point(6, 19); + this.chkDitheringEnabled.Location = new System.Drawing.Point(7, 22); + this.chkDitheringEnabled.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkDitheringEnabled.Name = "chkDitheringEnabled"; - this.chkDitheringEnabled.Size = new System.Drawing.Size(109, 17); + this.chkDitheringEnabled.Size = new System.Drawing.Size(120, 19); this.chkDitheringEnabled.TabIndex = 3; this.chkDitheringEnabled.Text = "Dithering enabled"; this.chkDitheringEnabled.UseVisualStyleBackColor = true; @@ -1597,9 +1702,10 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pbGradient.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbGradient.Location = new System.Drawing.Point(6, 92); + this.pbGradient.Location = new System.Drawing.Point(7, 106); + this.pbGradient.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.pbGradient.Name = "pbGradient"; - this.pbGradient.Size = new System.Drawing.Size(524, 205); + this.pbGradient.Size = new System.Drawing.Size(611, 236); this.pbGradient.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pbGradient.TabIndex = 0; this.pbGradient.TabStop = false; @@ -1611,18 +1717,21 @@ this.grpMiscellaneousOptions.Controls.Add(this.edtBlankScreenSaverShortcut); this.grpMiscellaneousOptions.Controls.Add(this.lblFixChromeFontsDescription); this.grpMiscellaneousOptions.Controls.Add(this.chkFixChromeFonts); - this.grpMiscellaneousOptions.Location = new System.Drawing.Point(6, 253); + this.grpMiscellaneousOptions.Location = new System.Drawing.Point(7, 292); + this.grpMiscellaneousOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpMiscellaneousOptions.Name = "grpMiscellaneousOptions"; - this.grpMiscellaneousOptions.Size = new System.Drawing.Size(400, 130); + this.grpMiscellaneousOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpMiscellaneousOptions.Size = new System.Drawing.Size(467, 150); this.grpMiscellaneousOptions.TabIndex = 5; this.grpMiscellaneousOptions.TabStop = false; this.grpMiscellaneousOptions.Text = "Miscellaneous"; // // btnSetShortcutScreenSaver // - this.btnSetShortcutScreenSaver.Location = new System.Drawing.Point(154, 90); + this.btnSetShortcutScreenSaver.Location = new System.Drawing.Point(180, 104); + this.btnSetShortcutScreenSaver.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnSetShortcutScreenSaver.Name = "btnSetShortcutScreenSaver"; - this.btnSetShortcutScreenSaver.Size = new System.Drawing.Size(34, 23); + this.btnSetShortcutScreenSaver.Size = new System.Drawing.Size(40, 27); this.btnSetShortcutScreenSaver.TabIndex = 10; this.btnSetShortcutScreenSaver.Text = "Set"; this.btnSetShortcutScreenSaver.UseVisualStyleBackColor = true; @@ -1631,18 +1740,20 @@ // label11 // this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(3, 74); + this.label11.Location = new System.Drawing.Point(4, 85); + this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(219, 13); + this.label11.Size = new System.Drawing.Size(238, 15); this.label11.TabIndex = 9; this.label11.Text = "Set a shortcut to start the blank screensaver:"; // // edtBlankScreenSaverShortcut // - this.edtBlankScreenSaverShortcut.Location = new System.Drawing.Point(6, 92); + this.edtBlankScreenSaverShortcut.Location = new System.Drawing.Point(7, 106); + this.edtBlankScreenSaverShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtBlankScreenSaverShortcut.Name = "edtBlankScreenSaverShortcut"; this.edtBlankScreenSaverShortcut.ReadOnly = true; - this.edtBlankScreenSaverShortcut.Size = new System.Drawing.Size(142, 20); + this.edtBlankScreenSaverShortcut.Size = new System.Drawing.Size(165, 23); this.edtBlankScreenSaverShortcut.TabIndex = 7; this.edtBlankScreenSaverShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown); this.edtBlankScreenSaverShortcut.KeyUp += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyUp); @@ -1650,18 +1761,20 @@ // lblFixChromeFontsDescription // this.lblFixChromeFontsDescription.AutoSize = true; - this.lblFixChromeFontsDescription.Location = new System.Drawing.Point(3, 39); + this.lblFixChromeFontsDescription.Location = new System.Drawing.Point(4, 45); + this.lblFixChromeFontsDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblFixChromeFontsDescription.Name = "lblFixChromeFontsDescription"; - this.lblFixChromeFontsDescription.Size = new System.Drawing.Size(373, 13); + this.lblFixChromeFontsDescription.Size = new System.Drawing.Size(427, 15); this.lblFixChromeFontsDescription.TabIndex = 6; this.lblFixChromeFontsDescription.Text = "This will add the parameter --disable-lcd-text to Chrome and requires elevation."; // // chkFixChromeFonts // this.chkFixChromeFonts.AutoSize = true; - this.chkFixChromeFonts.Location = new System.Drawing.Point(6, 19); + this.chkFixChromeFonts.Location = new System.Drawing.Point(7, 22); + this.chkFixChromeFonts.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkFixChromeFonts.Name = "chkFixChromeFonts"; - this.chkFixChromeFonts.Size = new System.Drawing.Size(335, 17); + this.chkFixChromeFonts.Size = new System.Drawing.Size(378, 19); this.chkFixChromeFonts.TabIndex = 4; this.chkFixChromeFonts.Text = "ClearType: fix bad fonts in Chrome (turn on grayscale anti-aliasing)"; this.chkFixChromeFonts.UseVisualStyleBackColor = true; @@ -1669,35 +1782,38 @@ // // grpLGOptions // - this.grpLGOptions.Controls.Add(this.chkLgAllowDowngrade); - this.grpLGOptions.Controls.Add(this.chkLgOldWolMechanism); + this.grpLGOptions.Controls.Add(this.chkLgShowAdvancedActions); this.grpLGOptions.Controls.Add(this.btnLGTestPower); this.grpLGOptions.Controls.Add(this.lblLgMaxPowerOnRetriesDescription); this.grpLGOptions.Controls.Add(this.edtLgMaxPowerOnRetries); this.grpLGOptions.Controls.Add(this.lblLgMaxPowerOnRetries); - this.grpLGOptions.Location = new System.Drawing.Point(6, 118); + this.grpLGOptions.Location = new System.Drawing.Point(7, 136); + this.grpLGOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpLGOptions.Name = "grpLGOptions"; - this.grpLGOptions.Size = new System.Drawing.Size(403, 129); + this.grpLGOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpLGOptions.Size = new System.Drawing.Size(470, 149); this.grpLGOptions.TabIndex = 4; this.grpLGOptions.TabStop = false; this.grpLGOptions.Text = "LG controller"; // - // chkLgOldWolMechanism + // chkLgShowAdvancedActions // - this.chkLgOldWolMechanism.AutoSize = true; - this.chkLgOldWolMechanism.Location = new System.Drawing.Point(158, 72); - this.chkLgOldWolMechanism.Name = "chkLgOldWolMechanism"; - this.chkLgOldWolMechanism.Size = new System.Drawing.Size(187, 17); - this.chkLgOldWolMechanism.TabIndex = 7; - this.chkLgOldWolMechanism.Text = "Use old WOL mechanism (Npcap)"; - this.chkLgOldWolMechanism.UseVisualStyleBackColor = true; - this.chkLgOldWolMechanism.CheckedChanged += new System.EventHandler(this.chkLgAlternateWolMechanism_CheckedChanged); + this.chkLgShowAdvancedActions.AutoSize = true; + this.chkLgShowAdvancedActions.Location = new System.Drawing.Point(10, 112); + this.chkLgShowAdvancedActions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.chkLgShowAdvancedActions.Name = "chkLgShowAdvancedActions"; + this.chkLgShowAdvancedActions.Size = new System.Drawing.Size(419, 19); + this.chkLgShowAdvancedActions.TabIndex = 8; + this.chkLgShowAdvancedActions.Text = "Show advanced actions under the Expert-button (InStart, Software Update)"; + this.chkLgShowAdvancedActions.UseVisualStyleBackColor = true; + this.chkLgShowAdvancedActions.CheckedChanged += new System.EventHandler(this.chkLgShowAdvancedActions_CheckedChanged); // // btnLGTestPower // - this.btnLGTestPower.Location = new System.Drawing.Point(9, 68); + this.btnLGTestPower.Location = new System.Drawing.Point(10, 78); + this.btnLGTestPower.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnLGTestPower.Name = "btnLGTestPower"; - this.btnLGTestPower.Size = new System.Drawing.Size(143, 23); + this.btnLGTestPower.Size = new System.Drawing.Size(167, 27); this.btnLGTestPower.TabIndex = 6; this.btnLGTestPower.Text = "Test power off/on"; this.btnLGTestPower.UseVisualStyleBackColor = true; @@ -1706,16 +1822,18 @@ // lblLgMaxPowerOnRetriesDescription // this.lblLgMaxPowerOnRetriesDescription.AutoSize = true; - this.lblLgMaxPowerOnRetriesDescription.Location = new System.Drawing.Point(6, 40); + this.lblLgMaxPowerOnRetriesDescription.Location = new System.Drawing.Point(7, 46); + this.lblLgMaxPowerOnRetriesDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgMaxPowerOnRetriesDescription.Name = "lblLgMaxPowerOnRetriesDescription"; - this.lblLgMaxPowerOnRetriesDescription.Size = new System.Drawing.Size(375, 13); + this.lblLgMaxPowerOnRetriesDescription.Size = new System.Drawing.Size(415, 15); this.lblLgMaxPowerOnRetriesDescription.TabIndex = 5; this.lblLgMaxPowerOnRetriesDescription.Text = "Retries are necessary to wait for the network link of your pc to be established. " + ""; // // edtLgMaxPowerOnRetries // - this.edtLgMaxPowerOnRetries.Location = new System.Drawing.Point(299, 17); + this.edtLgMaxPowerOnRetries.Location = new System.Drawing.Point(349, 20); + this.edtLgMaxPowerOnRetries.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLgMaxPowerOnRetries.Maximum = new decimal(new int[] { 25, 0, @@ -1723,7 +1841,7 @@ 0}); this.edtLgMaxPowerOnRetries.Name = "edtLgMaxPowerOnRetries"; this.edtLgMaxPowerOnRetries.ReadOnly = true; - this.edtLgMaxPowerOnRetries.Size = new System.Drawing.Size(74, 20); + this.edtLgMaxPowerOnRetries.Size = new System.Drawing.Size(86, 23); this.edtLgMaxPowerOnRetries.TabIndex = 1; this.edtLgMaxPowerOnRetries.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.edtLgMaxPowerOnRetries.ValueChanged += new System.EventHandler(this.edtLgPowerOnAfterResumeDelay_ValueChanged); @@ -1731,9 +1849,10 @@ // lblLgMaxPowerOnRetries // this.lblLgMaxPowerOnRetries.AutoSize = true; - this.lblLgMaxPowerOnRetries.Location = new System.Drawing.Point(6, 19); + this.lblLgMaxPowerOnRetries.Location = new System.Drawing.Point(7, 22); + this.lblLgMaxPowerOnRetries.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblLgMaxPowerOnRetries.Name = "lblLgMaxPowerOnRetries"; - this.lblLgMaxPowerOnRetries.Size = new System.Drawing.Size(294, 13); + this.lblLgMaxPowerOnRetries.Size = new System.Drawing.Size(340, 15); this.lblLgMaxPowerOnRetries.TabIndex = 0; this.lblLgMaxPowerOnRetries.Text = "Maximum number of retries powering on after startup/resume:"; // @@ -1741,9 +1860,11 @@ // this.grpHDROptions.Controls.Add(this.edtDelayDisplaySettings); this.grpHDROptions.Controls.Add(this.label6); - this.grpHDROptions.Location = new System.Drawing.Point(412, 316); + this.grpHDROptions.Location = new System.Drawing.Point(481, 365); + this.grpHDROptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpHDROptions.Name = "grpHDROptions"; - this.grpHDROptions.Size = new System.Drawing.Size(400, 72); + this.grpHDROptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpHDROptions.Size = new System.Drawing.Size(467, 83); this.grpHDROptions.TabIndex = 3; this.grpHDROptions.TabStop = false; this.grpHDROptions.Text = "HDR"; @@ -1756,7 +1877,8 @@ 0, 0, 0}); - this.edtDelayDisplaySettings.Location = new System.Drawing.Point(296, 17); + this.edtDelayDisplaySettings.Location = new System.Drawing.Point(345, 20); + this.edtDelayDisplaySettings.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtDelayDisplaySettings.Maximum = new decimal(new int[] { 5000, 0, @@ -1764,7 +1886,7 @@ 0}); this.edtDelayDisplaySettings.Name = "edtDelayDisplaySettings"; this.edtDelayDisplaySettings.ReadOnly = true; - this.edtDelayDisplaySettings.Size = new System.Drawing.Size(74, 20); + this.edtDelayDisplaySettings.Size = new System.Drawing.Size(86, 23); this.edtDelayDisplaySettings.TabIndex = 1; this.edtDelayDisplaySettings.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.edtDelayDisplaySettings.ValueChanged += new System.EventHandler(this.edtDelayDisplaySettings_ValueChanged); @@ -1772,32 +1894,49 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 19); + this.label6.Location = new System.Drawing.Point(7, 22); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(174, 13); + this.label6.Size = new System.Drawing.Size(197, 15); this.label6.TabIndex = 0; this.label6.Text = "Delay opening display settings (ms):"; // // grpGeneralOptions // + this.grpGeneralOptions.Controls.Add(this.chkGdiScaling); this.grpGeneralOptions.Controls.Add(this.chkCheckForUpdates); this.grpGeneralOptions.Controls.Add(this.chkMinimizeToSystemTray); this.grpGeneralOptions.Controls.Add(this.chkMinimizeOnClose); this.grpGeneralOptions.Controls.Add(this.chkStartMinimized); this.grpGeneralOptions.Controls.Add(this.chkStartAfterLogin); - this.grpGeneralOptions.Location = new System.Drawing.Point(6, 6); + this.grpGeneralOptions.Location = new System.Drawing.Point(7, 7); + this.grpGeneralOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpGeneralOptions.Name = "grpGeneralOptions"; - this.grpGeneralOptions.Size = new System.Drawing.Size(400, 106); + this.grpGeneralOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpGeneralOptions.Size = new System.Drawing.Size(467, 122); this.grpGeneralOptions.TabIndex = 2; this.grpGeneralOptions.TabStop = false; this.grpGeneralOptions.Text = "General"; // + // chkGdiScaling + // + this.chkGdiScaling.AutoSize = true; + this.chkGdiScaling.Location = new System.Drawing.Point(238, 75); + this.chkGdiScaling.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.chkGdiScaling.Name = "chkGdiScaling"; + this.chkGdiScaling.Size = new System.Drawing.Size(197, 19); + this.chkGdiScaling.TabIndex = 7; + this.chkGdiScaling.Text = "Use GDI Scaling (requires restart)"; + this.chkGdiScaling.UseVisualStyleBackColor = true; + this.chkGdiScaling.CheckedChanged += new System.EventHandler(this.chkGdiScaling_CheckedChanged); + // // chkCheckForUpdates // this.chkCheckForUpdates.AutoSize = true; - this.chkCheckForUpdates.Location = new System.Drawing.Point(204, 42); + this.chkCheckForUpdates.Location = new System.Drawing.Point(238, 48); + this.chkCheckForUpdates.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkCheckForUpdates.Name = "chkCheckForUpdates"; - this.chkCheckForUpdates.Size = new System.Drawing.Size(177, 17); + this.chkCheckForUpdates.Size = new System.Drawing.Size(197, 19); this.chkCheckForUpdates.TabIndex = 6; this.chkCheckForUpdates.Text = "Automatically check for updates"; this.chkCheckForUpdates.UseVisualStyleBackColor = true; @@ -1806,9 +1945,10 @@ // chkMinimizeToSystemTray // this.chkMinimizeToSystemTray.AutoSize = true; - this.chkMinimizeToSystemTray.Location = new System.Drawing.Point(204, 19); + this.chkMinimizeToSystemTray.Location = new System.Drawing.Point(238, 22); + this.chkMinimizeToSystemTray.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkMinimizeToSystemTray.Name = "chkMinimizeToSystemTray"; - this.chkMinimizeToSystemTray.Size = new System.Drawing.Size(133, 17); + this.chkMinimizeToSystemTray.Size = new System.Drawing.Size(152, 19); this.chkMinimizeToSystemTray.TabIndex = 5; this.chkMinimizeToSystemTray.Text = "Minimize to system tray"; this.chkMinimizeToSystemTray.UseVisualStyleBackColor = true; @@ -1817,9 +1957,10 @@ // chkMinimizeOnClose // this.chkMinimizeOnClose.AutoSize = true; - this.chkMinimizeOnClose.Location = new System.Drawing.Point(6, 65); + this.chkMinimizeOnClose.Location = new System.Drawing.Point(7, 75); + this.chkMinimizeOnClose.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkMinimizeOnClose.Name = "chkMinimizeOnClose"; - this.chkMinimizeOnClose.Size = new System.Drawing.Size(109, 17); + this.chkMinimizeOnClose.Size = new System.Drawing.Size(122, 19); this.chkMinimizeOnClose.TabIndex = 4; this.chkMinimizeOnClose.Text = "Minimize on close"; this.chkMinimizeOnClose.UseVisualStyleBackColor = true; @@ -1828,9 +1969,10 @@ // chkStartMinimized // this.chkStartMinimized.AutoSize = true; - this.chkStartMinimized.Location = new System.Drawing.Point(6, 42); + this.chkStartMinimized.Location = new System.Drawing.Point(7, 48); + this.chkStartMinimized.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkStartMinimized.Name = "chkStartMinimized"; - this.chkStartMinimized.Size = new System.Drawing.Size(96, 17); + this.chkStartMinimized.Size = new System.Drawing.Size(109, 19); this.chkStartMinimized.TabIndex = 3; this.chkStartMinimized.Text = "Start minimized"; this.chkStartMinimized.UseVisualStyleBackColor = true; @@ -1838,9 +1980,10 @@ // chkStartAfterLogin // this.chkStartAfterLogin.AutoSize = true; - this.chkStartAfterLogin.Location = new System.Drawing.Point(6, 19); + this.chkStartAfterLogin.Location = new System.Drawing.Point(7, 22); + this.chkStartAfterLogin.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.chkStartAfterLogin.Name = "chkStartAfterLogin"; - this.chkStartAfterLogin.Size = new System.Drawing.Size(160, 17); + this.chkStartAfterLogin.Size = new System.Drawing.Size(183, 19); this.chkStartAfterLogin.TabIndex = 2; this.chkStartAfterLogin.Text = "Automatically start after login"; this.chkStartAfterLogin.UseVisualStyleBackColor = true; @@ -1850,19 +1993,21 @@ // this.tabLog.Controls.Add(this.btnClearLog); this.tabLog.Controls.Add(this.edtLog); - this.tabLog.Location = new System.Drawing.Point(4, 22); + this.tabLog.Location = new System.Drawing.Point(4, 24); + this.tabLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabLog.Name = "tabLog"; - this.tabLog.Padding = new System.Windows.Forms.Padding(3); - this.tabLog.Size = new System.Drawing.Size(954, 453); + this.tabLog.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabLog.Size = new System.Drawing.Size(1114, 525); this.tabLog.TabIndex = 3; this.tabLog.Text = "Log"; this.tabLog.UseVisualStyleBackColor = true; // // btnClearLog // - this.btnClearLog.Location = new System.Drawing.Point(6, 6); + this.btnClearLog.Location = new System.Drawing.Point(7, 7); + this.btnClearLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnClearLog.Name = "btnClearLog"; - this.btnClearLog.Size = new System.Drawing.Size(75, 23); + this.btnClearLog.Size = new System.Drawing.Size(88, 27); this.btnClearLog.TabIndex = 2; this.btnClearLog.Text = "Clear log"; this.btnClearLog.UseVisualStyleBackColor = true; @@ -1873,23 +2018,25 @@ this.edtLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.edtLog.Location = new System.Drawing.Point(6, 35); + this.edtLog.Location = new System.Drawing.Point(7, 40); + this.edtLog.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.edtLog.MaxLength = 327670; this.edtLog.Multiline = true; this.edtLog.Name = "edtLog"; this.edtLog.ReadOnly = true; this.edtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.edtLog.Size = new System.Drawing.Size(942, 415); + this.edtLog.Size = new System.Drawing.Size(1098, 478); this.edtLog.TabIndex = 0; // // tabInfo // this.tabInfo.Controls.Add(this.grpNVIDIAInfo); this.tabInfo.Controls.Add(this.groupBox3); - this.tabInfo.Location = new System.Drawing.Point(4, 22); + this.tabInfo.Location = new System.Drawing.Point(4, 24); + this.tabInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tabInfo.Name = "tabInfo"; - this.tabInfo.Padding = new System.Windows.Forms.Padding(3); - this.tabInfo.Size = new System.Drawing.Size(954, 453); + this.tabInfo.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.tabInfo.Size = new System.Drawing.Size(1114, 525); this.tabInfo.TabIndex = 4; this.tabInfo.Text = "Info"; this.tabInfo.UseVisualStyleBackColor = true; @@ -1901,9 +2048,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.grpNVIDIAInfo.Controls.Add(this.btnRefreshNVIDIAInfo); this.grpNVIDIAInfo.Controls.Add(this.tvNVIDIAInfo); - this.grpNVIDIAInfo.Location = new System.Drawing.Point(397, 6); + this.grpNVIDIAInfo.Location = new System.Drawing.Point(463, 7); + this.grpNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.grpNVIDIAInfo.Name = "grpNVIDIAInfo"; - this.grpNVIDIAInfo.Size = new System.Drawing.Size(551, 443); + this.grpNVIDIAInfo.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpNVIDIAInfo.Size = new System.Drawing.Size(643, 511); this.grpNVIDIAInfo.TabIndex = 4; this.grpNVIDIAInfo.TabStop = false; this.grpNVIDIAInfo.Text = "NVIDIA info"; @@ -1911,9 +2060,10 @@ // btnRefreshNVIDIAInfo // this.btnRefreshNVIDIAInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnRefreshNVIDIAInfo.Location = new System.Drawing.Point(6, 414); + this.btnRefreshNVIDIAInfo.Location = new System.Drawing.Point(7, 478); + this.btnRefreshNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.btnRefreshNVIDIAInfo.Name = "btnRefreshNVIDIAInfo"; - this.btnRefreshNVIDIAInfo.Size = new System.Drawing.Size(75, 23); + this.btnRefreshNVIDIAInfo.Size = new System.Drawing.Size(88, 27); this.btnRefreshNVIDIAInfo.TabIndex = 1; this.btnRefreshNVIDIAInfo.Text = "Refresh"; this.btnRefreshNVIDIAInfo.UseVisualStyleBackColor = true; @@ -1924,9 +2074,10 @@ this.tvNVIDIAInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.tvNVIDIAInfo.Location = new System.Drawing.Point(6, 19); + this.tvNVIDIAInfo.Location = new System.Drawing.Point(7, 22); + this.tvNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tvNVIDIAInfo.Name = "tvNVIDIAInfo"; - this.tvNVIDIAInfo.Size = new System.Drawing.Size(539, 389); + this.tvNVIDIAInfo.Size = new System.Drawing.Size(628, 448); this.tvNVIDIAInfo.TabIndex = 0; // // groupBox3 @@ -1934,9 +2085,11 @@ this.groupBox3.Controls.Add(this.lbPlugins); this.groupBox3.Controls.Add(this.label7); this.groupBox3.Controls.Add(this.lblInfo); - this.groupBox3.Location = new System.Drawing.Point(6, 6); + this.groupBox3.Location = new System.Drawing.Point(7, 7); + this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(385, 220); + this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.groupBox3.Size = new System.Drawing.Size(449, 254); this.groupBox3.TabIndex = 5; this.groupBox3.TabStop = false; this.groupBox3.Text = "Info"; @@ -1945,49 +2098,43 @@ // this.lbPlugins.FormattingEnabled = true; this.lbPlugins.HorizontalScrollbar = true; - this.lbPlugins.Location = new System.Drawing.Point(9, 67); + this.lbPlugins.ItemHeight = 15; + this.lbPlugins.Location = new System.Drawing.Point(10, 77); + this.lbPlugins.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lbPlugins.Name = "lbPlugins"; - this.lbPlugins.Size = new System.Drawing.Size(371, 147); + this.lbPlugins.Size = new System.Drawing.Size(432, 169); this.lbPlugins.TabIndex = 3; // // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 51); + this.label7.Location = new System.Drawing.Point(7, 59); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(236, 13); + this.label7.Size = new System.Drawing.Size(267, 15); this.label7.TabIndex = 2; this.label7.Text = "This app contains the following 3rd party plugins:"; // // lblInfo // this.lblInfo.AutoSize = true; - this.lblInfo.Location = new System.Drawing.Point(6, 20); + this.lblInfo.Location = new System.Drawing.Point(7, 23); + this.lblInfo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblInfo.Name = "lblInfo"; - this.lblInfo.Size = new System.Drawing.Size(25, 13); + this.lblInfo.Size = new System.Drawing.Size(28, 15); this.lblInfo.TabIndex = 1; this.lblInfo.Text = "Info"; // - // chkLgAllowDowngrade - // - this.chkLgAllowDowngrade.AutoSize = true; - this.chkLgAllowDowngrade.Location = new System.Drawing.Point(9, 97); - this.chkLgAllowDowngrade.Name = "chkLgAllowDowngrade"; - this.chkLgAllowDowngrade.Size = new System.Drawing.Size(275, 17); - this.chkLgAllowDowngrade.TabIndex = 8; - this.chkLgAllowDowngrade.Text = "Allow firmware downgrade with Software Update-app"; - this.chkLgAllowDowngrade.UseVisualStyleBackColor = true; - this.chkLgAllowDowngrade.CheckedChanged += new System.EventHandler(this.chkLgAllowDowngrade_CheckedChanged); - // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; - this.ClientSize = new System.Drawing.Size(986, 503); + this.ClientSize = new System.Drawing.Size(1150, 580); this.Controls.Add(this.tcMain); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(800, 535); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MinimumSize = new System.Drawing.Size(1140, 611); this.Name = "MainForm"; this.Text = "ColorControl"; this.Activated += new System.EventHandler(this.MainForm_Activated); @@ -1995,6 +2142,8 @@ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); this.Shown += new System.EventHandler(this.MainForm_Shown); + this.ResizeBegin += new System.EventHandler(this.MainForm_ResizeBegin); + this.ResizeEnd += new System.EventHandler(this.MainForm_ResizeEnd); this.Resize += new System.EventHandler(this.MainForm_Resize); this.tcMain.ResumeLayout(false); this.tabNVIDIA.ResumeLayout(false); @@ -2116,7 +2265,6 @@ private System.Windows.Forms.ToolStripMenuItem spatialStatic2x2ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem temporalToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem miNvPresetApplyOnStartup; - private System.Windows.Forms.CheckBox chkLgOldWolMechanism; private System.Windows.Forms.ToolStripMenuItem mnuLgRcButtons; private System.Windows.Forms.ToolStripMenuItem mnuLgActions; private System.Windows.Forms.Button btnDeleteAmd; @@ -2183,7 +2331,6 @@ private System.Windows.Forms.CheckBox chkLgRemoteControlShow; private System.Windows.Forms.Button btnLgExpert; private System.Windows.Forms.ContextMenuStrip mnuLgExpert; - private System.Windows.Forms.ToolStripMenuItem mnuLgExpertBacklight; private System.Windows.Forms.ToolStripMenuItem mnuLgOLEDMotionPro; private System.Windows.Forms.ToolStripMenuItem miLgEnableMotionPro; private System.Windows.Forms.ToolStripMenuItem miLgDisableMotionPro; @@ -2200,7 +2347,11 @@ private System.Windows.Forms.Button btnLgPresetEditTriggerConditions; private System.Windows.Forms.TextBox edtLgPresetTriggerConditions; private System.Windows.Forms.CheckBox chkCheckForUpdates; - private System.Windows.Forms.CheckBox chkLgAllowDowngrade; + private System.Windows.Forms.CheckBox chkLgShowAdvancedActions; + private System.Windows.Forms.Button btnLgGameBar; + private System.Windows.Forms.Label lblGameBarShortcut; + private System.Windows.Forms.TextBox edtLgGameBarShortcut; + private System.Windows.Forms.CheckBox chkGdiScaling; } } diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs index 64d0fd6..21faafe 100644 --- a/ColorControl/MainForm.cs +++ b/ColorControl/MainForm.cs @@ -1,5 +1,6 @@ using ATI.ADL; using LgTv; +using Newtonsoft.Json; using NLog; using NStandard; using NvAPIWrapper.Display; @@ -8,8 +9,6 @@ using NWin32; using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; -using System.Deployment.Application; using System.Diagnostics; using System.Drawing; using System.IO; @@ -23,11 +22,11 @@ namespace ColorControl { public partial class MainForm : Form { - private static string TS_TASKNAME = "ColorControl"; private static bool SystemShutdown = false; private static bool EndSession = false; private static bool UserExit = false; private static int SHORTCUTID_SCREENSAVER = -100; + private static int SHORTCUTID_GAMEBAR = -101; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -45,9 +44,9 @@ namespace ColorControl private LgService _lgService; - private MenuItem _nvTrayMenu; - private MenuItem _amdTrayMenu; - private MenuItem _lgTrayMenu; + private ToolStripMenuItem _nvTrayMenu; + private ToolStripMenuItem _amdTrayMenu; + private ToolStripMenuItem _lgTrayMenu; private StartUpParams StartUpParams { get; } @@ -57,6 +56,8 @@ namespace ColorControl private bool _checkedForUpdates = false; private string _updateHtmlUrl; + private LgGameBar _gameBarForm; + public MainForm(AppContext appContext) { InitializeComponent(); @@ -69,29 +70,32 @@ namespace ColorControl MessageForms.MainForm = this; - _nvTrayMenu = new MenuItem("NVIDIA presets"); - _amdTrayMenu = new MenuItem("NVIDIA presets"); - _lgTrayMenu = new MenuItem("LG presets"); + _nvTrayMenu = new ToolStripMenuItem("NVIDIA presets"); + _amdTrayMenu = new ToolStripMenuItem("NVIDIA presets"); + _lgTrayMenu = new ToolStripMenuItem("LG presets"); _trayIcon = new NotifyIcon() { Icon = Icon, - ContextMenu = new ContextMenu(new MenuItem[] { - _nvTrayMenu, - _amdTrayMenu, - _lgTrayMenu, - new MenuItem("-"), - new MenuItem("Open", OpenForm), - new MenuItem("-"), - new MenuItem("Exit", Exit) - }), + ContextMenuStrip = new ContextMenuStrip(), Visible = _config.MinimizeToTray, Text = Text }; + + _trayIcon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { + _nvTrayMenu, + _amdTrayMenu, + _lgTrayMenu, + new ToolStripSeparator(), + new ToolStripMenuItem("Open", null, OpenForm), + new ToolStripSeparator(), + new ToolStripMenuItem("Exit", null, Exit) + }); + _trayIcon.MouseDoubleClick += trayIcon_MouseDoubleClick; - _trayIcon.ContextMenu.Popup += trayIconContextMenu_Popup; + _trayIcon.ContextMenuStrip.Opened += trayIconContextMenu_Popup; _trayIcon.BalloonTipClicked += trayIconBalloonTip_Clicked; - chkStartAfterLogin.Checked = Utils.TaskExists(TS_TASKNAME, true); + chkStartAfterLogin.Checked = Utils.TaskExists(Program.TS_TASKNAME, true); chkFixChromeFonts.Enabled = Utils.IsChromeInstalled(); if (chkFixChromeFonts.Enabled) @@ -177,8 +181,7 @@ namespace ColorControl edtLgMaxPowerOnRetries.Value = _lgService.Config.PowerOnRetries; edtLgDeviceFilter.Text = _lgService.Config.DeviceSearchKey; - chkLgOldWolMechanism.Checked = _lgService.Config.UseOldNpcapWol; - chkLgAllowDowngrade.Checked = _lgService.Config.AllowFirmwareDowngrade; + chkLgShowAdvancedActions.Checked = _lgService.Config.ShowAdvancedActions; var values = Enum.GetValues(typeof(ButtonType)); foreach (var button in values) @@ -196,6 +199,13 @@ namespace ColorControl _lgService.InstallEventHandlers(); LgDevice.ExternalServiceHandler = HandleExternalServiceForLgDevice; + + if (!string.IsNullOrEmpty(_lgService.Config.GameBarShortcut)) + { + Utils.RegisterShortcut(Handle, SHORTCUTID_GAMEBAR, _lgService.Config.GameBarShortcut); + + edtLgGameBarShortcut.Text = _lgService.Config.GameBarShortcut; + } } catch (Exception e) { @@ -236,14 +246,14 @@ namespace ColorControl { _currentVersionInfo = FileVersionInfo.GetVersionInfo(Path.GetFileName(Application.ExecutablePath)); - if (ApplicationDeployment.IsNetworkDeployed) - { - Text = Application.ProductName + " " + ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); - } - else - { + //if (ApplicationDeployment.IsNetworkDeployed) + //{ + // Text = Application.ProductName + " " + ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); + //} + //else + //{ Text = Application.ProductName + " " + Application.ProductVersion; - } + //} lblInfo.Text = Text + " - " + _currentVersionInfo.LegalCopyright; @@ -316,7 +326,7 @@ namespace ColorControl return; } - var text = TS_TASKNAME; + var text = Program.TS_TASKNAME; foreach (var displayInfo in displays) { var display = displayInfo.Display; @@ -372,7 +382,7 @@ namespace ColorControl return; } - var text = TS_TASKNAME; + var text = Program.TS_TASKNAME; foreach (var displayInfo in displays) { var display = displayInfo.Display; @@ -504,10 +514,29 @@ namespace ColorControl } } + private Control FindFocusedControl() + { + ContainerControl container = this; + Control control = null; + while (container != null) + { + control = container.ActiveControl; + container = control as ContainerControl; + } + + return control; + } + + private bool IsShortcutControlFocused() + { + var control = FindFocusedControl(); + return control?.Name.Contains("Shortcut") ?? false; + } + protected override void WndProc(ref Message m) { // 5. Catch when a HotKey is pressed ! - if (m.Msg == NativeConstants.WM_HOTKEY && !edtShortcut.Focused && !edtShortcutLg.Focused && !edtAmdShortcut.Focused && !edtBlankScreenSaverShortcut.Focused) + if (m.Msg == NativeConstants.WM_HOTKEY && !IsShortcutControlFocused()) { int id = m.WParam.ToInt32(); @@ -515,7 +544,11 @@ namespace ColorControl if (id == SHORTCUTID_SCREENSAVER) { var screenSaver = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "scrnsave.scr"); - Process.Start(screenSaver); + Process.Start("explorer.exe", screenSaver); + } + else if (id == SHORTCUTID_GAMEBAR) + { + ToggleGameBar(); } else { @@ -623,7 +656,7 @@ namespace ColorControl return; } var enabled = chkStartAfterLogin.Checked; - Utils.RegisterTask(TS_TASKNAME, enabled); + Utils.ExecuteElevated(enabled ? StartUpParams.EnableAutoStartParam : StartUpParams.DisableAutoStartParam); } private void LoadConfig() @@ -634,6 +667,7 @@ namespace ColorControl chkCheckForUpdates.Checked = _config.CheckForUpdates; edtDelayDisplaySettings.Value = _config.DisplaySettingsDelay; edtBlankScreenSaverShortcut.Text = _config.ScreenSaverShortcut; + chkGdiScaling.Checked = _config.UseGdiScaling; if (!string.IsNullOrEmpty(_config.ScreenSaverShortcut)) { @@ -663,7 +697,7 @@ namespace ColorControl try { - var data = Utils.JsonSerializer.Serialize(_config); + var data = JsonConvert.SerializeObject(_config); File.WriteAllText(Program.ConfigFilename, data); } catch (Exception e) @@ -1348,9 +1382,25 @@ namespace ColorControl var preset = _nvService.GetLastAppliedPreset() ?? GetSelectedNvPreset(); if (firstTime || preset != null) { - chkDitheringEnabled.Checked = preset?.ditheringEnabled ?? true; - cbxDitheringBitDepth.SelectedIndex = (int)(preset?.ditheringBits ?? (int)NvDitherBits.Bits8); - cbxDitheringMode.SelectedIndex = (int)(preset?.ditheringMode ?? (int)NvDitherMode.Temporal); + var ditheringEnabled = true; + int ditherBitsIndex; + int ditherModeIndex; + if (preset == null) + { + var hdrEnabled = _nvService.IsHDREnabled(); + ditherBitsIndex = (int)(hdrEnabled ? NvDitherBits.Bits8 : NvDitherBits.Bits6); + ditherModeIndex = (int)NvDitherMode.Temporal; + } + else + { + ditheringEnabled = preset.ditheringEnabled; + ditherBitsIndex = (int)preset.ditheringBits; + ditherModeIndex = (int)preset.ditheringMode; + } + + chkDitheringEnabled.Checked = ditheringEnabled; + cbxDitheringBitDepth.SelectedIndex = ditherBitsIndex; + cbxDitheringMode.SelectedIndex = ditherModeIndex; FillGradient(); } } @@ -1445,7 +1495,7 @@ namespace ColorControl { var presets = _nvService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.applyRefreshRate); - _nvTrayMenu.MenuItems.Clear(); + _nvTrayMenu.DropDownItems.Clear(); foreach (var preset in presets) { @@ -1455,10 +1505,10 @@ namespace ColorControl name += "\t" + preset.shortcut; } - var item = new MenuItem(name); + var item = new ToolStripMenuItem(name); item.Tag = preset; item.Click += TrayMenuItemNv_Click; - _nvTrayMenu.MenuItems.Add(item); + _nvTrayMenu.DropDownItems.Add(item); } } @@ -1466,7 +1516,7 @@ namespace ColorControl { var presets = _amdService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.applyRefreshRate); - _amdTrayMenu.MenuItems.Clear(); + _amdTrayMenu.DropDownItems.Clear(); foreach (var preset in presets) { @@ -1476,16 +1526,16 @@ namespace ColorControl name += "\t" + preset.shortcut; } - var item = new MenuItem(name); + var item = new ToolStripMenuItem(name); item.Tag = preset; item.Click += TrayMenuItemAmd_Click; - _amdTrayMenu.MenuItems.Add(item); + _amdTrayMenu.DropDownItems.Add(item); } } private void TrayMenuItemNv_Click(object sender, EventArgs e) { - var item = sender as MenuItem; + var item = sender as ToolStripMenuItem; var preset = (NvPreset)item.Tag; ApplyNvPreset(preset); @@ -1493,7 +1543,7 @@ namespace ColorControl private void TrayMenuItemAmd_Click(object sender, EventArgs e) { - var item = sender as MenuItem; + var item = sender as ToolStripMenuItem; var preset = (AmdPreset)item.Tag; ApplyAmdPreset(preset); @@ -1524,7 +1574,7 @@ namespace ColorControl { var presets = _lgService.GetPresets().Where(x => !string.IsNullOrEmpty(x.appId) || x.steps.Any()); - _lgTrayMenu.MenuItems.Clear(); + _lgTrayMenu.DropDownItems.Clear(); foreach (var preset in presets) { @@ -1534,16 +1584,16 @@ namespace ColorControl name += "\t" + preset.shortcut; } - var item = new MenuItem(name); + var item = new ToolStripMenuItem(name); item.Tag = preset; item.Click += TrayMenuItemLg_Click; - _lgTrayMenu.MenuItems.Add(item); + _lgTrayMenu.DropDownItems.Add(item); } } private void TrayMenuItemLg_Click(object sender, EventArgs e) { - var item = sender as MenuItem; + var item = sender as ToolStripMenuItem; var preset = (LgPreset)item.Tag; ApplyLgPreset(preset); @@ -2182,11 +2232,6 @@ Do you want to continue?"; AddOrUpdateItem(); } - private void chkLgAlternateWolMechanism_CheckedChanged(object sender, EventArgs e) - { - _lgService.Config.UseOldNpcapWol = chkLgOldWolMechanism.Checked; - } - private void MainForm_Deactivate(object sender, EventArgs e) { GlobalSave(); @@ -2218,7 +2263,7 @@ Do you want to continue?"; } } - private bool ShortCutExists(string shortcut, int presetId) + private bool ShortCutExists(string shortcut, int presetId = 0) { return (_nvService?.GetPresets().Any(x => x.id != presetId && shortcut.Equals(x.shortcut)) ?? false) || @@ -2708,28 +2753,85 @@ Do you want to continue?" mnuLgOLEDMotionPro.Visible = visible; miLgExpertSeparator1.Visible = visible; - if (mnuLgExpertBacklight.DropDownItems.Count == 0) - { - for (var i = 0; i <= 10; i++) - { - var name = (i * 10).ToString(); - - var item = mnuLgExpertBacklight.DropDownItems.Add(name); - item.Click += btnLgExpertBacklight_Click; - } - } - // Does not work yet, getting a "401 no permissions" error //var task = device?.GetPictureSettings(); //var settings = Utils.WaitForTask(task); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Picture Mode", typeof(PictureMode), btnLgExpertColorGamut_Click, "pictureMode"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Color Gamut", typeof(ColorGamut), btnLgExpertColorGamut_Click, "colorGamut"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Dynamic Contrast", typeof(OffToAuto), btnLgExpertColorGamut_Click, "dynamicContrast"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Smooth Gradation", typeof(OffToAuto), btnLgExpertColorGamut_Click, "smoothGradation"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Peak Brightness", typeof(OffToAuto), btnLgExpertColorGamut_Click, "peakBrightness"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "OLED Motion Pro", typeof(OffToHigh), btnLgExpertColorGamut_Click, "motionProOLED"); - Utils.BuildDropDownMenuEx(mnuLgExpert, "Energy Saving", typeof(EnergySaving), btnLgExpertColorGamut_Click, "energySaving"); + if (device == null) + { + return; + } + + var actions = device.GetInvokableActions(); + var gameBarActions = device.GetInvokableActionsForGameBar(); + var activatedGameBarActions = device.GetActionsForGameBar(); + + const string gameBarName = "miGameBar"; + + foreach (var action in actions.Where(a => !a.Name.Contains("Hdmi", StringComparison.OrdinalIgnoreCase) && (a.EnumType != null || a.MinValue >= 0 && a.MaxValue > a.MinValue))) + { + var menu = Utils.BuildDropDownMenuEx(mnuLgExpert, action.Title, action.EnumType, btnLgExpertColorGamut_Click, action.Name, (int)action.MinValue, (int)action.MaxValue); + + if (!gameBarActions.Contains(action)) + { + continue; + } + + var itemName = $"{menu.Name}_{gameBarName}"; + var gameBarItem = (ToolStripMenuItem)menu.DropDownItems.Find(itemName, false).FirstOrDefault(); + + 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; + } + } + + if (!_lgService.Config.ShowAdvancedActions) + { + return; + } + + var presetActions = actions.Where(a => a.Preset != null); + + if (presetActions.Any() && mnuLgExpert.Items.Find("miLgExpertActionsSeparator", false).Length == 0) + { + mnuLgExpert.Items.Add(new ToolStripSeparator + { + Name = "miLgExpertActionsSeparator" + }); + } + + foreach (var presetAction in presetActions) + { + var menu = Utils.BuildDropDownMenuEx(mnuLgExpert, presetAction.Name, null, btnLgExpertPresetAction_Click, presetAction.Preset); + } + } + + private void miLgGameBarToggle_Click(object sender, EventArgs e) + { + var device = _lgService.SelectedDevice; + + if (device == null) + { + return; + } + + var item = sender as ToolStripMenuItem; + if (item.Checked) + { + device.AddGameBarAction((string)item.Tag); + } + else + { + device.RemoveGameBarAction((string)item.Tag); + } } private void btnLgExpert_Click(object sender, EventArgs e) @@ -2737,14 +2839,6 @@ Do you want to continue?" mnuLgExpert.Show(btnLgExpert, btnLgExpert.PointToClient(Cursor.Position)); } - private void btnLgExpertBacklight_Click(object sender, EventArgs e) - { - var item = sender as ToolStripItem; - var backlight = int.Parse(item.Text); - - _lgService.SelectedDevice?.SetBacklight(backlight); - } - private void btnLgExpertColorGamut_Click(object sender, EventArgs e) { var item = sender as ToolStripItem; @@ -2754,6 +2848,14 @@ Do you want to continue?" _lgService.SelectedDevice?.SetSystemSettings(name, value); } + private void btnLgExpertPresetAction_Click(object sender, EventArgs e) + { + var item = sender as ToolStripItem; + var preset = (LgPreset)item.Tag; + + _lgService.ApplyPreset(preset).ConfigureAwait(false); + } + private void miLgEnableMotionPro_Click(object sender, EventArgs e) { if (MessageForms.QuestionYesNo("Are you sure you want to enable OLED Motion Pro? This app and its creator are in no way accountable for any damages it may cause to your tv.") == DialogResult.Yes) @@ -2818,31 +2920,105 @@ Do you want to continue?" } } - private void chkLgAllowDowngrade_CheckedChanged(object sender, EventArgs e) + private void chkLgShowAdvancedActions_CheckedChanged(object sender, EventArgs e) { if (!_initialized) { return; } - if (chkLgAllowDowngrade.Checked) + if (chkLgShowAdvancedActions.Checked) { if (MessageForms.QuestionYesNo( -@"Are you sure you want to enable firmware downgrade functionality with the Software Update-app? -This may cause irreversible damage to your tv and will void your warranty. +@"Are you sure you want to enable the advanced actions under the Expert-button? +These actions include: +- InStart service menu +- Software Update-app with firmware downgrade functionality enabled + +These features may cause irreversible damage to your tv and will void your warranty. This app and its creator are in no way accountable for any damages it may cause to your tv." ) != DialogResult.Yes) { - chkLgAllowDowngrade.Checked = false; + chkLgShowAdvancedActions.Checked = false; return; } MessageForms.InfoOk( -@"Firmware downgrade functionality activated. -In order to use it, you must create and execute a preset on the LG controller tab that starts the app Software Update (com.webos.app.softwareupdate)." +@"Advanced actions activated. +The InStart and Software Update items are now visible under the Expert-button." ); } - _lgService.Config.AllowFirmwareDowngrade = chkLgAllowDowngrade.Checked; + _lgService.Config.ShowAdvancedActions = chkLgShowAdvancedActions.Checked; + } + + private void ToggleGameBar() + { + if (_gameBarForm == null || !_gameBarForm.Visible) + { + if (_gameBarForm == null || _gameBarForm.IsDisposed) + { + _gameBarForm = new LgGameBar(_lgService); + } + + _gameBarForm.Show(); + _gameBarForm.Activate(); + } + else + { + _gameBarForm?.Hide(); + } + } + + private void btnLgGameBar_Click(object sender, EventArgs e) + { + ToggleGameBar(); + } + + private void edtLgGameBarShortcut_KeyDown(object sender, KeyEventArgs e) + { + ((TextBox)sender).Text = Utils.FormatKeyboardShortcut(e); + } + + private void edtLgGameBarShortcut_KeyUp(object sender, KeyEventArgs e) + { + Utils.HandleKeyboardShortcutUp(e); + } + + private void edtLgGameBarShortcut_TextChanged(object sender, EventArgs e) + { + var text = edtLgGameBarShortcut.Text; + + var blnOk = string.IsNullOrEmpty(text) || !ShortCutExists(text); + edtLgGameBarShortcut.ForeColor = blnOk ? Color.Red : SystemColors.WindowText; + + if (blnOk) + { + _lgService.Config.GameBarShortcut = text; + + if (string.IsNullOrEmpty(text)) + { + Utils.UnregisterHotKey(Handle, SHORTCUTID_GAMEBAR); + } + else + { + Utils.RegisterShortcut(Handle, SHORTCUTID_GAMEBAR, text); + } + } + } + + private void chkGdiScaling_CheckedChanged(object sender, EventArgs e) + { + _config.UseGdiScaling = chkGdiScaling.Checked; + } + + private void MainForm_ResizeBegin(object sender, EventArgs e) + { + SuspendLayout(); + } + + private void MainForm_ResizeEnd(object sender, EventArgs e) + { + ResumeLayout(true); } } } \ No newline at end of file diff --git a/ColorControl/MainForm.resx b/ColorControl/MainForm.resx index 7229478..bb2dd65 100644 --- a/ColorControl/MainForm.resx +++ b/ColorControl/MainForm.resx @@ -1,64 +1,4 @@ - - - + diff --git a/ColorControl/NvService.cs b/ColorControl/NvService.cs index 4ca5582..ff27218 100644 --- a/ColorControl/NvService.cs +++ b/ColorControl/NvService.cs @@ -1,7 +1,7 @@ -using NvAPIWrapper; +using Newtonsoft.Json; +using NvAPIWrapper; using NvAPIWrapper.Display; using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; using NvAPIWrapper.Native.GPU.Structures; using System; using System.Collections.Generic; @@ -71,8 +71,7 @@ namespace ColorControl public NvService(string dataPath) : base(dataPath, "NvPresets.json") { - var converter = new ColorDataConverter(); - _JsonDeserializer.RegisterConverters(new[] { converter }); + AddJsonConverter(new ColorDataConverter()); LoadPresets(); } @@ -135,7 +134,7 @@ namespace ColorControl { try { - var json = _JsonSerializer.Serialize(_presets); + var json = JsonConvert.SerializeObject(_presets); File.WriteAllText(_presetsFilename, json); } catch (Exception e) diff --git a/ColorControl/Program.cs b/ColorControl/Program.cs index a490f08..c5b9cf2 100644 --- a/ColorControl/Program.cs +++ b/ColorControl/Program.cs @@ -1,4 +1,5 @@ -using NLog; +using Newtonsoft.Json; +using NLog; using NWin32; using System; using System.Diagnostics; @@ -10,11 +11,13 @@ namespace ColorControl { static class Program { + public const string TS_TASKNAME = "ColorControl"; public static string DataDir { get; private set; } public static string ConfigFilename { get; private set; } public static Config Config { get; private set; } public static AppContext AppContext { get; private set; } + /// /// The main entry point for the application. /// @@ -32,6 +35,11 @@ namespace ColorControl LoadConfig(); + if (Config.UseGdiScaling) + { + Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled); + } + var startUpParams = StartUpParams.Parse(args); AppContext = new AppContext(Config, startUpParams); @@ -112,7 +120,7 @@ namespace ColorControl if (File.Exists(ConfigFilename)) { var data = File.ReadAllText(ConfigFilename); - Config = Utils.JsonSerializer.Deserialize(data); + Config = JsonConvert.DeserializeObject(data); } else { @@ -127,6 +135,11 @@ namespace ColorControl Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix); return true; } + if (startUpParams.EnableAutoStart || startUpParams.DisableAutoStart) + { + Utils.RegisterTask(TS_TASKNAME, startUpParams.EnableAutoStart); + return true; + } var useConsole = startUpParams.NoGui || existingProcess != null; diff --git a/ColorControl/Properties/AssemblyInfo.cs b/ColorControl/Properties/AssemblyInfo.cs deleted file mode 100644 index 1a0519e..0000000 --- a/ColorControl/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ColorControl")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Maassoft")] -[assembly: AssemblyProduct("ColorControl")] -[assembly: AssemblyCopyright("Copyright © Maassoft 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a6005d08-70f0-44cb-a384-9219eba84f21")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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.5.0.0")] -[assembly: AssemblyFileVersion("4.5.0.0")] diff --git a/ColorControl/Properties/Resources.Designer.cs b/ColorControl/Properties/Resources.Designer.cs index 378073f..2d4d2a4 100644 --- a/ColorControl/Properties/Resources.Designer.cs +++ b/ColorControl/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace ColorControl.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -71,7 +71,7 @@ namespace ColorControl.Properties { } /// - /// Looks up a localized string similar to Power;120;132 + /// Looks up a localized string similar to Power;120;136 ///1;106;228 ///2;196;228 ///3;286;228 @@ -81,15 +81,32 @@ namespace ColorControl.Properties { ///7;106;362 ///8;196;362 ///9;286;362 + ///List;106;425 ///0;196;425 + ///SAP;286;425 ///Vol +;98;513 ///Mute;198;513 ///Channel +;298;513 ///Vol -;98;622 - ///Speech;198;633 ///Channel -;298;622 ///Home;78;695 - ///Settings;318;695. + ///Settings;318;695 + ///Up;200;748 + ///Left;98;852 + ///Enter;200;852 + ///Right;304;852 + ///Down;200;952 + ///Back;80;1000 + ///TV Guide;320;1000 + ///Netflix;92;1076 + ///Inputs;200;1066 + ///Amazon Prime;312;1076 + ///Red;90;1150 + ///Green;164;1150 + ///Yellow;240;1150 + ///Blue;316;1150 + ///Rakuten TV;116;1218 + ///Play;202 [rest of string was truncated]";. /// internal static string RC_coords { get { diff --git a/ColorControl/Properties/Settings.Designer.cs b/ColorControl/Properties/Settings.Designer.cs index cfaea48..3532d1d 100644 --- a/ColorControl/Properties/Settings.Designer.cs +++ b/ColorControl/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace ColorControl.Properties -{ - - +namespace ColorControl.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/ColorControl/ServiceBase.cs b/ColorControl/ServiceBase.cs index 6c7544d..a0c039b 100644 --- a/ColorControl/ServiceBase.cs +++ b/ColorControl/ServiceBase.cs @@ -1,8 +1,8 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Web.Script.Serialization; namespace ColorControl { @@ -16,20 +16,17 @@ namespace ColorControl protected string _presetsBaseFilename; protected string _presetsFilename; protected string _presetsBackupFilename; - protected JavaScriptSerializer _JsonSerializer; - protected JavaScriptSerializer _JsonDeserializer; protected bool _initialized = false; protected List _presets; protected T _lastAppliedPreset; protected string _loadPresetsError; + private List _jsonConverters; public ServiceBase(string dataPath, string presetsBaseFilename) { _dataPath = dataPath; _presetsBaseFilename = presetsBaseFilename; - - _JsonSerializer = new JavaScriptSerializer(); - _JsonDeserializer = new JavaScriptSerializer(); + _jsonConverters = new List(); Initialize(); } @@ -92,7 +89,7 @@ namespace ColorControl // Hack to convert incorrect triggers json = json.Replace(@"""Triggers"":0", @"""Triggers"":[]"); - _presets = _JsonDeserializer.Deserialize>(json); + _presets = JsonConvert.DeserializeObject>(json, _jsonConverters.ToArray()); if (_presets != null) { @@ -134,5 +131,10 @@ namespace ColorControl } protected abstract List GetDefaultPresets(); + + protected void AddJsonConverter(JsonConverter jsonConverter) + { + _jsonConverters.Add(jsonConverter); + } } } diff --git a/ColorControl/StartUpParams.cs b/ColorControl/StartUpParams.cs index bb3da34..b953fe1 100644 --- a/ColorControl/StartUpParams.cs +++ b/ColorControl/StartUpParams.cs @@ -12,6 +12,8 @@ namespace ColorControl public const string ExecuteAmdPresetParam = "--amdpreset"; public const string ExecuteLgPresetParam = "--lgpreset"; public const string NoGuiParam = "--nogui"; + public const string EnableAutoStartParam = "--enable-auto-start"; + public const string DisableAutoStartParam = "--disable-auto-start"; public bool RunningFromScheduledTask { get; private set; } public bool ActivateChromeFontFix { get; private set; } @@ -24,6 +26,8 @@ namespace ColorControl public bool ExecuteLgPreset { get; private set; } public string LgPresetName { get; private set; } public bool NoGui { get; set; } + public bool EnableAutoStart { get; private set; } + public bool DisableAutoStart { get; private set; } public static StartUpParams Parse(IEnumerable args) { @@ -102,6 +106,16 @@ namespace ColorControl settings.NoGui = true; break; } + case EnableAutoStartParam: + { + settings.EnableAutoStart = true; + break; + } + case DisableAutoStartParam: + { + settings.DisableAutoStart = true; + break; + } } } return settings; diff --git a/ColorControl/TreeNodeBuilder.cs b/ColorControl/TreeNodeBuilder.cs index 0771904..c60df22 100644 --- a/ColorControl/TreeNodeBuilder.cs +++ b/ColorControl/TreeNodeBuilder.cs @@ -1,12 +1,7 @@ using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; -using System; -using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Script.Serialization; using System.Windows.Forms; namespace ColorControl @@ -19,7 +14,6 @@ namespace ColorControl public static TreeNode CreateTree(object obj, string text) { - JavaScriptSerializer jss = new JavaScriptSerializer(); var serialized = JsonConvert.SerializeObject(obj, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, @@ -30,7 +24,7 @@ namespace ColorControl }, Converters = new [] { new Newtonsoft.Json.Converters.StringEnumConverter() } }); - Dictionary dic = jss.Deserialize>(serialized); + var dic = JsonConvert.DeserializeObject>(serialized); var root = new TreeNode(); root.Text = text; BuildTree(dic, root); @@ -48,9 +42,9 @@ namespace ColorControl node.Nodes.Add(keyValueNode); BuildTree(kv.Value, keyValueNode); } - else if (item is ArrayList) + else if (item.GetType() == typeof(JArray)) { - ArrayList list = (ArrayList)item; + var list = (JArray)item; int index = 0; foreach (object value in list) { @@ -70,6 +64,14 @@ namespace ColorControl BuildTree(d, node); } } + else if (item.GetType() == typeof(JObject)) + { + var jobject = item as JObject; + foreach (var property in jobject.Properties()) + { + BuildTree(new KeyValuePair(property.Name, property.Value), node); + } + } } private static string GetValueAsString(object value) @@ -82,13 +84,13 @@ namespace ColorControl return "[]"; } - if (value is ArrayList) + if (value.GetType() == typeof(JArray)) { - var arr = value as ArrayList; + var arr = value as JArray; return $"[{arr.Count}]"; } - if (type.IsGenericType) + if (type.IsGenericType || value.GetType() == typeof(JObject)) { return "{}"; } diff --git a/ColorControl/Utils.cs b/ColorControl/Utils.cs index 82dda5e..e412588 100644 --- a/ColorControl/Utils.cs +++ b/ColorControl/Utils.cs @@ -7,7 +7,6 @@ using NWin32.NativeTypes; using System; using System.Collections.Generic; using System.ComponentModel; -using System.Deployment.Application; using System.Diagnostics; using System.Drawing; using System.Globalization; @@ -19,7 +18,6 @@ using System.Runtime.InteropServices; using System.Security.Principal; using System.Threading; using System.Threading.Tasks; -using System.Web.Script.Serialization; using System.Windows.Forms; using Windows.Devices.Enumeration; using Windows.Devices.Enumeration.Pnp; @@ -64,8 +62,6 @@ namespace ColorControl public delegate void PCREATE_PROCESS_NOTIFY_ROUTINE(IntPtr ParentId, IntPtr ProcessId, bool Create); - public static JavaScriptSerializer JsonSerializer = new JavaScriptSerializer(); - public static bool ConsoleOpened { get; private set; } [DllImport("user32.dll", SetLastError = true)] @@ -205,9 +201,10 @@ namespace ColorControl internal static bool ExecuteElevated(string args) { - var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location, args) + var info = new ProcessStartInfo(Process.GetCurrentProcess().MainModule.FileName, args) { Verb = "runas", // indicates to elevate privileges + UseShellExecute = true, }; var process = new Process @@ -470,7 +467,7 @@ namespace ColorControl public static void RegisterTask(string taskName, bool enabled) { - var file = Assembly.GetExecutingAssembly().Location; + var file = Process.GetCurrentProcess().MainModule.FileName; var directory = Path.GetDirectoryName(file); try @@ -509,19 +506,16 @@ namespace ColorControl if (task != null) { - if (update && ApplicationDeployment.IsNetworkDeployed) - { - var action = task.Definition.Actions.FirstOrDefault(x => x.ActionType == TaskActionType.Execute); - if (action != null) - { - var execAction = action as ExecAction; - if (!execAction.Path.Equals(file)) - { - RegisterTask(taskName, false); - RegisterTask(taskName, true); - } - } - } + //var action = task.Definition.Actions.FirstOrDefault(x => x.ActionType == TaskActionType.Execute); + //if (action != null) + //{ + // var execAction = action as ExecAction; + // if (!execAction.Path.Equals(file)) + // { + // RegisterTask(taskName, false); + // RegisterTask(taskName, true); + // } + //} return true; } return false; @@ -551,16 +545,22 @@ namespace ColorControl return true; } - public static void BuildDropDownMenuEx(ContextMenuStrip mnuParent, string name, Type enumType, EventHandler clickEvent, object tag = null) + public static ToolStripMenuItem BuildDropDownMenuEx(ContextMenuStrip mnuParent, string name, Type enumType, EventHandler clickEvent, object tag = null, int min = 0, int max = 0) { var subMenuName = $"{mnuParent.Name}_{name}"; var subMenuItems = mnuParent.Items.Find(subMenuName, false); - ToolStripMenuItem subMenuItem; - if (subMenuItems.Length == 0) - { - subMenuItem = (ToolStripMenuItem)mnuParent.Items.Add(name); - subMenuItem.Name = subMenuName; + if (subMenuItems.Length > 0) + { + return subMenuItems[0] as ToolStripMenuItem; + } + + ToolStripMenuItem subMenuItem; + subMenuItem = (ToolStripMenuItem)mnuParent.Items.Add(name); + subMenuItem.Name = subMenuName; + + if (enumType != null) + { foreach (var enumValue in Enum.GetValues(enumType)) { var item = subMenuItem.DropDownItems.Add(enumValue.ToString()); @@ -568,6 +568,27 @@ namespace ColorControl item.Click += clickEvent; } } + else if (min >= 0 && max > min) + { + for (var i = 0; i <= 10; i++) + { + var value = i * (max / 10); + + var subSubItemName = $"{subMenuName}_{value}"; + + var item = subMenuItem.DropDownItems.Add(value.ToString()); + item.Name = subSubItemName; + item.Tag = tag; + item.Click += clickEvent; + } + } + else + { + subMenuItem.Tag = tag; + subMenuItem.Click += clickEvent; + } + + return subMenuItem; } public static void BuildDropDownMenu(ToolStripDropDownItem mnuParent, string name, Type enumType, object colorData, string propertyName, EventHandler clickEvent) diff --git a/ColorControl/WOL.cs b/ColorControl/WOL.cs index 030b904..4a00e7e 100644 --- a/ColorControl/WOL.cs +++ b/ColorControl/WOL.cs @@ -1,9 +1,6 @@ using NLog; using System; -using PacketDotNet; using System.Net.NetworkInformation; -using SharpPcap; -using SharpPcap.Npcap; using System.Net; using System.Net.Sockets; @@ -17,13 +14,8 @@ namespace ColorControl private const string ArgumentExceptionInvalidPasswordLength = "Invalid password length."; private const int DefaultWolPort = 9; - public static bool WakeFunction(string macAddress, bool usePcap = false) + public static bool WakeFunction(string macAddress) { - if (usePcap) - { - return WakeFunctionPcap(macAddress); - } - return WakeFunctionToAllNics(macAddress); } @@ -117,70 +109,5 @@ namespace ColorControl } return packet; } - - - //You need SharpPcap for this to work - private static bool WakeFunctionPcap(string macAddress) - { - /* Retrieve the device list */ - var devices = CaptureDeviceList.Instance; - - Logger.Debug("Waking device with MAC-address " + macAddress); - - /*If no device exists, print error */ - if (devices.Count < 1) - { - Logger.Debug("No network device found on this machine"); - return false; - } - - foreach (var device in devices) - { - //if (device is NpcapDevice npcapDevice) - //{ - // if (!npcapDevice.Interface.GatewayAddresses.Any()) - // { - // continue; - // } - //} - - if (device is NpcapDevice npcapDevice) - { - Logger.Debug($"Opening network device (NpcapDevice): FriendlyName: {npcapDevice.Interface.FriendlyName}, Description: {npcapDevice.Interface.Description}"); - } - else - { - Logger.Debug($"Opening network device (NOT A NpcapDevice!): {device.Name}, Description: {device.Description}"); - } - - //Open the device - device.Open(); - - //A magic packet is a broadcast frame containing anywhere within its payload: 6 bytes of ones - //(resulting in hexadecimal FF FF FF FF FF FF), followed by sixteen repetitions - - string response = macAddress.Replace(":", "-"); - - var address = PhysicalAddress.Parse("FFFFFFFFFFFF"); - EthernetPacket ethernet = new EthernetPacket(address, address, EthernetType.WakeOnLan); - ethernet.PayloadPacket = new WakeOnLanPacket(PhysicalAddress.Parse(response)); - - byte[] bytes = ethernet.Bytes; - - try - { - //Send the packet out the network device - device.SendPacket(bytes); - } - catch (Exception e) - { - Logger.Debug(e.Message); - } - - device.Close(); - } - - return true; - } - } + } } \ No newline at end of file diff --git a/ColorControl/lgtv/LgTvApi.cs b/ColorControl/lgtv/LgTvApi.cs index 73266cc..49c6bd6 100644 --- a/ColorControl/lgtv/LgTvApi.cs +++ b/ColorControl/lgtv/LgTvApi.cs @@ -19,11 +19,11 @@ namespace LgTv public enum PictureMode { - cinema, eco, expert1, expert2, game, - normal, photo, sports, technicolor, vivid, hdrEffect, hdrCinema, - hdrCinemaBright, hdrExternal, hdrGame, hdrStandard, hdrTechnicolor, - hdrVivid, dolbyHdrCinema, dolbyHdrCinemaBright, dolbyHdrDarkAmazon, - dolbyHdrGame, dolbyHdrStandard, dolbyHdrVivid, dolbyStandard + cinema, eco, expert1, expert2, game, normal, photo, sports, technicolor, vivid, hdrEffect, filmMaker, + + hdrCinema, hdrCinemaBright, hdrExternal, hdrGame, hdrStandard, hdrTechnicolor, hdrVivid, hdrFilmMaker, + + dolbyHdrCinema, dolbyHdrCinemaBright, dolbyHdrDarkAmazon, dolbyHdrGame, dolbyHdrStandard, dolbyHdrVivid, dolbyStandard } public enum OffToHigh @@ -102,6 +102,14 @@ namespace LgTv true_ } + public enum GammaExp + { + low, + medium, + high1, + high2 + } + public class LgTvApi:IDisposable { public bool ConnectionClosed { get => _connection?.ConnectionClosed ?? true; } @@ -383,7 +391,7 @@ namespace LgTv { if (payload == null) { - var keys = @"[ ""contrast"", ""backlight"" ]"; + var keys = @"[ ""contrast"", ""backlight"", ""brightness"", ""color"" ]"; var json = @"{ ""category"": ""picture"", ""keys"": " + keys + @", ""subscribe"": true }"; diff --git a/ColorControl/lgtv/LgWebOsMouseService.cs b/ColorControl/lgtv/LgWebOsMouseService.cs index d64c8d2..faa44f2 100644 --- a/ColorControl/lgtv/LgWebOsMouseService.cs +++ b/ColorControl/lgtv/LgWebOsMouseService.cs @@ -41,7 +41,20 @@ namespace LgTv SAP, PROGRAM, PLAY, - PAUSE + PAUSE, + STOP, + REWIND, + FASTFORWARD, + GUIDE, + AMAZON, + NETFLIX, + MAGNIFIER_ZOOM, + LIVE_ZOOM, + _3D_MODE, + ASPECT_RATIO, + RECENT, + RECORD, + SCREEN_REMOTE } public class LgWebOsMouseService : IDisposable @@ -59,7 +72,7 @@ namespace LgTv } public void SendButton(int number) { - _connection.SendMessageAsync($"type:button\nname:{number}\n\n"); + _connection.SendMessageAsync($"type:button\nname:{number}\n\n").ConfigureAwait(false); } public void SendButton(ButtonType bt) { @@ -68,23 +81,23 @@ namespace LgTv { text = text.Substring(1); } - _connection.SendMessageAsync($"type:button\nname:{text}\n\n"); + _connection.SendMessageAsync($"type:button\nname:{text}\n\n").ConfigureAwait(false); } public void Move(double dx, double dy, bool drag = false) { - _connection.SendMessageAsync($"type:move\ndx:{dx}\ndy:{dy}\ndown:{(drag ? 1 : 0)}\n\n"); + _connection.SendMessageAsync($"type:move\ndx:{dx}\ndy:{dy}\ndown:{(drag ? 1 : 0)}\n\n").ConfigureAwait(false); } public void Scroll(double dx, double dy) { - _connection.SendMessageAsync($"type:scroll\ndx:{dx}\ndy:{dy}\n\n"); + _connection.SendMessageAsync($"type:scroll\ndx:{dx}\ndy:{dy}\n\n").ConfigureAwait(false); } public void Click() { - _connection.SendMessageAsync("type:click\n\n"); + _connection.SendMessageAsync("type:click\n\n").ConfigureAwait(false); } public void Dispose() diff --git a/ColorControl/packages.config b/ColorControl/packages.config deleted file mode 100644 index 8adeeb0..0000000 --- a/ColorControl/packages.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WakeOnLan/ArpRequest.cs b/WakeOnLan/ArpRequest.cs deleted file mode 100644 index 7a1aa59..0000000 --- a/WakeOnLan/ArpRequest.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.ComponentModel; -using System.Net.NetworkInformation; -using System.Threading.Tasks; - -namespace System.Net -{ - /// Stellt Methoden für das Senden von Anfragen über das ARP-Protokoll bereit. - public static class ArpRequest - { - /// - /// Sendet eine Anfrage über das ARP-Protokoll, um eine IP-Adresse in die Physikalische Adresse aufzulösen. Falls sich die physikalische Adresse bereits im Cache des Hosts befindet, wird diese zurückgegeben. - /// - /// Destination . - /// Eine ArpRequestResult-Instanz, welche die Ergebnisse der Anfrage enthält. - public static ArpRequestResult Send(IPAddress destination) - { - if (destination == null) - throw new ArgumentNullException(nameof(destination)); - - int destIp = BitConverter.ToInt32(destination.GetAddressBytes(), 0); - - var addr = new byte[6]; - var len = addr.Length; - - var res = NativeMethods.SendARP(destIp, 0, addr, ref len); - - if (res == 0) - return new ArpRequestResult(new PhysicalAddress(addr)); - return new ArpRequestResult(new Win32Exception(res)); - } - - /// - /// Sendet eine Anfrage über das ARP-Protokoll, um eine IP-Adresse in die Physikalische Adresse aufzulösen. Falls sich die physikalische Adresse bereits im Cache des Hosts befindet, wird diese zurückgegeben. - /// - /// Destination . - /// Ein asynchroner Task, welcher einen ARP-Request sendet. - public static Task SendAsync(IPAddress destination) => Task.Run(() => Send(destination)); - } -} diff --git a/WakeOnLan/ArpRequestResult.cs b/WakeOnLan/ArpRequestResult.cs deleted file mode 100644 index ae5ffd1..0000000 --- a/WakeOnLan/ArpRequestResult.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Net.NetworkInformation; -using System.Text; - -namespace System.Net -{ - // TODO: rethink the whole exception thing - - /// - /// Enthält die Rückgabewerte der ArpRequest.Send-Funktion. - /// - public class ArpRequestResult - { - /// Falls Fehler bei der Protokollanfrage auftreten, werden diese in dieser Eigenschaft abgelegt. Andernfalls null. - public Exception Exception { get; } - - /// Die aufgelöste physikalische Adresse. - public PhysicalAddress Address { get; } - - /// Erstellt eine neue ArpRequestResult-Instanz - /// Die physikalische Adresse - public ArpRequestResult(PhysicalAddress address) - { - this.Exception = null; - Address = address; - } - - /// Erstellt eine neue ArpRequestResult-Instanz - /// Der aufgetretene Fehler - public ArpRequestResult(Exception exception) - { - this.Exception = exception; - Address = null; - } - - /// Konvertiert ARP-Rückgabewerte in eine Zeichenfolge. - public override string ToString() - { - var sb = new StringBuilder(); - if (Address == null) - sb.Append("no address"); - else - { - sb.Append("address: "); - sb.Append(Address); - } - sb.Append(", "); - if (Exception == null) - sb.Append("no exception"); - else - { - sb.Append("exception: "); - sb.Append(Exception.Message); - } - return sb.ToString(); - } - } -} diff --git a/WakeOnLan/GlobalSuppressions.cs b/WakeOnLan/GlobalSuppressions.cs deleted file mode 100644 index 5652ddc..0000000 --- a/WakeOnLan/GlobalSuppressions.cs +++ /dev/null @@ -1,62 +0,0 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. -// -// To add a suppression to this file, right-click the message in the -// Code Analysis results, point to "Suppress Message", and click -// "In Suppression File". -// You do not need to add suppressions to this file manually. - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte[],System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte[],System.Int32,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Byte[],System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWol(System.Net.IPAddress,System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte[],System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte[],System.Int32,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Byte[],System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPAddressExtensions.#SendWolAsync(System.Net.IPAddress,System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWol(System.Net.IPEndPoint,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWol(System.Net.IPEndPoint,System.Byte[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWol(System.Net.IPEndPoint,System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWol(System.Net.IPEndPoint,System.Byte[],System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWol(System.Net.IPEndPoint,System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWolAsync(System.Net.IPEndPoint,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWolAsync(System.Net.IPEndPoint,System.Byte[])")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWolAsync(System.Net.IPEndPoint,System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWolAsync(System.Net.IPEndPoint,System.Byte[],System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.IPEndPointExtensions.#SendWolAsync(System.Net.IPEndPoint,System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lan")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "System.Net.Topology.INetMask.#GetMaskBytes()")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#op_Equality(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#op_Inequality(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#op_BitwiseAnd(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Scope = "type", Target = "System.Net.Topology.SiblingOptions")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "type", Target = "System.Net.SendWol")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPEndPoint)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPEndPoint,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPEndPoint)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWol(System.Net.NetworkInformation.PhysicalAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#op_BitwiseOr(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#BitwiseOr(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPAddress)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPAddress,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wol", Scope = "member", Target = "System.Net.PhysicalAddressExtensions.#SendWolAsync(System.Net.NetworkInformation.PhysicalAddress,System.Net.IPEndPoint,System.Net.SecureOnPassword)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cidr", Scope = "member", Target = "System.Net.Topology.INetMask.#Cidr")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "m", Scope = "member", Target = "System.Net.Topology.NetMask.#.ctor(System.Byte,System.Byte,System.Byte,System.Byte)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n", Scope = "member", Target = "System.Net.Topology.NetMask.#BitwiseAnd(System.Net.Topology.NetMask,System.Net.Topology.NetMask)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "cidr", Scope = "member", Target = "System.Net.Topology.NetMask.#.ctor(System.Int32)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "cidr", Scope = "member", Target = "System.Net.Topology.NetMask.#.ctor(System.Byte)")] diff --git a/WakeOnLan/IPAddressExtensions.cs b/WakeOnLan/IPAddressExtensions.cs deleted file mode 100644 index 72b049b..0000000 --- a/WakeOnLan/IPAddressExtensions.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System.Threading.Tasks; -using System.Net.NetworkInformation; -using System.Net.Sockets; - -namespace System.Net -{ - /// Provides extension methods for sending Wake On LAN signals (magic packets) to a specific . - public static class IPAddressExtensions - { - private const int DefaultWolPort = 7; - #region Wol - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The port to send the packet to. - /// The length of the array is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, byte[] macAddress, int port) => target.SendWol(macAddress, port, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The port to send the packet to. - /// The SecureOn password of the client. - /// The length of the array is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, byte[] macAddress, int port, SecureOnPassword password) - { - Net.MagicPacket.Send(new IPEndPoint(target, port), macAddress, password); - } - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the array is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, byte[] macAddress) => target.SendWol(macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the array is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, byte[] macAddress, SecureOnPassword password) - { - Net.MagicPacket.Send(new IPEndPoint(target, DefaultWolPort), macAddress, password); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, PhysicalAddress macAddress) => target.SendWol(macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the is not 6. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void SendWol(this IPAddress target, PhysicalAddress macAddress, SecureOnPassword password) - { - Net.MagicPacket.Send(new IPEndPoint(target, DefaultWolPort), macAddress, password); - } - - #endregion - #region ARP - - /// - /// Sendet eine Anfrage über das ARP-Protokoll, um eine IP-Adresse in die Physikalische Adresse aufzulösen. Falls sich die physikalische Adresse bereits im Cache des Hosts befindet, wird diese zurückgegeben. - /// - /// Destination . - /// Eine ArpRequestResult-Instanz, welche die Ergebnisse der Anfrage enthält. - public static ArpRequestResult SendArpRequest(this IPAddress destination) => ArpRequest.Send(destination); - - #endregion - #region TAP - - #region Wol - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The port to send the packet to. - /// The length of the array is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, byte[] macAddress, int port) => target.SendWolAsync(macAddress, port, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The port to send the packet to. - /// The SecureOn password of the client. - /// The length of the array is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, byte[] macAddress, int port, SecureOnPassword password) - { - return Net.MagicPacket.SendAsync(new IPEndPoint(target, port), macAddress, password); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the array is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, byte[] macAddress) => target.SendWolAsync(macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the array is not 6. - /// is null. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, byte[] macAddress, SecureOnPassword password) - { - return Net.MagicPacket.SendAsync(new IPEndPoint(target, DefaultWolPort), macAddress, password); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, PhysicalAddress macAddress) => target.SendWolAsync(macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the is not 6. - /// is null. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPAddress target, PhysicalAddress macAddress, SecureOnPassword password) - { - return Net.MagicPacket.SendAsync(new IPEndPoint(target, DefaultWolPort), macAddress, password); - } - - #endregion - - #region ARP - - /// Sends a request via ARP to resolve an IP address to aphysical address. If the physical address is already cached, it's cached value is returned. - /// Destination . - /// An asynchronous which sends an ARP request. - public static Task SendArpRequestAsync(this IPAddress destination) => ArpRequest.SendAsync(destination); - - #endregion - - #endregion - } -} diff --git a/WakeOnLan/IPEndPointExtensions.cs b/WakeOnLan/IPEndPointExtensions.cs deleted file mode 100644 index 5c5ad52..0000000 --- a/WakeOnLan/IPEndPointExtensions.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Threading.Tasks; -using System.Net.NetworkInformation; - -namespace System.Net -{ - /// Provides extension methods for sending Wake On LAN signals (magic packets) to a specific . - public static class IPEndPointExtensions - { - #region Wol - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the array macAddress is not 6. - /// is null. - public static void SendWol(this IPEndPoint target, byte[] macAddress) - { - Net.MagicPacket.Send(target, macAddress); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// is null. - public static void SendWol(this IPEndPoint target, PhysicalAddress macAddress) - { - Net.MagicPacket.Send(target, macAddress); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the array macAddress is not 6. - /// is null. - public static void SendWol(this IPEndPoint target, byte[] macAddress, SecureOnPassword password) - { - Net.MagicPacket.Send(target, macAddress, password); - } - - /// - /// Sendet ein Wake-On-LAN-Signal an einen Client. - /// - /// Der Ziel-IPEndPoint. - /// The MAC address of the client. - /// The SecureOn password of the client. - /// is null. - public static void SendWol(this IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password) - { - Net.MagicPacket.Send(target, macAddress, password); - } - - #endregion - #region TAP - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The length of the array macAddress is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPEndPoint target, byte[] macAddress) - { - return Net.MagicPacket.SendAsync(target, macAddress); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPEndPoint target, PhysicalAddress macAddress) - { - return Net.MagicPacket.SendAsync(target, macAddress); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// The length of the array macAddress is not 6. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPEndPoint target, byte[] macAddress, SecureOnPassword password) - { - return Net.MagicPacket.SendAsync(target, macAddress, password); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the client. - /// The SecureOn password of the client. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password) - { - return Net.MagicPacket.SendAsync(target, macAddress, password); - } - #endregion - } -} diff --git a/WakeOnLan/Localization.cs b/WakeOnLan/Localization.cs deleted file mode 100644 index 405c9d3..0000000 --- a/WakeOnLan/Localization.cs +++ /dev/null @@ -1,12 +0,0 @@ -#define GERMAN - -namespace System.Net -{ - internal static class Localization - { - public const string ArgumentExceptionInvalidMacAddressLength = "Invalid MAC address length."; - public const string ArgumentExceptionInvalidPasswordLength = "Invalid password length."; - - public const string ArgumentExceptionIsNotAValidMadAddress = " is not a valid MAC address."; - } -} diff --git a/WakeOnLan/MagicPacket.cs b/WakeOnLan/MagicPacket.cs deleted file mode 100644 index 15aa6b7..0000000 --- a/WakeOnLan/MagicPacket.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Threading.Tasks; -using System.Net.NetworkInformation; -using System.Net.Sockets; - -namespace System.Net -{ - /// Provides methods for sending Wake On LAN signals (magic packets). - public static class MagicPacket - { - #region Wol - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// target is null. - /// is null. - /// The length of the array macAddress is not 6. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void Send(IPEndPoint target, byte[] macAddress) => Send(target, macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// The SecureOn password of the client. - /// is null. - /// is null. - /// The length of the array is not 6. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void Send(IPEndPoint target, byte[] macAddress, SecureOnPassword password) - { - if (macAddress == null) - throw new ArgumentNullException(nameof(macAddress)); - - byte[] passwordBuffer = password?.GetPasswordBytes(); - byte[] packet = GetWolPacket(macAddress, passwordBuffer); - SendPacket(target, packet); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void Send(IPEndPoint target, PhysicalAddress macAddress) => Send(target, macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// The SecureOn password of the client. - /// is null. - /// An error occurred when accessing the socket. See Remarks section of for more information. - public static void Send(IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password) - { - if (macAddress == null) - throw new ArgumentNullException(nameof(macAddress)); - - byte[] passwordBuffer = password?.GetPasswordBytes(); - byte[] packet = GetWolPacket(macAddress.GetAddressBytes(), passwordBuffer); - SendPacket(target, packet); - } - - private static void SendPacket(IPEndPoint target, byte[] packet) - { - using (var cl = new UdpClient()) - cl.Send(packet, packet.Length, target); - } - - #endregion - #region TAP - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// is null. - /// is null. - /// The length of the array is not 6. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendAsync(IPEndPoint target, byte[] macAddress) => SendAsync(target, macAddress); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// The SecureOn password of the client. - /// is null. - /// is null. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendAsync(IPEndPoint target, byte[] macAddress, SecureOnPassword password) - { - if (target == null) - throw new ArgumentNullException(nameof(target)); - if (macAddress == null) - throw new ArgumentNullException(nameof(macAddress)); - - var passwordBuffer = password?.GetPasswordBytes(); - var packet = GetWolPacket(macAddress, passwordBuffer); - return SendPacketAsync(target, packet); - } - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// is null. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendAsync(IPEndPoint target, PhysicalAddress macAddress) => SendAsync(target, macAddress, null); - - /// Sends a Wake On LAN signal (magic packet) to a client. - /// Destination . - /// The MAC address of the designated client. - /// The SecureOn password of the client. - /// is null. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendAsync(IPEndPoint target, PhysicalAddress macAddress, SecureOnPassword password) - { - if (target == null) - throw new ArgumentNullException(nameof(target)); - if (macAddress == null) - throw new ArgumentNullException(nameof(macAddress)); - - var passwordBuffer = password?.GetPasswordBytes(); - var p = GetWolPacket(macAddress.GetAddressBytes(), passwordBuffer); - return SendPacketAsync(target, p); - } - - private static Task SendPacketAsync(IPEndPoint target, byte[] packet) - { - var cl = new UdpClient(); - return cl.SendAsync(packet, packet.Length, target).ContinueWith((Task t) => cl.Close()); - } - - #endregion - #region internal - - /// is null. - /// The length of the array is not 6. - /// The length of the array is not 0 or 6. - private static byte[] GetWolPacket(byte[] macAddress, byte[] password) - { - if (macAddress == null) - throw new ArgumentNullException(nameof(macAddress)); - if (macAddress.Length != 6) - throw new ArgumentException(Localization.ArgumentExceptionInvalidMacAddressLength); - - password = password ?? new byte[0]; - if (password.Length != 0 && password.Length != 6) - throw new ArgumentException(Localization.ArgumentExceptionInvalidPasswordLength); - - var packet = new byte[17 * 6 + password.Length]; - - int offset, i; - for (offset = 0; offset < 6; ++offset) - packet[offset] = 0xFF; - - for (offset = 6; offset < 17 * 6; offset += 6) - for (i = 0; i < 6; ++i) - packet[i + offset] = macAddress[i]; - - if (password.Length > 0) - { - for (offset = 16 * 6 + 6; offset < (17 * 6 + password.Length); offset += 6) - for (i = 0; i < 6; ++i) - packet[i + offset] = password[i]; - } - return packet; - } - - #endregion - } -} diff --git a/WakeOnLan/NativeMethods.cs b/WakeOnLan/NativeMethods.cs deleted file mode 100644 index 73c4f88..0000000 --- a/WakeOnLan/NativeMethods.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.InteropServices; -using System.Security; - -namespace System.Net -{ - internal static class NativeMethods - { - private const string IphlpApi = "iphlpapi.dll"; - - [DllImport(IphlpApi, ExactSpelling = true)] - [SecurityCritical] - internal static extern int SendARP(int destinationIp, int sourceIp, byte[] macAddress, ref int physicalAddrLength); - } -} diff --git a/WakeOnLan/PhysicalAddressExtensions.cs b/WakeOnLan/PhysicalAddressExtensions.cs deleted file mode 100644 index 4a8ac93..0000000 --- a/WakeOnLan/PhysicalAddressExtensions.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System.Threading.Tasks; -using System.Net.NetworkInformation; - -namespace System.Net -{ - /// Provides extension methods for sending Wake On LAN signals (magic packets) using a specific . - public static class PhysicalAddressExtensions - { - #region Wol - - /// Sends a Wake On LAN signal (magic packet) to the broadcast IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// is null. - public static void SendWol(this PhysicalAddress address) => address.SendWol(IPAddress.Broadcast, null); - - /// Sends a Wake On LAN signal (magic packet) to a specific IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// is null. - public static void SendWol(this PhysicalAddress address, IPAddress target) => address.SendWol(target, null); - - /// Sends a Wake On LAN signal (magic packet) to a specific IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// The SecureOn password of the client. - /// is null. - public static void SendWol(this PhysicalAddress address, IPAddress target, SecureOnPassword password) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - target.SendWol(address.GetAddressBytes(), password); - } - - - /// Sends a Wake On LAN signal (magic packet) to a specific IP end point with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// is null. - public static void SendWol(this PhysicalAddress address, IPEndPoint target) => address.SendWol(target, null); - - /// Sends a Wake On LAN signal (magic packet) to a specific IP end point with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// The SecureOn password of the client. - /// is null. - public static void SendWol(this PhysicalAddress address, IPEndPoint target, SecureOnPassword password) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - target.SendWol(address.GetAddressBytes(), password); - } - - #endregion - #region TAP - - /// Sends a Wake On LAN signal (magic packet) to the broadcast IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - /// is null. - public static Task SendWolAsync(this PhysicalAddress address) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - return IPAddress.Broadcast.SendWolAsync(address.GetAddressBytes()); - } - - /// Sends a Wake On LAN signal (magic packet) to a specific IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this PhysicalAddress address, IPAddress target) => address.SendWolAsync(target, null); - - - /// Sends a Wake On LAN signal (magic packet) to a specific IP address with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// The SecureOn password of the client. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this PhysicalAddress address, IPAddress target, SecureOnPassword password) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - return target.SendWolAsync(address.GetAddressBytes(), password); - } - - /// Sends a Wake On LAN signal (magic packet) to a specific IP end point with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this PhysicalAddress address, IPEndPoint target) => address.SendWolAsync(target, null); - - /// Sends a Wake On LAN signal (magic packet) to a specific IP end point with the physical address. - /// The instance of the physical address that should be used in the magic packet. - /// Destination . - /// The SecureOn password of the client. - /// is null. - /// An asynchronous which sends a Wake On LAN signal (magic packet) to a client. - public static Task SendWolAsync(this PhysicalAddress address, IPEndPoint target, SecureOnPassword password) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - return target.SendWolAsync(address.GetAddressBytes(), password); - } - - #endregion - #region common - - /// Gets the type () of the . - /// The address. - /// is null. - /// The of the physical addess (MAC address). - public static PhysicalAddressType GetAddressType(this PhysicalAddress address) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - var bytes = address.GetAddressBytes(); - if (bytes == null || bytes.Length < 1) - throw new ArgumentException($"Invalid {nameof(address)}."); - return (bytes[0] & 0x1) == 0 ? PhysicalAddressType.Unicast : PhysicalAddressType.Multicast; - } - - /// Gets the administrator () of the . - /// The address. - /// is null. - /// The of the physical addess (MAC address). - public static PhysicalAddressAdministrator GetAddressAdministrator(this PhysicalAddress address) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - - var bytes = address.GetAddressBytes(); - if (bytes == null || bytes.Length < 1) - throw new ArgumentException($"Invalid {nameof(address)}."); - return (bytes[0] & 0x2) == 0 ? PhysicalAddressAdministrator.Global : PhysicalAddressAdministrator.Local; - } - - #endregion - } -} diff --git a/WakeOnLan/PhysicalAddressProperties.cs b/WakeOnLan/PhysicalAddressProperties.cs deleted file mode 100644 index 837f5f7..0000000 --- a/WakeOnLan/PhysicalAddressProperties.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace System.Net -{ - /// - /// Der Administrator der physikalischen Adresse gibt an, ob die Adresse globally unique oder local administrated ist. - /// - public enum PhysicalAddressAdministrator - { - /// - /// Die Adresse ist global einzigartig (nach der OUI). - /// - Global, - - /// - /// Die Adresse ist lokal administriert. - /// - Local - } - - /// - /// Der Typ der physikalischen Adresse gibt an, ob es um eine UNicast oder Multicast-Adresse handelt. - /// - public enum PhysicalAddressType - { - /// - /// Bezeichnet eine Unicast-Adresse. - /// - Unicast, - - /// - /// Bezeichnet eine Multicast-Adresse - /// - Multicast - } -} diff --git a/WakeOnLan/Properties/AssemblyInfo.cs b/WakeOnLan/Properties/AssemblyInfo.cs deleted file mode 100644 index 97813fb..0000000 --- a/WakeOnLan/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Runtime.CompilerServices; -using System; - -[assembly: InternalsVisibleTo("WakeOnLan.Tests")] diff --git a/WakeOnLan/SecureOnPassword.cs b/WakeOnLan/SecureOnPassword.cs deleted file mode 100644 index d159dab..0000000 --- a/WakeOnLan/SecureOnPassword.cs +++ /dev/null @@ -1,95 +0,0 @@ -namespace System.Net -{ - /// Provides a SecureOn password. - [Serializable] - public sealed class SecureOnPassword - { - private readonly byte[] _password; - - /// Initializes a new instance of with the given password. - /// The password as array. - /// is null. - /// The length of the array password is not 6. - public SecureOnPassword(byte[] password) - { - if (password == null) - throw new ArgumentNullException(nameof(password)); - if (password.Length != 6) - throw new ArgumentException(Localization.ArgumentExceptionInvalidPasswordLength); - _password = password; - } - - /// Gets the buffer of the password. - public byte[] GetPasswordBytes() - { - if (_password == null) - return null; - var buffer = new byte[_password.Length]; - Array.Copy(_password, buffer, 0); - return buffer; - } - - /// Initializes a new instance of with the given password. - /// The password as . - /// is null. - /// Uses as encoding. - public SecureOnPassword(string password) - : this(password, Text.Encoding.Default) - { } - - - /// Initializes a new instance of with the given password. - /// The password as . - /// The instance to use for the password. - /// is null. - /// is null. - /// The array wich is created using the password has more elements than 6. - public SecureOnPassword(string password, Text.Encoding encoding) - { - if (password == null) - throw new ArgumentNullException(nameof(password)); - if (encoding == null) - throw new ArgumentNullException(nameof(encoding)); - - if (string.IsNullOrEmpty(password)) - _password = new byte[6]; - - var bytes = encoding.GetBytes(password); - if (bytes.Length > 6) - throw new ArgumentException(Localization.ArgumentExceptionInvalidPasswordLength); - - _password = new byte[6]; - for (int i = 0; i < bytes.Length; i++) - _password[i] = bytes[i]; - if (bytes.Length < 6) - { - for (int i = bytes.Length - 1; i < 6; i++) - _password[i] = 0x00; - } - } - - /// Converts the to dash notation. - /// A representing the as dash notation. - public override string ToString() => ToString("X2"); - - /// Converts the to dash notation. - /// A representing the as dash notation. - private string ToString(string format) - { - var f = new string[6]; - for (int i = 0; i < f.Length; i++) - f[i] = _password[i].ToString(format); - return string.Join("-", f); - } - - /// Converts the to dash notation. - /// A representing the as dash notation. - public string ToString(IFormatProvider format) - { - var f = new string[6]; - for (int i = 0; i < f.Length; i++) - f[i] = _password[i].ToString(format); - return string.Join("-", f); - } - } -} diff --git a/WakeOnLan/Topology/ByteArrayExtensions.cs b/WakeOnLan/Topology/ByteArrayExtensions.cs deleted file mode 100644 index 5f33979..0000000 --- a/WakeOnLan/Topology/ByteArrayExtensions.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace System.Net.Topology -{ - internal static class ByteArrayExtensions - { - internal static IEnumerable ToBitStream(this byte[] bytes, bool fromLeft) - { - if (bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if (fromLeft) - { - for (int i = 0; i < bytes.Length; ++i) - { - byte tmp = bytes[i].ReverseBits(); - for (int j = 0; j < 8; ++j) - { - yield return (tmp & 1) == 1; - tmp >>= 1; - } - } - } - else - { - for (int i = bytes.Length - 1; i >= 0; --i) - { - byte tmp = bytes[i]; - for (int j = 0; j < 8; ++j) - { - yield return (tmp & 1) == 1; - tmp >>= 1; - } - } - } - } - - private static int CountFromSide(byte[] bits, bool value, bool fromleft) - { - int counter = 0; - var str = bits.ToBitStream(fromleft); - foreach (var bit in str) - { - if (bit == value) - ++counter; - else return counter; - } - return counter; - } - - internal static int CountFromLeft(this byte[] bits, bool value) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - return CountFromSide(bits, value, true); - } - - internal static int CountFromRight(this byte[] bits, bool value) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - return CountFromSide(bits, value, false); - } - - internal static string ToBinaryString(this byte[] bits, char separator) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - - const int radix = 2; - const int padding = 8; - const char paddingChar = '0'; - - var sb = new StringBuilder(); - sb.Append(Convert.ToString(bits[0], radix).PadLeft(padding, paddingChar)).Append(separator); - sb.Append(Convert.ToString(bits[1], radix).PadLeft(padding, paddingChar)).Append(separator); - sb.Append(Convert.ToString(bits[2], radix).PadLeft(padding, paddingChar)).Append(separator); - sb.Append(Convert.ToString(bits[3], radix).PadLeft(padding, paddingChar)); - return sb.ToString(); - } - - internal static string ToBinaryString(this byte[] bits) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - - const int radix = 2; - const int padding = 8; - const char paddingChar = '0'; - - var sb = new StringBuilder(); - sb.Append(Convert.ToString(bits[0], radix).PadLeft(padding, paddingChar)); - sb.Append(Convert.ToString(bits[1], radix).PadLeft(padding, paddingChar)); - sb.Append(Convert.ToString(bits[2], radix).PadLeft(padding, paddingChar)); - sb.Append(Convert.ToString(bits[3], radix).PadLeft(padding, paddingChar)); - return sb.ToString(); - } - - internal static bool RepresentsValidNetMask(this byte[] bits) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - - int fromLeft = bits.CountFromLeft(true); - int fromRight = bits.CountFromRight(false); - - // Sum of all counted indexes schloud be equal the whole length - return (fromLeft + fromRight) == (8 * NetMask.MaskLength); - } - - internal static byte[] And(this byte[] b1, byte[] b2) - { - if (b1 == null) - throw new ArgumentNullException(nameof(b1)); - if (b2 == null) - throw new ArgumentNullException(nameof(b2)); - - if (b1.Length == 1 && b2.Length == 1) - { - int ib1 = b1[0]; - int ib2 = b2[0]; - return new[] { (byte)(ib1 & ib2) }; - } - if (b1.Length == 2 && b2.Length == 2) - { - var sb1 = BitConverter.ToInt16(b1, 0); - var sb2 = BitConverter.ToInt16(b2, 0); - return BitConverter.GetBytes((short)(sb1 & sb2)); - } - if (b1.Length == 4 && b2.Length == 4) - { - var ib1 = BitConverter.ToInt32(b1, 0); - var ib2 = BitConverter.ToInt32(b2, 0); - return BitConverter.GetBytes(ib1 & ib2); - } - if (b1.Length != b2.Length) - { - // Or maybe throw exception? - - int maxIndex = Math.Max(b1.Length, b2.Length); - byte[] biggerArray = b1.Length > b2.Length ? b1 : b2; - byte[] smallerArray = b1.Length <= b2.Length ? b1 : b2; - - var paddedArray = new byte[maxIndex]; - - Buffer.BlockCopy(smallerArray, 0, paddedArray, 0, smallerArray.Length); - - Debug.Assert(biggerArray.Length == paddedArray.Length); - - return And(biggerArray, paddedArray); - } - - var targetIndex = b1.Length; - var andedArray = new byte[targetIndex]; - Buffer.BlockCopy(b1, 0, andedArray, 0, andedArray.Length); - - for (int i = 0; i < targetIndex; ++i) - andedArray[i] &= b2[i]; - - return andedArray; - } - - internal static byte[] Or(this byte[] b1, byte[] b2) - { - if (b1 == null) - throw new ArgumentNullException(nameof(b1)); - if (b2 == null) - throw new ArgumentNullException(nameof(b2)); - - if (b1.Length == 1 && b2.Length == 1) - { - int ib1 = b1[0]; - int ib2 = b2[0]; - return new[] { (byte)(ib1 | ib2) }; - } - if (b1.Length == 2 && b2.Length == 2) - { - var sb1 = BitConverter.ToInt16(b1, 0); - var sb2 = BitConverter.ToInt16(b2, 0); - return BitConverter.GetBytes((short)(sb1 | sb2)); - } - if (b1.Length == 4 && b2.Length == 4) - { - var ib1 = BitConverter.ToInt32(b1, 0); - var ib2 = BitConverter.ToInt32(b2, 0); - return BitConverter.GetBytes(ib1 | ib2); - } - if (b1.Length != b2.Length) - { - // Or maybe throw exception? - - int maxIndex = Math.Max(b1.Length, b2.Length); - byte[] biggerArray = b1.Length > b2.Length ? b1 : b2; - byte[] smallerArray = b1.Length <= b2.Length ? b1 : b2; - - var paddedArray = new byte[maxIndex]; - - Buffer.BlockCopy(smallerArray, 0, paddedArray, 0, smallerArray.Length); - - Debug.Assert(biggerArray.Length == paddedArray.Length); - - return Or(biggerArray, paddedArray); - } - - var targetIndex = b1.Length; - var oredArray = new byte[targetIndex]; - Buffer.BlockCopy(b1, 0, oredArray, 0, oredArray.Length); - - for (int i = 0; i < targetIndex; ++i) - oredArray[i] |= b2[i]; - - return oredArray; - } - - internal static byte[] Xor(this byte[] b1, byte[] b2) - { - if (b1 == null) - throw new ArgumentNullException(nameof(b1)); - if (b2 == null) - throw new ArgumentNullException(nameof(b2)); - - // TODO: Testing - - if (b1.Length == 1 && b2.Length == 1) - { - int ib1 = b1[0]; - int ib2 = b2[0]; - return new[] { (byte)(ib1 ^ ib2) }; - } - if (b1.Length == 2 && b2.Length == 2) - { - var sb1 = BitConverter.ToInt16(b1, 0); - var sb2 = BitConverter.ToInt16(b2, 0); - return BitConverter.GetBytes((short)(sb1 ^ sb2)); - } - if (b1.Length == 4 && b2.Length == 4) - { - var ib1 = BitConverter.ToInt32(b1, 0); - var ib2 = BitConverter.ToInt32(b2, 0); - return BitConverter.GetBytes(ib1 ^ ib2); - } - if (b1.Length != b2.Length) - { - // Or maybe throw exception? - - int maxIndex = Math.Max(b1.Length, b2.Length); - byte[] biggerArray = b1.Length > b2.Length ? b1 : b2; - byte[] smallerArray = b1.Length <= b2.Length ? b1 : b2; - - var paddedArray = new byte[maxIndex]; - - Buffer.BlockCopy(smallerArray, 0, paddedArray, 0, smallerArray.Length); - - Debug.Assert(biggerArray.Length == paddedArray.Length); - - return Xor(biggerArray, paddedArray); - } - - var targetIndex = b1.Length; - var xoredArray = new byte[targetIndex]; - Buffer.BlockCopy(b1, 0, xoredArray, 0, xoredArray.Length); - - for (int i = 0; i < targetIndex; ++i) - xoredArray[i] ^= b2[i]; - - return xoredArray; - } - - internal static byte[] Not(this byte[] bits) - { - if (bits == null) - throw new ArgumentNullException(nameof(bits)); - - if (bits.Length == 4) - { - var i = BitConverter.ToInt32(bits, 0); - return BitConverter.GetBytes(~i); - } - var newBytes = new byte[bits.Length]; - for (int i = 0; i < newBytes.Length; ++i) - newBytes[i] = unchecked((byte)(~bits[i])); - return newBytes; - } - } -} diff --git a/WakeOnLan/Topology/ByteExtensions.cs b/WakeOnLan/Topology/ByteExtensions.cs deleted file mode 100644 index 403e94a..0000000 --- a/WakeOnLan/Topology/ByteExtensions.cs +++ /dev/null @@ -1,43 +0,0 @@ - -namespace System.Net.Topology -{ - internal static class ByteExtensions - { - public static byte[] BitReverseTable = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff - }; - - public static byte ReverseBits(this byte toReverse) => BitReverseTable[toReverse]; - } -} diff --git a/WakeOnLan/Topology/INetMask.cs b/WakeOnLan/Topology/INetMask.cs deleted file mode 100644 index 6413a37..0000000 --- a/WakeOnLan/Topology/INetMask.cs +++ /dev/null @@ -1,17 +0,0 @@ - -namespace System.Net.Topology -{ - /// Provides an interface for IP net masks. - public interface INetMask - { - /// Gets the length of the net mask in bits. - int AddressLength { get; } - - /// Gets the amount of set bits from the left side (used in CIDR-Notation of net masks). - int Cidr { get; } - - /// Gets the bits of the net mask instance as an BitArray object instance. - /// The bits of the net mask instance as an BitArray object instance - byte[] GetMaskBytes(); - } -} diff --git a/WakeOnLan/Topology/IPAddressExtensions.cs b/WakeOnLan/Topology/IPAddressExtensions.cs deleted file mode 100644 index 4919f45..0000000 --- a/WakeOnLan/Topology/IPAddressExtensions.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; - -namespace System.Net.Topology -{ - /// Provides extension methods for the . - public static class IPAddressExtensions - { - private const string OnlyIPv4Supported = "Only IPv4 is currently supported"; - - /// Enumerates through the siblings of an in a network. Compliant to RFC 950 (2^n-2). - /// The address - /// The net mask of the network - public static IEnumerable GetSiblings(this IPAddress address, NetMask mask) - { - return GetSiblings(address, mask, SiblingOptions.ExcludeUnusable); - } - - /// Enumerates through the siblings of an in a network. - /// The address - /// The net mask of the network - /// Options which addresses to include an which not - public static IEnumerable GetSiblings(this IPAddress address, NetMask mask, SiblingOptions options) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - if (mask == null) - throw new ArgumentNullException(nameof(mask)); - if (address.AddressFamily != Sockets.AddressFamily.InterNetwork) - throw new NotSupportedException(OnlyIPv4Supported); - - bool includeSelf = BitHelper.IsOptionSet(options, SiblingOptions.IncludeSelf); - bool includeBroadcast = BitHelper.IsOptionSet(options, SiblingOptions.IncludeBroadcast); - bool includeNetworkIdentifier = BitHelper.IsOptionSet(options, SiblingOptions.IncludeNetworkIdentifier); - - bool alreadyReturnedSelf = false; - - var netPrefix = address.GetNetworkPrefix(mask); - - if (includeNetworkIdentifier) - { - netPrefix = address.GetNetworkPrefix(mask); - if (netPrefix.Equals(address)) - alreadyReturnedSelf = true; - yield return netPrefix; - } - - var selfAddressBytes = address.GetAddressBytes(); - - var netPrefixBytes = netPrefix.GetAddressBytes(); - - int cidr = mask.Cidr; - uint maxHosts = 0xFFFFFFFF; - - if (cidr > 0) - maxHosts = (uint)(1 << (8 * NetMask.MaskLength - cidr)) - 1; - - var hostBytes = new byte[NetMask.MaskLength]; - for (int hostPart = 1; hostPart < maxHosts; ++hostPart) - { - unchecked - { - hostBytes[0] = (byte)(hostPart >> 24); - hostBytes[1] = (byte)(hostPart >> 16); - hostBytes[2] = (byte)(hostPart >> 8); - hostBytes[3] = (byte)(hostPart >> 0); - } - - Debug.WriteLine("HostPart: " + hostPart.ToString("X2").PadLeft(8, '0') + " (" + BitConverter.ToString(hostBytes) + ")"); - - var nextIpBytes = netPrefixBytes.Or(hostBytes); - var nextIp = new IPAddress(nextIpBytes); - - if (!alreadyReturnedSelf) - { - if (includeSelf) - { - if (nextIpBytes[0] == selfAddressBytes[0] - && nextIpBytes[1] == selfAddressBytes[1] - && nextIpBytes[2] == selfAddressBytes[2] - && nextIpBytes[3] == selfAddressBytes[3]) - alreadyReturnedSelf = true; - yield return nextIp; - } - else if (nextIpBytes[0] != selfAddressBytes[0] - || nextIpBytes[1] != selfAddressBytes[1] - || nextIpBytes[2] != selfAddressBytes[2] - || nextIpBytes[3] != selfAddressBytes[3]) - yield return nextIp; - } - else - yield return nextIp; - } - - if (includeBroadcast) - { - var broadcastAddress = address.GetBroadcastAddress(mask); - if (!address.Equals(broadcastAddress) || (address.Equals(broadcastAddress) && !alreadyReturnedSelf)) - yield return broadcastAddress; - } - } - - /// Gets the network prefix of an . - /// The address - /// The net mask of the network - /// The network prefix of an - public static IPAddress GetNetworkPrefix(this IPAddress address, NetMask mask) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - if (mask == null) - throw new ArgumentNullException(nameof(mask)); - - if (address.AddressFamily != Sockets.AddressFamily.InterNetwork) - throw new NotSupportedException(OnlyIPv4Supported); - - return mask & address; - } - - /// Gets the broadcast address of an . - /// The address - /// The net mask of the network - /// The broadcast address of an - public static IPAddress GetBroadcastAddress(this IPAddress address, NetMask mask) - { - if (address == null) - throw new ArgumentNullException("address"); - if (mask == null) - throw new ArgumentNullException("mask"); - - if (address.AddressFamily != Sockets.AddressFamily.InterNetwork) - throw new NotSupportedException(OnlyIPv4Supported); - - // TODO: Test - - var ipBytes = address.GetAddressBytes(); - var notMaskBytes = mask.GetMaskBytes().Not(); - - var broadcastAddressBytes = notMaskBytes.Or(ipBytes); - return new IPAddress(broadcastAddressBytes); - } - - /// Gets the host identifier (rest) an . - /// The address - /// The net mask of the network - /// The host identifier (rest) an - public static IPAddress GetHostIdentifier(this IPAddress address, NetMask mask) - { - if (address == null) - throw new ArgumentNullException(nameof(address)); - if (mask == null) - throw new ArgumentNullException(nameof(mask)); - if (address.AddressFamily != Sockets.AddressFamily.InterNetwork) - throw new NotSupportedException(OnlyIPv4Supported); - - var maskBits = mask.GetMaskBytes(); - var ipBits = address.GetAddressBytes(); - - // ~Mask & IP - var retVal = maskBits.Not().And(ipBits); - var bytes = new byte[NetMask.MaskLength]; - Buffer.BlockCopy(retVal, 0, bytes, 0, bytes.Length); - - return new IPAddress(bytes); - } - } -} diff --git a/WakeOnLan/Topology/NetMask.cs b/WakeOnLan/Topology/NetMask.cs deleted file mode 100644 index 7706aac..0000000 --- a/WakeOnLan/Topology/NetMask.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Text; - -namespace System.Net.Topology -{ - // TODO: Use Span when available (instead of byte arrays) - /// Represents an IPv4 net mask. - [StructLayout(LayoutKind.Explicit)] - public struct NetMask : INetMask, IEquatable - { - [FieldOffset(0)] - private readonly uint _mask; - - #region byte-wise fields - - // We are assuming here, that the byte-ordering is like on a normal x86 system - - [FieldOffset(3)] - private readonly byte _maskB0; - [FieldOffset(2)] - private readonly byte _maskB1; - [FieldOffset(1)] - private readonly byte _maskB2; - [FieldOffset(0)] - private readonly byte _maskB3; - - #endregion - - internal const int MaskLength = 4; - - /// Represents an empty IPv4 NetMask (all bits set to 0). - public static NetMask Empty { get; } = new NetMask(); - - /// Gets the length of the net mask in bits. - public int AddressLength => MaskLength * 8; - - /// Gets the amount of set bits from the left side (used in CIDR-Notation of net masks). - public int Cidr => GetCidr(_mask); - - #region Ctors - - /// Creates a new instance of cloning an existing instance of . - public NetMask(NetMask mask) - { - if (mask == null) - throw new ArgumentNullException(nameof(mask)); - _maskB0 = _maskB1 = _maskB2 = _maskB3 = 0; - _mask = mask._mask; - } - - /// Creates a new instance of from an array of . - public NetMask(byte[] value) - { - _maskB0 = _maskB1 = _maskB2 = _maskB3 = 0; - _mask = 0; - if (value == null || value.Length == 0) // maybe throw ArgumentNullException? - return; - - if (value.Length != MaskLength) - throw new ArgumentException("Invalid mask length."); - - CheckMaskBytes(value); // check if passed mask are a valid mask. if not, throw Exception - _maskB0 = value[0]; - _maskB1 = value[1]; - _maskB2 = value[2]; - _maskB3 = value[3]; - } - - /// Creates a new instance of from a given . - /// The IPv4 address. - public NetMask(IPAddress address) - : this(address == null ? null : address.GetAddressBytes()) - { } - - /// Creates a new instance of . - /// The first byte. - /// The second byte. - /// The third byte. - /// The fourth byte. - public NetMask(byte m0, byte m1, byte m2, byte m3) - : this(new[] { m0, m1, m2, m3 }) - { } - - /// Creates a new instance of . - /// The mask represented by the CIDR notation integer. - public NetMask(byte cidr) - { - // maybe change parameter type interpretation to CIDR? - if (cidr > MaskLength * 8) - throw new ArgumentException("Invalid CIDR length"); - _maskB0 = _maskB1 = _maskB2 = _maskB3 = 0; // to keep init checks happy - _mask = GetUIntFromCidrValue(cidr); - } - - private NetMask(uint ipv4Mask) - { - _maskB0 = _maskB1 = _maskB2 = _maskB3 = 0; // to keep init checks happy - _mask = ipv4Mask; - } - - #endregion - - private static void CheckMaskBytes(byte[] bytes) - { - if (!bytes.RepresentsValidNetMask()) - throw new ArgumentException("The passed mask do not represent a valid net mask."); - } - - /// Gets the bits of the net mask instance as an BitArray object instance. - /// The bits of the net mask instance as an BitArray object instance. - public byte[] GetMaskBytes() => new[] { _maskB0, _maskB1, _maskB2, _maskB3 }; - - private static int GetCidr(uint mask) - { - Debug.Assert(sizeof(uint) == MaskLength); - return mask.CountOnesFromLeft(); - } - - /// Extends the current instance by a given value (CIDR-wise). - /// The mask to use as a reference. - /// The value. - /// Because is a reference type, this method is static. If it were not like this, you could change the value of .Empty, for example. - public static NetMask Extend(NetMask mask, int value) - { - int currentCidr = mask.Cidr; - if (currentCidr >= MaskLength * 8) - return new NetMask(mask); - if (currentCidr <= 0) - currentCidr = 0; - - int newLength = Math.Max(Math.Min(currentCidr + value, 32), 0); - - var m = BytesFromCidrValue(newLength); - - return new NetMask(m); - } - - /// Abbreviates the current instance by a given value (CIDR-wise). - /// The mask to use as a reference. - /// The value. - /// Because is a reference type, this method is static. If it were not like this, you could change the value of .Empty, for example. - public static NetMask Abbreviate(NetMask mask, int value) - { - int currentCidr = mask.Cidr; - if (currentCidr < 1) - return new NetMask(mask); - if (currentCidr >= MaskLength * 8) - currentCidr = MaskLength * 8; - - int newLength = Math.Max(Math.Min(currentCidr - value, 32), 0); - - var m = BytesFromCidrValue(newLength); - return new NetMask(m); - } - - /// Returns a value indicating whether the given array of represents a valid net mask. - /// True if the given array of represents a valid net mask, otherwise false. - public static bool GetIsValidNetMask(byte[] mask) => mask.RepresentsValidNetMask(); - - // TODO: Testing(!) - [Obsolete] - private static byte[] BytesFromCidrValue(int cidr) - { - int target = MaskLength * 8 - cidr; - int mask = 0; - for (int i = 0; i < target; ++i) - { - mask >>= 1; - mask |= unchecked((int)0x80000000); - } - var bytes = BitConverter.GetBytes(~mask); - return new[] { - bytes[0].ReverseBits(), - bytes[1].ReverseBits(), - bytes[2].ReverseBits(), - bytes[3].ReverseBits() - }; - } - - // TODO: Testing(!) - private static uint GetUIntFromCidrValue(int cidr) => UIntExtensions.CreateWithOnesFromLeft(cidr); - - #region Operators - - #region Equality - - /// Returns a other indicating whether two instances of are equal. - /// The first other to compare. - /// The second other to compare. - /// true if and are equal; otherwise, false. - public static bool operator ==(NetMask n1, NetMask n2) - { - if (ReferenceEquals(n1, n2)) - return true; - if (((object)n1 == null) || ((object)n2 == null)) - return false; - return n1.Equals(n2); - } - - /// Returns a other indicating whether two instances of are not equal. - /// The first other to compare. - /// The second other to compare. - /// true if and are not equal; otherwise, false. - public static bool operator !=(NetMask n1, NetMask n2) => !(n1 == n2); // Problem solved - - #endregion - #region And - - /// Bitwise combines a instance and an the AND operation. - /// The net mask. - /// The IPAddress. - /// The bitwised combination using the AND operation. - public static IPAddress operator &(IPAddress address, NetMask mask) => mask & address; - - /// Bitwise combines a instance and an the AND operation. - /// The net mask. - /// The IPAddress. - /// The bitwised combination using the AND operation. - public static IPAddress BitwiseAnd(IPAddress address, NetMask mask) => mask & address; - - /// Bitwise combines a instance and an the AND operation. - /// The net mask. - /// The IPAddress. - /// The bitwised combination using the AND operation. - public static IPAddress operator &(NetMask mask, IPAddress address) - { - var ipBytes = address == null - ? new byte[MaskLength] - : address.GetAddressBytes(); - var maskBytes = mask == null - ? new byte[MaskLength] - : new byte[] { mask._maskB0, mask._maskB1, mask._maskB2, mask._maskB3 }; - - byte[] combinedBytes = maskBytes.And(ipBytes); - return new IPAddress(combinedBytes); - } - - /// Bitwise combines a instance and an the AND operation. - /// The net mask. - /// The IPAddress. - /// The bitwised combination using the AND operation. - public static IPAddress BitwiseAnd(NetMask mask, IPAddress address) => mask & address; - - /// Bitwise combines the two instances of using the AND operation. - /// The first other. - /// The second other. - /// The bitwised combination using the AND operation. - public static NetMask operator &(NetMask n1, NetMask n2) => new NetMask(n1._mask & n2._mask); - - /// Bitwise combines the two instances of using the AND operation. - /// The first other. - /// The second other. - /// The bitwised combination using the AND operation. - public static NetMask BitwiseAnd(NetMask n1, NetMask n2) => n1 & n2; - - #endregion - #region Or - - /// Bitwise combines the two instances of using the OR operation. - /// The first other. - /// The second other. - /// The bitwised combination using the OR operation. - public static NetMask operator |(NetMask n1, NetMask n2) => new NetMask(n1._mask | n2._mask); - - /// Bitwise combines the two instances of using the OR operation. - /// The first other. - /// The second other. - /// The bitwised combination using the OR operation. - public static NetMask BitwiseOr(NetMask n1, NetMask n2) => n1 | n2; - - #endregion - - #endregion - #region Common overrides - - /// Converts the other of this instance to its equivalent string representation. - /// A string that represents the other of this instance. - /// 1 - public override string ToString() - { - var sb = new StringBuilder(4 * 3 + 3 * 3 + 32 + 3 + 3); // 255.255.255.255 (11111111111111111111111111111111) - - var arr = new byte[] { _maskB0, _maskB1, _maskB2, _maskB3 }; - var asString = arr.ToBinaryString('.'); - - sb.Append(arr[0]).Append('.').Append(arr[1]).Append('.').Append(arr[2]).Append('.').Append(arr[3]).Append(" ("); - sb.Append(asString).Append(')'); - - return sb.ToString(); - } - - /// Returns a value indicating whether this instance and a specified represent the same type and other. - /// true if is a and equal to this instance; otherwise, false. - /// The object to compare with this instance. - /// 2 - public override bool Equals(object obj) => obj != null && obj is NetMask && Equals((NetMask)obj); - - /// Returns a value indicating whether this instance and a specified object represent the same other. - /// true if is equal to this instance; otherwise, false. - /// An object to compare to this instance. - /// 2 - public bool Equals(NetMask other) => other._mask == _mask; - - /// Returns the hash code for this instance. - /// A 32-bit signed integer hash code. - /// 2 - public override int GetHashCode() => unchecked((int)_mask); - - #endregion - } -} diff --git a/WakeOnLan/Topology/NetMaskExtensions.cs b/WakeOnLan/Topology/NetMaskExtensions.cs deleted file mode 100644 index 6b12ae7..0000000 --- a/WakeOnLan/Topology/NetMaskExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ - -namespace System.Net.Topology -{ - /// Provides extension methods for the . - public static class NetMaskExtensions - { - /// Gets the number of siblings an can have in a given network. Compliant to RFC 950 (2^n-2). - /// The net mask of the network - /// The number of siblings an can have in the given network. - public static int GetSiblingCount(this NetMask mask) => GetSiblingCount(mask, SiblingOptions.ExcludeUnusable); - - /// Gets the number of siblings an can have in a given network. - /// The net mask of the network - /// Options which addresses to include an which not - /// The number of siblings an can have in the given network. - public static int GetSiblingCount(this NetMask mask, SiblingOptions options) - { - if (mask == null) - throw new ArgumentNullException(nameof(mask)); - - bool includeSelf = BitHelper.IsOptionSet(options, SiblingOptions.IncludeSelf); - bool includeBroadcast = BitHelper.IsOptionSet(options, SiblingOptions.IncludeBroadcast); - bool includeNetworkIdentifier = BitHelper.IsOptionSet(options, SiblingOptions.IncludeNetworkIdentifier); - - var hostPartBits = mask.GetMaskBytes().CountFromRight(false); - var total = 1 << hostPartBits; - total -= includeSelf ? 0 : 1; - total -= includeBroadcast ? 0 : 1; - total -= includeNetworkIdentifier ? 0 : 1; - - // TODO: Testing - - return total; - } - } -} diff --git a/WakeOnLan/Topology/SiblingOptions.cs b/WakeOnLan/Topology/SiblingOptions.cs deleted file mode 100644 index 5a84476..0000000 --- a/WakeOnLan/Topology/SiblingOptions.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace System.Net.Topology -{ - /// Provides options for doing network sibling calculations using a net mask. - [Flags] - public enum SiblingOptions - { - /// Do not include the broadcast or net address neither the addess passed to the method. - ExcludeAll = 0, - /// Include the addess passed to the method. - IncludeSelf = 1, - /// Include the addess passed to the method. Compliant to RFC 950 (2^n-2). - ExcludeUnusable = IncludeSelf, - /// Include the broadcast address. - IncludeBroadcast = 2, - /// Include the net address. - IncludeNetworkIdentifier = 4, - /// Include all addresses possible. RFC 1878 (2^n). - IncludeAll = IncludeSelf | IncludeBroadcast | IncludeNetworkIdentifier - } - - internal static class BitHelper - { - [Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] // as if NGen will ever compile this assembly ;) - [Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] - internal static bool IsOptionSet(SiblingOptions value, SiblingOptions testValue) => (value & testValue) == testValue; - } -} diff --git a/WakeOnLan/Topology/StringExtensions.cs b/WakeOnLan/Topology/StringExtensions.cs deleted file mode 100644 index e506670..0000000 --- a/WakeOnLan/Topology/StringExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ - -namespace System.Net.Topology -{ - internal static class StringExtensions - { - // TODO: The following method uses unsafe stuff. We don't want to pass the /unsafe flag to the compiler, so we use a simple, safe method instead. - // As soon as .NET Standard with Span and the new String.Create is available, we can make this faster and safe. - /* - internal static unsafe string Reverse(this string input) - { - int len = input.Length; - - // Why allocate a char[] array on the heap when you won't use it - // outside of this method? Use the stack. - char* reversed = stackalloc char[len]; - - // Avoid bounds-checking performance penalties. - fixed (char* str = input) - { - int i = 0; - int j = i + len - 1; - while (i < len) - reversed[i++] = str[j--]; - } - - // Need to use this overload for the System.String constructor - // as providing just the char* pointer could result in garbage - // at the end of the string (no guarantee of null terminator). - return new string(reversed, 0, len); - } - */ - internal static string Reverse(this string input) - { - char[] chars = input.ToCharArray(); - Array.Reverse(chars); - return new string(chars); - } - } -} diff --git a/WakeOnLan/Topology/UIntExtensions.cs b/WakeOnLan/Topology/UIntExtensions.cs deleted file mode 100644 index ccad88d..0000000 --- a/WakeOnLan/Topology/UIntExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace System.Net.Topology -{ - internal static class UIntExtensions - { - // TODO: Tests - public static int CountOnesFromLeft(this uint value) - { - var occurences = 0; - for (uint i = 1u << 31; i >= 0; i >>= 1) - { - if ((i & value) != 0) - ++occurences; - else - break; - } - return occurences; - } - - // TODO: Tests - public static uint CreateWithOnesFromLeft(int count) - { - if (count > 32) - throw new ArgumentException("Cannot set more than 32 bits to one!"); - - var value = 0u; - - var mask = 1u << 31; - for (int i = 0; i < count; ++i) - { - value |= mask; - mask >>= 1; - } - - return value; - } - } -} diff --git a/WakeOnLan/WakeOnLan.csproj b/WakeOnLan/WakeOnLan.csproj deleted file mode 100644 index b9ef27c..0000000 --- a/WakeOnLan/WakeOnLan.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - netstandard2.0 - Niklas Mollenhauer - 2.0.2 - Library for Sending magic packets and performing IP address operations. - LGPL-3.0-only - https://github.com/nikeee/wake-on-lan - https://github.com/nikeee/wake-on-lan.git - WakeOnLan, magic packets - True - System.Net - - - - latest - - - - - - - - -