Ejemplo n.º 1
0
        public void ShouldGetWithKeyIndexer()
        {
            var grid = CustomKeyboardEffect.Create();

            grid[Key.Escape] = Color.Red;
            Assert.AreEqual(Color.Red, grid[Key.Escape]);
        }
Ejemplo n.º 2
0
        public void ShouldSetWithIndexIndexer()
        {
            var grid = CustomKeyboardEffect.Create();

            grid[5] = Color.Red;

            Assert.AreEqual(Color.Red, grid[5]);
        }
Ejemplo n.º 3
0
        public void ShouldNotEqualNull()
        {
            var grid = CustomKeyboardEffect.Create();

            Assert.False(grid == null);
            Assert.True(grid != null);
            Assert.AreNotEqual(grid, null);
        }
Ejemplo n.º 4
0
        public void ShouldClearToBlack()
        {
            var grid = new CustomKeyboardEffect(Color.Pink);

            grid.Clear();

            Assert.That(grid, Is.EqualTo(CustomKeyboardEffect.Create()));
        }
Ejemplo n.º 5
0
        public void ShouldSetNewColors()
        {
            var grid = CustomKeyboardEffect.Create();

            grid[0, 5] = Color.Red;

            Assert.That(grid[0, 5], Is.EqualTo(Color.Red));
        }
Ejemplo n.º 6
0
        public void ShouldNotEqualArbitraryObject()
        {
            var grid = CustomKeyboardEffect.Create();
            var obj  = new object();

            Assert.False(grid == obj);
            Assert.True(grid != obj);
            Assert.False(grid.Equals(obj));
            Assert.AreNotEqual(grid, obj);
        }
Ejemplo n.º 7
0
        public void ShouldNotEqual2DArrayWithInvalidRowCount()
        {
            var grid = CustomKeyboardEffect.Create();
            var arr  = new Color[2][];

            Assert.False(grid == arr);
            Assert.True(grid != arr);
            Assert.False(grid.Equals(arr));
            Assert.AreNotEqual(grid, arr);
        }
Ejemplo n.º 8
0
        public void ShouldSetToBlackWithCreate()
        {
            var grid = CustomKeyboardEffect.Create();

            for (var row = 0; row < KeyboardConstants.MaxRows; row++)
            {
                for (var column = 0; column < KeyboardConstants.MaxColumns; column++)
                {
                    Assert.That(grid[row, column], Is.EqualTo(Color.Black));
                }
            }
        }
Ejemplo n.º 9
0
        /// <inheritdoc />
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyboardImplementation" /> class.
        /// </summary>
        public KeyboardImplementation(IChromaApi api)
            : base(api)
        {
            Log.Info("Keyboard initializing...");

            CurrentEffectId = Guid.Empty;

            // We keep a local copy of a grid to speed up grid operations
            Log.Debug("Initializing private copy of Custom");
            _grid = CustomKeyboardEffect.Create();

            Log.Debug("Initializing private copy of Deathstalker grid");
            _deathstalkerGrid = DeathstalkerGridEffect.Create();
        }
Ejemplo n.º 10
0
        public async Task ApplyAsync(IVirtualLedGrid virtualGrid, CancellationToken cancellationToken = default)
        {
            var keyboardGrid   = CustomKeyboardEffect.Create();
            var mouseGrid      = CustomMouseEffect.Create();
            var mousepadGrid   = CustomMousepadEffect.Create();
            var headsetGrid    = CustomHeadsetEffect.Create();
            var chromaLinkGrid = CustomChromaLinkEffect.Create();

            foreach (var k in virtualGrid)
            {
                switch (k.Type)
                {
                case KeyType.Invalid:
                    break;

                case KeyType.Keyboard:
                    var kbVal = (Key)Enum.Parse(typeof(Key), k.FriendlyName);
                    keyboardGrid[kbVal] = ToColoreColor(k.Color);
                    break;

                case KeyType.Mouse:
                    var mouseVal = (GridLed)Enum.Parse(typeof(GridLed), k.FriendlyName);
                    mouseGrid[mouseVal] = ToColoreColor(k.Color);
                    break;

                case KeyType.Mousepad:
                    mousepadGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;

                case KeyType.Headset:
                    headsetGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;

                case KeyType.ChromaLink:
                    chromaLinkGrid[k.KeyCode] = ToColoreColor(k.Color);
                    break;
                }
            }

            await this._chromaInterface.Keyboard.SetCustomAsync(keyboardGrid);

            await this._chromaInterface.Mouse.SetGridAsync(mouseGrid);

            await this._chromaInterface.Mousepad.SetCustomAsync(mousepadGrid);

            await this._chromaInterface.Headset.SetCustomAsync(headsetGrid);

            await this._chromaInterface.ChromaLink.SetCustomAsync(chromaLinkGrid);
        }
Ejemplo n.º 11
0
        public override Task ApplyAsync(IVirtualLedGrid virtualGrid, CancellationToken cancellationToken = default)
        {
            if (!this.Initialized)
            {
                return(Task.CompletedTask);
            }

            var keyboardGrid = CustomKeyboardEffect.Create();

            for (var row = 0; row < virtualGrid.RowCount; row++)
            {
                for (var col = 0; col < virtualGrid.ColumnCount; col++)
                {
                    keyboardGrid[row, col] = ToColoreColor(virtualGrid[col, row]);
                }
            }

            return(this.ChromaInterface !.Keyboard.SetCustomAsync(keyboardGrid));
        }
Ejemplo n.º 12
0
        public void ShouldThrowWhenOutOfRange1DSet()
        {
            var grid = CustomKeyboardEffect.Create();

            Assert.That(
                () => grid[-1] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => grid[KeyboardConstants.MaxKeys] = Color.Red,
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("index")
                .And.Property("ActualValue")
                .EqualTo(KeyboardConstants.MaxKeys));
        }
Ejemplo n.º 13
0
        public void ShouldThrowWhenOutOfRange2DGet()
        {
            var grid = CustomKeyboardEffect.Create();

            // ReSharper disable once NotAccessedVariable
            Color dummy;

            Assert.That(
                () => dummy = grid[-1, 0],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => dummy = grid[KeyboardConstants.MaxRows, 0],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("row")
                .And.Property("ActualValue")
                .EqualTo(KeyboardConstants.MaxRows));

            Assert.That(
                () => dummy = grid[0, -1],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(-1));

            Assert.That(
                () => dummy = grid[0, KeyboardConstants.MaxColumns],
                Throws.InstanceOf <ArgumentOutOfRangeException>()
                .With.Property("ParamName")
                .EqualTo("column")
                .And.Property("ActualValue")
                .EqualTo(KeyboardConstants.MaxColumns));
        }