From ceca75c160283e24b78828ab80f5d0932307ee25 Mon Sep 17 00:00:00 2001 From: Baton34 Date: Fri, 26 Oct 2018 13:18:59 +0300 Subject: [PATCH 1/5] fixes NVidia card data on debug form In Form_Debug "Vendor Code", "Device Code" and "Subvendor Code" always equals "N/A". --- MSI-LED-Custom/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MSI-LED-Custom/Program.cs b/MSI-LED-Custom/Program.cs index b935686..5492bce 100644 --- a/MSI-LED-Custom/Program.cs +++ b/MSI-LED-Custom/Program.cs @@ -175,9 +175,9 @@ private static bool InitializeNvidiaAdapters(int gpuCount) return false; } - string deviceCode = NdaGraphicsInfo.Card_pDeviceId.Substring(0, 4).ToUpper(); - string vendorCode = NdaGraphicsInfo.Card_pDeviceId.Substring(4, 4).ToUpper(); - string subVendorCode = NdaGraphicsInfo.Card_pSubSystemId.Substring(4, 4).ToUpper(); + deviceCode = NdaGraphicsInfo.Card_pDeviceId.Substring(0, 4).ToUpper(); + vendorCode = NdaGraphicsInfo.Card_pDeviceId.Substring(4, 4).ToUpper(); + subVendorCode = NdaGraphicsInfo.Card_pSubSystemId.Substring(4, 4).ToUpper(); if (overwriteSecurityChecks) { From 5887c423321d91f79000a65bc37c5e3774c164e6 Mon Sep 17 00:00:00 2001 From: Baton34 Date: Fri, 26 Oct 2018 13:26:13 +0300 Subject: [PATCH 2/5] Add "updateAll" parameter Run with "updateAll" parameter for setting led color, mode and temperatures on Windows start. --- MSI-LED-Custom/Program.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/MSI-LED-Custom/Program.cs b/MSI-LED-Custom/Program.cs index 5492bce..7535d7b 100644 --- a/MSI-LED-Custom/Program.cs +++ b/MSI-LED-Custom/Program.cs @@ -34,6 +34,7 @@ static class Program public static string deviceCode = "N/A"; public static string subVendorCode = "N/A"; public static string[] args; + static bool updateAll = false; [STAThread] @@ -71,6 +72,10 @@ static void Main(String[] args ) { overwriteSecurityChecks = true; } + else if (args[i].Equals("updateAll")) + { + updateAll = true; + } } int gpuCountNda = 0; @@ -108,10 +113,12 @@ static void Main(String[] args ) ledManager.StartAll(); ledManager.UpdateAll(ledColor, animationType, tempMin, tempMax); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - + if (!updateAll) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } ledManager.StopAll(); From 92b2a81d0797a173c1fb039b0024d4a702e9a911 Mon Sep 17 00:00:00 2001 From: Baton34 Date: Sat, 6 Apr 2019 12:51:40 +0400 Subject: [PATCH 3/5] Change UpdateAll logic --- MSI-LED-Custom/Program.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/MSI-LED-Custom/Program.cs b/MSI-LED-Custom/Program.cs index 7535d7b..1520597 100644 --- a/MSI-LED-Custom/Program.cs +++ b/MSI-LED-Custom/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; +using System.Timers; namespace MSI_LED_Custom { @@ -16,7 +17,7 @@ static class Program /// /// - + public static bool overwriteSecurityChecks; public static List adapterIndexes; public static Manufacturer manufacturer; @@ -30,15 +31,17 @@ static class Program public static int tempMax = 70; - public static string vendorCode = "N/A"; - public static string deviceCode = "N/A"; + public static string vendorCode = "N/A"; + public static string deviceCode = "N/A"; public static string subVendorCode = "N/A"; public static string[] args; static bool updateAll = false; + + [STAThread] - static void Main(String[] args ) + static void Main(String[] args) { if (Properties.Settings.Default["Color"] is Color) @@ -75,6 +78,7 @@ static void Main(String[] args ) else if (args[i].Equals("updateAll")) { updateAll = true; + } } @@ -107,19 +111,15 @@ static void Main(String[] args ) } } - + ledManager = new LedManager_Common(manufacturer, animationType); ledManager.InitLedManagers(); ledManager.StartAll(); ledManager.UpdateAll(ledColor, animationType, tempMin, tempMax); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1(updateAll)); - if (!updateAll) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - ledManager.StopAll(); } @@ -176,7 +176,7 @@ private static bool InitializeNvidiaAdapters(int gpuCount) { for (int i = 0; i < gpuCount; i++) { - + if (_NDA.NDA_GetGraphicsInfo(i, out NdaGraphicsInfo) == false) { return false; From 4de1d83db3119a338fd1571c200cc50dc1a1831d Mon Sep 17 00:00:00 2001 From: Baton34 Date: Sat, 6 Apr 2019 12:52:32 +0400 Subject: [PATCH 4/5] Change UpdateAll logic --- MSI-LED-Custom/Form1.cs | 73 +++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/MSI-LED-Custom/Form1.cs b/MSI-LED-Custom/Form1.cs index 6012dab..7b94186 100644 --- a/MSI-LED-Custom/Form1.cs +++ b/MSI-LED-Custom/Form1.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -7,20 +7,27 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Timers; +using System.Threading; namespace MSI_LED_Custom { public partial class Form1 : Form { - public Form1() + bool updateAll; + System.Timers.Timer updateAllTimer; + private readonly SynchronizationContext syncContext; + public Form1(bool updateAll) { + this.updateAll = updateAll; InitializeComponent(); + syncContext = SynchronizationContext.Current; } private void Form1_Load(object sender, EventArgs e) { label1.Text = Program.ledColor.ToString(); - label4.Text = Program.adapterIndexes.Count.ToString(); + label4.Text = Program.adapterIndexes.Count.ToString(); textBox1.Text = Program.ledColor.R.ToString(); textBox2.Text = Program.ledColor.G.ToString(); @@ -28,6 +35,8 @@ private void Form1_Load(object sender, EventArgs e) textBox4.Text = Program.tempMin.ToString(); textBox5.Text = Program.tempMax.ToString(); + comboBox1.SelectedIndex = (int)Program.animationType; + } private void button1_Click(object sender, EventArgs e) @@ -56,13 +65,13 @@ private void button1_Click(object sender, EventArgs e) { textBox3.Text = "0"; } - + Program.ledColor = Color.FromArgb(255, Int32.Parse(textBox1.Text), Int32.Parse(textBox2.Text), Int32.Parse(textBox3.Text)); label1.Text = Program.ledColor.ToString(); Program.tempMin = Int32.Parse(textBox4.Text); Program.tempMax = Int32.Parse(textBox5.Text); - + Program.ledManager.UpdateAll(Program.ledColor, AnimationType.Off, Program.tempMin, Program.tempMax); Program.ledManager.UpdateAll(Program.ledColor, Program.animationType, Program.tempMin, Program.tempMax); Properties.Settings.Default["Color"] = Program.ledColor; @@ -75,31 +84,31 @@ private void button1_Click(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { - switch ( comboBox1.SelectedIndex ) + switch (comboBox1.SelectedIndex) { case (int)AnimationType.NoAnimation: - Program.animationType = AnimationType.NoAnimation; - break; + Program.animationType = AnimationType.NoAnimation; + break; case (int)AnimationType.Breathing: - Program.animationType = AnimationType.Breathing; - break; + Program.animationType = AnimationType.Breathing; + break; case (int)AnimationType.Flashing: - Program.animationType = AnimationType.Flashing; - break; + Program.animationType = AnimationType.Flashing; + break; case (int)AnimationType.DoubleFlashing: - Program.animationType = AnimationType.DoubleFlashing; - break; + Program.animationType = AnimationType.DoubleFlashing; + break; case (int)AnimationType.Off: - Program.animationType = AnimationType.Off; - break; + Program.animationType = AnimationType.Off; + break; case (int)AnimationType.TemperatureBased: - Program.animationType = AnimationType.TemperatureBased; - break; + Program.animationType = AnimationType.TemperatureBased; + break; } } @@ -123,5 +132,33 @@ private void label9_Click(object sender, EventArgs e) { } + + private void Form1_Shown(object sender, EventArgs e) + { + if (this.updateAll) + { + this.WindowState = FormWindowState.Minimized; + updateAllTimer = new System.Timers.Timer(20000); // через 20 секунд программа закроется + updateAllTimer.AutoReset = false; + updateAllTimer.Elapsed += updateTimer; + updateAllTimer.Enabled = true; + updateAllTimer.Start(); + + } + } + void updateTimer(Object source, System.Timers.ElapsedEventArgs e) + { + FormClose(); + + } + private void FormClose() + { + syncContext.Post(FormClose2, null); + } + + private void FormClose2(object temp) + { + this.Close(); + } } } From 44493c151906153dda9fb4b31ef766a8e117b1fa Mon Sep 17 00:00:00 2001 From: Baton34 Date: Sat, 6 Apr 2019 12:57:30 +0400 Subject: [PATCH 5/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c5ad2e1..7237436 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ You have the choice between : 5. Off 6. Temperature Based +You can start program with 'updateAll' arg and it will apply color settings and close after 20 seconds. Usefull for autostart with Windows. + ## Why there is no motherboard support ? The control of the motherboard need to communicate with a kernel driver, and I don't know anything about this, but you can read more about this here : https://github.com/nagisa/msi-rgb/