0

I have 2 panels. The first panel shows a list of image files. When a user selects a file its displayed in a picturebox in the right panel. The user is allowed to select an area in the image. I need to save this selection for future use ie. to show the selection when this image is selected again. I intend to use an array with Multiple Data types

[Filename(string),Location(Point),Size(Size)]

Is this approach okay? Is there a better approach to solve this issue?

James Z
  • 12,209
  • 10
  • 24
  • 44
techno
  • 6,100
  • 16
  • 86
  • 192
  • See this simple example: [How to call a method that uses coordinates variables](https://stackoverflow.com/a/53708936/7444103). More or less what the answers here are suggesting. You need a specialized class that can hold all the informations needed to store, serialize and restore the selections key values. The notes there may be interesting. – Jimi Dec 17 '18 at 07:52
  • Also, you can use Jpeg metadata in order to save your parameter permanently. [Here is a good example](https://stackoverflow.com/a/23762564/4527628) – M.Armoun Dec 17 '18 at 08:12

1 Answers1

1

I'd say that the proper thing to do here is to first define a class to store the state associated to a single picturebox:

class PictureboxState
{
  public string Filename { get; set }
  public Point Location { get; set; }
  public Size Size { get; set; }
}

Then you keep an array of instances of this class; or even better, a dictionary where the keys are the pictureboxes (or something else that can identify the picturebox) and the values are the state objects.

Konamiman
  • 49,681
  • 17
  • 108
  • 138