Beispiel #1
0
        private void contextMenuStrip_Opened(object sender, EventArgs e)
        {
            bool canStart  = false;
            bool canPause  = false;
            bool canCancel = false;

            if (listView.SelectedItems.Count > 0)
            {
                canCancel = true;
            }

            foreach (ListViewItem item in listView.SelectedItems)
            {
                Downloader.Download download = item.Tag as Downloader.Download;
                if (download.IsRunning)
                {
                    canPause = true;
                }
                else
                {
                    canStart = true;
                }
            }

            startToolStripMenuItem.Enabled  = canStart;
            pauseToolStripMenuItem.Enabled  = canPause;
            cancelToolStripMenuItem.Enabled = canCancel;
        }
Beispiel #2
0
        private void cancelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in listView.SelectedItems)
            {
                Downloader.Download download = item.Tag as Downloader.Download;
                download.Cancel();
            }

            UpdateView();
        }
Beispiel #3
0
        private void pauseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in listView.SelectedItems)
            {
                Downloader.Download download = item.Tag as Downloader.Download;
                if (download.IsRunning)
                {
                    download.Stop();
                }
            }

            UpdateView();
        }