Exemplo n.º 1
0
 private void ImportFromExistingDatabaseToolsMenuItem_Click(object sender, EventArgs e)
 {
     using (var ofd = new OpenFileDialog())
     {
         ofd.Filter = "PdfAnnotator databases (*.pdfannotatordb)|*.pdfannotatordb";
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             ClearContextAndUi();
             var stats = Annotations.ImportUnseenPdfs(ofd.FileName);
             var msg   = $"Success. Imported {stats.annotationCount} annotations for {stats.pdfCount} new documents, your database has never seen.";
             if (stats.mergeCandidatesCount == 0)
             {
                 MessageBox.Show(this, msg, "Import Data from Existing Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 msg = $"{msg} Furthermore there exist annotations for {stats.mergeCandidatesCount} documentes your database has annotations for too. Do you want to import these annotations too? If there are annotations for the same word in your database and the imported file, your annotation will be prefered.";
                 if (MessageBox.Show(this, msg, "Import Data from Existing Database", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                 {
                     return;
                 }
                 var mergeStats = Annotations.MergeSeenPdfs(ofd.FileName);
                 msg = $"Success. Added {stats.annotationCount} annotations to {stats.pdfCount} documents during merge.";
                 MessageBox.Show(this, msg, "Import Data from Existing Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }