private void ExportBtn_Click(object sender, EventArgs e) { if (SelectedCalendar != null) { SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = SelectedCalendar.Name; dlg.Filter = "Bitmap Image |*.bmp|JPEG Image|*.jpg|GIF Image|*.gif|PNG Image|*.png"; if (dlg.ShowDialog() == DialogResult.OK) { ImageFormat format = ImageFormat.Bmp; switch (dlg.FilterIndex) { case 1: format = ImageFormat.Bmp; break; case 2: format = ImageFormat.Jpeg; break; case 3: format = ImageFormat.Gif; break; case 4: format = ImageFormat.Png; break; } Bitmap bmp = Screenshot.Calendar(CalendarPnl.Calendar, CalendarPnl.MonthIndex, CalendarPnl.Year, new Size(800, 600)); bmp.Save(dlg.FileName, format); } } }
private void ExportBtn_Click(object sender, EventArgs e) { if (this.SelectedCalendar != null) { SaveFileDialog saveFileDialog = new SaveFileDialog() { FileName = this.SelectedCalendar.Name, Filter = "Bitmap Image |*.bmp|JPEG Image|*.jpg|GIF Image|*.gif|PNG Image|*.png" }; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ImageFormat bmp = ImageFormat.Bmp; switch (saveFileDialog.FilterIndex) { case 1: { bmp = ImageFormat.Bmp; break; } case 2: { bmp = ImageFormat.Jpeg; break; } case 3: { bmp = ImageFormat.Gif; break; } case 4: { bmp = ImageFormat.Png; break; } } Bitmap bitmap = Screenshot.Calendar(this.CalendarPnl.Calendar, this.CalendarPnl.MonthIndex, this.CalendarPnl.Year, new System.Drawing.Size(800, 600)); bitmap.Save(saveFileDialog.FileName, bmp); } } }