Exemplo n.º 1
0
        private void CreateNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextBox tbSender = (TextBox)((ContextMenuStrip)((ToolStripMenuItem)sender).GetCurrentParent()).SourceControl;

            if (tbSender == tbSummonsXML)
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter = "XML Files (*.xml)| *.xml";
                    sfd.Title  = "New Summon XML File";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        Summons s = new Summons();
                        s.Save(sfd.FileName);
                        tbSummonsXML.Text = sfd.FileName;
                    }
                }
            }
            if (tbSender == tbSpellsXML)
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.Filter = "XML Files (*.xml)| *.xml";
                    sfd.Title  = "New Spell XML File";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        Spells s = new Spells();
                        s.Save(sfd.FileName);
                        tbSpellsXML.Text = sfd.FileName;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void TvTemplates_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                if (!File.Exists(Properties.Settings.Default.SummonsXML))
                {
                    MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (tvTemplates.SelectedNode != null)
                {
                    if (tvTemplates.SelectedNode.Tag is Summon selSumm)
                    {
                        if (MessageBox.Show(string.Format("Are you sure you want to delete {0} from this list?", ((Summon)tvTemplates.SelectedNode.Tag).Name), "Delete Summon Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
                        {
                            Summons summons    = Summons.Retrieve(Properties.Settings.Default.SummonsXML);
                            int     indexMatch = summons.FindIndex(x => x.Name.ToUpper() == selSumm.Name.ToUpper() && x.SummonSpell.ToUpper() == selSumm.SummonSpell.ToUpper());

                            if (indexMatch > -1)
                            {
                                summons.RemoveAt(indexMatch);
                            }

                            summons.Save(Properties.Settings.Default.SummonsXML);
                            RefreshSummonPage();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (string.IsNullOrEmpty(Properties.Settings.Default.SummonsXML))
            {
                //try to find it in local folder
                string local = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Summons.xml");
                if (!File.Exists(local))
                {
                    //if not, I'm creating a blank one for you;
                    //you can handle a change later
                    Summons s = new Summons();
                    s.Save(local);
                }
                Properties.Settings.Default.SummonsXML = local;
                Properties.Settings.Default.Save();
            }

            if (string.IsNullOrEmpty(Properties.Settings.Default.SpellsXML))
            {
                //try to find it in local folder
                string local = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Spells.xml");
                if (!File.Exists(local))
                {
                    //if not, I'm creating a blank one for you;
                    //you can handle a change later
                    Spells s = new Spells();
                    s.Save(local);
                }

                Properties.Settings.Default.SpellsXML = local;
                Properties.Settings.Default.Save();
            }

            Application.Run(new DruidMain());
        }
Exemplo n.º 4
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SummonsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (sittingSummonIndex == 0)
            {
                MessageBox.Show("Summon does not exist.", "Summon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (tbName.Text == "")
                {
                    MessageBox.Show("Summon Name must be filled out", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (cbSummonSpell.Text == "")
                {
                    MessageBox.Show("Summon Spell/Category must be specified", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                List <Size> sizes = Enum.GetValues(typeof(Size)).Cast <Size>().ToList();
                int         index = sizes.FindIndex(x => x.ToString() == cbSize.SelectedItem.ToString());
                Size        size  = index > -1 ? sizes[index] : DruidAssistant.Size.Medium;

                Summon updateSummon = new Summon
                {
                    Index        = sittingSummonIndex,
                    SummonSpell  = cbSummonSpell.Text,
                    Name         = tbName.Text,
                    Abilities    = new Abilities((int)nudSTR.Value, (int)nudDEX.Value, (int)nudCON.Value, (int)nudINT.Value, (int)nudWIS.Value, (int)nudCHA.Value),
                    Saves        = new Saves((int)nudFort.Value, (int)nudRef.Value, (int)nudWill.Value),
                    Level        = (int)nudLevel.Value,
                    HitDie       = (int)nudHD.Value,
                    NaturalArmor = (int)nudNatural.Value,
                    BAB          = (int)nudBAB.Value,
                    Grapple      = (int)nudGrapple.Value,
                    Size         = size,
                    Type         = tbType.Text,
                    Environment  = tbEnvironment.Text,
                    Space        = tbSpace.Text,
                    Reach        = tbReach.Text,
                    Movement     = tbMovement.Text,
                    Skills       = rtbSkills.Text.Split(',').ToList(),
                    Feats        = tbFeats.Text.Split(',').ToList(),
                    SpecAtks     = tbSpecAtks.Text.Split(',').ToList(),
                    SpecQual     = tbSpecQual.Text.Split(',').ToList(),
                    Notes        = rtbCombat.Text.Split('\r').ToList(),
                    Attacks      = Summon.GetAttacks(rtbAttacks.Text),
                    FullAttacks  = Summon.GetFullAttacks(rtbFullAttacks.Text)
                };

                Summons summons    = Summons.Retrieve(Properties.Settings.Default.SummonsXML);
                int     indexMatch = summons.FindIndex(x => x.Index == sittingSummonIndex);
                if (indexMatch > -1)
                {
                    summons[indexMatch] = updateSummon;
                }
                else
                {
                    MessageBox.Show("Summon cannot be found.", "Summon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                summons.Save(Properties.Settings.Default.SummonsXML);
                RefreshSummonPage();
            }
        }
Exemplo n.º 5
0
        private void AddToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SummonsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (tbName.Text == "")
            {
                MessageBox.Show("Summon Name must be filled out", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (cbSummonSpell.Text == "")
            {
                MessageBox.Show("Summon Spell/Category must be specified", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <Size> sizes = Enum.GetValues(typeof(Size)).Cast <Size>().ToList();
            int         index = sizes.FindIndex(x => x.ToString() == cbSize.SelectedItem.ToString());
            Size        size  = index > -1 ? sizes[index] : DruidAssistant.Size.Medium;

            Summon addSummon = new Summon
            {
                SummonSpell  = cbSummonSpell.Text,
                Name         = tbName.Text,
                Abilities    = new Abilities((int)nudSTR.Value, (int)nudDEX.Value, (int)nudCON.Value, (int)nudINT.Value, (int)nudWIS.Value, (int)nudCHA.Value),
                Saves        = new Saves((int)nudFort.Value, (int)nudRef.Value, (int)nudWill.Value),
                Level        = (int)nudLevel.Value,
                HitDie       = (int)nudHD.Value,
                NaturalArmor = (int)nudNatural.Value,
                BAB          = (int)nudBAB.Value,
                Grapple      = (int)nudGrapple.Value,
                Size         = size,
                Type         = tbType.Text,
                Environment  = tbEnvironment.Text,
                Space        = tbSpace.Text,
                Reach        = tbReach.Text,
                Movement     = tbMovement.Text,
                Skills       = rtbSkills.Text.Split(',').ToList(),
                Feats        = tbFeats.Text.Split(',').ToList(),
                SpecAtks     = tbSpecAtks.Text.Split(',').ToList(),
                SpecQual     = tbSpecQual.Text.Split(',').ToList(),
                Notes        = rtbCombat.Text.Split('\r').ToList(),
                Attacks      = Summon.GetAttacks(rtbAttacks.Text),
                FullAttacks  = Summon.GetFullAttacks(rtbFullAttacks.Text)
            };

            Summons summons    = Summons.Retrieve(Properties.Settings.Default.SummonsXML);
            int     indexMatch = summons.FindIndex(x => x.Name.ToUpper() == addSummon.Name.ToUpper() && x.SummonSpell.ToUpper() == addSummon.SummonSpell.ToUpper());

            if (indexMatch > -1)
            {
                if (MessageBox.Show("Summon of the same name and level already exists\rWould you like to add a duplicate?", "Spell already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    addSummon.Index = summons.Max(x => x.Index) + 1;
                    summons.Add(addSummon);
                    ClearSummonPage();
                }
            }
            else
            {
                addSummon.Index = summons.Max(x => x.Index) + 1;
                summons.Add(addSummon);
                ClearSummonPage();
            }

            summons.Save(Properties.Settings.Default.SummonsXML);
            RefreshSummonPage();
        }