pop up d'une image, au click
Bonjour,
j'ai crée un control chart avec Ms chart pour une application winform
et je souhaiterai afficher en grand l'image du chart lors du clik sur ce dernier.
je ne sais pas si les pop menu existent en c#
sinon il existe l'alternative d'afficher l'image dans un nouveau formulaire temporaire comme ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| chartIta.Size = new Size(740, 580);
Form frmDisplay = new Form();
frmDisplay.ShowInTaskbar = false;
frmDisplay.StartPosition = FormStartPosition.CenterParent;
frmDisplay.Size = new Size(740, 580);
// create a memory stream to save the chart image
System.IO.MemoryStream stream = new System.IO.MemoryStream();
// save the chart image to the stream
chartIta.SaveImage(stream,System.Drawing.Imaging.ImageFormat.Bmp);
// create a bitmap using the stream
Bitmap ImagePlot = new Bitmap(stream);
// put the image in a control box
PictureBox picBox = new PictureBox();
picBox.Size = new Size(740, 580);
picBox.Dock = DockStyle.Fill;
ImagePlot.Size = new Size(740, 580);
frmDisplay.Controls.Add(picBox);
frmDisplay.ShowDialog();
stream.Dispose(); |
Mon probleme est que la fonction Dock n'agrandit pas l'image dans la nouvelle fenetre,
y aurait moyen de faire plus simple, quelqu'un a-t'il deja eu affaire a une situation pareil.
merci ?
Solution, Serializer et MemoryStream
J'ai trouver un moyen de le faire,
en copiant le chart dans un autre chart temporaire eten affichant ce dernier,
pour cela j'utilise un memorystream,
Code:
1 2 3 4 5 6 7
| Chart tempChart = new Chart();
MemoryStream ms = new MemoryStream();
myChart.Serializer.Save(ms);
// Load data from memory stream into the temp chart
ms.Seek(0, SeekOrigin.Begin);
tempChart.Serializer.Load(ms);
//a present je dispose de la copie de myChart |
voila