private void PictureBoxDoubleClick(object sender, EventArgs e) { int id = GetID(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y)); if (id < 0) { return; } Bitmap origBitmap = _bitmaps[id]; System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); string dimensions = origBitmap.Width + " x " + origBitmap.Height; fileDialog.Filter = "Bitmap images (*.bmp)|*.bmp"; fileDialog.Title = "Please choose a bitmap file with the following dimensions: " + dimensions; DialogResult result = fileDialog.ShowDialog(); if (result == DialogResult.OK) { System.IO.Stream strm = fileDialog.OpenFile(); Bitmap b = new Bitmap(strm); if (b.Width != origBitmap.Width || b.Height != origBitmap.Height) { string fileDims = b.Width + " x " + b.Height; throw new ArgumentException("Size of loaded image (" + fileDims + ") does not match original (" + dimensions + ")"); } // Modify the block with the new images _file.SetBitmap(b, id); _pictureBox.Refresh(); _file.save(); } }