private void ComboBoxChange(object sender)
        {
            ComboBox changedBox;
            string   boxIndexString;
            int      boxIndex;
            string   newValueString;
            Guid     newValue;

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

            //grab the new value
            //newValueString = Regex.Match(changedBox.SelectedItem, @"\d+").Value;
            newValueString  = changedBox.SelectedItem.ToString();
            ModelofFeatType = new FeatTypeModel();
            ModelofFeatType.Initialize(newValueString);
            newValue = ModelofFeatType.Id;

            if (newValue != ModelofCharacter[boxIndex].FeatTypeId)
            {
                ModelofCharacter[boxIndex].FeatTypeId = newValue;
                LevelDataHasChanged[boxIndex]         = true;
            }
        }
        /// <summary>
        /// Populate the fields with the appropriate Character data.
        /// </summary>
        private void PopulateFields()
        {
            string featTypeName;

            for (int i = 1; i <= Constant.MaxLevels; i++)
            {
                featTypeName = "";

                ControlName            = "HitPointsInputBox" + i;
                HitPointsInputBox      = (TextBox)this.Controls[ControlName];
                HitPointsInputBox.Text = ModelofCharacter[i - 1].HitPoints.ToString();

                ControlName                = "FortitudeSave" + i + "InputBox";
                FortitudeSaveInputBox      = (TextBox)this.Controls[ControlName];
                FortitudeSaveInputBox.Text = ModelofCharacter[i - 1].FortitudeSave.ToString();

                ControlName             = "ReflexSaveInputBox" + i;
                ReflexSaveInputBox      = (TextBox)this.Controls[ControlName];
                ReflexSaveInputBox.Text = ModelofCharacter[i - 1].ReflexSave.ToString();

                ControlName           = "WillSaveInputBox" + i;
                WillSaveInputBox      = (TextBox)this.Controls[ControlName];
                WillSaveInputBox.Text = ModelofCharacter[i - 1].WillSave.ToString();

                ControlName                  = "BaseAttackBonusInputbox" + i;
                BaseAttackBonusInputBox      = (TextBox)this.Controls[ControlName];
                BaseAttackBonusInputBox.Text = ModelofCharacter[i - 1].BaseAttackBonus.ToString();

                ControlName     = "BonusFeatCombo" + i;
                ModelofFeatType = new FeatTypeModel();
                ModelofFeatType.Initialize(ModelofCharacter[i - 1].FeatTypeId);
                BonusFeatTypeCombo = (ComboBox)this.Controls[ControlName];
                if (ModelofFeatType.Name != null)
                {
                    featTypeName = ModelofFeatType.Name.ToString();
                    if (featTypeName != "")
                    {
                        BonusFeatTypeCombo.SelectedItem = ModelofFeatType.Name.ToString();
                    }
                }

                //Need to set these to false since we are just populating the fields and haven't changed that data.
                LevelDataHasChanged[i - 1] = false;
            }
        }
        private void ArrayComboBoxChange(object sender, InputType Type)
        {
            ComboBox      changedBox;
            string        boxIndexString;
            int           boxIndex;
            string        newValueString;
            FeatTypeModel modelofFeatType;

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

            switch (Type)
            {
            case InputType.BonusFeat:
            {
                if (changedBox.SelectedIndex == 0)
                {
                    Model.LevelDetails[boxIndex].FeatTypeId = Guid.Empty;
                }
                else
                {
                    //grab the selection's guid
                    newValueString  = changedBox.SelectedItem.ToString();
                    modelofFeatType = new FeatTypeModel();
                    modelofFeatType.Initialize(newValueString);
                    Model.LevelDetails[boxIndex].FeatTypeId = modelofFeatType.Id;
                }
                DataHasChanged = true;
                break;
            }

            default:
            {
                Debug.WriteLine("Error: Unknown Type in Array Combo Box Change");
                break;
            }
            }
        }
Exemple #4
0
        private void ComboBoxChange(object sender, InputType type)
        {
            ComboBox changedBox;
            string   boxIndexString;
            int      boxIndex;
            string   newValueString;
            Guid     newValueGuid;

            ClassModel    modelofClass;
            FeatModel     modelofFeat;
            FeatTypeModel modelofFeatType;

            switch (type)
            {
            case InputType.StrMin:
            {
                newValueString = StrengthMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.StrengthMinimum.ToString())
                {
                    ModelofRace.StrengthMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged          = true;
                }
                break;
            }

            case InputType.StrMax:
            {
                newValueString = StrengthMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.StrengthMaximum.ToString())
                {
                    ModelofRace.StrengthMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged          = true;
                }
                break;
            }

            case InputType.DexMin:
            {
                newValueString = DexterityMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.DexterityMinimum.ToString())
                {
                    ModelofRace.DexterityMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged           = true;
                }
                break;
            }

            case InputType.DexMax:
            {
                newValueString = DexterityMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.DexterityMaximum.ToString())
                {
                    ModelofRace.DexterityMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged           = true;
                }
                break;
            }

            case InputType.ConMin:
            {
                newValueString = ConstitutionMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.ConstitutionMinimum.ToString())
                {
                    ModelofRace.ConstitutionMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged = true;
                }
                break;
            }

            case InputType.ConMax:
            {
                newValueString = ConstitutionMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.ConstitutionMaximum.ToString())
                {
                    ModelofRace.ConstitutionMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged = true;
                }
                break;
            }

            case InputType.IntMin:
            {
                newValueString = IntelligenceMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.IntelligenceMinimum.ToString())
                {
                    ModelofRace.IntelligenceMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged = true;
                }
                break;
            }

            case InputType.IntMax:
            {
                newValueString = IntelligenceMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.IntelligenceMaximum.ToString())
                {
                    ModelofRace.IntelligenceMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged = true;
                }
                break;
            }

            case InputType.WisMin:
            {
                newValueString = WisdomMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.WisdomMinimum.ToString())
                {
                    ModelofRace.WisdomMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged        = true;
                }
                break;
            }

            case InputType.WisMax:
            {
                newValueString = WisdomMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.WisdomMaximum.ToString())
                {
                    ModelofRace.WisdomMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged        = true;
                }
                break;
            }

            case InputType.ChaMin:
            {
                newValueString = CharismaMinimumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.CharismaMinimum.ToString())
                {
                    ModelofRace.CharismaMinimum = Int32.Parse(newValueString);
                    HasRaceDataChanged          = true;
                }
                break;
            }

            case InputType.ChaMax:
            {
                newValueString = CharismaMaximumBox.SelectedItem.ToString();

                if (newValueString != ModelofRace.CharismaMaximum.ToString())
                {
                    ModelofRace.CharismaMaximum = Int32.Parse(newValueString);
                    HasRaceDataChanged          = true;
                }
                break;
            }

            case InputType.StartingClass:
            {
                newValueString = StartingClassComboBox.SelectedItem.ToString();
                if (newValueString == "")
                {
                    newValueGuid = Guid.Empty;
                }
                else
                {
                    modelofClass = new ClassModel();
                    modelofClass.Initialize(newValueString);
                    newValueGuid = modelofClass.Id;
                }

                if (newValueGuid != ModelofRace.StartingClassId)
                {
                    ModelofRace.StartingClassId = newValueGuid;
                    HasRaceDataChanged          = true;
                }
                break;
            }

            case InputType.PastLifeFeat:
            {
                newValueString = PastLifeFeatCombo.SelectedItem.ToString();
                if (newValueString == "")
                {
                    newValueGuid = Guid.Empty;
                }
                else
                {
                    modelofFeat = new FeatModel();
                    modelofFeat.Initialize(newValueString);
                    newValueGuid = modelofFeat.Id;
                }
                if (newValueGuid != ModelofRace.PastLifeFeatId)
                {
                    ModelofRace.PastLifeFeatId = newValueGuid;
                    HasRaceDataChanged         = true;
                }
                break;
            }

            case InputType.BonusFeatChoice:
            {
                changedBox     = new ComboBox();
                changedBox     = (ComboBox)sender;
                boxIndexString = Regex.Match(changedBox.Name, @"\d+").Value;
                boxIndex       = Int32.Parse(boxIndexString) - 1;

                newValueString  = changedBox.SelectedItem.ToString();
                modelofFeatType = new FeatTypeModel();
                modelofFeatType.Initialize(newValueString);
                newValueGuid = modelofFeatType.Id;

                if (newValueGuid != ModelofRaceDetail[boxIndex].FeatTypeId)
                {
                    ModelofRaceDetail[boxIndex].FeatTypeId = newValueGuid;
                    HasRaceDetailsChanged[boxIndex]        = true;
                }
                break;
            }
            }
        }
        /// <summary>
        /// for a given selected record, show its data in the appropriate fields
        /// </summary>
        /// <param name="recordName">The name of the record to show</param>
        private void PopulateFields(string recordName)
        {
            string             controlName;
            ComboBox           bonusFeatComboBox;
            FeatTypeModel      featType;
            List <string>      destinyName;
            DestinySphereModel currentDestiny;

            Model.Initialize(recordName);
            //cache the name and abbreviation strings for later comparisons
            DatabaseName           = Model.Name;
            DatabaseAbbreviation   = Model.Abbreviation;
            ClassNameInputBox.Text = Model.Name;
            DescriptionPreview.Navigate("about:blank");
            DescriptionPreview.Document.OpenNew(false);
            DescriptionPreview.Document.Write(Model.Description);
            DescriptionPreview.Refresh();
            HitDieInputBox.Text = Model.HitDie.ToString();
            ClassNameAbbreviationInputBox.Text = Model.Abbreviation;
            SkillPointsInputBox.Text           = Model.SkillPoints.ToString();
            IconNameInputBox.Text = Model.ImageFilename;
            ClassIcon             = new IconClass(Model.ImageFilename);
            ClassIcon.SetLocation(this.Width, this.Height, IconLocation);
            for (int i = 1; i <= Constant.NumHeroicLevels; i++)
            {
                controlName = "FortSaveInputBox" + i;
                Controls[controlName].Text = Model.LevelDetails[i - 1].FortitudeSave.ToString();
                controlName = "ReflexSaveInputBox" + i;
                Controls[controlName].Text = Model.LevelDetails[i - 1].ReflexSave.ToString();
                controlName = "WillSaveInputBox" + i;
                Controls[controlName].Text = Model.LevelDetails[i - 1].WillSave.ToString();
                controlName = "BABInputBox" + i;
                Controls[controlName].Text = Model.LevelDetails[i - 1].BaseAttackBonus.ToString();
                controlName       = "BonusFeatComboBox" + i;
                bonusFeatComboBox = Controls[controlName] as ComboBox;
                if (Model.LevelDetails[i - 1].FeatTypeId == Guid.Empty)
                {
                    bonusFeatComboBox.SelectedIndex = 0;
                }
                else
                {
                    featType = new FeatTypeModel();
                    featType.Initialize(Model.LevelDetails[i - 1].FeatTypeId);
                    bonusFeatComboBox.SelectedIndex = bonusFeatComboBox.FindStringExact(featType.Name);
                }
            }
            AlignmentsAllowedListBox.Items.Clear();
            if (Model.AllowedAlignments != null)
            {
                foreach (AlignmentModel alignment in Model.AllowedAlignments)
                {
                    AlignmentsAllowedListBox.Items.Add(alignment.Name);
                }
            }

            ClassSkillsListBox.Items.Clear();
            if (Model.ClassSkills != null)
            {
                foreach (SkillModel skill in Model.ClassSkills)
                {
                    ClassSkillsListBox.Items.Add(skill.Name);
                }
            }

            RecordGUIDLabel.Text = Model.Id.ToString();
            ModDateLabel.Text    = Model.LastUpdatedDate.ToString();
            ModVersionLabel.Text = Model.LastUpdatedVersion;

            destinyName = DestinySphereModel.GetNames();
            StartingDestinySphereComboBox.Items.Clear();
            foreach (string name in destinyName)
            {
                StartingDestinySphereComboBox.Items.Add(name);
            }

            MaxSpellLevelComboBox.Items.Clear();
            for (int i = 0; i <= 9; i++)
            {
                MaxSpellLevelComboBox.Items.Add(i.ToString());
            }
            MaxSpellLevelComboBox.SelectedIndex = Model.MaxSpellLevel;

            currentDestiny = new DestinySphereModel();
            currentDestiny.Initialize(Model.StartingDestinySphereId);
            StartingDestinySphereComboBox.SelectedIndex = StartingDestinySphereComboBox.FindStringExact(currentDestiny.Name);


            //make sure we haven't changed the data (Populating data from the database doesn't count as a change!)
            DataHasChanged = false;
        }