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);
        }
Beispiel #3
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 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 void PopulateEnhancementTreeListBox()
 {
     TreeNames = EnhancementTreeModel.GetNames();
     foreach (string name in TreeNames)
     {
         EnhancementTreeListBox.Items.Add(name);
     }
 }
 private bool CheckForUniqueness(string newValue, InputType type)
 {
     switch (type)
     {
     case InputType.Name:
     {
         if (EnhancementTreeModel.DoesNameExist(newValue) == true)
         {
             return(false);
         }
         break;
     }
     }
     return(true);
 }
        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);
            }
        }
Beispiel #8
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();
            }
        }
        public DataInputEnhancementScreenClass()
        {
            Debug.WriteLine("EnhancementScreen Constructor");
            InitializeComponent();
            AllowChangeEvents = false;
            NewRecord         = false;
            //Set the controls to the Chosen Skin Settings
            ApplySkin();

            TreeNames  = new List <string>();
            TreeModel  = new EnhancementTreeModel();
            SlotModels = new List <EnhancementSlotModel>();
            //EnhancementModels = new List<EnhancementModel>();
            //RankModels = new List<EnhancementRankModel>();

            //Lets populate the Main Tree List and sets it selected value to the first record
            PopulateEnhancementTreeListBox();
            if (TreeNames.Count() != 0)
            {
                EnhancementTreeListBox.SelectedIndex = 0;
            }

            //Lets Fill our fields out now
            if (TreeNames.Count() != 0)
            {
                PopulateFields(EnhancementTreeListBox.SelectedItem.ToString());
            }
            else
            {
                NewRecord = true;
                PopulateFields("_New Enhancement Tree_");
            }

            //Set our main tracking variable to false
            RecordChanged = false;

            //turn on our change events
            AllowChangeEvents = true;
        }
        private void comboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            string categoryName;

            categoryName = comboCategory.SelectedItem.ToString();

            ApplyToNames.Clear();
            comboApplyTo.Items.Clear();
            comboTree.Items.Clear();
            //resize our form
            this.Size = new Size(DefaultWidth, DefaultHeight);
            //hide our optional controls
            labelTree.Visible = false;
            comboTree.Visible = false;
            labelSlot.Visible = false;
            comboSlot.Visible = false;

            if (categoryName == "Ability")
            {
                ApplyToNames      = AbilityModel.GetNames();
                labelApplyTo.Text = "Select an Ability";
            }

            else if (categoryName == "Alignments")
            {
                ApplyToNames      = AlignmentModel.GetNames();
                labelApplyTo.Text = "Select an Alignment";
            }
            else if (categoryName == "Attribute")
            {
                ApplyToNames      = AttributeModel.GetNames();
                labelApplyTo.Text = "Select an Attribute";
            }

            else if (categoryName == "Character")
            {
                ApplyToNames.Add("Level");
                labelApplyTo.Text = "Select Character Property";
            }

            else if (categoryName == "Class")
            {
                ApplyToNames      = ClassModel.GetNames();
                labelApplyTo.Text = "Select a Class";
            }

            else if (categoryName == "Enhancement")
            {
                //lets resie our form to make room for other controls
                this.Size         = new Size(DefaultWidth, DefaultHeight + 99);
                labelTree.Visible = true;
                comboTree.Visible = true;
                labelSlot.Visible = true;
                comboSlot.Visible = true;
                TreeNames         = EnhancementTreeModel.GetNames();
                foreach (string name in TreeNames)
                {
                    comboTree.Items.Add(name);
                }
                labelApplyTo.Text = "Select an Enhancement";
                buttonOk.Enabled  = false;
                return;
            }

            else if (categoryName == "EnhancementSlot")
            {
                //lets resize our form to make room for other controls
                this.Size         = new Size(DefaultWidth, DefaultHeight + 47);
                labelTree.Visible = true;
                comboTree.Visible = true;
                TreeNames         = EnhancementTreeModel.GetNames();
                foreach (string name in TreeNames)
                {
                    comboTree.Items.Add(name);
                }
                labelApplyTo.Text = "Select an Enhancement Slot";
                buttonOk.Enabled  = false;
                return;
            }

            else if (categoryName == "Feat")
            {
                ApplyToNames      = FeatModel.GetNames();
                labelApplyTo.Text = "Select a Feat";
            }

            else if (categoryName == "Race")
            {
                ApplyToNames      = RaceModel.GetNames();
                labelApplyTo.Text = "Select a Race";
            }

            else if (categoryName == "Skill")
            {
                ApplyToNames      = SkillModel.GetNames();
                labelApplyTo.Text = "Select a Skill";
            }

            else
            {
                Debug.WriteLine("Error: No category exists for the one selected. RequirementDialogClass : comboCategory_SelectedIndexChanged()");
                return;
            }

            foreach (string name in ApplyToNames)
            {
                comboApplyTo.Items.Add(name);
            }
            buttonOk.Enabled = false;
        }
Beispiel #11
0
        private void CategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string category;

            category = CategoryComboBox.SelectedItem.ToString();

            ApplyToNames.Clear();
            ApplyToComboBox.Items.Clear();
            TreeComboBox.Items.Clear();
            //Lets set the default size of our form
            this.Size = new Size(DefaultWidth, DefaultHeight);
            //Hide our optional controls
            TreeLabel.Visible    = false;
            TreeComboBox.Visible = false;
            SlotLabel.Visible    = false;
            SlotComboBox.Visible = false;

            if (category == "Ability")
            {
                ApplyToNames      = AbilityModel.GetNames();
                ApplyToLabel.Text = "Select an Ability";
            }

            else if (category == "Attribute")
            {
                ApplyToNames      = AttributeModel.GetNames();
                ApplyToLabel.Text = "Select an Attribute";
            }

            else if (category == "Class")
            {
                ApplyToNames      = ClassModel.GetNames();
                ApplyToLabel.Text = "Select a Class";
            }

            else if (category == "Enhancement")
            {
                //Lets resize our form to make room for other controls
                this.Size            = new Size(DefaultWidth + 100, DefaultHeight + 94);
                TreeLabel.Visible    = true;
                TreeComboBox.Visible = true;
                SlotLabel.Visible    = true;
                SlotComboBox.Visible = true;
                TreeNames            = EnhancementTreeModel.GetNames();
                foreach (string name in TreeNames)
                {
                    TreeComboBox.Items.Add(name);
                }
                ApplyToLabel.Text = "Select an Enhancement";
                UpdateNameField();
                return;
            }

            else if (category == "EnhancementSlot")
            {
                //Lets resize our form to make room for other controls
                this.Size            = new Size(DefaultWidth + 100, DefaultHeight + 42);
                TreeLabel.Visible    = true;
                TreeComboBox.Visible = true;
                TreeNames            = EnhancementTreeModel.GetNames();
                foreach (string name in TreeNames)
                {
                    TreeComboBox.Items.Add(name);
                }
                ApplyToLabel.Text = "Select An Enhancement Slot";
                UpdateNameField();
                return;
            }
            else if (category == "Feat")
            {
                ApplyToNames      = FeatModel.GetNames();
                ApplyToLabel.Text = "Select a Feat";
            }

            else if (category == "Race")
            {
                ApplyToNames      = RaceModel.GetNames();
                ApplyToLabel.Text = "Select a Race";
            }

            else if (category == "Skill")
            {
                ApplyToNames      = SkillModel.GetNames();
                ApplyToLabel.Text = "Select a Skill";
            }

            else
            {
                Debug.WriteLine("Error: No category exists for the one selected. NewRequirementDialogClass : CategoryComboBox_SelectedIndexChanged()");
                return;
            }

            foreach (string name in ApplyToNames)
            {
                ApplyToComboBox.Items.Add(name);
            }

            UpdateNameField();
        }
Beispiel #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;
        }