public async Task ShowColor(int keyID, byte r, byte g, byte b)
 {
     await this.ConnectionWrapper((deck) =>
     {
         KeyBitmap bitmap = KeyBitmap.FromRGBColor(r, g, b);
         deck.SetKeyBitmap(keyID, bitmap);
         return(Task.FromResult(0));
     });
 }
Exemplo n.º 2
0
        private void InitDeck(IStreamDeck deck)
        {
            deck.SetBrightness(100);
            deck.ClearKeys();
            var bitmap = KeyBitmap.FromFile(@"Resources\drum.png");

            deck.SetKeyBitmap(0, bitmap);
            var bitmapSad = KeyBitmap.FromFile(@"Resources\trumpet.png");

            deck.SetKeyBitmap(1, bitmapSad);
            var bitmapSnip = KeyBitmap.FromFile(@"Resources\snipping.png");

            deck.SetKeyBitmap(4, bitmapSnip);
        }
 /// <summary>
 /// Sets a background image for all keys
 /// </summary>
 /// <param name="deck"></param>
 /// <param name="bitmap"></param>
 public static void SetKeyBitmap(this IStreamDeck deck, StreamDeckKeyBitmap bitmap)
 {
     for (int i = 0; i < StreamDeckHID.numOfKeys; i++)
     {
         deck.SetKeyBitmap(i, bitmap.rawBitmapData);
     }
 }
        private static void startGame(IStreamDeck deck)
        {
            //suffle memory cards
            openCard[0] = -1;
            openCard[1] = -1;
            mode        = 0;
            suffleArray(gameState, rnd);

            for (int i = 0; i < cardVisible.Length; i++)
            {
                cardVisible[i] = false;
            }

            //Clear all tiles (except restart key)
            for (int i = 0; i < deck.KeyCount; i++)
            {
                if (i != restartKey)
                {
                    deck.ClearKey(i);
                }
            }

            //(Re-)Draw restart key image
            deck.SetKeyBitmap(restartKey, restartIcon);
        }
 /// <summary>
 /// Sets a background image for all keys
 /// </summary>
 /// <param name="deck"></param>
 /// <param name="bitmap"></param>
 public static void SetKeyBitmap(this IStreamDeck deck, KeyBitmap bitmap)
 {
     for (int i = 0; i < deck.KeyCount; i++)
     {
         deck.SetKeyBitmap(i, bitmap);
     }
 }
Exemplo n.º 6
0
        static void ExampleWithSystemDrawing(IStreamDeck deck)
        {
            //Create a key with lambda graphics
            var key = KeyBitmap.FromGraphics(g =>
            {
                //See https://stackoverflow.com/questions/6311545/c-sharp-write-text-on-bitmap for details
                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

                //Fill background black
                g.FillRectangle(Brushes.Black, 0, 0, deck.IconSize, deck.IconSize);

                //Write text to graphics
                var f = new Font("Arial", 13);
                g.DrawString("Drawing", f, Brushes.White, new PointF(5, 20));

                //Draw other stuff to image
                //g.DrawImage
                //g.DrawLine
            });

            deck.SetKeyBitmap(7, key);
        }
Exemplo n.º 7
0
 public static void DrawFullScreenBitmap(this IStreamDeck deck, byte[] imgData)
 {
     for (int i = 0; i < deck.KeyCount; i++)
     {
         var img = GetKeyImageFromFull(i, imgData);
         deck.SetKeyBitmap(i, img);
     }
 }
        private static void refreshKeyIcon(IStreamDeck deck, int cardId)
        {
            var keyId = cardId >= restartKey ? cardId + 1 : cardId;

            if (cardVisible[cardId])
            {
                if ((openCard[0] == cardId || openCard[1] == cardId))
                {
                    deck.SetKeyBitmap(keyId, iconsInactive[gameState[cardId]]);
                }
                else
                {
                    deck.SetKeyBitmap(keyId, iconsActive[gameState[cardId]]);
                }
            }
            else
            {
                deck.SetKeyBitmap(keyId, KeyBitmap.Black);
            }
        }
Exemplo n.º 9
0
        private static void InitDeck(IStreamDeck deck)
        {
            deck.SetBrightness(100);
            deck.ClearKeys();
            var bitmap = KeyBitmap.FromFile(@"C:\Users\oddva\Downloads\streamdeck_key.png");

            deck.SetKeyBitmap(1, bitmap);
            var bitmapTBK = KeyBitmap.FromFile(@"C:\Users\oddva\Downloads\tbk.png");

            deck.SetKeyBitmap(0, bitmapTBK);
            var bitmapPanic = KeyBitmap.FromFile(@"C:\Users\oddva\Downloads\power_icon.png");

            deck.SetKeyBitmap(4, bitmapPanic);
            var bitmapCopy1 = KeyBitmap.FromRGBColor(55, 200, 55);

            deck.SetKeyBitmap(10, bitmapCopy1);
            var bitmapCopy2 = KeyBitmap.FromRGBColor(255, 200, 55);

            deck.SetKeyBitmap(11, bitmapCopy2);
        }
Exemplo n.º 10
0
 public void renderPage()
 {
     if (Deck != null)
     {
         var i = 0;
         CurrentPage.Keys.TrimExcess();
         foreach (var key in CurrentPage.Keys)
         {
             Deck.SetKeyBitmap(i, key.getImage());
             ++i;
         }
     }
 }
        public static void DrawFullScreenBitmap(this IStreamDeck deck, Bitmap b)
        {
            byte[] imgData = null;
            using (var resizedImage = ResizeToFullStreamDeckImage(b))
            {
                imgData = GetRgbArray(resizedImage);
            }

            for (int i = 0; i < deck.KeyCount; i++)
            {
                var img = GetKeyImageFromFull(i, imgData);
                deck.SetKeyBitmap(i, img);
            }
        }
Exemplo n.º 12
0
        static void ExampleWithWpfElement(IStreamDeck deck)
        {
            var c = new Canvas();

            c.Width      = deck.IconSize;
            c.Height     = deck.IconSize;
            c.Background = System.Windows.Media.Brushes.Black;

            var t = new TextBlock();

            t.Text       = "WPF";
            t.FontFamily = new System.Windows.Media.FontFamily("Arial");
            t.FontSize   = 13;
            t.Foreground = System.Windows.Media.Brushes.White;

            Canvas.SetLeft(t, 10);
            Canvas.SetTop(t, 10);

            c.Children.Add(t);

            var k = KeyBitmap.FromWpfElement(c);

            deck.SetKeyBitmap(7, k);
        }
 /// <summary>
 /// Sets background to black for all given keys
 /// </summary>
 /// <param name="deck"></param>
 public static void ClearKeys(this IStreamDeck deck)
 {
     deck.SetKeyBitmap(StreamDeckKeyBitmap.Black);
 }
 /// <summary>
 /// Sets background to black for a given key
 /// </summary>
 /// <param name="deck"></param>
 /// <param name="keyId"></param>
 public static void ClearKey(this IStreamDeck deck, int keyId)
 {
     deck.SetKeyBitmap(keyId, StreamDeckKeyBitmap.Black);
 }
 /// <summary>
 /// Sets a background image for a given key
 /// </summary>
 /// <param name="deck"></param>
 /// <param name="keyId"></param>
 /// <param name="bitmap"></param>
 public static void SetKeyBitmap(this IStreamDeck deck, int keyId, StreamDeckKeyBitmap bitmap)
 {
     deck.SetKeyBitmap(keyId, bitmap.rawBitmapData);
 }