Example #1
0
        private void OnTimer200msTick(object sender, EventArgs e)
        {
            // Populate chat feed box
            List <string> offloadBuffer = BotTools.ConsoleBuffer;

            BotTools.ClearConsoleBuffer();

            // Color lines
            foreach (string line in offloadBuffer)
            {
                int startIndex = rtbChatFeed.Text.Length;
                rtbChatFeed.AppendText(line + '\n');
                rtbChatFeed.Select(startIndex, line.Length);
                rtbChatFeed.SelectionColor = GetNextColor();
                if (rtbChatFeed.SelectedText.StartsWith("○"))
                {
                    rtbChatFeed.SelectionBackColor = GetNextColor();//Color.FromArgb(192, 21, 72);
                    rtbChatFeed.SelectionColor     = Color.FromArgb(0, 0, 0);
                    rtbChatFeed.SelectionFont      = new Font(rtbChatFeed.Font, FontStyle.Bold);
                }
                rtbChatFeed.DeselectAll();
            }

            // Untick SubMenu checkboxes
            cbWit.Checked      = witTrainerForm.Visible;
            cbPlaylist.Checked = playlistManagerForm.Visible || playlistManagerForm.importForm.Visible;

            // Update Twitch connection window
            bool channelJoined = TwitchBot.Client.JoinedChannels.Count != 0;

            btnJoinChannel.Enabled  = !channelJoined && !String.IsNullOrEmpty(tbChannel.Text);
            btnLeaveChannel.Enabled = channelJoined;
            tbChannel.Enabled       = !channelJoined;
            if (!channelJoined && !pnlTwitchConnect.Visible)
            {
                try
                {
                    TwitchBot.JoinChannel(BotTools.Settings["twitch_channel"]);
                }
                catch { }
            }

            // Flash LIVE display if stream is live + hosting
            if (TwitchBot.StreamStatus == StreamState.OnlineHosting)
            {
                timerFlashLive.Enabled = true;
                timerLiveAlert.Enabled = true;
            }
            else
            {
                timerFlashLive.Enabled = false;
                timerLiveAlert.Enabled = false;

                pbLive.BackgroundImage.Dispose();
                pbLive.BackgroundImage = (int)TwitchBot.StreamStatus % 2 == 0 ? Properties.Resources.live_on : Properties.Resources.live_off;
            }

            // Music Player Work/Feed
            SetPlayerControlsEnabled(Music.LoadedSong != null);


            if (!bgwCycleAudioQueue.IsBusy)
            {
                bgwCycleAudioQueue.RunWorkerAsync();
            }

            pnlPlayerPanel.Visible = !playerStopped;

            if (windowsMP.currentMedia != null && windowsMP.playState == WMPLib.WMPPlayState.wmppsPlaying && draggingTracker == false)
            {
                // Display source video title
                if (Music.LoadedSong != null && Music.LoadedSong.Requestor == "RazBot")
                {
                    var playerFeed = $"Playing: {Music.LoadedSong.Title}";
                    if (rtbPlayerFeed.Text != playerFeed)
                    {
                        rtbPlayerFeed.Text = playerFeed;
                    }
                }
                else if (Music.DownloadedSong != null)
                {
                    var playerFeed = $"Playing {Music.LoadedSong.Requestor}'s Request: {Music.LoadedSong.Title}";
                    if (rtbPlayerFeed.Text != playerFeed)
                    {
                        rtbPlayerFeed.Text = playerFeed;
                        rtbPlayerFeed.Select(8, Music.LoadedSong.Requestor.Length);
                        rtbPlayerFeed.SelectionColor = Color.FromArgb(255, 35, 255);
                        btnAddToDefault.Enabled      = true;
                    }
                }
                // Save player feed to file for external use
                BotTools.DumpToTextFile(rtbPlayerFeed.Text, "datasources\\now_playing");

                // Update tracking bar
                double position = windowsMP.Ctlcontrols.currentPosition / windowsMP.currentMedia.duration * 100;
                trackPosition.Value = Math.Min(Math.Max((int)position, 0), 100);
            }
            else if (downloadingAudio == true)
            {
                // Show download progress in player feed
                int progress = (int)(downloadProgress * 100);
                rtbPlayerFeed.Text = $"Downloading: {progress}%";
            }
            else if (normalizingAudio == true)
            {
                rtbPlayerFeed.Text = $"Normalizing audio...";
            }
            else if (draggingTracker == false)
            {
                // Show tracker position in player feed
                if (rtbPlayerFeed.Text != idleMessage)
                {
                    rtbPlayerFeed.Text = idleMessage;
                }
                BotTools.DumpToTextFile(idleMessage, "datasources\\now_playing");
                if (!playerStopped)
                {
                    btnAddToDefault.Enabled = false;
                }
            }
        }