Ejemplo n.º 1
0
 // Actually fails right now
 public static void Base64Test()
 {
     Ext = new Extractor("C:/Users/nr/Desktop/extractor/test.xml");
     foreach (XmlNode pdf in Ext.GetPdfs())
     {
         string decodeString = Encoding.Default.GetString(
             Extractor.Base64Decode(pdf.InnerText));
         Console.WriteLine("Base64Test: " +
                           (pdf.InnerText == Extractor.Base64Encode(decodeString)));
     }
 }
        private void InputSelect_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog opf = new OpenFileDialog
            {
                Filter = "XML Files (*.xml)|*.xml"
            };

            if (opf.ShowDialog() == true)
            {
                InputFile.Text = opf.FileName;
                Extractor ext;
                try
                {
                    ext = new Extractor(InputFile.Text);
                }
                catch (XmlException)
                {
                    MessageBox.Show("Selected file is not an XML file",
                                    "Not XML file",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    return;
                }
                ButtonGrid.Children.Clear();

                if (ext.HasPdfNames())
                {
                    List <XmlNode> pdfs = ext.GetPdfs();

                    if (pdfs.Count < 1)
                    {
                        MessageBox.Show("No PDF's found for this file, " +
                                        "perhaps the XML tag needs to be added to the config file",
                                        "No PDF found",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                    }
                    foreach (XmlNode pdf in pdfs)
                    {
                        Button pdfButton = AddPdfButton(pdf);
                    }
                }
            }
        }