/// <summary> /// Responds to the event when user has selected a file name to save and pressed 'OK' button. /// </summary> private void ExportAsExcel(object sender, CancelEventArgs e) { var fd = (Forms20.SaveFileDialog)sender; var fileName = fd.FileName; var fileNameWithoutPath = Path.GetFileName(fileName); StatusText.Content = string.Format("Exporting data to {0} file is in progress...", fileNameWithoutPath); ThreadPool.QueueUserWorkItem((state) => { Dispatcher.Invoke(delegate { OSLEBotDataGrid.ExportToExcel(fileName); StatusText.Content = string.Format("Data export to {0} completed", fileNameWithoutPath); }); }); }
/// <summary> /// Responds to the event when user has selected a file name to save and pressed 'OK' button. /// </summary> private void ExportAsXps(object sender, CancelEventArgs e) { var fd = (Forms20.SaveFileDialog)sender; var fileName = fd.FileName; var fileNameWithoutPath = Path.GetFileName(fileName); StatusText.Content = string.Format("Exporting data to {0} file is in progress...", fileNameWithoutPath); ThreadPool.QueueUserWorkItem((state) => { const double a4Width = 8.3 * 96; //inches * dpi const double a4Height = 11.7 * 96; //inches * dpi Dispatcher.Invoke(delegate { OSLEBotDataGrid.ExportToXps(fileName, new Size(a4Width, a4Height), true); StatusText.Content = string.Format("Data export to {0} completed", fileNameWithoutPath); }); }); }