private void saveButton_Click(object sender, EventArgs e) { if (personInfo.ID >= 0) { Bitmap informationBitmap = ImageHandling.GetBitmapFromPanel(InformationPanel); SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Image"; saveDialog.Filter = "Image file (.PNG)|*.png"; if (personPictureBox.BackgroundImage != Properties.Resources.NoImage) { Bitmap pictureBitmap = (Bitmap)personPictureBox.BackgroundImage; ComposeImage ci = new ComposeImage(new Size(pictureBitmap.Width + informationBitmap.Width, pictureBitmap.Height + informationBitmap.Height)); ci.Images.Add(new ImagePart(new Point(0, 0), pictureBitmap)); ci.Images.Add(new ImagePart(new Point(0, pictureBitmap.Height), informationBitmap)); if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ImageHandling.SaveImage(ci.ComposeTheImage(), saveDialog.FileName, ImageFormat.Png); pictureBitmap.Dispose(); } } else if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ImageHandling.SaveImage(informationBitmap, saveDialog.FileName, ImageFormat.Png); } informationBitmap.Dispose(); saveDialog.Dispose(); } else { MessageBox.Show("No person selected.", "Tennis Management Software", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { Bitmap informationBitmap = ImageHandling.GetBitmapFromPanel(InformationPanel); Rectangle rect = e.MarginBounds; if (personPictureBox.BackgroundImage != Properties.Resources.NoImage) { Bitmap pictureBitmap = (Bitmap)personPictureBox.BackgroundImage; ComposeImage ci = new ComposeImage(new Size(pictureBitmap.Width + informationBitmap.Width, pictureBitmap.Height + informationBitmap.Height)); ci.Images.Add(new ImagePart(new Point(0, 0), pictureBitmap)); ci.Images.Add(new ImagePart(new Point(0, pictureBitmap.Height), informationBitmap)); rect = ImageHandling.GetResizedRectBoundsFromBitmap(ci.ComposeTheImage(), rect); e.Graphics.DrawImage(ci.ComposeTheImage(), rect); } else { rect = ImageHandling.GetResizedRectBoundsFromBitmap(informationBitmap, rect); e.Graphics.DrawImage(informationBitmap, rect); } informationBitmap.Dispose(); }