static void Main(string[] args) // Args - [Filepath - Relative to "C:\ProgramData\ZRazer\Lightpacks\" or absolute.] { AppCall callArgs = new AppCall(args); // Create a mutex to confirm it is the only existing process of its type. mutex = new Mutex(true, "RazerColor", out bool createdNew); // If its not created new, send its message to the main client. if (!createdNew) { string str = string.Join(":", args); // Combine the args back together StartInternalClient(str); // Send it off to the client server return; } // Fetch a chroma interface IChroma chromaInstance = GetInstance().Result; bool state = SwitchColour(callArgs, chromaInstance).Result; while (state) { Console.WriteLine("Starting a new server connection..."); string incomingData = StartInternalServer(); state = SwitchColour(new AppCall(incomingData.Split(':')), chromaInstance).Result; // End program if it didn't work } ; Error(chromaInstance).Wait(); }
static async Task <bool> SwitchColour(AppCall args, IChroma chroma) { if (args.invalid) { return(false); } var grid = KeyboardCustom.Create(); if (args.addWeak || args.addStrong) { grid = currentKeyboard; } ColoreColor clr = ColoreColor.Black; foreach (string fline in File.ReadLines(args.filePath)) { string line = fline; if (line.Contains(";")) { line = line.Substring(0, line.IndexOf(";")); } line = line.Trim(); if (line == "") { continue; } if (line.ToLower().StartsWith("rgb")) { var b = line.Remove(0, 3).Trim(); try { clr = ColoreColor.FromRgb(uint.Parse(b, System.Globalization.NumberStyles.HexNumber)); } catch (Exception e) { Console.WriteLine("yo your color was invalid dude"); Console.WriteLine(e); return(false); } } if (line.ToLower().StartsWith("all")) { grid.Set(clr); } if (!Enum.TryParse(line, true, out Key currKey) && !line.ToLower().StartsWith("rgb") && !line.ToLower().StartsWith("all")) // horrible code hours { Console.WriteLine("thats not a valid key pls fix"); Console.WriteLine(currKey.ToString()); return(false); } if (args.addWeak) { if (grid[currKey] == ColoreColor.Black) { grid[currKey] = clr; } } else { grid[currKey] = clr; } } currentKeyboard = grid; Console.WriteLine("bro"); await chroma.Keyboard.SetCustomAsync(grid); return(true); }