コード例 #1
0
        private void AddSpellDetailRecordUI(SpellDetailsModel detail)
        {
            SpellDetailRecordCount++;

            //Lets add a new set of controls
            //Create the class combo box
            SpellDetailClassComboBox.Add(new ComboBox());
            SpellDetailSubPanel.Controls.Add(SpellDetailClassComboBox[SpellDetailRecordCount - 1]);
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].Location                  = new Point(0, (SpellDetailRecordCount - 1) * 23);
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].Name                      = "SpellDetailClassComboBox[" + (SpellDetailRecordCount - 1) + "]";
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].Size                      = new Size(121, 21);
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].DropDownStyle             = ComboBoxStyle.DropDownList;
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].SelectionChangeCommitted += new System.EventHandler(this.OnSpellDetailClassComboBoxSelectedChangeCommitted);
            foreach (string name in ClassNames)
            {
                SpellDetailClassComboBox[SpellDetailRecordCount - 1].Items.Add(name);
            }
            SpellDetailClassComboBox[SpellDetailRecordCount - 1].SelectedItem = ClassModel.GetNameFromId(detail.ClassId);

            //Create the level combo box
            SpellDetailLevelComboBox.Add(new ComboBox());
            SpellDetailSubPanel.Controls.Add(SpellDetailLevelComboBox[SpellDetailRecordCount - 1]);
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].Location                  = new Point(127, (SpellDetailRecordCount - 1) * 23);
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].Name                      = "SpellDetailLevelComboBox[" + (SpellDetailRecordCount - 1) + "]";
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].Size                      = new Size(40, 21);
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].DropDownStyle             = ComboBoxStyle.DropDownList;
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].SelectionChangeCommitted += new System.EventHandler(this.OnSpellDetailLevelComboBoxSelectedChangeCommitted);
            for (int i = 1; i <= SpellMaxLevelByClass[SpellDetailClassComboBox[SpellDetailRecordCount - 1].SelectedIndex]; i++)
            {
                SpellDetailLevelComboBox[SpellDetailRecordCount - 1].Items.Add(i.ToString());
            }
            SpellDetailLevelComboBox[SpellDetailRecordCount - 1].SelectedItem = detail.Level.ToString();

            //Create the Cooldown numeric up/down box
            SpellDetailCoolDownTextBox.Add(new TextBox());
            SpellDetailSubPanel.Controls.Add(SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1]);
            SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1].Location = new Point(176, (SpellDetailRecordCount - 1) * 23);
            SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1].Name     = "SpellDetailCoolDownTextBox[" + (SpellDetailRecordCount - 1) + "]";
            SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1].Size     = new Size(73, 20);
            SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1].Leave   += new System.EventHandler(this.OnSpellDetailCoolDownTextBoxLeave);
            SpellDetailCoolDownTextBox[SpellDetailRecordCount - 1].Text     = detail.Cooldown;

            //Create the SP Cost text box
            SpellDetailSPCostUpDownBox.Add(new NumericUpDown());
            SpellDetailSubPanel.Controls.Add(SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1]);
            SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1].Location = new Point(255, (SpellDetailRecordCount - 1) * 23);
            SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1].Name     = "SpellDetailSPCostTextBox[" + (SpellDetailRecordCount - 1) + "]";
            SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1].Size     = new Size(60, 20);
            SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1].Leave   += new System.EventHandler(this.OnSpellDetailSPCostUpDownLeave);
            SpellDetailSPCostUpDownBox[SpellDetailRecordCount - 1].Value    = detail.SPCost;

            //create the delete button
            SpellDetailDeleteButton.Add(new Button());
            SpellDetailSubPanel.Controls.Add(SpellDetailDeleteButton[SpellDetailRecordCount - 1]);
            SpellDetailDeleteButton[SpellDetailRecordCount - 1].Location = new Point(318, (SpellDetailRecordCount - 1) * 23);
            SpellDetailDeleteButton[SpellDetailRecordCount - 1].Name     = "SpellDetailDeleteButton[" + (SpellDetailRecordCount - 1) + "]";
            SpellDetailDeleteButton[SpellDetailRecordCount - 1].Size     = new Size(20, 20);
            SpellDetailDeleteButton[SpellDetailRecordCount - 1].Image    = Properties.Resources.DeleteSmall;
            SpellDetailDeleteButton[SpellDetailRecordCount - 1].Click   += new System.EventHandler(this.OnSpellDetailDeleteButtonClick);
        }
コード例 #2
0
        /// <summary>
        /// Save the data from the model into the database
        /// </summary>
        private void SaveScreen()
        {
            Guid spellId;

            SaveFeedbackLabel.Text = "Saving Record...";
            SaveFeedbackLabel.Refresh();

            Model.Save();
            //clear the detail model in the database to make sure we save the correct data
            spellId = SpellModel.GetIdFromName(Model.SpellName);
            SpellDetailsModel.DeleteBySpell(spellId);
            for (int i = 0; i < DetailModel.Count; i++)
            {
                //note: It is possible the detail models don't yet have the correct spell ID. Make sure they do before saving
                DetailModel[i].SpellId = spellId;
                DetailModel[i].Save();
            }
            DataHasChanged = false;

            //repopulate the spell list (in case any of the names have changed or new ones added)
            PopulateSpellListBox();

            //update the modification fields
            ModDateLabel.Text    = Model.LastUpdatedDate.ToString();
            ModVersionLabel.Text = Model.LastUpdatedVersion;

            SaveFeedbackLabel.Text = "Record Saved";

            DatabaseName = Model.SpellName;
        }
コード例 #3
0
 private void OnSpellListBoxSelectedIndexChanged(object sender, EventArgs e)
 {
     if (DataChangeWarning() == false)
     {
         return;
     }
     AllowChangeEvents = false;
     Model             = new SpellModel();
     DetailModel.Clear();
     if (SpellListBox.SelectedIndex != -1)
     {
         Model.Initialize(SpellListBox.SelectedItem.ToString());
         DetailModel = SpellDetailsModel.GetAll(Model.Id);
     }
     PopulateFields(Model.SpellName);
     AllowChangeEvents = true;
 }
コード例 #4
0
        private void PopulateFields(string recordName)
        {
            bool bitFlag;

            Model       = new SpellModel();
            DetailModel = new List <SpellDetailsModel>();
            if (recordName != string.Empty)
            {
                Model.Initialize(recordName);
                DetailModel = SpellDetailsModel.GetAll(Model.Id);
            }

            //basic fields
            SpellNameInputBox.Text           = Model.SpellName;
            SpellSchoolComboBox.SelectedItem = SpellSchoolModel.GetNameFromId(Model.SpellSchoolId);
            SpellIconInputBox.Text           = Model.IconFilename;
            DescriptionPreview.Navigate("about:blank");
            DescriptionPreview.Document.OpenNew(false);
            DescriptionPreview.Document.Write(Model.Description);
            DescriptionPreview.Refresh();
            RangeInputComboBox.SelectedItem = Model.SpellRange;
            for (int i = 0; i < ComponentCheckListBox.Items.Count; i++)
            {
                bitFlag = ((Model.SpellComponents & (1 << i)) > 0);
                ComponentCheckListBox.SetItemChecked(i, bitFlag);
            }
            for (int i = 0; i < MetamagicFeatCheckListBox.Items.Count; i++)
            {
                bitFlag = ((Model.MetamagicFeats & (1 << i)) > 0);
                MetamagicFeatCheckListBox.SetItemChecked(i, bitFlag);
            }
            for (int i = 0; i < TargetCheckListBox.Items.Count; i++)
            {
                bitFlag = ((Model.Targets & (1 << i)) > 0);
                TargetCheckListBox.SetItemChecked(i, bitFlag);
            }
            DurationInputTextBox.Text        = Model.Duration;
            SavingThrowComboBox.SelectedItem = Model.SavingThrow;
            if (Model.SpellResistance == true)
            {
                SpellResistanceComboBox.SelectedItem = "Yes";
            }
            else
            {
                SpellResistanceComboBox.SelectedItem = "No";
            }
            ModDateLabel.Text    = Model.LastUpdatedDate.ToString();
            ModVersionLabel.Text = Model.LastUpdatedVersion;
            RecordGUIDLabel.Text = Model.Id.ToString();

            //the icon
            SpellIcon = new IconClass("Spells\\" + Model.IconFilename);
            SpellIcon.SetLocation(this.Width, this.Height, IconLocation);

            //the spell detail panel
            //Delete/Remove Current Controls
            for (int i = 0; i < SpellDetailSubPanel.Controls.Count; i++)
            {
                SpellDetailSubPanel.Controls[i].Dispose();
            }
            SpellDetailSubPanel.Controls.Clear();
            SpellDetailClassComboBox.Clear();
            SpellDetailLevelComboBox.Clear();
            SpellDetailCoolDownTextBox.Clear();
            SpellDetailSPCostUpDownBox.Clear();
            SpellDetailDeleteButton.Clear();
            //reload the panel
            SpellDetailRecordCount = 0;
            foreach (SpellDetailsModel detail in DetailModel)
            {
                AddSpellDetailRecordUI(detail);
            }

            DatabaseName = Model.SpellName;
            //invalidate the screen to make sure everything gets updated (icon, etc).
            Invalidate();
        }