コード例 #1
0
        private void AddFolderButton_Click(object p_Sender, RoutedEventArgs p_EventArgs)
        {
            // todo: CommonOpenFileDialog is from WindowsAPICodePack-Shell: analyse Nuget warnings
            CommonOpenFileDialog openDialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            if (openDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                try {
                    string packedPathDir = CurrentFolder.GetItemPathString();
                    if (packedPathDir == "/")
                    {
                        packedPathDir = "";
                    }

                    var packedPath = packedPathDir + System.IO.Path.GetFileName(openDialog.FileName);

                    LoadedPackedFile.Add(openDialog.FileName, packedPath);
                    //(FileTree.Items[0] as TreeEntry).AddFileData(LoadedPackedFile.GetFileIndexDataForFile(packedPath));
                    //TreeContent_ReloadCurrentFolder();
                    RefreshTreeView(); // todo: make this not need to refresh whole tree
                } catch (Exception ex) {
                    Error(ex);
                }
                PendingChanges = true;
            }
        }
コード例 #2
0
        private void ExtractToFile(TreeEntry p_TreeEntry)
        {
            string packedPath      = p_TreeEntry.IndexData.FilePath;
            string defaultFilename = packedPath.Split('/').Last();

            SaveFileDialog saveFileDialog = new SaveFileDialog {
                FileName = defaultFilename
            };

            if (saveFileDialog.ShowDialog() == true)
            {
                try {
                    LoadedPackedFile.Extract(p_TreeEntry.IndexData.FilePath, saveFileDialog.FileName);
                } catch (Exception ex) {
                    Error(ex);
                }
            }
        }
コード例 #3
0
        private void SaveWithOverwriteWarning(string p_NewFileName)
        {
            if (File.Exists(p_NewFileName))
            {
                if (MessageBox.Show($"Do you really want to overwrite {p_NewFileName}?",
                                    "Overwrite?",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Question, MessageBoxResult.No) != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            try {
                LoadedPackedFile.SaveToFile(p_NewFileName);
                PendingChanges = false;
            } catch (Exception ex) {
                Error(ex);
            }
        }
コード例 #4
0
        private void ExtractToFolder(IList p_SelectedItems)
        {
            // todo: CommonOpenFileDialog is from WindowsAPICodePack-Shell: analyse Nuget warnings
            CommonOpenFileDialog folderDialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                foreach (var item in p_SelectedItems)
                {
                    Debug.Assert(item is TreeEntry); // should always be the case
                    TreeEntry entry = item as TreeEntry;
                    try {
                        LoadedPackedFile.Extract(entry.GetItemPathString(), System.IO.Path.Combine(folderDialog.FileName, entry.Name));
                    } catch (Exception ex) {
                        Error(ex);
                    }
                }
            }
        }
コード例 #5
0
        private void RefreshTreeView()
        {
            TreeEntry root = new TreeEntry(null)
            {
                Name = LoadedPackedFile.FileName
            };

            foreach (PackedFileIndexData file in LoadedPackedFile.GetFileIndexDataList())
            {
                root.AddFileData(file);
            }
            root.Sort();
            FileTree.Items.Clear();
            FileTree.Items.Add(root);

            TreeContent.Items.Clear();
            foreach (var item in root.Items)
            {
                TreeContent.Items.Add(item);
            }

            CurrentFolder = root;
        }
コード例 #6
0
        private void AddButton_Click(object p_Sender, RoutedEventArgs p_EventArgs)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            if (openDialog.ShowDialog() == true)
            {
                try {
                    string packedPathDir = CurrentFolder.GetItemPathString();
                    if (packedPathDir == "/")
                    {
                        packedPathDir = "";
                    }

                    var packedPath = packedPathDir + System.IO.Path.GetFileName(openDialog.FileName);

                    LoadedPackedFile.Add(openDialog.FileName, packedPath);
                    (FileTree.Items[0] as TreeEntry).AddFileData(LoadedPackedFile.GetFileIndexDataForFile(packedPath));
                    TreeContent_ReloadCurrentFolder();
                } catch (Exception ex) {
                    Error(ex);
                }
                PendingChanges = true;
            }
        }