Esempio n. 1
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();
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void ChangeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextBox tbSender = (TextBox)((ContextMenuStrip)((ToolStripMenuItem)sender).GetCurrentParent()).SourceControl;

            if (tbSender == tbSummonsXML)
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Multiselect     = false;
                    ofd.Filter          = "XML Files (*.xml)| *.xml";
                    ofd.CheckFileExists = true;
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            Summons s = Summons.Retrieve(ofd.FileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("File not valid\rError: {0}", ex.Message), "File Select Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        tbSummonsXML.Text = ofd.FileName;
                    }
                }
            }
            if (tbSender == tbSpellsXML)
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Multiselect     = false;
                    ofd.Filter          = "XML Files (*.xml)| *.xml";
                    ofd.CheckFileExists = true;
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            Spells s = Spells.Retrieve(ofd.FileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("File not valid\rError: {0}", ex.Message), "File Select Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        tbSpellsXML.Text = ofd.FileName;
                    }
                }
            }
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        private void RefreshSummonPage()
        {
            if (!File.Exists(Properties.Settings.Default.SummonsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Summons summons = Summons.Retrieve(Properties.Settings.Default.SummonsXML);

            tvTemplates.Nodes.Clear();

            TreeNode tn1 = tvTemplates.Nodes.Add("Summon Nature's Ally 1");
            TreeNode tn2 = tvTemplates.Nodes.Add("Summon Nature's Ally 2");
            TreeNode tn3 = tvTemplates.Nodes.Add("Summon Nature's Ally 3");
            TreeNode tn4 = tvTemplates.Nodes.Add("Summon Nature's Ally 4");
            TreeNode tn5 = tvTemplates.Nodes.Add("Summon Nature's Ally 5");
            TreeNode tn6 = tvTemplates.Nodes.Add("Summon Nature's Ally 6");
            TreeNode tn7 = tvTemplates.Nodes.Add("Summon Nature's Ally 7");
            TreeNode tn8 = tvTemplates.Nodes.Add("Summon Nature's Ally 8");
            TreeNode tn9 = tvTemplates.Nodes.Add("Summon Nature's Ally 9");

            for (int i = 0; i < summons.Count; i++)
            {
                TreeNode thisSummon = new TreeNode(summons[i].Name);
                thisSummon.Tag = summons[i];
                if (summons[i].SummonSpell == "Summon Nature's Ally 1")
                {
                    tn1.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 2")
                {
                    tn2.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 3")
                {
                    tn3.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 4")
                {
                    tn4.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 5")
                {
                    tn5.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 6")
                {
                    tn6.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 7")
                {
                    tn7.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 8")
                {
                    tn8.Nodes.Add(thisSummon);
                }
                if (summons[i].SummonSpell == "Summon Nature's Ally 9")
                {
                    tn9.Nodes.Add(thisSummon);
                }
            }
            tvTemplates.Sort();
        }