Exemplo n.º 1
0
        private void Delete_Item()
        {
            DialogResult Rep;

            if (TV_Folders.Focused)
            {
                if (!(TV_Folders.SelectedNode == null))
                {
                    Rep = MessageBox.Show("Do you really want remove selected record event from the disk ?",
                                          Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (Rep.Equals(DialogResult.Yes))
                    {
                        Directory.Delete(TV_Folders.SelectedNode.Tag.ToString(), true);

                        while (Directory.Exists(TV_Folders.SelectedNode.Tag.ToString()))
                        {
                            System.Threading.Thread.Sleep(1);
                        }

                        TV_Folders.Nodes.Remove(TV_Folders.SelectedNode);
                        UpDate_FolderTree(RootPath);
                    }
                }
            }
            else if (LV_Sessions.Focused)
            {
                if (LV_Sessions.SelectedItems.Count > 0)
                {
                    Rep = MessageBox.Show("Do you really want remove selected record sessions from the disk ?",
                                          Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (Rep.Equals(DialogResult.Yes))
                    {
                        foreach (ListViewItem It in LV_Sessions.SelectedItems)
                        {
                            object[] ItTags = (object[])It.Tag;
                            Directory.Delete(ItTags[0].ToString(), true);
                            LV_Sessions.Items.Remove(It);
                        }

                        UpDate_FolderTree(RootPath);
                    }
                }
            }
            else if (LV_Files.Focused)
            {
                if (LV_Files.SelectedItems.Count > 0)
                {
                    Rep = MessageBox.Show("Do you really want remove selected files from the disk ?",
                                          Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (Rep.Equals(DialogResult.Yes))
                    {
                        foreach (ListViewItem It in LV_Files.SelectedItems)
                        {
                            object[] ItTags = (object[])It.Tag;
                            File.Delete(ItTags[0].ToString());
                            LV_Files.Items.Remove(It);
                        }

                        Color_FileItems();
                    }
                }
            }
        }