Ejemplo n.º 1
0
        private void ResignExternalBankToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title  = "Locate bank to sign";
            openFileDialog1.Filter = "Starcraft 2 Bank File (*.SC2Bank)|*.SC2Bank|XML file (*.xml)|*.xml|All files (*.*)|*.*";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Read the bank
                BankReader    reader = new BankReader();
                BankInfo      bankInfo;
                BankInfoCache bankInfoCache = new BankInfoCache();
                if (!BankPathParser.IsValidBankPath(openFileDialog1.FileName))
                {
                    PlayerNumberForm numberForm = new PlayerNumberForm();
                    if (numberForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    bankInfo = bankInfoCache.GetOrAddBankInfo(openFileDialog1.FileName, numberForm.PlayerNumber,
                                                              numberForm.AuthorNumber);
                }
                else
                {
                    bankInfo = bankInfoCache.GetOrAddBankInfo(openFileDialog1.FileName);
                }
                Bank bank = reader.LoadBankFromPath(bankInfo);

                //Write the bank back; automatically re-signs
                BankWriter bankWriter = new BankWriter();
                bankWriter.WriteBank(bank, openFileDialog1.FileName);
            }
        }
Ejemplo n.º 2
0
        private void RefreshBankListView()
        {
            if (_selectedMap == null)
            {
                _selectedMapBank = null;
                bankEditor1.Bank = null;
                return;
            }

            if (_selectedMapBank == null || cmbBankFile.SelectedItem != _selectedMapBank.BankInfo)
            {
                //Refresh the bank also
                BankReader bankReader = new BankReader();
                _selectedMapBank = (GetApplicableBankInfos(_selectedMap).Any()
                                        ? bankReader.LoadBankFromPath((BankInfo)cmbBankFile.SelectedItem)
                                        : null);
                bankEditor1.Bank = _selectedMapBank;
            }
        }