private static void SetVolumeScale(ref KeyboardCustom keyboardGrid, List <Key> Keys, ColoreColor color) { for (var i = 0; i < (player.PlayerEngine.SoundVolume * Keys.Count) / 100; i++) //volume bar (D0-D9) { keyboardGrid[Keys[i]] = color; } }
private static void SetVolumeScale(ref MouseCustom mouseGrid, List <GridLed> Keys, ColoreColor color) { for (var i = 0; i < (player.PlayerEngine.SoundVolume * Keys.Count) / 100; i++) //volume bar (D0-D9) { mouseGrid[Keys[i]] = color; } }
private static ColoreColor BackgroundColorDecision(ref double opacity, double density, ColoreColor backgroundDetermine) { if (Properties.Settings.Default.AlbumCoverRenderEnable && player.PlayerEngine.PlayerState == ITPlayerState.ITPlayerStatePlaying) { if (MusicChanged) { var mostUsedColor = ImageHelper.GetMostUsedColor((System.Drawing.Bitmap)ImageHelper.GetImage(ref player)); AlbumArtworkColor = new ColoreColor((byte)mostUsedColor.R, (byte)mostUsedColor.G, (byte)mostUsedColor.B); MusicChanged = false; } backgroundDetermine = AlbumArtworkColor; } /* * if (Properties.Settings.Default.BackgroundFadeEnable) * { * opacity = player.PlayerEngine.SoundVolume * 0.01; * backgroundDetermine = new ColoreColor((byte)((backgroundDetermine.R * opacity / density)), (byte)((backgroundDetermine.G * opacity / density)), (byte)((backgroundDetermine.B * opacity / density))); * } * else * { * backgroundDetermine = new ColoreColor((byte)((backgroundDetermine.R / density)), (byte)((backgroundDetermine.G / density)), (byte)((backgroundDetermine.B / density))); * }*/ backgroundDetermine = new ColoreColor((byte)((backgroundDetermine.R * density)), (byte)((backgroundDetermine.G * density)), (byte)((backgroundDetermine.B * density))); return(backgroundDetermine); }
private static void SetPlayingPosition(ref KeyboardCustom keyboardGrid, double position, List <Key> functionKeys, ColoreColor pos, ColoreColor background) { var currentPlayPosition = (int)Math.Round(position * 1.1, 0); //can replace 1.1 with ((double)(functionKeys.Count - 1) / 10) for safe calculation for (var i = 0; i < currentPlayPosition + 1; i++) { keyboardGrid[functionKeys[i]] = background; } keyboardGrid[functionKeys[currentPlayPosition]] = pos; }
private static void SetPlayingPosition(ref MouseCustom mouseGrid, double Position, List <GridLed> Strip, ColoreColor pos, ColoreColor background) { var currentPlayPosition = (int)Math.Round(Position * 0.6, 0); //can replace 1.1 with ((double)(leftStrip.Count - 1) / 10) for safe calculation for (var i = 0; i < currentPlayPosition + 1; i++) { mouseGrid[Strip[i]] = background; } mouseGrid[Strip[currentPlayPosition]] = pos; }
private static async void ChromaUpdateAsync() { AllKeys.Remove(Key.Invalid); // no idea why this key is inside the enum? var opacity = 0.5; var keyboardGrid = KeyboardCustom.Create(); var mouseGrid = MouseCustom.Create(); var chroma = await ColoreProvider.CreateNativeAsync(); var bg_playing = new ColoreColor((byte)Properties.Settings.Default.Background_Playing.R, (byte)Properties.Settings.Default.Background_Playing.G, (byte)Properties.Settings.Default.Background_Playing.B); var bg_pause = new ColoreColor((byte)Properties.Settings.Default.Background_Pause.R, (byte)Properties.Settings.Default.Background_Pause.G, (byte)Properties.Settings.Default.Background_Pause.B); var pos_fore = new ColoreColor((byte)Properties.Settings.Default.Position_Foreground.R, (byte)Properties.Settings.Default.Position_Foreground.G, (byte)Properties.Settings.Default.Position_Foreground.B); var pos_back = new ColoreColor((byte)Properties.Settings.Default.Position_Background.R, (byte)Properties.Settings.Default.Position_Background.G, (byte)Properties.Settings.Default.Position_Background.B); var vol = new ColoreColor((byte)Properties.Settings.Default.Volume.R, (byte)Properties.Settings.Default.Volume.G, (byte)Properties.Settings.Default.Volume.B); var backgroundColor = ColoreColor.Black; while (true) { var backgroundDetermine = player.PlayerEngine.PlayerState == ITPlayerState.ITPlayerStatePlaying ? bg_playing : bg_pause; backgroundColor = BackgroundColorDecision(ref opacity, Properties.Settings.Default.AdaptiveDensity ? ActiveDevice.AudioMeterInformation.MasterPeakValue : 1, backgroundDetermine);// (10 - Properties.Settings.Default.RefreshRate) + 1, backgroundDetermine); ColorsVariableDecision(ref bg_playing, ref bg_pause, ref pos_fore, ref pos_back, ref vol); try { var currentTime = TimeSpan.FromSeconds(player.PlayerEngine.PlayerPosition); var position = player.CalculatedPosition; keyboardGrid.Set(backgroundColor); mouseGrid.Set(backgroundColor); SetIndividualKeys(ref keyboardGrid); SetPlayingTime(ref keyboardGrid, currentTime, ColoreColor.Red, ThisIsWhatCalledOrange, ColoreColor.Yellow); SetPlayingPosition(ref keyboardGrid, position, FunctionKeys, pos_fore, pos_back); SetPlayingPosition(ref mouseGrid, position, Properties.Settings.Default.ReverseLEDRender ? RightStrip : LeftStrip, pos_fore, pos_back); SetVolumeScale(ref mouseGrid, Properties.Settings.Default.ReverseLEDRender ? LeftStrip : RightStrip, vol); SetVolumeScale(ref keyboardGrid, DPadKeys, vol); } catch { continue; //in case the music is not playing yet, the position is unobtainable. } finally { await chroma.Keyboard.SetCustomAsync(keyboardGrid); await chroma.Mouse.SetGridAsync(mouseGrid); await chroma.Headset.SetAllAsync(backgroundColor); await chroma.Mousepad.SetAllAsync(backgroundColor); Thread.Sleep(500 * (Properties.Settings.Default.AdaptiveDensity ? Properties.Settings.Default.RefreshRate / 10 : 1)); } } }
private static void ColorsVariableDecision(ref ColoreColor bg_playing, ref ColoreColor bg_pause, ref ColoreColor pos_fore, ref ColoreColor pos_back, ref ColoreColor vol) { if (Properties.Settings.Default.DynamicColorEnable) { bg_playing = new ColoreColor((byte)Properties.Settings.Default.Background_Playing.R, (byte)Properties.Settings.Default.Background_Playing.G, (byte)Properties.Settings.Default.Background_Playing.B); bg_pause = new ColoreColor((byte)Properties.Settings.Default.Background_Pause.R, (byte)Properties.Settings.Default.Background_Pause.G, (byte)Properties.Settings.Default.Background_Pause.B); pos_fore = new ColoreColor((byte)Properties.Settings.Default.Position_Foreground.R, (byte)Properties.Settings.Default.Position_Foreground.G, (byte)Properties.Settings.Default.Position_Foreground.B); pos_back = new ColoreColor((byte)Properties.Settings.Default.Position_Background.R, (byte)Properties.Settings.Default.Position_Background.G, (byte)Properties.Settings.Default.Position_Background.B); vol = new ColoreColor((byte)Properties.Settings.Default.Volume.R, (byte)Properties.Settings.Default.Volume.G, (byte)Properties.Settings.Default.Volume.B); } if (Properties.Settings.Default.AlbumCoverRenderEnable) //Album render has high priority over dynamic color { var complement = System.Drawing.Color.FromArgb((int)(System.Drawing.Color.FromArgb(AlbumArtworkColor.R, AlbumArtworkColor.G, AlbumArtworkColor.B).ToArgb() ^ 0xFFFFFFFu)); var complement_bg = new ColoreColor(complement.R, complement.G, complement.B); //var complement_bg = new ColoreColor((byte)~origin_bg.R, (byte)~origin_bg.G, (byte)~origin_bg.B); bg_playing = AlbumArtworkColor; bg_pause = ColoreColor.Black; pos_fore = complement_bg; pos_back = complement_bg; vol = complement_bg; } }
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); }