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 void comboSlot_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <EnhancementModel> enhancementModels;

            if (e.ToString() != "")
            {
                //lets pull the enhancement data for the selected slot
                enhancementModels = EnhancementModel.GetAll(GetSlotId());

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

            buttonOk.Enabled = false;
        }
예제 #3
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();
            }
        }
        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;
        }
        private void PopulateEnhancementTreeFields()
        {
            TreeNameTextBox.Text      = TreeModel.Name;
            TreeBackgoundTextBox.Text = TreeModel.Background;
            if (TreeModel.RaceTree == true)
            {
                RaceRadioButton.Checked = true;
            }
            else
            {
                ClassRadioButton.Checked = true;
            }

            //Let set up the Tree control
            EnhancementTreeControl.Clear();
            if (NewRecord == true)
            {
                EnhancementTreeControl.AddSlot(0);
                SlotChanged[0] = true; //Mark this slot as changed so that it will be saved. as all trees have at least this 1 slot.
                EnhancementTreeControl.ChangeSlotType(0, SlotControl.SCType.Active);
                EnhancementTreeControl.BackgroundImage = Image.FromFile(Application.StartupPath + "\\Graphics\\Interface\\" + "BackgroundEmpty" + ".png");
            }
            else
            {
                //set up the slot control inside the tree control
                for (int i = 0; i < 31; i++)
                {
                    if (SlotModels[i].Id != Guid.Empty)
                    {
                        //TODO: Add the slot and update its Icon if available
                        EnhancementTreeControl.AddSlot(i);

                        if (SlotModels[i].UseEnhancementInfo)
                        {
                            List <EnhancementModel> EnhancementModels;
                            EnhancementModels = new List <EnhancementModel>();
                            EnhancementModels = EnhancementModel.GetAll(SlotModels[i].Id);
                            if (EnhancementModels.Count > 0)
                            {
                                if (EnhancementModels[0].Icon != null)
                                {
                                    EnhancementTreeControl.ChangeSlotIcon(i, EnhancementModels[0].Icon);
                                }
                                else
                                {
                                    EnhancementTreeControl.ChangeSlotIcon(i, "noImage");
                                }
                            }
                            else
                            {
                                EnhancementTreeControl.ChangeSlotIcon(i, "noImageDesign");
                            }
                        }
                        else if (SlotModels[i].Icon != null)
                        {
                            EnhancementTreeControl.ChangeSlotIcon(i, SlotModels[i].Icon);
                        }

                        if (SlotModels[i].Active == true)
                        {
                            EnhancementTreeControl.ChangeSlotType(i, SlotControl.SCType.Active);
                        }
                        else
                        {
                            EnhancementTreeControl.ChangeSlotType(i, SlotControl.SCType.Passive);
                        }
                    }
                    else
                    {
                        EnhancementTreeControl.ChangeSlotIcon(i, "noImageDesign");
                        EnhancementTreeControl.ChangeSlotType(i, SlotControl.SCType.Active);
                    }
                }

                //set the background image of the tree control.
                try
                {
                    EnhancementTreeControl.BackgroundImage = Image.FromFile(Application.StartupPath + "\\Graphics\\Interface\\" + TreeModel.Background + ".png");
                }
                catch (FileNotFoundException)
                {
                    EnhancementTreeControl.BackgroundImage = Image.FromFile(Application.StartupPath + "\\Graphics\\Interface\\BackgroundEmpty.png");
                }
            }

            //lets set the index of the tree control
            //if (EnhancementTreeControl.IsSlotShowing(0) == true)
            EnhancementTreeControl.SelectedIndex = 0;
            //else
            //    EnhancementTreeControl.SelectedIndex = -1;
            //Set the treeName field in the TreeControl
            EnhancementTreeControl.TreeText = TreeModel.Name;
        }