private void DatabaseLoad(string filename)
        {
            try
            {
                database.Load(filename);
            }
            catch (Exception)
            {
                MessageBox.Show("Database appears to be corrupted!", "Character Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Characters.Clear();
            listBoxCharacters.Items.Clear();

            try
            {
                int characterCount = database.ReadBlobByKey("num")[0];
                for (int i = 0; i < characterCount; ++i)
                {
                    CharacterData character = new CharacterData(i);
                    character.Load(database);

                    Characters.Add(character);
                    listBoxCharacters.Items.Add(character.Name);
                }
            }
            catch (Exception exception)
            {
                StringBuilder message = new StringBuilder();
                message.AppendLine("Database appears to be corrupted!");
                message.AppendLine(exception.Message);
                message.AppendLine(exception.Source);
                message.AppendLine(exception.StackTrace);

                MessageBox.Show(message.ToString(), "Character Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Characters.Clear();
                listBoxCharacters.Items.Clear();
            }
        }
        private void ListBoxCharactersSelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxCharacters.SelectedIndex < 0 || listBoxCharacters.SelectedIndex >= Characters.Count)
                return;

            SelectedCharacter = Characters[listBoxCharacters.SelectedIndex];
            DialogResult = DialogResult.OK;
            Close();
        }
Пример #3
0
        private void LoadCharacterDatabase()
        {
            Enabled = false;

            FormLoadCharacter formLoadCharacter = new FormLoadCharacter(database)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            DialogResult result = formLoadCharacter.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                character = formLoadCharacter.SelectedCharacter;

                SyncCharacterDataToGui();
            }

            Enabled = character != null;
        }