public string SetDevLed_Color(RGBDevice rgbdev, int ledidx, RGBColor color) { // set device specific led color string error = ""; try { if (!SDK_Class.API_RESULT(SDK_Class.MLAPI_SetLedColor(rgbdev.DevType, Convert.ToUInt32(ledidx), color.R, color.G, color.B), out error)) { return("SetLedColor Error: " + error); } } catch { } return((error) ?? ""); }
public string GetDevLed_Color(RGBDevice rgbdev, int ledidx, out RGBColor color) { // get device specific led color color = null; string error = ""; try { if (!SDK_Class.API_RESULT(SDK_Class.MLAPI_GetLedColor(rgbdev.DevType, Convert.ToUInt32(ledidx), out uint R, out uint G, out uint B), out error)) { return("GetLedColor Error: " + error); } color = new RGBColor(R, G, B); } catch { } return((error) ?? ""); }
private async void btnColorList_Click(object sender, EventArgs e) { //test //known color list.. string style = rgbDevices[0].leddevices[0].StyleList[7]; //steady lc.SetDevLed_Style(rgbDevices[0], 0, style); /* * KnownColor[] colors = (KnownColor[])Enum.GetValues(typeof(KnownColor)); * foreach (KnownColor knowColor in colors) * { * Color color = Color.FromKnownColor(knowColor); * RGBColor c = new RGBColor(Convert.ToUInt32(color.R), Convert.ToUInt32(color.G), Convert.ToUInt32(color.B)); * * lc.SetDevLed_Color(rgbDevices[0], 0, c); * await Task.Delay(1000); * } * */ Type colorType = typeof(System.Drawing.Color); System.Reflection.PropertyInfo[] propInfos = colorType.GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public); foreach (System.Reflection.PropertyInfo propInfo in propInfos) { //Console.WriteLine(propInfo.Name); Color color = Color.FromName(propInfo.Name); RGBColor c = new RGBColor(Convert.ToUInt32(color.R), Convert.ToUInt32(color.G), Convert.ToUInt32(color.B)); lc.SetDevLed_Color(rgbDevices[0], 0, c); await Task.Delay(1000); } MessageBox.Show("end"); }
private async void btnTestEnum_Click(object sender, EventArgs e) { string style = rgbDevices[0].leddevices[0].StyleList[7]; //steady lc.SetDevLed_Style(rgbDevices[0], 0, style); foreach (string cn in Enum.GetNames(typeof(Colors))) { Color color = Color.FromName(cn); RGBColor c = new RGBColor(Convert.ToUInt32(color.R), Convert.ToUInt32(color.G), Convert.ToUInt32(color.B)); lc.SetDevLed_Color(rgbDevices[0], 0, c); await Task.Delay(1000); } MessageBox.Show("end"); }