示例#1
0
 public void SetupHelper(XciItem xci, formRenamer formRenamer)
 {
     this.formRenamer = formRenamer;
     this.xci         = xci;
     AddListBoxItem("{name}", xci.gameName);
     AddListBoxItem("{titleid}", xci.titleId);
     AddListBoxItem("{tid}", xci.titleId);
     AddListBoxItem("{productcode}", xci.productCode);
     AddListBoxItem("{prodcode}", xci.productCode);
     AddListBoxItem("{size}", Helpers.XciHelper.ReadableFileSize(xci.gameSize));
     AddListBoxItem("{developer}", xci.gameDeveloper);
     AddListBoxItem("{dev}", xci.gameDeveloper);
     AddListBoxItem("{trimmed}", xci.isXciTrimmed ? "trimmed" : "");
     AddListBoxItem("{uniquecert}", xci.isUniqueCert ? "unique" : "");
     AddListBoxItem("{cert}", xci.isUniqueCert ? "unique" : "");
     AddListBoxItem("{revision}", xci.gameRevision);
     AddListBoxItem("{gamerev}", xci.gameRevision);
     AddListBoxItem("{rev}", xci.gameRevision);
     AddListBoxItem("{masterkey}", xci.masterKeyRevision);
     AddListBoxItem("{keyrev}", xci.masterKeyRevision);
     AddListBoxItem("{keyrevision}", xci.masterKeyRevision);
     listSelect.SelectedIndex = 0;
 }
示例#2
0
        private void ToolStripManagement(object sender, EventArgs e)
        {
            //use ProcessFileManagement
            //delete all copies
            //trim
            //show cert
            //show xciexplorer
            //show in explorer
            string     message = string.Empty, action = string.Empty, source = string.Empty, destination = string.Empty;
            FileStruct fileAction = new FileStruct();

            ToolStripItem clicked   = sender as ToolStripItem;
            int           toolIndex = olvList.ContextMenuStrip.Items.IndexOf(clicked);

            if (toolIndex < 0)
            {
                toolIndex = gameManagementToolStripMenuItem.DropDownItems.IndexOf(clicked);
            }

            if (toolIndex == 1)
            {
                fileAction.action = FileAction.CompletelyDelete;
            }
            if (toolIndex == 2)
            {
                fileAction.action = FileAction.Trim;
            }
            if (toolIndex == 3)
            {
                fileAction.action = FileAction.ShowRenameWindow;
            }
            if (toolIndex == 4)
            {
                fileAction.action = FileAction.ShowCert;
            }
            if (toolIndex == 5)
            {
                fileAction.action = FileAction.ShowXciInfo;
            }
            if (toolIndex == 6)
            {
                fileAction.action = FileAction.ShowInExplorer;
            }
            if (toolIndex == 7)
            {
                fileAction.action = FileAction.OpenOnTinfoilWeb;
            }

            if (Helpers.Settings.config.defaultView == XciLocation.PC)
            {
                fileAction.destination = XciLocation.SD;
                fileAction.source      = XciLocation.PC;
            }
            else
            {
                fileAction.destination = XciLocation.PC;
                fileAction.source      = XciLocation.SD;
            }

            switch (fileAction.action)
            {
            case FileAction.ShowRenameWindow:
                formRenamer renamer = new formRenamer();

                List <XciItem> renameList = olvList.SelectedObjects.Cast <XciItem>().ToList();

                renamer.PopulateList(renameList);
                renamer.Show();
                return;

            case FileAction.ShowInExplorer:
            case FileAction.ShowCert:
            case FileAction.ShowXciInfo:
                List <XciItem> showInfo = olvList.SelectedObjects.Cast <XciItem>().ToList();

                foreach (XciItem item in showInfo)
                {
                    item.fileAction = Clone(fileAction);
                    ProcessFileManagement(item);
                }
                return;

            case FileAction.OpenOnTinfoilWeb:
                List <XciItem> openWeb = olvList.SelectedObjects.Cast <XciItem>().ToList();

                foreach (XciItem item in openWeb)
                {
                    if (item.titleId != null || item.titleId.Length > 0)
                    {
                        System.Diagnostics.Process.Start("https://tinfoil.io/Title/" + item.titleId);
                    }
                }
                return;


            default:
                break;
            }

            XciItem xci;
            int     success = 0, failure = 0;

            action = Enum.GetName(typeof(FileAction), fileAction.action);

            if (fileAction.action == FileAction.CompletelyDelete)
            {
                action = "completely delete (from all locations)";
            }

            if (olvList.SelectedIndices.Count > 1)
            {
                if (MessageBox.Show($"Are you sure you want to {action} {olvList.SelectedObjects.Count} games?", $"Confirm {action.ToUpperInvariant()}", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }

                List <XciItem> actionList = olvList.SelectedObjects.Cast <XciItem>().ToList();

                foreach (XciItem obj in actionList)
                {
                    xci            = Clone(obj);
                    xci.fileAction = Clone(fileAction);

                    if (ProcessFileManagement(xci))
                    {
                        success++;
                    }
                    else
                    {
                        failure++;
                    }

                    UpdateToolStripLabel($"{action.ToUpperInvariant()} results: Success: {success} Failed: {failure}");

                    if (fileAction.action == FileAction.Trim)
                    {
                        XciHelper.UpdateXci(xci);
                    }
                }
            }
            else
            {
                xci            = Clone((XciItem)olvList.GetItem(olvList.SelectedIndex).RowObject);
                xci.fileAction = fileAction;

                if (MessageBox.Show($"Are you sure you want to {action} {xci.gameName}?", $"Confirm {action.ToUpperInvariant()}", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }

                ProcessFileManagement(xci);

                if (fileAction.action == FileAction.Trim)
                {
                    XciHelper.UpdateXci(xci);
                }
            }

            if (fileAction.action == FileAction.CompletelyDelete)
            {
                XciHelper.RefreshList();
            }
        }