Пример #1
0
        public void RefreshStreamDeckPage()
        {
            if (ButtonMatrixPanel == null || MainWindowPanel == null)
            {
                return;
            }

            for (int i = 0; i < 15; i++)
            {
                Bitmap bmp_up            = ButtonMatrixPanel.btnList[i].GetRenderBitmap();
                Bitmap bmp_down          = ButtonMatrixPanel.btnList[i].GetRenderBitmap(true);
                StreamDeckKeyBitmap sdkb = StreamDeckKeyBitmap.FromDrawingBitmap(bmp_up);
                if (Deck != null)
                {
                    Deck.SetKeyBitmap(i, sdkb);
                }

                // Save bitmap to ButtonData
                if (ButtonMatrixPanel.btnList[i].DataContext != null)
                {
                    (ButtonMatrixPanel.btnList[i].DataContext as ButtonData).ButtonBitmapBuf_UP   = bmp_up;
                    (ButtonMatrixPanel.btnList[i].DataContext as ButtonData).ButtonBitmapBuf_DOWN = bmp_down;
                }
            }
        }
Пример #2
0
        private void Deck_KeyPressed(object sender, StreamDeckKeyEventArgs e)
        {
            var d = sender as IStreamDeck;

            if (d == null)
            {
                return;
            }

            if (Deck == null)
            {
                return;
            }

            if (e.IsDown)
            {
                if (DateTime.Now - lastKeyPress < TimeSpan.FromMilliseconds(250))
                {
                    return;
                }

                lastKeyPress = DateTime.Now;
                // Key Down
                MainWindowPanel.Dispatcher.Invoke(() =>
                {
                    Bitmap bmp = (ButtonMatrixPanel.btnList[e.Key].DataContext as ButtonData).ButtonBitmapBuf_DOWN;
                    StreamDeckKeyBitmap sdkb = StreamDeckKeyBitmap.FromDrawingBitmap(bmp);
                    Deck.SetKeyBitmap(e.Key, sdkb);
                    ButtonData bd = ButtonMatrixPanel.btnList[e.Key].DataContext as ButtonData;
                    ButtonFuncProcess(bd);
                });
            }
            else
            {
                // Key up
                MainWindowPanel.Dispatcher.Invoke(() =>
                {
                    Bitmap bmp = (ButtonMatrixPanel.btnList[e.Key].DataContext as ButtonData).ButtonBitmapBuf_UP;
                    StreamDeckKeyBitmap sdkb = StreamDeckKeyBitmap.FromDrawingBitmap(bmp);
                    Deck.SetKeyBitmap(e.Key, sdkb);
                });
            }
        }