예제 #1
0
        private void Import()
        {
            AddMessage(Messages.MSG_IMPORT_STARTED);
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = OptionsController.DownloadPath;
            dlg.Filter           = Constants.MODPACK_FILTER;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                pbImport.Visible = true;
                new AsyncTask <bool>(() =>
                {
                    if (cbClearModSelection.Checked)
                    {
                        AddMessage(Messages.MSG_CLEARING_MODSELECTION);
                        InvokeIfRequired(() => ModSelectionController.RemoveAllMods());
                    }

                    AddMessage(string.Format(Messages.MSG_IMPORTING_FROM_0, dlg.FileName));
                    ModPackHandler.MessageCallbackFunction = AddMessage;
                    ModPackHandler.Import(dlg.FileName, OptionsController.DownloadPath, cbExtract.Checked, cbDownloadIfNeeded.Checked, rbCopyDestination.Checked, rbAddOnly.Checked);
                    ModPackHandler.MessageCallbackFunction = null;
                    return(true);
                },
                                     (b, ex) =>
                {
                    pbImport.Visible = false;
                    if (ex != null)
                    {
                        AddMessage(Messages.MSG_IMPORTING_FAILED, true, ex);
                        MessageBox.Show(this, ex.Message, Messages.MSG_TITLE_ERROR);
                    }
                    else
                    {
                        AddMessage(Messages.MSG_IMPORTING_DONE);
                        Close();
                    }
                }).Run();
            }
            else
            {
                AddMessage(Messages.MSG_IMPORTING_ABORTED);
            }
        }
 private void tsbRemoveAll_Click(object sender, EventArgs e)
 {
     ModSelectionController.RemoveAllMods();
 }