private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();

            ParsingUtility.IDataExporter dataExporter = null;
            switch (exportComboBox.SelectedItem.ToString())
            {
            case "PDF":
            {
                saveFileDialog.DefaultExt = ".pdf";
                saveFileDialog.Filter     = "Text documents (.pdf)|*.pdf";
                dataExporter = new ParsingUtility.PdfCreator();
            }
            break;

            case "CSV":
            {
                saveFileDialog.DefaultExt = ".csv";
                saveFileDialog.Filter     = "Text documents (.csv)|*.csv";
                dataExporter = new ParsingUtility.CsvCreator();
            }
            break;

            default:
            {
                MessageBox.Show("Choose file type to export to.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            }

            saveFileDialog.FileName = "statisticsData";

            bool?result = saveFileDialog.ShowDialog();

            if (result == true)
            {
                ExportStatisticData(saveFileDialog.FileName, dataExporter, statisticsData, true);
            }
        }
 public void ExportStatisticData(string fileName, ParsingUtility.IDataExporter dataExporter, Model.StatisticsData statisticData, bool openFileAfterFinish = false)
 {
     try
     {
         if (System.IO.File.Exists(fileName))
         {
             System.IO.File.Delete(fileName);
         }
         dataExporter.ExportData(fileName, statisticsData);
         if (openFileAfterFinish)
         {
             System.Diagnostics.Process.Start(fileName);
         }
     }
     catch (System.IO.IOException)
     {
         MessageBox.Show("File is in use. Please close it or choose different path.", "Can't write file!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (System.UnauthorizedAccessException)
     {
         MessageBox.Show("File is in use. Please close it or choose different path.", "Can't write file!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }