Exemple #1
0
        public void Show(StateManager mgr)
        {
            if (mgr != null)
            {
                this.mgr = mgr;

                udLevel.Value = mgr.Hero.Level;
                udAttack.Value = mgr.Hero.Attack;
                udDefense.Value = mgr.Hero.Defense;
                udSpellPower.Value = mgr.Hero.SpellPower;
                udKnowledge.Value = mgr.Hero.Knowledge;
                udLuck.Value = mgr.Hero.Luck;
                udMorale.Value = mgr.Hero.Morale;
                udInitiative.Value = mgr.Hero.Initiative;
                udKnight.Value = mgr.Hero.Knight;
                udNecromancer.Value = mgr.Hero.Necromancer;
                udWizard.Value = mgr.Hero.Wizard;
                udElf.Value = mgr.Hero.Elf;
                udBarbarian.Value = mgr.Hero.Barbarian;
                udDarkElf.Value = mgr.Hero.DarkElf;
                udDemon.Value = mgr.Hero.Demon;
                udDwarf.Value = mgr.Hero.Dwarf;

                switch (mgr.Hero.Fraction)
                {
                    case Hero.FractionKind.Knight: rbKnight.Checked = true; break;
                    case Hero.FractionKind.Necromancer: rbNecromancer.Checked = true; break;
                    case Hero.FractionKind.Wizard: rbWizard.Checked = true; break;
                    case Hero.FractionKind.Elf: rbElf.Checked = true; break;
                    case Hero.FractionKind.Barbarian: rbBarbarian.Checked = true; break;
                    case Hero.FractionKind.DarkElf: rbDarkElf.Checked = true; break;
                    case Hero.FractionKind.Demon: rbDemon.Checked = true; break;
                    case Hero.FractionKind.Dwarf: rbDwarf.Checked = true; break;
                }

                base.Show();
            }
        }
Exemple #2
0
        private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Stream stream = null;
                    try
                    {
                        IFormatter formatter = new BinaryFormatter();
                        stream = new FileStream(
                            openFileDialog1.FileName,
                            FileMode.Open,
                            FileAccess.Read,
                            FileShare.Read);

                        //mgr
                        mgr = (StateManager)formatter.Deserialize(stream);

                        //full units list
                        listOfUnits = (BindingList<Unit>)formatter.Deserialize(stream);

                        //корявенько -> перенести в Bind
                        hilightid = 0;
                        dgvFull.DataSource = listOfUnits;
                        txtComment.Text = "";

                        DoBind();
                        DoShow();
                    }
                    finally
                    {
                        if (stream != null)
                            stream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }