Example #1
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if (PopUpHelper.WouldYouLikeToSave(CharacterExists(characterName.Text), "Character"))
     {
         //save the doc
     }
 }
Example #2
0
        /// <summary>
        /// Save our data
        /// </summary>
        private void ExportToFile()
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = false;

            if (spellsToCreate != null && spellsToCreate.Count > 0)
            {
                if (PopUpHelper.WouldYouLikeToSave(SpellExists(spellName.Text), "item"))
                {
                    OnSaveClicked(this, null);
                }

                XmlWriter writer = XmlWriter.Create(filePathToConfig, settings);
                writer.WriteStartDocument();
                writer.WriteStartElement("SpellConfig");

                //Add all of our spells we have created
                foreach (var spell in spellsToCreate)
                {
                    writer.WriteStartElement("Spell");
                    writer.WriteAttributeString("Name", spell.Name);
                    writer.WriteAttributeString("ID", spell.ID.ToString());
                    writer.WriteElementString("resourceCost", spell.resourceCost.ToString());
                    writer.WriteElementString("power", spell.power.ToString());
                    writer.WriteElementString("coolDown", spell.coolDown.ToString());
                    writer.WriteElementString("castTime", spell.castTime.ToString());
                    //Used for all special effects of the spell
                    writer.WriteStartElement("SpellEffects");
                    writer.WriteElementString("effect", spell.effectType);
                    writer.WriteElementString("radius", spell.radius.ToString());
                    writer.WriteElementString("duration", spell.duration.ToString());
                    writer.WriteElementString("interval", spell.interval.ToString());
                    writer.WriteElementString("spellType", spell.spellType);
                    writer.WriteElementString("spellSchool", spell.spellSchool);
                    writer.WriteEndElement();

                    writer.WriteElementString("classType", spell.classType);
                    writer.WriteElementString("imagePath", spell.imagePath);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();

                System.Windows.Forms.MessageBox.Show("Spells successfully exported!");
            }
            else
            {
                //Something is wrong no spells added or to create
                System.Windows.Forms.MessageBox.Show("Somethings went wrong, no spells where found. Are you sure you hit the Save Button?");
            }
        }
Example #3
0
        /// <summary>
        /// Save button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            //This has to be based off of the current tab we are on.

            switch (selectedTab)
            {
            //save here
            case ITEM_TAB.Armor:
                break;

            default:
                if (PopUpHelper.WouldYouLikeToSave(ItemExists(itemName.Text), "item"))
                {
                }
                break;
                {
                }
            }
        }
Example #4
0
        /// <summary>
        /// Write out the xml
        /// </summary>
        /// <param name="showPopup"></param>
        private void WriteOutXML(bool showPopup = true)
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            settings.NewLineOnAttributes = false;

            var selectedList = getListboxFromTab(selectedTab);

            if (selectedList != null && selectedList.Items.Count > 0)
            {
                if (showPopup && PopUpHelper.WouldYouLikeToSave(ItemExists(itemName.Text), selectedTab.ToString()))
                {
                    //OnSaveClicked(this, null);
                }

                //GetfilePath from selected tab,
                var       configPath = LoadAppConfigs.filePathToData + selectedTab.ToString() + "Config.xml";
                XmlWriter writer     = XmlWriter.Create(configPath, settings);
                writer.WriteStartDocument();
                writer.WriteStartElement(selectedTab.ToString() + "s");

                //Add all of our spells we have created
                foreach (var item in selectedList.Items)
                {
                    writer.WriteStartElement(selectedTab.ToString());
                    writer.WriteAttributeString("itemName", item.ToString());
                    writer.WriteAttributeString("id", "0");
                    writer.WriteElementString("isEquipped", "0");
                    writer.WriteElementString("rarity", "0");
                    writer.WriteElementString("itemClass", "0");
                    writer.WriteElementString("type", "0");
                    writer.WriteElementString("imagePath", "x.png");

                    //output the specifics based on the tab we are in
                    switch (selectedTab)
                    {
                    case ITEM_TAB.Weapon:
                        writer.WriteElementString("minDmgLow", "1.1");
                        writer.WriteElementString("minDmgHigh", "1.1");
                        writer.WriteElementString("maxDmgLow", "1.1");
                        writer.WriteElementString("maxDmgHigh", "1.1");
                        writer.WriteElementString("weaponSpeed", "1.1");
                        break;

                    case ITEM_TAB.Armor:
                        writer.WriteElementString("armorMin", "0");
                        writer.WriteElementString("armorMax", "100");
                        break;

                    case ITEM_TAB.Jewelry:
                        writer.WriteElementString("effectedStat", "0");
                        writer.WriteElementString("value", "0");
                        break;

                    case ITEM_TAB.Misc:
                        writer.WriteElementString("displayText", "0");
                        break;
                    }
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();

                if (showPopup)
                {
                    System.Windows.Forms.MessageBox.Show(selectedTab.ToString() + "s successfully exported!");
                }
            }
            else
            {
                //Something is wrong no spells added or to create
                System.Windows.Forms.MessageBox.Show("Somethings went wrong, no items where found. Are you sure you hit the Save Button?");
            }
        }