Ejemplo n.º 1
0
        public void Run(Patcher patcher, string input, string output)
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.RunWorkerCompleted += HandleRunWorkerCompleted;
            worker.DoWork             += delegate(object sender, DoWorkEventArgs e) {
                // Check first output since it takes less time
                ErrorCode code = patcher.SetOutput(output, FileChecker.RomLength);
                if (code.IsValid())
                {
                    code = patcher.SetInput(input);
                }

                e.Result = code;
            };

            Animation.Instance.Add(animationPanel, familiars);
            worker.RunWorkerAsync();
        }
Ejemplo n.º 2
0
        private ErrorCode AskForFiles(Patcher patcher)
        {
            string input;

            InfoDialog.ShowSelectInput(this);
            using (OpenFileDialog inputDialog = new OpenFileDialog()) {
                inputDialog.AddExtension                 = true;
                inputDialog.CheckFileExists              = true;
                inputDialog.CheckPathExists              = true;
                inputDialog.DefaultExt                   = ".nds";
                inputDialog.DereferenceLinks             = true;
                inputDialog.Filter                       = "Nintendo DS ROM|*.nds";
                inputDialog.Multiselect                  = false;
                inputDialog.ShowHelp                     = false;
                inputDialog.ShowReadOnly                 = false;
                inputDialog.SupportMultiDottedExtensions = true;
                inputDialog.ValidateNames                = true;
                if (inputDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return(ErrorCode.UserCancel);
                }

                input = inputDialog.FileName;
            }

            string output;

            InfoDialog.ShowSelectOutput(this);
            using (SaveFileDialog outputDialog = new SaveFileDialog()) {
                outputDialog.AddExtension                 = true;
                outputDialog.CheckFileExists              = false;
                outputDialog.CheckPathExists              = true;
                outputDialog.DefaultExt                   = ".nds";
                outputDialog.DereferenceLinks             = true;
                outputDialog.Filter                       = "Nintendo DS ROM|*.nds";
                outputDialog.ShowHelp                     = false;
                outputDialog.SupportMultiDottedExtensions = true;
                outputDialog.ValidateNames                = true;
                outputDialog.OverwritePrompt              = true;
                outputDialog.FileName                     = "Ninokuni - El Mago de las Tinieblas.nds";
                if (outputDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return(ErrorCode.UserCancel);
                }

                output = outputDialog.FileName;
            }

            if (input == output)
            {
                return(ErrorCode.OutputIsInputToo);
            }

            CheckingWindow checkWindow = new CheckingWindow();

            checkWindow.Run(patcher, input, output);
            checkWindow.ShowDialog(this);

            ErrorCode result = checkWindow.Result;

            checkWindow.Dispose();

            return(result);
        }