/// <summary> /// Prevents a default instance of the <see cref="Keyboard" /> class from being created. /// </summary> private Keyboard() { Log.Info("Keyboard initializing..."); Chroma.InitInstance(); CurrentEffectId = Guid.Empty; // We keep a local copy of a grid to speed up grid operations Log.Debug("Initializing private copy of Custom"); _grid = Custom.Create(); }
/// <summary> /// Prevents a default instance of the <see cref="Keyboard" /> class from being created. /// </summary> private Keyboard() { Log.Info("Keyboard initializing..."); Chroma.Initialize(); CurrentEffectId = Guid.Empty; // We keep a local copy of a grid to speed up grid operations Log.Debug("Creating grid array"); var gridArray = new Color[Constants.MaxRows][]; for (var i = 0; i < Constants.MaxRows; i++) gridArray[i] = new Color[Constants.MaxColumns]; Log.Debug("Initializing private copy of Custom"); _grid = new Custom(gridArray); }
/// <summary> /// Sets a custom grid effect on the keyboard. /// </summary> /// <param name="effect">Effect options.</param> /// <remarks> /// This will overwrite the current internal <see cref="Custom" /> /// struct in the <see cref="Keyboard" /> class. /// </remarks> public void SetCustom(Custom effect) { _grid = effect; SetGuid(NativeWrapper.CreateKeyboardEffect(_grid)); }
public void Pulse(object sender, EventArgs e) { //Chroma.Instance.SetAll(ColoreColor.Red); //var customEffect = new Corale.Colore.Razer.Keyboard.Effects.Custom(Color.Green); // Chroma.Instance.Keyboard.SetCustom(customEffect); //Chroma.Instance.Keyboard.SetKey(Key.A, ColoreColor.Blue); // Create a Random Generator //Random random = new Random(); //// Create the custom Grid //var keyboardGrid = KeyboardCustom.Create(); //// Loop through all Rows //for (var r = 0; r < Constants.MaxRows; r++) //{ // //Loop through all Columns // for (var c = 0; c < Constants.MaxColumns; c++) // { // // Set the current row and column to the random color // keyboardGrid[r, c] = new ColoreColor(random.Next(256), random.Next(256), random.Next(256)); // } //} //Chroma.Instance.Keyboard.SetCustom(keyboardGrid); Random random = new Random(); var keyboardGrid = KeyboardCustom.Create(); var sleepTime = 50; for (var r = 0; r < Constants.MaxRows; r++) { if (r % 2 == 0) { for (int c = 0; c < Constants.MaxColumns; c++) { keyboardGrid[r, c] = ColoreColor.White; //keyboardGrid[r, c] = new ColoreColor(random.Next(256), random.Next(256), random.Next(256)); Chroma.Instance.Keyboard.SetCustom(keyboardGrid); Thread.Sleep(sleepTime); } } else { for (int c = Constants.MaxColumns - 1; c >= 0; c--) { keyboardGrid[r, c] = ColoreColor.Blue; Chroma.Instance.Keyboard.SetCustom(keyboardGrid); Thread.Sleep(sleepTime); } } } Chroma.Instance.SetAll(ColoreColor.Green); Thread.Sleep(1000); Chroma.Instance.SetAll(ColoreColor.Red); Thread.Sleep(1000); Chroma.Instance.SetAll(ColoreColor.Black); for (var r = 0; r < Constants.MaxRows; r++) { if (r % 2 != 0) { for (int c = 0; c < Constants.MaxColumns; c++) { keyboardGrid[r, c] = ColoreColor.White; //keyboardGrid[r, c] = new ColoreColor(random.Next(256), random.Next(256), random.Next(256)); Chroma.Instance.Keyboard.SetCustom(keyboardGrid); Thread.Sleep(sleepTime); } } else { for (int c = Constants.MaxColumns - 1; c >= 0; c--) { keyboardGrid[r, c] = ColoreColor.Blue; Chroma.Instance.Keyboard.SetCustom(keyboardGrid); Thread.Sleep(sleepTime); } } } Chroma.Instance.SetAll(ColoreColor.Black); }
public void ShouldNotEqualDifferentArray() { var grid = new Custom(Color.Pink); var arr = new Color[Constants.MaxRows][]; // Populate the 2D array for (var row = 0; row < Constants.MaxRows; row++) { arr[row] = new Color[Constants.MaxColumns]; for (var col = 0; col < Constants.MaxColumns; col++) arr[row][col] = Color.Red; } Assert.False(grid == arr); Assert.True(grid != arr); Assert.False(grid.Equals(arr)); Assert.AreNotEqual(grid, arr); }
public void ShouldNotEqualDifferentGrid() { var a = new Custom(Color.Red); var b = new Custom(Color.Pink); Assert.False(a == b); Assert.True(a != b); Assert.False(a.Equals(b)); Assert.AreNotEqual(a, b); }
public void ShouldEqualIdenticalGrid() { var a = new Custom(Color.Red); var b = new Custom(Color.Red); Assert.True(a == b); Assert.False(a != b); Assert.True(a.Equals(b)); Assert.AreEqual(a, b); }
public void ShouldClearToBlack() { var grid = new Custom(Color.Pink); grid.Clear(); Assert.That(grid, Is.EqualTo(Custom.Create())); }
public void ShouldSetProperColorsWithArrCtor() { var arr = new Color[Constants.MaxRows][]; for (var row = 0; row < Constants.MaxRows; row++) arr[row] = new Color[Constants.MaxColumns]; // Set some arbitrary colors to test arr[0][5] = Color.Purple; arr[2][3] = Color.Pink; arr[4][0] = Color.Blue; var grid = new Custom(arr); for (var row = 0; row < Constants.MaxRows; row++) { for (var col = 0; col < Constants.MaxColumns; col++) Assert.That(grid[row, col], Is.EqualTo(arr[row][col])); } }
public void ShouldSetAllColorsWithColorCtor() { var grid = new Custom(Color.Red); for (var row = 0; row < Constants.MaxRows; row++) { for (var column = 0; column < Constants.MaxColumns; column++) Assert.That(grid[row, column], Is.EqualTo(Color.Red)); } }
public void ShouldThrowWhenInvalidColumnCount() { var arr = new Color[Constants.MaxRows][]; // We only need to populate one of the rows, as the // code shouldn't check further anyway. arr[0] = new Color[2]; // ReSharper disable once NotAccessedVariable Custom dummy; Assert.That( () => dummy = new Custom(arr), Throws.ArgumentException.With.Property("ParamName").EqualTo("colors")); }
public void ShouldThrowWhenInvalidRowCount() { // We don't need to set up the columns as the code should throw before // it reaches the point of iterating rows var arr = new Color[2][]; // ReSharper disable once NotAccessedVariable Custom dummy; Assert.That( () => dummy = new Custom(arr), Throws.ArgumentException.With.Property("ParamName").EqualTo("colors")); }
public void Set(Custom effect) { SetCustom(effect); }