Example #1
0
        private void addImageButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = false;
            fileDialog.CheckFileExists = true;
            fileDialog.CheckPathExists = true;
            // Only find compatible images
            fileDialog.Filter = "PNG(*.PNG)|*.PNG|" +
                "JPEG (*.JPG;*.JPEG;*.JPE;*.JFIF)|*.JPG;*.JPEG;*.JPE;*.JFIF|"+
                "GIF (*.GIF)|*.GIF|"+
                "BMP (*.BMP;*.DIB;*.RLE)|*.BMP;*.DIB;*.RLE|" +
                "TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF";

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                Picture pic = new Picture(new Bitmap(fileDialog.FileName));
                currentDoc.Images.Add(pic);
                imageList.Images.Add(pic.Image);

                ListViewItem item = new ListViewItem();
                item.ImageIndex = imageList.Images.Count -1;
                item.Tag = pic;
                listView.Items.Add(item);

                modified = true;
                saveButton.Enabled = true;
            }
        }
Example #2
0
        public static void DeletePicture(string projectId, Picture picture)
        {
            string pictureId = picture.Id;
            picture.Image.Dispose();
            string fileName = projectId + "\\" + pictureId + ".JPG";

            // Checks if a filename exists, if it does, delete it.
            if (File.Exists(fileName))
            {
                try
                {
                    File.Delete(fileName);
                }
                catch (IOException)
                {
                    Debug.Print("Could not Delete picture named " + fileName + " because the program could not access the file.");
                }
            }
            else
            {
                Console.WriteLine("No file exists by that name");
            }
        }
Example #3
0
 public static void DeletePicture(string projectId, Picture picture)
 {
     Storage.DeletePicture(projectId, picture);
 }
Example #4
0
 private static void SavePictureToFile(Picture pic, string path)
 {
     try
     {
         // Create a Bitmap object from the image, and save that in the projects folder.
         Bitmap b = new Bitmap(pic.Image);
         b.Save(path);
     }
     catch (Exception)
     {
         Console.WriteLine("Could not save Image");
     }
 }