public async Task Disconnect()
        {
            await this.ConnectionWrapper((deck) =>
            {
                deck.ClearKeys();
                deck.ConnectionStateChanged -= Deck_ConnectionStateChanged;
                deck.KeyStateChanged        -= Deck_KeyStateChanged;
                return(Task.FromResult(0));
            });

            this.deck.Dispose();
            this.deck = null;
        }
예제 #2
0
 private void onApplicationExit(object sender, EventArgs e)
 {
     if (Deck != null)
     {
         Deck.ClearKeys();
         Deck.SetBrightness(0);
     }
 }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        public DeckHandler()
        {
            //Load the default profile
            var path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/OpenStreamDeck/profiles/default.json";

            try
            {
                CurrentProfile = ProfileManager.loadProfile(path);
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("An error occurred while loading your default profile. Generating a new default profile. ({0})", e.Message));
                if (CurrentProfile == null)
                {
                    CurrentProfile = new Profile("Default");
                    ProfileManager.saveProfile(CurrentProfile);
                }
            }

            try
            {
                Deck = StreamDeck.FromHID();
            }
            catch (Exception e)
            {
                //MessageBox.Show(String.Format("Cannot connect to StreamDeck ({0})", e.Message));
                Debug.WriteLine("Cannot connect to StreamDeck {0}", e.Message);
                return;
            }
            Application.ApplicationExit += onApplicationExit;
            Deck.ClearKeys();
            Deck.SetBrightness(DeckBrightness);
            Deck.KeyPressed         += onKeyPressed;
            KeyPressedTimer          = new System.Timers.Timer();
            KeyPressedTimer.Interval = 10;
            KeyPressedTimer.Elapsed += onKeyHeld;

            CurrentPage = CurrentProfile.MainPage;
            PageStack   = new Stack <Page>();
            renderPage();
        }