Example #1
0
        private void objectListView1_DoubleClick(object sender, EventArgs e)
        {
            PRTableNode selObject = (PRTableNode)objectListView1.SelectedObject;

            if (selObject.Node.Flags.HasFlag(NodeFlag.Directory))
            {
                DirListing = PRX.GetChildren(selObject.GUID);

                if (selObject.GUID != PRX.RootPath.GUID)
                {
                    DirListing.Insert(0, PRX.MasterFileTable.GetVirtualUpNode(selObject));
                }

                objectListView1.SetObjects(DirListing);
            }
        }
Example #2
0
        //CURRENT Move this to PackRat.cs - Doesn't belong in the UI
        //TODO Why is this in the UI? Needs to be moved to PackRat.cs
        //private void ExtractRecurse(PRTableNode tn, string outPath) {
        //    DirectoryInfo di = Directory.CreateDirectory(outPath + tn.Name);
        //    outPath = di.FullName + @"\";

        //    foreach (PRTableNode prtn in PRX.GetChildren(tn.GUID)) {
        //        if (prtn.Flags.HasFlag(NodeFlag.File)) {
        //            FileInfo fi = new FileInfo(outPath + prtn.Name);
        //            Log($"EXFil: {prtn.GUID} => {fi.Directory}", LogType.IO);
        //            PRX.ExtractFile(prtn.Node, fi.Directory, fi.Name);
        //            }

        //        if (prtn.Flags.HasFlag(NodeFlag.Directory)) {
        //            Log($"EXDir: {prtn.GUID} => {outPath}", LogType.IO);
        //            ExtractRecurse(prtn, outPath);
        //            }

        //        }

        //    }

        private void bExtract_Click(object sender, EventArgs e)
        {
            if (objectListView1.SelectedObjects.Count == 1)
            {
                //    Log("Multiple items selected, aborting", LogType.Warning);
                //    return;
                //    }
                PRTableNode selObject = (PRTableNode)objectListView1.SelectedObject;
                if (selObject == null)
                {
                    return;
                }

                ProgressTracker pt = new ProgressTracker();
                Log($"Extract: {selObject.Name}", LogType.Info);
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName         = selObject.DisplayName;
                sfd.InitialDirectory = saveState.LastDirectory.FullName;

                if (selObject.Node.Flags.HasFlag(NodeFlag.Directory))
                {
                    FolderBrowserDialog fbd = new FolderBrowserDialog();
                    fbd.ShowNewFolderButton = true;
                    //TODO Store previously selected directory
                    fbd.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                    DialogResult fbdres = fbd.ShowDialog();
                    if (fbdres == DialogResult.OK || fbdres == DialogResult.Yes)
                    {
                        Log($"Selected \"{fbd.SelectedPath}\" for output", LogType.IO);
                        //ExtractRecurse(selObject, fbd.SelectedPath);
                        PRX.Extract(selObject.Node, new DirectoryInfo(fbd.SelectedPath), out pt);
                    }
                    return;
                }


                DialogResult res = sfd.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Yes)
                {
                    FileInfo fi     = new FileInfo(sfd.FileName);
                    ErrCode  result = HasPermission(fi.Directory.FullName);
                    if (!result.HasFlag(ErrCode.SUCCESS))
                    {
                        Log($"Extract Failed: {result}", LogType.Error);
                        MessageBox.Show($"Failed to extract {Environment.NewLine}{fi.Directory.FullName} : {result}");
                        return;
                    }
                    // extract file to target dir
                    Log($"EX: {selObject.GUID} => {fi.Directory}", LogType.IO);
                    PRX.Extract(selObject.Node, fi.Directory, out pt, sfd.FileName);
                }
            }
            else if (objectListView1.SelectedObjects.Count > 1)
            {
                ProgressTracker pt = new ProgressTracker();
                Log($"Extract: Multiple", LogType.Info);

                FolderBrowserDialog fbd = new FolderBrowserDialog();
                fbd.ShowNewFolderButton = true;
                //TODO Store previously selected directory
                fbd.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                DialogResult fbdres = fbd.ShowDialog();
                if (fbdres == DialogResult.OK || fbdres == DialogResult.Yes)
                {
                    Log($"Selected \"{fbd.SelectedPath}\" for output", LogType.IO);
                    foreach (PRTableNode selObject in objectListView1.SelectedObjects)
                    {
                        PRX.Extract(selObject.Node, new DirectoryInfo(fbd.SelectedPath), out pt);
                    }
                }
                return;
            }
        }