private Guid GetSlotId()
        {
            Guid   treeId;
            Guid   slotId;
            string slotName;
            string slotIndexString;
            int    startLoc = 0;
            int    index    = -1;
            string tempName;

            slotName = "";
            treeId   = EnhancementTreeModel.GetIdFromTreeName(comboTree.SelectedItem.ToString());
            if (comboCategory.SelectedItem.ToString() == "EnhancementSlot")
            {
                slotName = comboApplyTo.SelectedItem.ToString();
            }
            if (comboCategory.SelectedItem.ToString() == "Enhancement")
            {
                slotName = comboSlot.SelectedItem.ToString();
            }
            tempName        = slotName.Remove(0, 5);
            startLoc        = tempName.IndexOf(":: ");
            slotIndexString = tempName.Remove(startLoc);
            index           = Int32.Parse(slotIndexString);
            slotId          = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, index);
            return(slotId);
        }
        private string GetTreeName(Guid requirementId)
        {
            string               treeName = "";
            RequirementModel     reqModel;
            string               tableName = "";
            EnhancementSlotModel slotModel;
            EnhancementModel     enhModel;

            reqModel  = GetRequirementModel(requirementId);
            tableName = TableNamesModel.GetTableNameFromId(reqModel.TableNamesId);
            slotModel = new EnhancementSlotModel();

            if (tableName == "EnhancementSlot")
            {
                slotModel.Initialize(reqModel.ApplytoId);
                treeName = EnhancementTreeModel.GetNameFromId(slotModel.EnhancementTreeId);
            }

            if (tableName == "Enhancement")
            {
                enhModel = new EnhancementModel();
                enhModel.Initialize(reqModel.ApplytoId);
                slotModel.Initialize(enhModel.EnhancementSlotId);
                treeName = EnhancementTreeModel.GetNameFromId(slotModel.EnhancementTreeId);
            }

            return(treeName);
        }
        private EnhancementSlotModel GetSlotModel(Guid requirementId)
        {
            EnhancementSlotModel slotModel;
            EnhancementModel     enhModel;
            RequirementModel     reqModel;
            string tableName = "";

            slotModel = new EnhancementSlotModel();
            reqModel  = GetRequirementModel(requirementId);
            //tableName = TableNamesModel.GetNameFromId(reqModel.Id);
            tableName = TableNamesModel.GetTableNameFromId(reqModel.TableNamesId);

            if (tableName == "EnhancementSlot")
            {
                slotModel.Initialize(reqModel.ApplytoId);
            }

            if (tableName == "Enhancement")
            {
                enhModel = new EnhancementModel();
                enhModel.Initialize(reqModel.ApplytoId);
                slotModel.Initialize(enhModel.EnhancementSlotId);
            }

            return(slotModel);
        }
        private void comboTree_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid treeId;
            List <EnhancementSlotModel> slotModels;

            if (e.ToString() != "")
            {
                treeId = EnhancementTreeModel.GetIdFromTreeName(comboTree.SelectedItem.ToString());

                slotModels = EnhancementSlotModel.GetAll(treeId);
                if (comboCategory.SelectedItem.ToString() == "Enhancement")
                {
                    comboSlot.Items.Clear();
                    foreach (EnhancementSlotModel model in slotModels)
                    {
                        comboSlot.Items.Add(BuildSlotName(model));
                    }
                    comboApplyTo.Items.Clear();
                }
                else
                {
                    comboApplyTo.Items.Clear();
                    foreach (EnhancementSlotModel model in slotModels)
                    {
                        comboApplyTo.Items.Add(BuildSlotName(model));
                    }
                }
            }
            buttonOk.Enabled = false;
        }
        private string BuildSlotName(EnhancementSlotModel model)
        {
            string name = "";

            name = "Slot " + model.SlotIndex.ToString() + ":: " + GetSlotName(model);
            return(name);
        }
Example #6
0
        private void TreeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid treeId;
            List <EnhancementSlotModel> slotModels;

            if (e.ToString() != "")
            {
                treeId = EnhancementTreeModel.GetIdFromTreeName(TreeComboBox.SelectedItem.ToString());
                //Lets pull slot data for the tree Selected
                slotModels = EnhancementSlotModel.GetAll(treeId);

                if (CategoryComboBox.SelectedItem.ToString() == "Enhancement")
                {
                    SlotComboBox.Items.Clear();
                    foreach (EnhancementSlotModel model in slotModels)
                    {
                        SlotComboBox.Items.Add("Slot " + model.SlotIndex.ToString() + ": " + GetSlotName(model));
                    }
                    ApplyToComboBox.Items.Clear();
                }
                else
                {
                    ApplyToComboBox.Items.Clear();
                    foreach (EnhancementSlotModel model in slotModels)
                    {
                        ApplyToComboBox.Items.Add("Slot " + model.SlotIndex.ToString() + ": " + GetSlotName(model));
                    }
                }
                UpdateNameField();
            }
        }
        private void GatherData()
        {
            //Enhancment Slot Data
            SlotModel = new EnhancementSlotModel();
            SlotModel.Initialize(SlotId);

            //Enhancement Data
            EnhancementModels = EnhancementModel.GetAll(SlotId);
            if (EnhancementModels.Count == 0)
            {
                //we need to add an enhancement as one was never assigned and all slots should have at least 1 enhancement.
                AddEnhancementModel();
            }

            //Enhancement Rank Data
            RankModels = new List <List <EnhancementRankModel> >();
            foreach (EnhancementModel model in EnhancementModels)
            {
                List <EnhancementRankModel> sublist = new List <EnhancementRankModel>();
                sublist = EnhancementRankModel.GetAll(model.Id);
                RankModels.Add(sublist);
                if (RankModels[RankModels.Count - 1].Count == 0)
                {
                    AddRankModel(RankModels.Count - 1);
                }
            }
        }
        private string GetSlotName(EnhancementSlotModel model)
        {
            string name;
            Guid   enhancementId;

            name = "";
            if (model.UseEnhancementInfo == true)
            {
                //Retrieve the Name of the First enhancement for this slot
                enhancementId = EnhancementModel.GetIdFromSlotIdandDisplayOrder(model.Id, 0);
                name          = EnhancementModel.GetNameFromId(enhancementId);
            }
            else
            {
                name = model.Name;
            }

            return(name);
        }
        private string BuildSlotName(Guid slotId)
        {
            string slotName;
            EnhancementSlotModel slotModel;

            slotName  = "";
            slotModel = new EnhancementSlotModel();
            slotModel.Initialize(slotId);

            if (slotModel.UseEnhancementInfo == true)
            {
                slotName = EnhancementModel.GetNameFromId(EnhancementModel.GetIdFromSlotIdandDisplayOrder(slotModel.Id, 0));
            }
            else
            {
                slotName = slotModel.Name;
            }

            return(slotName);
        }
        private void GrabData(string treeName)
        {
            //TreeModel Data
            TreeModel = new EnhancementTreeModel();
            if (treeName != "_New Enhancement Tree_")
            {
                TreeModel.Initialize(treeName);
            }

            //SlotModels Data and associated trackers
            SlotModels  = new List <EnhancementSlotModel>();
            SlotChanged = new List <bool>();
            SlotDeleted = new List <bool>();
            for (int i = 0; i < 31; i++)
            {
                SlotModels.Add(new EnhancementSlotModel());
                SlotModels[i].Initialize(EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(TreeModel.Id, i));
                SlotChanged.Add(false);
                SlotDeleted.Add(false);
            }
        }
Example #11
0
        private void SlotComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <EnhancementModel> enhancementModels;
            Guid slotId;
            Guid treeId;

            if (e.ToString() != "")
            {
                treeId = EnhancementTreeModel.GetIdFromTreeName(TreeComboBox.SelectedItem.ToString());
                slotId = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, GetSlotIndex(SlotComboBox.SelectedItem.ToString()));
                //lets pull the enhancement data for the selected slot
                enhancementModels = EnhancementModel.GetAll(slotId);

                ApplyToComboBox.Items.Clear();
                foreach (EnhancementModel model in enhancementModels)
                {
                    ApplyToComboBox.Items.Add("Pos " + model.DisplayOrder.ToString() + ": " + model.Name);
                }

                UpdateNameField();
            }
        }
Example #12
0
        private void AddNewRequirementRecord()
        {
            RequirementModel model;
            string           categoryName;
            string           applyToName;
            string           treeName;
            Guid             treeId;
            Guid             slotId;
            Guid             enhancementId;

            treeName     = "";
            model        = new RequirementModel();
            categoryName = CategoryComboBox.SelectedItem.ToString();
            applyToName  = ApplyToComboBox.SelectedItem.ToString();
            if (categoryName == "Enhancement" || categoryName == "EnhancementSlot")
            {
                treeName = TreeComboBox.SelectedItem.ToString();
            }

            model.Initialize(Guid.Empty);
            model.TableNamesId = TableNamesModel.GetIdFromTableName(categoryName);
            if (categoryName == "Ability")
            {
                model.ApplytoId = AbilityModel.GetIdFromName(applyToName);
            }
            if (categoryName == "Attribute")
            {
                model.ApplytoId = AttributeModel.GetIdFromName(applyToName);
            }
            if (categoryName == "Class")
            {
                model.ApplytoId = ClassModel.GetIdFromName(applyToName);
            }
            if (categoryName == "Enhancement")
            {
                treeId          = EnhancementTreeModel.GetIdFromTreeName(treeName);
                slotId          = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, GetSlotIndex(SlotComboBox.SelectedItem.ToString()));
                enhancementId   = EnhancementModel.GetIdFromSlotIdandDisplayOrder(slotId, GetDisplayOrder(ApplyToComboBox.SelectedItem.ToString()));
                model.ApplytoId = enhancementId;
            }
            if (categoryName == "EnhancementSlot")
            {
                treeId          = EnhancementTreeModel.GetIdFromTreeName(treeName);
                slotId          = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, GetSlotIndex(ApplyToComboBox.SelectedItem.ToString()));
                model.ApplytoId = slotId;
            }
            if (categoryName == "Feat")
            {
                model.ApplytoId = FeatModel.GetIdFromName(applyToName);
            }
            if (categoryName == "Race")
            {
                model.ApplytoId = RaceModel.GetIdFromName(applyToName);
            }
            if (categoryName == "Skill")
            {
                model.ApplytoId = SkillModel.GetIdFromName(applyToName);
            }

            model.Name = NameTextBox.Text;
            model.Save();
            NewRequirementId = model.Id;
        }
        private void buttonDuplicateRecord_Click(object sender, EventArgs e)
        {
            string selection;
            EnhancementTreeModel newTreeModel = new EnhancementTreeModel();
            List <EnhancementTreeRequirementModel> newTreeRequirementModels            = new List <EnhancementTreeRequirementModel>();
            List <EnhancementSlotModel>            newSlotModels                       = new List <EnhancementSlotModel>();
            List <EnhancementModel>                newEnhancementModels                = new List <EnhancementModel>();
            List <EnhancementRankModel>            newEnhancementRankModels            = new List <EnhancementRankModel>();
            List <EnhancementRankModifierModel>    newEnhancementRankModifierModels    = new List <EnhancementRankModifierModel>();
            List <EnhancementRankRequirementModel> newEnhancementRankRequirementModels = new List <EnhancementRankRequirementModel>();
            Guid oldSlotId;
            Guid oldEnhancementId;
            Guid oldRankId;
            Guid oldModifierId;
            Guid oldRequirementId;

            //Copy the Tree Model First
            newTreeModel.Initialize(TreeModel.Id);
            newTreeModel.ConvertToNewRecord();
            newTreeModel.Name = TreeModel.Name + "Duplicate";
            newTreeModel.Save();

            //Copy the Tree Requirement Models
            newTreeRequirementModels = EnhancementTreeRequirementModel.GetAll(TreeModel.Id);
            foreach (EnhancementTreeRequirementModel etrm in newTreeRequirementModels)
            {
                etrm.ConvertToNewRecord();
                etrm.EnhancementTreeId = newTreeModel.Id;
                etrm.Save();
            }

            //Copy the Slot Models
            newSlotModels = EnhancementSlotModel.GetAll(TreeModel.Id);
            foreach (EnhancementSlotModel slot in newSlotModels)
            {
                oldSlotId = slot.Id;
                slot.ConvertToNewRecord();
                slot.EnhancementTreeId = newTreeModel.Id;
                slot.Save();
                //Copy the Enhancements for this Slot Model.
                newEnhancementModels = EnhancementModel.GetAll(oldSlotId);
                foreach (EnhancementModel em in newEnhancementModels)
                {
                    oldEnhancementId = em.Id;
                    em.ConvertToNewRecord();
                    em.EnhancementSlotId = slot.Id;
                    em.Save();
                    //Copy the Enhancement Ranks for this Enhancement.
                    newEnhancementRankModels = EnhancementRankModel.GetAll(oldEnhancementId);
                    foreach (EnhancementRankModel erm in newEnhancementRankModels)
                    {
                        oldRankId = erm.Id;
                        erm.ConvertToNewRecord();
                        erm.EnhancementId = em.Id;
                        erm.Save();
                        //Copy the Enhancement Rank Modifier Models
                        newEnhancementRankModifierModels = EnhancementRankModifierModel.GetAll(oldRankId);
                        foreach (EnhancementRankModifierModel ermm in newEnhancementRankModifierModels)
                        {
                            oldModifierId = ermm.Id;
                            ermm.ConvertToNewRecord();
                            ermm.EnhancementRankId = erm.Id;
                            ermm.Save();
                        }
                        //Copy the Enhancement Rank Requirement Models
                        newEnhancementRankRequirementModels = EnhancementRankRequirementModel.GetAll(oldRankId);
                        foreach (EnhancementRankRequirementModel errm in newEnhancementRankRequirementModels)
                        {
                            oldRequirementId = errm.Id;
                            errm.ConvertToNewRecord();
                            errm.EnhancementRankId = erm.Id;
                            errm.Save();
                        }
                    }
                }
            }

            //Now lets update our screen with the new record
            selection = newTreeModel.Name;
            EnhancementTreeListBox.Items.Clear();
            PopulateEnhancementTreeListBox();
            //AllowChangeEvents = false;
            EnhancementTreeListBox.SelectedItem = selection;
            //AllowChangeEvents = true;

            //Now we can reset our flags
            RecordChanged = false;
            NewRecord     = false;
        }