Ejemplo n.º 1
0
        private void listBox1_KeyDown(object sender, KeyEventArgs e)
        {
            string clipboardUrl = Clipboard.GetText();

            // look for ctrl v
            if (e.Control && e.KeyCode == Keys.V)// && _urlManager.isValidUrl(clipboardUrl))
            {
                e.SuppressKeyPress = false;

                // add dictionary to keep track of names and urls
                var url = new YoutubeUrl(Downloader.getWebsiteTitle(Clipboard.GetText()), clipboardUrl);
                _urlManager.AddUrl(url);

                // only add urls not already in the list
                if (!_urls.Contains(clipboardUrl))
                {
                    _urls.Add(url.title);

                    listBox1.DataSource = null;
                    listBox1.DataSource = _urls;
                }
            }
            else
            {
                e.SuppressKeyPress = true;
                //MessageBox.Show(string.Format("Url: {0} not valid", clipboardUrl));
            }
        }
Ejemplo n.º 2
0
 public void AddUrl(YoutubeUrl url)
 {
     _urls.Add(url);
 }