Exemplo n.º 1
0
        private void toolStripMenuItemExportToXml_Click(object sender, EventArgs e)
        {
            IFragment[] fragments = SelectedRows.GetSelectedFragmentsInGuiOrder();
            if ((fragments == null) || (fragments.Length == 0))
            {
                MessageBox.Show(this, "Nothing to be exported was selected. Please make a selection in the file tree first.",
                                GetDisplayedText(toolStripMenuItemSaveAsContiguousFile),
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            var saveFileDialog = new SaveFilePresenter();

            saveFileDialog.FilterXml();
            FileInfo xmlFile;

            if (saveFileDialog.ShowDialog(this, out xmlFile))
            {
                try
                {
                    if (ExportToXml != null)
                    {
                        RunBackgroundTask(toolStripMenuItemExportToXml, "Export to " + xmlFile.Name,
                                          p => ExportToXml(this, new FileExportEventArgs <IEnumerable <IFragment> >(fragments, xmlFile.FullName, p)));
                    }
                }
                catch (IOException ex)
                {
                    MessageBox.Show(this, "An error occurred when trying to write to file '" + xmlFile.FullName + "'" + Environment.NewLine + ex.Message, "Error writing file");
                }
            }
        }
Exemplo n.º 2
0
        private void toolStripMenuItemSaveAsContiguousFile_Click(object sender, EventArgs e)
        {
            if (!HasSelectedRows)
            {
                MessageBox.Show(this, "No selection was made. Please make a selection in the file tree first.",
                                GetDisplayedText(toolStripMenuItemSaveAsContiguousFile),
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            var fileDialog = new SaveFilePresenter();

            fileDialog.FilterAllFiles();
            fileDialog.Title = "Save As Contiguous File";

            // Using the GUI, it is only possible to select one file or one or more container and codec streams
            Row firstSelectedRow = SelectedRows[0];

            if (firstSelectedRow.Item is IInputFile)
            {
                if (SaveAsSingleFile != null)
                {
                    FileInfo contiguousFile;
                    if (fileDialog.ShowDialog(this, out contiguousFile))
                    {
                        RunBackgroundTask(toolStripMenuItemSaveAsContiguousFile, "Save as " + contiguousFile.Name,
                                          p => SaveAsSingleFile(this, new FileExportEventArgs <IInputFile>(firstSelectedRow.Item as IInputFile, contiguousFile.FullName, p)));
                    }
                }
            }
            else if (firstSelectedRow.Item is IFragment)
            {
                if (SaveAsContiguousFile != null)
                {
                    // Fill the SaveFileDialog filter
                    var       fragment = firstSelectedRow.Item as IFragment;
                    IDetector detector;
                    if ((fragment != null) &&
                        (fragment.Detectors != null) &&
                        (fragment.Detectors.Count() > 0) &&
                        ((detector = fragment.Detectors.FirstOrDefault()) != null))
                    {
                        string extension = detector.OutputFileExtension;
                        fileDialog.Filter = string.Format("{0} Files (*{1})|*{2}|All Files (*.*)|*.*", detector.Name, extension, extension);
                    }

                    FileInfo contiguousFile;
                    if (fileDialog.ShowDialog(this, out contiguousFile))
                    {
                        RunBackgroundTask(toolStripMenuItemSaveAsContiguousFile, "Save as " + contiguousFile.Name,
                                          p => SaveAsContiguousFile(this, new FileExportEventArgs <IEnumerable <IDataPacket> >(SelectedRows.GetSelectedFragmentsInGuiOrder(), contiguousFile.FullName, p)));
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void saveFrameAsImage_Click(object sender, EventArgs e)
        {
            var fileDialog = new SaveFilePresenter();

            fileDialog.FilterImages();
            fileDialog.FilterImagesIndex();
            fileDialog.Title = "Save frame as Image";
            FileInfo imageFile;

            if (fileDialog.ShowDialog(this, out imageFile))
            {
                SaveCurrentBitmapToFile(imageFile.FullName, GetImageFormatFromFileInfo(imageFile), SaveFilePresenter.ExportForensicIntegrityLog);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the current selection to a file.
        /// </summary>
        public void SaveSelectionAs(ISelection selection)
        {
            if (!HasSelectedRows)
            {
                return;
            }

            var saveFileDialog = new SaveFilePresenter();

            saveFileDialog.FilterAllFiles();
            saveFileDialog.Title = "Save Selection As";

            IResultNode result = SelectedRows[0].Item as IResultNode;

            if (result != null && result.Detectors != null && result.Detectors.Count() > 0)
            {
                saveFileDialog.Filter = string.Format("{0} Files (*{1})|*{2}|All Files (*.*)|*.*",
                                                      result.Detectors.First().Name, result.Detectors.First().OutputFileExtension,
                                                      result.Detectors.First().OutputFileExtension);
            }

            FileInfo contiguousFile;

            if ((saveFileDialog.ShowDialog(this, out contiguousFile)))
            {
                try
                {
                    // Saves the current selection to disk as one contiguous file
                    IEnumerable <IDataPacket> dataPackets = Enumerable.Repeat(selection.DataPacket, 1);
                    IList <IDetector>         detectors   = new List <IDetector>();
                    foreach (IResultNode resultNode in selection.Results)
                    {
                        AddDetectors(resultNode, detectors);
                    }

                    _fileExport.SaveAsContiguousFile(dataPackets, detectors, contiguousFile.FullName, SaveFilePresenter.ExportForensicIntegrityLog);
                }
                catch (IOException ex)
                {
                    MessageBox.Show(this, string.Format("An error occurred when trying to write to file '{0}'\n{1}", contiguousFile.FullName, ex.Message),
                                    "Error writing file");
                }
            }
        }