Example #1
0
        public void Extract(EntryViewModel entry, string destination)
        {
            var view_model = m_main.ViewModel;
            var selected   = m_main.CurrentDirectory.SelectedItems.Cast <EntryViewModel>();

            if (!selected.Any() && entry.Name == "..")
            {
                selected = view_model;
            }

            IEnumerable <Entry> file_list = selected.Select(e => e.Source);

            if (m_fs is TreeArchiveFileSystem)
            {
                file_list = (m_fs as TreeArchiveFileSystem).GetFilesRecursive(file_list);
            }

            if (!file_list.Any())
            {
                m_main.SetStatusText(guiStrings.MsgChooseFiles);
                return;
            }

            ExtractDialog extractDialog;
            bool          multiple_files = file_list.Skip(1).Any();

            if (multiple_files)
            {
                extractDialog = new ExtractArchiveDialog(m_arc_name, destination);
            }
            else
            {
                extractDialog = new ExtractFile(entry, destination);
            }
            extractDialog.Owner = m_main;
            var result = extractDialog.ShowDialog();

            if (!result.Value)
            {
                return;
            }
            if (multiple_files)
            {
                m_skip_images = !Settings.Default.appExtractImages;
                m_skip_script = !Settings.Default.appExtractText;
                m_skip_audio  = !Settings.Default.appExtractAudio;
            }
            destination = extractDialog.Destination;
            if (!string.IsNullOrEmpty(destination))
            {
                destination = Path.GetFullPath(destination);
                PrepareDestination(destination);
            }
            if (!m_skip_images)
            {
                m_image_format = FormatCatalog.Instance.ImageFormats.FirstOrDefault(f => f.Tag.Equals(Settings.Default.appImageFormat));
            }

            ExtractFilesFromArchive(string.Format(guiStrings.MsgExtractingFile, m_arc_name), file_list);
        }
Example #2
0
        public void ExtractAll(string destination)
        {
            var file_list = m_fs.GetFilesRecursive();

            if (!file_list.Any())
            {
                m_main.SetStatusText(string.Format("{1}: {0}", guiStrings.MsgEmptyArchive, m_arc_name));
                return;
            }
            var extractDialog = new ExtractArchiveDialog(m_arc_name, destination);

            extractDialog.Owner = m_main;
            var result = extractDialog.ShowDialog();

            if (!result.Value)
            {
                return;
            }

            destination = extractDialog.Destination;
            if (!string.IsNullOrEmpty(destination))
            {
                destination = Path.GetFullPath(destination);
                PrepareDestination(destination);
            }
            else
            {
                destination = ".";
            }
            m_skip_images = !extractDialog.ExtractImages.IsChecked.Value;
            m_skip_script = !extractDialog.ExtractText.IsChecked.Value;
            m_skip_audio  = !extractDialog.ExtractAudio.IsChecked.Value;
            if (!m_skip_images)
            {
                m_image_format = extractDialog.GetImageFormat(extractDialog.ImageConversionFormat);
            }

            m_main.SetStatusText(string.Format(guiStrings.MsgExtractingTo, m_arc_name, destination));
            ExtractFilesFromArchive(string.Format(guiStrings.MsgExtractingArchive, m_arc_name), file_list);
        }