コード例 #1
0
ファイル: MainGui.cs プロジェクト: amhood/PhotoSelect
        //delete selected photos buttun
        private void button1_Click(object sender, EventArgs e)
        {
            const string message = "you are going to delete all the selected photos,\n it means you will lose that picture completely. \n\nARE YOU SURE THAT YOU WANT TO DO THESE?";
            const string caption = "Delete Files";
            var          result  = MessageBox.Show(message, caption,
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Warning);

            // If the no button was pressed ...
            if (result == DialogResult.No)
            {
                return;
            }
            //dispose all memmory in use
            PictureResult.Image = null;
            pictureBox.Image    = null;
            PicLastRes.Image    = null;
            image.Dispose();
            //send to delete function if checked
            for (int i = 0; i < DeleteList.Items.Count; i++)
            {
                if (DeleteList.GetItemChecked(i))
                {
                    TryToDelete(DeleteList.Items[i].ToString());
                    itemsToDelete[i] = null;
                }
            }
            DeleteList.Items.Clear();
            for (int i = 0; i < itemsToDelete.Count; i++)
            {
                if (itemsToDelete[i] != null)
                {
                    DeleteList.Items.Add(itemsToDelete[i].ToString());
                }
            }
        }