예제 #1
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);
        }
예제 #2
0
        public static void DrawText(string text, int sdPos)
        {
            using (var deck = StreamDeck.OpenDevice())
            {
                var key = KeyBitmap.FromGraphics(g =>
                {
                    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", 24);
                    g.DrawString(text, f, Brushes.White, new PointF(12, 20));
                });
                deck.SetKeyBitmap(sdPos, key);
                Thread.Sleep(500);
            }
        }