public ActiveStreamersEventArgs(TwitchActiveStreamer[] activeStreamers, TwitchLiveStreamersLongPressAction longPressAction, int numberOfKeys, int currentPage)
 {
     ActiveStreamers = activeStreamers;
     NumberOfKeys    = numberOfKeys;
     CurrentPage     = currentPage;
     LongPressAction = longPressAction;
 }
        public async void ShowActiveStreamers(TwitchActiveStreamer[] streamers, TwitchLiveStreamersLongPressAction longPressAction)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"ShowActiveStreamers called");
            StopFlashAndReset();

            await SwitchToFullScreen();

            // Wait until the UI Action keys have subscribed to get events
            int retries = 0;

            while (!IsReady && retries < 60)
            {
                Thread.Sleep(100);
                retries++;
            }
            if (!IsReady)
            {
                Logger.Instance.LogMessage(TracingLevel.WARN, "Could not get full screen ready!");
                await connection.SwitchProfileAsync(null);

                return;
            }
            StopFlashAndReset();
            streamersEventArgs = new ActiveStreamersEventArgs(streamers, longPressAction, numberOfKeys, 0);

            ActiveStreamersChanged?.Invoke(this, streamersEventArgs);
        }
Esempio n. 3
0
        private async void Instance_ActiveStreamersChanged(object sender, ActiveStreamersEventArgs e)
        {
            flashMode                    = FlashMode.ActiveStreamers;
            pagedSequentialKey           = e.CurrentPage * (e.NumberOfKeys - 2) + sequentialKey;
            channelName                  = String.Empty;
            liveStreamersLongPressAction = e.LongPressAction;
            if (sequentialKey == 0)
            {
                await Connection.SetTitleAsync("Exit");
            }
            else if (e.ActiveStreamers != null && sequentialKey == e.NumberOfKeys - 1 && e.ActiveStreamers.Length > pagedSequentialKey) // There is more than one page
            {
                await Connection.SetTitleAsync(">>");

                numberOfElements = e.ActiveStreamers.Length;
                numberOfKeys     = e.NumberOfKeys;
            }
            else if (e.ActiveStreamers != null && e.ActiveStreamers.Length >= pagedSequentialKey) // >= because we're doing -1 as we're starting on the second key
            {
                var streamerInfo = e.ActiveStreamers[pagedSequentialKey - 1];
                using (Image image = FetchImage(streamerInfo.PreviewImages.Template.Replace(PREVIEW_IMAGE_WIDTH_TOKEN, PREVIEW_IMAGE_WIDTH_PIXELS.ToString()).Replace(PREVIEW_IMAGE_HEIGHT_TOKEN, PREVIEW_IMAGE_HEIGHT_PIXELS.ToString())))
                {
                    await DrawStreamerImage(streamerInfo, image);
                }
                channelName = streamerInfo?.Channel?.Name;
            }
        }
        private async void Instance_ActiveStreamersChanged(object sender, ActiveStreamersEventArgs e)
        {
            flashMode                    = FlashMode.ActiveStreamers;
            pagedSequentialKey           = e.CurrentPage * (e.NumberOfKeys - NUMBER_OF_SPECIAL_KEYS) + sequentialKey; // -3 for the Exit, Back, Next buttons
            channelName                  = String.Empty;
            liveStreamersLongPressAction = e.LongPressAction;
            if (sequentialKey == 0)
            {
                await Connection.SetTitleAsync("Exit");
            }
            else if (e.ActiveStreamers != null && sequentialKey == e.NumberOfKeys - 1 && e.ActiveStreamers.Length > e.NumberOfKeys - 3) // Last (Next) key, and there is more than one page *overall*
            {
                if (e.ActiveStreamers.Length + NUMBER_OF_SPECIAL_KEYS < pagedSequentialKey)                                             // We are on last page
                {
                    await Connection.SetTitleAsync(null);
                }
                else
                {
                    await Connection.SetTitleAsync(">>");
                }
                numberOfElements = e.ActiveStreamers.Length;
                numberOfKeys     = e.NumberOfKeys;
            }
            else if (e.ActiveStreamers != null && sequentialKey == e.NumberOfKeys - 2 && e.ActiveStreamers.Length > e.NumberOfKeys - 3) // Prev key, and there is more than one page *overall*
            {
                if (sequentialKey == pagedSequentialKey)                                                                                // We are on the first page
                {
                    await Connection.SetTitleAsync(null);
                }
                else
                {
                    await Connection.SetTitleAsync("<<");
                }
                numberOfElements = e.ActiveStreamers.Length;
                numberOfKeys     = e.NumberOfKeys;
            }
            else if (e.ActiveStreamers != null && e.ActiveStreamers.Length >= pagedSequentialKey) // >= because we're doing -1 as we're starting on the second key
            {
                await Connection.SetTitleAsync(null);

                var streamerInfo = e.ActiveStreamers[pagedSequentialKey - 1];
                using (Image image = FetchImage(streamerInfo.PreviewImages.Template.Replace(PREVIEW_IMAGE_WIDTH_TOKEN, PREVIEW_IMAGE_WIDTH_PIXELS.ToString()).Replace(PREVIEW_IMAGE_HEIGHT_TOKEN, PREVIEW_IMAGE_HEIGHT_PIXELS.ToString())))
                {
                    await DrawStreamerImage(streamerInfo, image);
                }
                channelName = streamerInfo?.Channel?.Name;
            }
        }
        public async void ShowActiveStreamers(TwitchActiveStreamer[] streamers, TwitchLiveStreamersLongPressAction longPressAction)
        {
            Logger.Instance.LogMessage(TracingLevel.INFO, $"ShowActiveStreamers called");
            StopFlashAndReset();

            switch (connection.DeviceInfo().Type)
            {
            case StreamDeckDeviceType.StreamDeckClassic:
                await connection.SwitchProfileAsync("FullScreenAlert");

                break;

            case StreamDeckDeviceType.StreamDeckMini:
                await connection.SwitchProfileAsync("FullScreenAlertMini");

                break;

            case StreamDeckDeviceType.StreamDeckXL:
                await connection.SwitchProfileAsync("FullScreenAlertXL");

                break;

            default:
                Logger.Instance.LogMessage(TracingLevel.WARN, $"SwitchProfileAsync: Unsupported device type: {connection.DeviceInfo().Type}");
                break;
            }

            // Wait until the UI Action keys have subscribed to get events
            int retries = 0;

            while (!IsReady && retries < 60)
            {
                Thread.Sleep(100);
                retries++;
            }
            if (!IsReady)
            {
                Logger.Instance.LogMessage(TracingLevel.WARN, "Could not get full screen ready!");
                await connection.SwitchProfileAsync(null);

                return;
            }
            StopFlashAndReset();
            streamersEventArgs = new ActiveStreamersEventArgs(streamers, longPressAction, numberOfKeys, 0);

            ActiveStreamersChanged?.Invoke(this, streamersEventArgs);
        }