Ejemplo n.º 1
0
        private void MultipleExtractAsync(List <GameFile> entries, string destination)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();
            ProgressBarWindow       window      = new ProgressBarWindow();

            window.StartDialogWithAction(() => {
                for (int i = 0; i < entries.Count; i++)
                {
                    if (tokenSource.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    entries[i].ExtractAsync(destination + '\\' + entries[i].Name, tokenSource.Token, (progress, description) =>
                    {
                        window.InvokeOnThread(new Action(() =>
                        {
                            int percent = (int)((float)i / entries.Count * 100);
                            window.SetProgress(percent);
                            window.SetOperationText(String.Format("({0}/{1}) {2}", i + 1, entries.Count, description));
                        }));
                    });
                }

                window.InvokeOnThread(new Action(() => window.Close()));
            }, tokenSource);
        }
Ejemplo n.º 2
0
        private void MultipleDeleteAsync(List <GameFile> entries)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();
            ProgressBarWindow       window      = new ProgressBarWindow();

            window.StartDialogWithAction(() => {
                for (int i = 0; i < entries.Count; i++)
                {
                    if (tokenSource.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    window.InvokeOnThread(new Action(() =>
                    {
                        int percent = (int)((float)i / entries.Count * 100);
                        window.SetProgress(percent);
                        window.SetOperationText(String.Format("({0}/{1}) Deleting {2}", i + 1, entries.Count, entries[i].Name));
                    }));

                    entries[i].Delete();
                }

                window.InvokeOnThread(new Action(() =>
                {
                    window.Close();
                }));

                if (InvokeRequired)
                {
                    Invoke(new Action(() => RefreshFileList()));
                }
            }, tokenSource);
        }
Ejemplo n.º 3
0
        private void InsertAsync(GameFile entry)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();
            ProgressBarWindow       window      = new ProgressBarWindow();

            window.StartDialogWithAction(() =>
            {
                archiveFile.InsertFileAsync(entry, tokenSource.Token, (progress, description) =>
                {
                    window.InvokeOnThread(new Action(() =>
                    {
                        window.SetProgress(progress);
                        window.SetOperationText(description);

                        if (progress == 100)
                        {
                            window.Close();
                        }
                    }));
                });

                if (InvokeRequired)
                {
                    Invoke(new Action(() => RefreshFileList()));
                }
            }, tokenSource);
        }
Ejemplo n.º 4
0
        private void ExtractAsync(GameFile entry, string destination)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();
            ProgressBarWindow       window      = new ProgressBarWindow();

            window.StartDialogWithAction(() => entry.ExtractAsync(destination, tokenSource.Token, (progress, description) =>
            {
                window.InvokeOnThread(new Action(() =>
                {
                    window.SetProgress(progress);
                    window.SetOperationText(description);

                    if (progress == 100)
                    {
                        window.Close();
                    }
                }));
            }), tokenSource);
        }