示例#1
0
文件: DruidMain.cs 项目: Nifusion/DSA
        private void FavoriteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Spells spells     = Spells.Retrieve(Properties.Settings.Default.SpellsXML);
            Spell  thisSpell  = (Spell)((TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).GetCurrentParent()).SourceControl).SelectedNode.Tag; //((TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).GetCurrentParent().tvSpells).SelectedNode.Tag;
            int    indexMatch = spells.FindIndex(x => x.Name.ToUpper() == thisSpell.Name.ToUpper() && x.Level.ToUpper() == thisSpell.Level.ToUpper());

            if (indexMatch > -1)
            {
                if (spells[indexMatch].Favorited)
                {
                    spells[indexMatch].Favorited = false;
                }
                else if (!spells[indexMatch].Favorited)
                {
                    spells[indexMatch].Favorited = true;
                }
                else
                {
                    spells[indexMatch].Favorited = true;
                }

                spells.Save(Properties.Settings.Default.SpellsXML);
            }

            RefreshSpellPage(GetSpellNodesExpansion());
        }
示例#2
0
文件: DruidMain.cs 项目: Nifusion/DSA
        private void TvSpells_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                if (!File.Exists(Properties.Settings.Default.SpellsXML))
                {
                    MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (tvSpells.SelectedNode != null)
                {
                    if (tvSpells.SelectedNode.Tag is Spell selSpell)
                    {
                        if (MessageBox.Show(string.Format("Are you sure you want to delete {0} from this list?", ((Spell)tvSpells.SelectedNode.Tag).Name), "Delete Summon Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
                        {
                            Spells spells     = Spells.Retrieve(Properties.Settings.Default.SpellsXML);
                            int    indexMatch = spells.FindIndex(x => x.Name.ToUpper() == selSpell.Name.ToUpper() && x.Level.ToUpper() == selSpell.Level.ToUpper());

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

                            spells.Save(Properties.Settings.Default.SpellsXML);
                            RefreshSpellPage(GetSpellNodesExpansion());
                        }
                    }
                }
            }
        }
示例#3
0
文件: DruidMain.cs 项目: Nifusion/DSA
        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;
                    }
                }
            }
        }
示例#4
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());
        }
示例#5
0
文件: DruidMain.cs 项目: Nifusion/DSA
        private void SaveSpellToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SpellsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (sittingSpellID == 0)
            {
                MessageBox.Show("Spell does not exist.", "Spell Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (tbSpellName.Text == "")
                {
                    MessageBox.Show("Spell Name must be filled out", "Spell Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!Regex.IsMatch(tbSpellLevel.Text, "[0-9]{1}"))
                {
                    MessageBox.Show("Spell Level must be a number 0 - 9", "Spell Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Spell updateSpell = new Spell
                {
                    Index           = sittingSpellID,
                    Favorited       = chkFavoriteSpell.Checked,
                    Name            = tbSpellName.Text,
                    Class           = tbSpellClass.Text,
                    Level           = tbSpellLevel.Text,
                    Domain          = tbSpellDomain.Text,
                    Components      = tbSpellComponents.Text,
                    Casting         = tbSpellCastingTime.Text,
                    Range           = tbSpellRange.Text,
                    Target          = tbSpellTarget.Text,
                    Effect          = tbSpellEffect.Text,
                    Duration        = tbSpellDuration.Text,
                    SavingThrow     = tbSpellSaving.Text,
                    SpellResistance = tbSpellResistance.Text,
                    SourceBook      = tbSource.Text,
                    Description     = rtbSpellDescription.Text,
                    PersonalNotes   = rtbPersonalNotes.Text
                };

                Spells spells     = Spells.Retrieve(Properties.Settings.Default.SpellsXML);
                int    indexMatch = spells.FindIndex(x => x.Index == sittingSpellID);

                if (indexMatch > -1)
                {
                    spells[indexMatch] = updateSpell;
                }
                else
                {
                    MessageBox.Show("Spell cannot be found.", "Spell Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                spells.Save(Properties.Settings.Default.SpellsXML);
                RefreshSpellPage(GetSpellNodesExpansion());
            }
        }
示例#6
0
文件: DruidMain.cs 项目: Nifusion/DSA
        private void AddSpellToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SpellsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (tbSpellName.Text == "")
            {
                MessageBox.Show("Spell Name must be filled out", "Spell Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!Regex.IsMatch(tbSpellLevel.Text, "[0-9]{1}"))
            {
                MessageBox.Show("Spell Level must be a number 0 - 9", "Spell Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Spell addSpell = new Spell
            {
                Favorited       = chkFavoriteSpell.Checked,
                Name            = tbSpellName.Text,
                Class           = tbSpellClass.Text,
                Level           = tbSpellLevel.Text,
                Domain          = tbSpellDomain.Text,
                Components      = tbSpellComponents.Text,
                Casting         = tbSpellCastingTime.Text,
                Range           = tbSpellRange.Text,
                Target          = tbSpellTarget.Text,
                Effect          = tbSpellEffect.Text,
                Duration        = tbSpellDuration.Text,
                SavingThrow     = tbSpellSaving.Text,
                SpellResistance = tbSpellResistance.Text,
                SourceBook      = tbSource.Text,
                Description     = rtbSpellDescription.Text,
                PersonalNotes   = rtbPersonalNotes.Text
            };

            Spells spells     = Spells.Retrieve(Properties.Settings.Default.SpellsXML);
            int    indexMatch = spells.FindIndex(x => x.Name.ToUpper() == addSpell.Name.ToUpper() && x.Level.ToUpper() == addSpell.Level.ToUpper());

            if (indexMatch > -1)
            {
                if (MessageBox.Show("Spell of the same name and level already exists\rWould you like to add a duplicate?", "Spell already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    addSpell.Index = spells.Max(x => x.Index) + 1;
                    spells.Add(addSpell);
                    ClearSpellPage();
                }
            }
            else
            {
                addSpell.Index = spells.Max(x => x.Index) + 1;
                spells.Add(addSpell);
                ClearSpellPage();
            }
            rtbSpellText.Clear();
            spells.Save(Properties.Settings.Default.SpellsXML);
            RefreshSpellPage(GetSpellNodesExpansion());
        }