Пример #1
0
        private async void btnRemove_Click(object sender, EventArgs e)
        {
            TabPage tab = materialTabControl1.SelectedTab;

            if (tab == null)
            {
                return;
            }
            if (tab.Text == "Link")
            {
                int     i    = gridView1.GetSelectedRows().FirstOrDefault();
                tblLink link = gridView1.GetRow(i) as tblLink;
                if (link == null)
                {
                    return;
                }
                await rpLink.DeleteById(link.Id);

                gridView1.DeleteRow(i);
                return;
            }

            if (tab.Text == "Downloaded")
            {
                string       fileName = string.Empty;
                ListViewItem item     = lstViewContent.SelectedItems[0];
                if (item == null)
                {
                    return;
                }
                if (item.Tag == null)
                {
                    item.Tag = "";
                }
                fileName = Path.GetFileName(item.Tag.ToString());
                await rpMovie.DeleteByFullPath(fileName);

                lstViewContent.Items.Remove(item);
                File.Delete(fileName);
            }
        }