Exemplo n.º 1
0
        /// <summary>
        /// Updates the compendium feat with id matching the parameter's id
        /// </summary>
        public void UpdateFeat(FeatModel model)
        {
            FeatModel currentModel = _feats.FirstOrDefault(x => x.Id == model.Id);

            if (currentModel != null)
            {
                _feats[_feats.IndexOf(currentModel)] = model;

                List <Guid> characterIDs = new List <Guid>();
                foreach (CharacterModel character in _characters)
                {
                    foreach (LevelModel level in character.Levels)
                    {
                        for (int i = 0; i < level.Feats.Count; ++i)
                        {
                            FeatModel feat = level.Feats[i];
                            if (feat.Id == model.Id)
                            {
                                level.Feats[i] = model;
                                characterIDs.Add(character.Id);
                            }
                        }
                    }
                }
                if (characterIDs.Any())
                {
                    CharacterChanged?.Invoke(this, new CompendiumChangeEventArgs(characterIDs.Distinct()));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the feat ids of the feats belonging to a parent feat
        /// </summary>
        /// <param name="featId">FeatId of the parent feat</param>
        /// <returns>A Guid List of the feats belonging to the parent feat</returns>
        public List <Guid> GetSubfeats(Guid featId)
        {
            List <Guid> subFeats = new List <Guid>();

            subFeats = FeatModel.GetIdsFromParentFeatId(featId);
            return(subFeats);
        }
Exemplo n.º 3
0
 private void ImportFeats()
 {
     foreach (FeatModel featModel in _feats)
     {
         if (_addAllEntries)
         {
             _compendium.AddFeat(featModel);
         }
         else if (_skipDuplicateEntries)
         {
             if (!_compendium.Feats.Any(x => x.Name.Equals(featModel.Name, StringComparison.CurrentCultureIgnoreCase)))
             {
                 _compendium.AddFeat(featModel);
             }
         }
         else if (_replaceExistingEntries)
         {
             FeatModel existing = _compendium.Feats.FirstOrDefault(x => x.Name.Equals(featModel.Name, StringComparison.CurrentCultureIgnoreCase));
             if (existing == null)
             {
                 _compendium.AddFeat(featModel);
             }
             else
             {
                 featModel.Id = existing.Id;
                 _compendium.UpdateFeat(featModel);
             }
         }
     }
 }
Exemplo n.º 4
0
        private string BuildRequirementText(Guid requirementId, string requirementComparison, double requirementValue)
        {
            string           text;
            string           tableName;
            RequirementModel reqModel;

            text = "";
            //text = RequirementModel.GetNameFromId(requirementId) + " " + requirementComparison + " " + requirementValue.ToString();
            reqModel = new RequirementModel();
            reqModel.Initialize(requirementId);
            tableName = TableNamesModel.GetTableNameFromId(reqModel.TableNamesId);
            if (tableName == "Ability")
            {
                text = AbilityModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString();
            }
            else if (tableName == "Alignments")
            {
                text = "Alignment: " + requirementComparison + " " + AlignmentModel.GetNameFromID(reqModel.ApplytoId);
            }
            else if (tableName == "Attribute")
            {
                text = AttributeModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString();
            }
            else if (tableName == "Character")
            {
                text = "Character " + requirementComparison + " Level " + requirementValue.ToString();
            }
            else if (tableName == "Class")
            {
                text = ClassModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Level " + requirementValue.ToString();
            }
            else if (tableName == "Enhancement")
            {
                text = "Enhnacement: " + EnhancementModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Rank " + requirementValue.ToString();
            }
            else if (tableName == "EnhancementSlot")
            {
                text = "Enhancement Slot: " + BuildSlotName(reqModel.ApplytoId) + " " + requirementComparison + " Rank " + requirementValue.ToString();
            }
            else if (tableName == "Feat")
            {
                text = "Feat: " + FeatModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Race")
            {
                text = RaceModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Level " + requirementValue.ToString();
            }
            else if (tableName == "Skill")
            {
                text = SkillModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString();
            }
            else
            {
                //we should not reach here
                Debug.WriteLine("Error: No category exists for this requirement. RequirementPanel2: BuildRequirementText()");
            }

            return(text);
        }
Exemplo n.º 5
0
 private void PopulateFeatListBox()
 {
     FeatNames = FeatModel.GetNames();
     foreach (string name in FeatNames)
     {
         FeatListBox.Items.Add(name);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a feat model
 /// </summary>
 public void AddFeat(FeatModel featModel)
 {
     if (featModel != null &&
         !_feats.Any(x => x.Id == featModel.Id))
     {
         _feats.Add(featModel);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Updates the model
        /// </summary>
        public void UpdateModel(FeatModel featModel)
        {
            _featModel = featModel;

            Initialize();

            OnPropertyChanged("");
        }
Exemplo n.º 8
0
 private void PopulatePastLifeFeatComboBoxList()
 {
     FeatNames = FeatModel.GetNames();
     PastLifeFeatCombo.Items.Add("");
     foreach (string name in FeatNames)
     {
         PastLifeFeatCombo.Items.Add(name);
     }
 }
        private void AddNewRequirementRecord()
        {
            RequirementModel reqModel;
            string           tableName;
            string           applyToName;

            reqModel    = new RequirementModel();
            tableName   = comboCategory.SelectedItem.ToString();
            applyToName = comboApplyTo.SelectedItem.ToString();

            reqModel.TableNamesId = TableNamesModel.GetIdFromTableName(tableName);
            if (tableName == "Ability")
            {
                reqModel.ApplytoId = AbilityModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Alignments")
            {
                reqModel.ApplytoId = AlignmentModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Attribute")
            {
                reqModel.ApplytoId = AttributeModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Class")
            {
                reqModel.ApplytoId = ClassModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Enhancement")
            {
                reqModel.ApplytoId = GetEnhancementId();
            }
            else if (tableName == "EnhancementSlot")
            {
                reqModel.ApplytoId = GetSlotId();
            }
            else if (tableName == "Feat")
            {
                reqModel.ApplytoId = FeatModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Race")
            {
                reqModel.ApplytoId = RaceModel.GetIdFromName(applyToName);
            }
            else if (tableName == "Skill")
            {
                reqModel.ApplytoId = SkillModel.GetIdFromName(applyToName);
            }
            else
            {
                Debug.WriteLine("Error: CategoryName isn't listed :: RequirementDialogClass: AddNewRequirement");
            }

            reqModel.Save();
            SelectedRequirementId = reqModel.Id;
        }
Exemplo n.º 10
0
        /// <summary>
        /// On initialization, preload the feat ids adn set up an entry in the dictionary
        /// </summary>
        private void LoadFeatIds()
        {
            List <Guid> featIds;

            featIds = FeatModel.GetIds();
            Feats   = new SortedDictionary <Guid, FeatDataClass>();
            foreach (Guid id in featIds)
            {
                Feats.Add(id, new FeatDataClass(id));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets formatted xml of object
        /// </summary>
        public string GetXML(FeatModel model)
        {
            string xml = String.Empty;

            if (model != null)
            {
                xml = $"<feat><id>{model.Id}</id>{model.XML}</feat>";
            }

            return(xml);
        }
Exemplo n.º 12
0
        private void AddFeat()
        {
            FeatModel         featModel    = _compendium.Feats.First();
            FeatEditViewModel featEditView = new FeatEditViewModel(featModel);

            featEditView.SelectionChanged += FeatEditView_SelectionChanged;
            _feats.Add(featEditView);

            UpdateModelFeats();

            OnPropertyChanged(nameof(Feats));
        }
Exemplo n.º 13
0
 private void PopulateParentFeatComboBox()
 {
     ParentFeatNames = FeatModel.GetNamesByIsParentFeat(true);
     ParentFeatComboBox.Items.Add("");
     if (ParentFeatNames != null)
     {
         foreach (string name in ParentFeatNames)
         {
             ParentFeatComboBox.Items.Add(name);
         }
     }
 }
Exemplo n.º 14
0
 private void UpdateModelFeats()
 {
     _levelModel.Feats.Clear();
     foreach (FeatEditViewModel feat in _feats)
     {
         FeatModel model = _compendium.Feats.FirstOrDefault(x => x.Id == feat.SelectedFeat.Item1);
         if (model != null)
         {
             _levelModel.Feats.Add(model);
         }
     }
 }
        private Guid GetApplyToId()
        {
            Guid   applyToId;
            string tableName;

            applyToId = Guid.Empty;
            tableName = comboCategory.SelectedItem.ToString();

            if (tableName == "Ability")
            {
                applyToId = AbilityModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Alignments")
            {
                applyToId = AlignmentModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Attribute")
            {
                applyToId = AttributeModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Character")
            {
                applyToId = Guid.Empty;
            }
            if (tableName == "Class")
            {
                applyToId = ClassModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Enhancement")
            {
                applyToId = GetEnhancementId();
            }
            if (tableName == "EnhancementSlot")
            {
                applyToId = GetSlotId();
            }
            if (tableName == "Feat")
            {
                applyToId = FeatModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Race")
            {
                applyToId = RaceModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }
            if (tableName == "Skill")
            {
                applyToId = SkillModel.GetIdFromName(comboApplyTo.SelectedItem.ToString());
            }

            return(applyToId);
        }
Exemplo n.º 16
0
        private void FillcomboModifier()
        {
            string categoryName;

            categoryName = comboCategory.SelectedItem.ToString();
            ModifierNames.Clear();
            comboModifier.Items.Clear();

            if (categoryName == "Ability")
            {
                labelModifier.Text = "Select an Ability";
                ModifierNames      = AbilityModel.GetNames();
            }
            else if (categoryName == "Attribute")
            {
                labelModifier.Text = "Select an Attribute";
                ModifierNames      = AttributeModel.GetNames();
            }
            else if (categoryName == "Feat")
            {
                labelModifier.Text = "Select a Feat";
                ModifierNames      = FeatModel.GetNames();
            }
            else if (categoryName == "Save")
            {
                labelModifier.Text = "Select a Save";
                ModifierNames      = SaveModel.GetNames();
            }
            else if (categoryName == "Skill")
            {
                labelModifier.Text = "Select a Skill";
                ModifierNames      = SkillModel.GetNames();
            }
            else if (categoryName == "Spell")
            {
                labelModifier.Text = "Select a Spell";
                ModifierNames      = SpellModel.GetNames();
            }
            else
            {
                //We should never reach this, if so, we need to add a category of fix one.
                Debug.WriteLine("Error: no category exist for the selected. ModifierDialogClass::FillcomboModifier()");
                return;
            }

            foreach (string name in ModifierNames)
            {
                comboModifier.Items.Add(name);
            }
        }
Exemplo n.º 17
0
 private bool CheckForUniqueness(string newValue, InputType type)
 {
     switch (type)
     {
     case InputType.Name:
     {
         if (FeatModel.DoesNameExist(newValue) == true)
         {
             return(false);
         }
         break;
     }
     }
     return(true);
 }
Exemplo n.º 18
0
        private void PopulateData()
        {
            // Generate our lists that will be used for our comboboxes.
            FeatNames = FeatModel.GetNames();
            Levels.Clear();
            for (int i = 1; i <= Constant.MaxLevels; i++)
            {
                if (i > Constant.NumHeroicLevels && MainScreen != ScreenType.Character)
                {
                    break;
                }
                Levels.Add(i.ToString());
            }

            //Get our model data and record count
            switch (MainScreen)
            {
            case ScreenType.Character:
            {
                CharacterFeatModel = CharacterBonusFeatModel.GetAll();
                RecordCount        = CharacterFeatModel.Count;
                break;
            }

            case ScreenType.Class:
            {
                ClassFeatModel = ClassBonusFeatModel.GetAll(MainRecordId);
                RecordCount    = ClassFeatModel.Count;
                break;
            }

            case ScreenType.Race:
            {
                RaceFeatModel = RaceBonusFeatModel.GetAll(MainRecordId);
                RecordCount   = RaceFeatModel.Count;
                break;
            }
            }

            //Set our tracking variables to false.
            HasDataChanged.Clear();
            RecordDeleted.Clear();
            for (int i = 0; i < RecordCount; i++)
            {
                HasDataChanged.Add(false);
                RecordDeleted.Add(false);
            }
        }
        private void CategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string category;

            category = CategoryComboBox.SelectedItem.ToString();

            ApplyToNames.Clear();
            if (category == "Ability")
            {
                ApplyToLabel.Text = "Select an Ability";
                ApplyToNames      = AbilityModel.GetNames();
            }
            else if (category == "Attribute")
            {
                ApplyToLabel.Text = "Select an Attribute";
                ApplyToNames      = AttributeModel.GetNames();
            }
            else if (category == "Feat")
            {
                ApplyToLabel.Text = "Select a Feat";
                ApplyToNames      = FeatModel.GetNames();
            }
            else if (category == "Save")
            {
                ApplyToLabel.Text = "Select a Save";
                ApplyToNames      = SaveModel.GetNames();
            }
            else if (category == "Skill")
            {
                ApplyToLabel.Text = "Select a Skill";
                ApplyToNames      = SkillModel.GetNames();
            }
            else if (category == "Spell")
            {
                ApplyToLabel.Text = "Select a spell";
                ApplyToNames      = SpellModel.GetNames();
            }
            else
            {
                Debug.WriteLine("Error: No category exists for the one selected. NewModifierDialogClass : CategoryComboBox_SelectedIndexChanged()");
                return;
            }
            FillApplyToComboBox();
            UpdateNameField();
        }
Exemplo n.º 20
0
        private void LoadData()
        {
            FeatModel model;

            model = new FeatModel();
            model.Initialize(_FeatId);
            _FeatName       = model.Name;
            _FeatCategoryId = model.FeatCategoryId;
            _isParentFeat   = model.IsParentFeat;
            _parentFeatId   = model.ParentFeat;
            _iconName       = model.ImageFileName;
            _description    = model.Description;
            _multiple       = model.Multiple;
            _duration       = model.Duration;
            _stanceId       = model.StanceId;
            _featTypeIds    = FeatFeatTypeModel.GetIdsByFeatId(_FeatId);
            IsLoaded        = true;
        }
Exemplo n.º 21
0
        private Guid GetApplyToId()
        {
            Guid   applyToId;
            string tableName;

            applyToId = Guid.Empty;
            tableName = comboCategory.SelectedItem.ToString();


            if (tableName == "Ability")
            {
                applyToId = AbilityModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Attribute")
            {
                applyToId = AttributeModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Feat")
            {
                applyToId = FeatModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Save")
            {
                applyToId = SaveModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Skill")
            {
                applyToId = SkillModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Spell")
            {
                applyToId = SpellModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else
            {
                //We should never reach this, if so, we need to add a category of fix one.
                Debug.WriteLine("Error: no category exists for the selected. ModifierDialogClass::GetApplyToId()");
                return(applyToId);
            }

            return(applyToId);
        }
Exemplo n.º 22
0
 public AutoGrantedFeatsPanel()
 {
     InitializeComponent();
     LevelComboBox         = new List <ComboBox>();
     FeatNameComboBox      = new List <ComboBox>();
     IgnorePreReqsCheckBox = new List <CheckBox>();
     DeleteButton          = new List <Button>();
     MainScreen            = ScreenType.Character;
     Levels             = new List <string>();
     FeatNames          = new List <string>();
     CharacterFeatModel = new List <CharacterBonusFeatModel>();
     ClassFeatModel     = new List <ClassBonusFeatModel>();
     RaceFeatModel      = new List <RaceBonusFeatModel>();
     HasDataChanged     = new List <bool>();
     RecordDeleted      = new List <bool>();
     RecordCount        = 0;
     MainRecordId       = new Guid();
     ModelofFeat        = new FeatModel();
     HasChanged         = false;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Temporary method to strip our current feat Description of the HTML tags that are no longer needed.
        /// </summary>
        public static void FixFeatDescriptions()
        {
            int           count;
            FeatModel     model;
            List <string> featNames;
            string        newDescription;

            featNames = FeatModel.GetNames();
            count     = featNames.Count();
            //count = 1;
            for (int i = 0; i < count; i++)
            {
                model = new FeatModel();
                model.Initialize(featNames[i]);
                if (model.Description != null)
                {
                    newDescription    = StripHTMLfromOldDescriptions(model.Description);
                    model.Description = newDescription;
                    model.Save();
                }
            }
        }
        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;
        }
Exemplo n.º 25
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();
        }
Exemplo n.º 26
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;
        }
Exemplo n.º 27
0
        private void ComboBoxChange(object sender, InputType type)
        {
            ComboBox changedBox;
            string   boxIndexString;
            int      boxIndex;
            string   newValueString;
            int      newValueInt;
            Guid     newValueGuid;

            //extract the index value of the cotnrol sending this message
            changedBox     = new ComboBox();
            changedBox     = (ComboBox)sender;
            boxIndexString = Regex.Match(changedBox.Name, @"\d+").Value;
            boxIndex       = Int32.Parse(boxIndexString);

            //grab the new value
            newValueString = changedBox.SelectedItem.ToString();

            switch (type)
            {
            case InputType.Level:
            {
                if (newValueString.Length == 0)
                {
                    newValueInt = 0;
                }
                else
                {
                    newValueInt = Int32.Parse(newValueString);
                }
                switch (MainScreen)
                {
                case ScreenType.Character:
                {
                    if (newValueInt != CharacterFeatModel[boxIndex].Level)
                    {
                        CharacterFeatModel[boxIndex].Level = newValueInt;
                        HasDataChanged[boxIndex]           = true;
                    }
                    break;
                }

                case ScreenType.Class:
                {
                    if (newValueInt != ClassFeatModel[boxIndex].Level)
                    {
                        ClassFeatModel[boxIndex].Level = newValueInt;
                        HasDataChanged[boxIndex]       = true;
                    }
                    break;
                }

                case ScreenType.Race:
                {
                    if (newValueInt != RaceFeatModel[boxIndex].Level)
                    {
                        RaceFeatModel[boxIndex].Level = newValueInt;
                        HasDataChanged[boxIndex]      = true;
                    }
                    break;
                }
                }
                break;
            }

            case InputType.FeatName:
            {
                ModelofFeat = new FeatModel();
                ModelofFeat.Initialize(newValueString);
                newValueGuid = ModelofFeat.Id;
                switch (MainScreen)
                {
                case ScreenType.Character:
                {
                    if (newValueGuid != CharacterFeatModel[boxIndex].FeatId)
                    {
                        CharacterFeatModel[boxIndex].FeatId = newValueGuid;
                        HasDataChanged[boxIndex]            = true;
                    }
                    break;
                }

                case ScreenType.Class:
                {
                    if (newValueGuid != ClassFeatModel[boxIndex].FeatId)
                    {
                        ClassFeatModel[boxIndex].FeatId = newValueGuid;
                        HasDataChanged[boxIndex]        = true;
                    }
                    break;
                }

                case ScreenType.Race:
                {
                    if (newValueGuid != RaceFeatModel[boxIndex].FeatId)
                    {
                        RaceFeatModel[boxIndex].FeatId = newValueGuid;
                        HasDataChanged[boxIndex]       = true;
                    }
                    break;
                }
                }
                break;
            }

            default:
            {
                Debug.WriteLine("Error: Unknown InputType in ComboBoxChange");
                break;
            }
            }
        }
Exemplo n.º 28
0
        private void PopulateFields(string featName)
        {
            List <FeatFeatTypeModel> featTypeModels;
            List <FeatTargetModel>   featTargetModels;

            Model = new FeatModel();
            Model.Initialize(featName);

            featTypeModels   = FeatFeatTypeModel.GetAllByFeatId(Model.Id);
            featTargetModels = FeatTargetModel.GetAllByFeatId(Model.Id);

            //set our Database values for Error checkign unique values.
            DatabaseName = Model.Name;

            //set the main control values
            NameInputBox.Text = Model.Name;
            CategoryFeatComboBox.SelectedItem = FeatCategoryModel.GetNameFromId(Model.FeatCategoryId);
            ParentFeatCheckBox.Checked        = Model.IsParentFeat;
            MultiplesCheckBox.Checked         = Model.Multiple;
            ParentFeatComboBox.SelectedItem   = FeatModel.GetNameFromId(Model.ParentFeat);
            StanceComboBox.SelectedItem       = StanceModel.GetStanceNameFromId(Model.StanceId);
            IconFileNameInputBox.Text         = Model.ImageFileName;
            FeatIcon = new IconClass("Feats\\" + Model.ImageFileName);
            FeatIcon.SetLocation(this.Width, this.Height, FeatIconLocation);
            DurationTextBox.Text = Model.Duration;

            //System tracking labels
            RecordGUIDLabel.Text = Model.Id.ToString();
            ModDateLabel.Text    = Model.LastUpdatedDate.ToString();
            ModVersionLabel.Text = Model.LastUpdatedVersion;

            //DescriptionWebBrowser control
            DescriptionHtmlEditor.Text = Model.Description;

            //Set the FeatTypes
            //clear previous values if any.
            FeatTypesSelected = new List <FeatTypeSelection>();
            foreach (int i in FeatTypesCheckedListBox.CheckedIndices)
            {
                FeatTypesCheckedListBox.SetItemChecked(i, false);
            }

            if (featTypeModels != null)
            {
                foreach (FeatFeatTypeModel ftmodel in featTypeModels)
                {
                    FeatTypesSelected.Add(new FeatTypeSelection());
                    FeatTypesSelected[FeatTypesSelected.Count - 1].Model        = ftmodel;
                    FeatTypesSelected[FeatTypesSelected.Count - 1].DeleteRecord = false;
                    FeatTypesCheckedListBox.SetItemChecked(FeatTypesCheckedListBox.FindStringExact(FeatTypeModel.GetNameFromId(ftmodel.FeatTypeId)), true);
                }
            }

            //Set the FeatTargets, clear previous values if any.
            FeatTargetsSelected = new List <FeatTargetSelection>();
            foreach (int i in FeatTargetsCheckedListBox.CheckedIndices)
            {
                FeatTargetsCheckedListBox.SetItemChecked(i, false);
            }

            if (featTargetModels != null)
            {
                foreach (FeatTargetModel ftmodel in featTargetModels)
                {
                    FeatTargetsSelected.Add(new FeatTargetSelection());
                    FeatTargetsSelected[FeatTargetsSelected.Count - 1].Model        = ftmodel;
                    FeatTargetsSelected[FeatTargetsSelected.Count - 1].DeleteRecord = false;
                    FeatTargetsCheckedListBox.SetItemChecked(FeatTargetsCheckedListBox.FindStringExact(TargetModel.GetNameFromId(ftmodel.TargetId)), true);
                }
            }

            //Set the the requirements panel
            FeatRequirementsRP2.Clear();
            FeatRequirementsRP2.RecordId = Model.Id;
            FeatRequirementsRP2.Initialize();

            //Set the modifiers panel
            MP2Modifiers.Clear();
            MP2Modifiers.RecordId = Model.Id;
            MP2Modifiers.Initialize();

            //Invalidate the screen to update graphics
            Invalidate();
        }
        private string GetApplyToName(Guid requirementId)
        {
            string           applyToName;
            string           tableName;
            RequirementModel reqModel;
            EnhancementModel enhancementModel;

            reqModel = GetRequirementModel(requirementId);
            //tableName = "Class";

            tableName = TableNamesModel.GetTableNameFromId(reqModel.TableNamesId);

            if (tableName == "Ability")
            {
                applyToName = AbilityModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Alignments")
            {
                applyToName = AlignmentModel.GetNameFromID(reqModel.ApplytoId);
            }
            else if (tableName == "Attribute")
            {
                applyToName = AttributeModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Character")
            {
                applyToName = "Level";
            }
            else if (tableName == "Class")
            {
                applyToName = ClassModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Enhancement")
            {
                //"Pos " + model.DisplayOrder.ToString() + ":: " + model.Name)
                enhancementModel = new EnhancementModel();
                enhancementModel.Initialize(reqModel.ApplytoId);
                applyToName = "Pos " + enhancementModel.DisplayOrder + ":: " + enhancementModel.Name;
            }
            else if (tableName == "EnhancementSlot")
            {
                applyToName = BuildSlotName(GetSlotModel(requirementId));
            }
            else if (tableName == "Feat")
            {
                applyToName = FeatModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Race")
            {
                applyToName = RaceModel.GetNameFromId(reqModel.ApplytoId);
            }
            else if (tableName == "Skill")
            {
                applyToName = SkillModel.GetNameFromId(reqModel.ApplytoId);
            }
            else
            {
                applyToName = "";
            }
            Debug.WriteLine("ApplyToName = " + applyToName);
            return(applyToName);
        }
Exemplo n.º 30
0
        private void ComboBoxChange(object sender, InputType type)
        {
            string newValueString;
            Guid   newValueGuid;

            switch (type)
            {
            case InputType.FeatCategory:
            {
                newValueString = CategoryFeatComboBox.SelectedItem.ToString();
                if (newValueString == "")
                {
                    newValueGuid = Guid.Empty;
                }
                else
                {
                    newValueGuid = FeatCategoryModel.GetIdFromName(newValueString);
                }

                if (newValueGuid != Model.FeatCategoryId)
                {
                    Model.FeatCategoryId = newValueGuid;
                    RecordChanged        = true;
                }
                break;
            }

            case InputType.ParentFeat:
            {
                newValueString = ParentFeatComboBox.SelectedItem.ToString();
                if (newValueString == "")
                {
                    newValueGuid = Guid.Empty;
                }
                else
                {
                    newValueGuid = FeatModel.GetIdFromName(newValueString);
                }

                if (newValueGuid != Model.ParentFeat)
                {
                    Model.ParentFeat = newValueGuid;
                    RecordChanged    = true;
                }
                break;
            }

            case InputType.Stance:
            {
                newValueString = StanceComboBox.SelectedItem.ToString();
                if (newValueString == "")
                {
                    newValueGuid = Guid.Empty;
                }
                else
                {
                    newValueGuid = StanceModel.GetIdFromStanceName(newValueString);
                }

                if (newValueGuid != Model.StanceId)
                {
                    Model.StanceId = newValueGuid;
                    RecordChanged  = true;
                }
                break;
            }
            }
        }