private void addReportButton_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = string.Format(Repository.SealRootProductName + " Reports files (*.{0})|*.{0}|All files (*.*)|*.*", Repository.SealReportFileExtension);
dlg.Title = "Select reports to add";
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
dlg.Multiselect = true;
if (_report != null) dlg.InitialDirectory = Path.GetDirectoryName(_report.FilePath);
if (string.IsNullOrEmpty(dlg.InitialDirectory)) dlg.InitialDirectory = _report.Repository.ReportsFolder;
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (var fileName in dlg.FileNames.Where(i => i != _report.FilePath))
{
string newFileName = convertFileName(fileName);
if (!reportsListBox.Items.Contains(newFileName))
{
try
{
Report report = Report.LoadFromFile(fileName, _report.Repository);
filterTextBox_TextChanged(null, null);
reportsListBox.Items.Add(new PropertyItem() { Name = newFileName, Object = report });
buildDestinationList();
}
catch (Exception ex)
{
MessageBox.Show(string.Format("Error loading report {0}:\r\n{1}", fileName, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}