コード例 #1
0
        public StreamDeckModel()
        {
            for (int i = 0; i < KeyCount; ++i)
            {
                ImageSources[i] = new WriteableBitmap(ImageWidth, ImageHeight, 96, 96, PixelFormats.Bgr24, null);
            }

            using (Graphics g = Graphics.FromImage(maskBitmap))
            {
                g.Clear(System.Drawing.Color.Black);


                int diameter = 32;
                var arc      = new Rectangle(0, 0, diameter, diameter);
                var path     = new GraphicsPath();

                // top left arc
                path.AddArc(arc, 180, 90);

                // top right arc
                arc.X = ImageWidth - diameter;
                path.AddArc(arc, 270, 90);

                // bottom right arc
                arc.Y = ImageHeight - diameter;
                path.AddArc(arc, 0, 90);

                // bottom left arc
                arc.X = 0;
                path.AddArc(arc, 90, 90);

                path.CloseFigure();

                using (path)
                {
                    g.FillPath(new System.Drawing.SolidBrush(System.Drawing.Color.White), path);
                }
            }

            StreamDeck             = StreamDeck.Get();
            StreamDeck.KeyChanged += StreamDeck_KeyChanged;
            StreamDeck.Open();
        }