Beispiel #1
0
        private void SetupDelegates()
        {
            textBoxFilter.TextChanged += delegate(object o, EventArgs e)
            {
                TextMatchFilter filter = TextMatchFilter.Contains(olvList, textBoxFilter.Text);
                olvList.AdditionalFilter = filter;
                UpdateToolStripLabel();
            };

            olvList.MouseClick += delegate(object s, MouseEventArgs e)
            {
                UpdateToolMenus();
                if (e.Button == MouseButtons.Right)
                {
                    contextMenuStrip.Show(e.X, e.Y);
                }
            };

            gameManagementToolStripMenuItem.Click += delegate(object s, EventArgs e) { UpdateToolMenus(); };

            olvList.MouseDoubleClick += delegate(object s, MouseEventArgs e)
            {
                XciItem xci = (XciItem)olvList.GetItem(olvList.SelectedIndex).RowObject;
                XciHelper.ShowXciExplorer(xci.xciFilePath);
            };

            exitToolStripMenuItem.Click += delegate(object s, EventArgs e) { Application.Exit(); };

            locationToolStripComboBox.SelectedIndexChanged += delegate(object s, EventArgs e) {
                Helpers.Settings.config.defaultView = (XciLocation)locationToolStripComboBox.SelectedIndex;
                XciHelper.RefreshList();
                UpdateToolStripLabel();
            };

            aboutToolStripMenuItem.Click += delegate(object o, EventArgs e)
            {
                formAbout formAbout = new formAbout();
                formAbout.Show();
            };

            this.FormClosing += delegate(object s, FormClosingEventArgs e) { SaveSettings(); };

            this.ResizeEnd += delegate(object s, EventArgs e)
            {
                if (this.WindowState != FormWindowState.Maximized)
                {
                    Helpers.Settings.config.formHeight = this.Height;
                    Helpers.Settings.config.formWidth  = this.Width;
                }
            };

            cancelTransfersToolStripMenuItem.Click  += delegate(object s, EventArgs e) { FileHelper.StopTransfers(); };
            rebuildCachetoolStripMenuItem.Click     += delegate(object s, EventArgs e) { XciHelper.RebuildCache(); };
            refreshGamesListToolStripMenuItem.Click += delegate(object s, EventArgs e) { XciHelper.LoadXcisInBackground(); };
        }
Beispiel #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();
            }
        }