Exemplo n.º 1
0
        private void _infoWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _infoResult = _infoWorker.Manager;
            _infoWorker.RunWorkerCompleted -= _infoWorker_RunWorkerCompleted;
            _infoWorker = null;

            int i = 0;

            foreach (var streamInfo in _infoResult.Streams)
            {
                var radio = new MaterialRadioButton();
                radio.Text            = streamInfo.ToString();
                radio.Size            = new Size(250, 18);
                radio.Location        = new Point(20, 122 + i * 20);
                radio.CheckedChanged += Radio_CheckedChanged;
                tabPage1.Controls.Add(radio);
                i++;
                _streamButtons.Add(radio, streamInfo);
            }

            if (_streamButtons.Count > 0)
            {
                txtFilename.Text = _infoResult.GetValidFileName(_infoResult.Streams.Last());
                pictureBox.Image = _infoResult.PosterImage;
                _streamButtons.Last().Key.Checked = true;
                btnStartDownload.Visible = true;
            }
            else
            {
                lblStatus.Text = "Status: Could not find stream";
            }
        }
Exemplo n.º 2
0
        private void txtUrl_TextChanged(object sender, EventArgs e)
        {
            _infoResult = null;
            btnStartDownload.Visible = false;

            foreach (var kvp in _streamButtons)
            {
                kvp.Key.CheckedChanged -= Radio_CheckedChanged;
                tabPage1.Controls.Remove(kvp.Key);
            }
            _streamButtons.Clear();
            pictureBox.Image = null;

            bool validUrl = IsValidUrl(txtUrl.Text);

            if (Math.Abs(txtUrl.TextLength - _previousLength) > 1 && validUrl)
            {
                _infoWorker = new InfoBackgroundWorker(txtUrl.Text);
                _infoWorker.RunWorkerCompleted += _infoWorker_RunWorkerCompleted;
                _infoWorker.RunWorkerAsync();
            }
            _previousLength = txtUrl.TextLength;
        }