Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes card info on debug form and add parameter for change color on windows start. #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 55 additions & 18 deletions MSI-LED-Custom/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand All @@ -7,27 +7,36 @@
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();
textBox3.Text = Program.ledColor.B.ToString();

textBox4.Text = Program.tempMin.ToString();
textBox5.Text = Program.tempMax.ToString();
comboBox1.SelectedIndex = (int)Program.animationType;

}

private void button1_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}

Expand All @@ -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();
}
}
}
33 changes: 20 additions & 13 deletions MSI-LED-Custom/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Timers;

namespace MSI_LED_Custom
{
Expand All @@ -16,7 +17,7 @@ static class Program
/// </summary>
///


public static bool overwriteSecurityChecks;
public static List<int> adapterIndexes;
public static Manufacturer manufacturer;
Expand All @@ -30,14 +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)
Expand Down Expand Up @@ -71,6 +75,11 @@ static void Main(String[] args )
{
overwriteSecurityChecks = true;
}
else if (args[i].Equals("updateAll"))
{
updateAll = true;

}
}

int gpuCountNda = 0;
Expand Down Expand Up @@ -102,17 +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());
Application.Run(new Form1(updateAll));


ledManager.StopAll();

}
Expand Down Expand Up @@ -169,15 +176,15 @@ private static bool InitializeNvidiaAdapters(int gpuCount)
{
for (int i = 0; i < gpuCount; i++)
{

if (_NDA.NDA_GetGraphicsInfo(i, out NdaGraphicsInfo) == false)
{
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)
{
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down