コード例 #1
0
        private void buttonDeleteMediaIInAdding_Click(object sender, EventArgs e)
        {
            if (this.pictureBox1.Image == null)
            {
                return;
            }
            var item = pictureBox1.Tag.ToString();

            Console.WriteLine(item);
            /*Console.WriteLine(pictureBox1.Name);*/

            /*var itemListed = this.listViewPicsInAdding.Items.Find(item, true).ToList()[0];
             * this.listViewPicsInAdding.Items.Remove(itemListed);*/
            var indexPic = this.listViewPicsInAdding.LargeImageList.Images.IndexOfKey(item);

            /*Console.WriteLine(indexPic);
             * Console.WriteLine("\n");*/
            foreach (ListViewItem itemPic in this.listViewPicsInAdding.Items)
            {
                if (itemPic.ImageIndex == indexPic)
                {
                    this.listViewPicsInAdding.Items.Remove(itemPic);

                    break;
                }
            }
            if (this.listViewPicsInAdding.Items.Count == 0)
            {
                this.pictureBox1.Image = null;
                //Console.WriteLine("this.listViewPicsInAdding.Items.Count == 0");
                //Console.WriteLine(this.listViewPicsInAdding.Items.Count == 0);
                //Console.WriteLine("\n");
            }
            else
            {
                //Console.WriteLine(this.listViewPicsInAdding.Items.Count);
                ListViewItem validare = this.listViewPicsInAdding.Items[0];
                //Console.WriteLine("validare.ImageIndex");
                //Console.WriteLine(validare.ImageIndex);
                /*Console.WriteLine("\n");*/
                this.pictureBox1.Image = this.listViewPicsInAdding.LargeImageList.Images[validare.ImageIndex];
                this.pictureBox1.Tag   = this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex];

                /*Console.WriteLine("this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex]");
                 * Console.WriteLine(this.listViewPicsInAdding.LargeImageList.Images.Keys[validare.ImageIndex]);
                 * Console.WriteLine("\n");*/
            }
            if (!(MediaLibraryFunctions.DeleteMedia(item)))
            {
                ErrForm errForm = new ErrForm("Err occured at DELETE MEDIA");
                errForm.ShowDialog();
            }
        }
コード例 #2
0
        private void buttonDeletePicturesModify_Click(object sender, EventArgs e)
        {
            if (this.pictureBoxModifyProety.Image == null)
            {
                return;
            }
            var item = pictureBoxModifyProety.Tag.ToString();

            Console.WriteLine(item);

            if (!(MediaLibraryFunctions.DeleteMedia(item)))
            {
                ErrForm errForm = new ErrForm("Err occured at DELETE MEDIA");
                errForm.ShowDialog();
            }
            Form.ActiveForm.Close();
        }