The topic says it all.
Using Compact Framework C#
I’m tiling (order/sequence is important) some images that i download from an url, into a Panel(each image is a PictureBox).
This can be a huge process, and may take some time.
Therefor i only want the user to download the images and tile them once. So the next time the user uses the Tile Application, the Panel that was created the first time is already stored in a file and is loaded from that file.
So what i want is a method to store a Panel as a file.
Is this possible, or do you think i should do it another way?
I’ve tried something like this:
BinaryWriter panelStorage = new BinaryWriter(new FileStream("imagePanel.panel", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None));
Byte[] bImageObject = new Byte[20000];
bImageObject = (byte[])(object)this.imagePanel;
panelStorage .Write(bMapObject);
panelStorage .Close();
But the casting was not very legal 😛
“InvalidCastException”
Can anyone help me with this problem?
Thank you in advance!
I wouldn’t serialize the control if I were you. I’d instead serialise the data that goes into the control. There are a couple of reasons.
Firstly, it’s easier. You can take whatever data you are putting in (images) and put them into a custom MyPanel class or whatever. Store information about how they are manipulated in there too, and then you can serialise that class, and it’s done.
The second reason is that if you want to change how the data is displayed or used at a later date, you have a lot more freedom. You can use it in other ways, or with other applications and controls without any real effort on your part.