Fixed the inability to add rows by using a BindingList instead of an IEnumerable.

Signed-off-by: Melissa Avery-Weir <melissa.avery@wellsfargo.com>
This commit is contained in:
Melissa Avery-Weir
2011-09-20 15:58:31 -04:00
parent 7a40926649
commit 93ebcdd896
4 changed files with 41 additions and 72 deletions

View File

@@ -37,7 +37,6 @@
this.classComboBox = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.characterTab = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label18 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
@@ -113,7 +112,6 @@
this.spellListTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.spellsDataGridView)).BeginInit();
this.characterTab.SuspendLayout();
this.groupBox2.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.mainToolStrip.SuspendLayout();
@@ -233,7 +231,7 @@
//
// characterTab
//
this.characterTab.Controls.Add(this.groupBox2);
this.characterTab.Controls.Add(this.tableLayoutPanel1);
this.characterTab.Controls.Add(this.charClassComboBox);
this.characterTab.Controls.Add(this.label6);
this.characterTab.Controls.Add(this.groupBox1);
@@ -248,16 +246,6 @@
this.characterTab.Text = "Character";
this.characterTab.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.tableLayoutPanel1);
this.groupBox2.Location = new System.Drawing.Point(272, 105);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(496, 229);
this.groupBox2.TabIndex = 24;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Spell DCs and Extra Spells Per Day";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.AutoSize = true;
@@ -307,21 +295,21 @@
this.tableLayoutPanel1.Controls.Add(this.label10, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.label19, 10, 0);
this.tableLayoutPanel1.Controls.Add(this.lblDC0, 1, 1);
this.tableLayoutPanel1.Location = new System.Drawing.Point(6, 43);
this.tableLayoutPanel1.Location = new System.Drawing.Point(272, 28);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10);
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(475, 117);
this.tableLayoutPanel1.Size = new System.Drawing.Size(475, 91);
this.tableLayoutPanel1.TabIndex = 3;
//
// label18
//
this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label18.Location = new System.Drawing.Point(328, 11);
this.label18.Location = new System.Drawing.Point(323, 6);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(17, 17);
this.label18.TabIndex = 11;
@@ -331,7 +319,7 @@
//
this.label17.AutoSize = true;
this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label17.Location = new System.Drawing.Point(302, 11);
this.label17.Location = new System.Drawing.Point(297, 6);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(17, 17);
this.label17.TabIndex = 10;
@@ -341,7 +329,7 @@
//
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label16.Location = new System.Drawing.Point(276, 11);
this.label16.Location = new System.Drawing.Point(271, 6);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(17, 17);
this.label16.TabIndex = 9;
@@ -351,7 +339,7 @@
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label15.Location = new System.Drawing.Point(250, 11);
this.label15.Location = new System.Drawing.Point(245, 6);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(17, 17);
this.label15.TabIndex = 8;
@@ -361,7 +349,7 @@
//
this.label14.AutoSize = true;
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label14.Location = new System.Drawing.Point(224, 11);
this.label14.Location = new System.Drawing.Point(219, 6);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(17, 17);
this.label14.TabIndex = 7;
@@ -371,7 +359,7 @@
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label13.Location = new System.Drawing.Point(198, 11);
this.label13.Location = new System.Drawing.Point(193, 6);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(17, 17);
this.label13.TabIndex = 6;
@@ -381,7 +369,7 @@
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.Location = new System.Drawing.Point(172, 11);
this.label12.Location = new System.Drawing.Point(167, 6);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(17, 17);
this.label12.TabIndex = 5;
@@ -391,7 +379,7 @@
//
this.label11.AutoSize = true;
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label11.Location = new System.Drawing.Point(146, 11);
this.label11.Location = new System.Drawing.Point(141, 6);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(17, 17);
this.label11.TabIndex = 4;
@@ -401,7 +389,7 @@
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(14, 11);
this.label7.Location = new System.Drawing.Point(9, 6);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(93, 17);
this.label7.TabIndex = 0;
@@ -411,7 +399,7 @@
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(14, 29);
this.label8.Location = new System.Drawing.Point(9, 24);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(75, 17);
this.label8.TabIndex = 1;
@@ -421,7 +409,7 @@
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(14, 47);
this.label9.Location = new System.Drawing.Point(9, 42);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(99, 17);
this.label9.TabIndex = 2;
@@ -431,7 +419,7 @@
//
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.Location = new System.Drawing.Point(120, 11);
this.label10.Location = new System.Drawing.Point(115, 6);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(17, 17);
this.label10.TabIndex = 3;
@@ -441,7 +429,7 @@
//
this.label19.AutoSize = true;
this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label19.Location = new System.Drawing.Point(354, 11);
this.label19.Location = new System.Drawing.Point(349, 6);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(17, 17);
this.label19.TabIndex = 12;
@@ -811,7 +799,7 @@
// lblDC0
//
this.lblDC0.AutoSize = true;
this.lblDC0.Location = new System.Drawing.Point(120, 29);
this.lblDC0.Location = new System.Drawing.Point(115, 24);
this.lblDC0.Name = "lblDC0";
this.lblDC0.Size = new System.Drawing.Size(19, 13);
this.lblDC0.TabIndex = 13;
@@ -820,7 +808,7 @@
// lblDC1
//
this.lblDC1.AutoSize = true;
this.lblDC1.Location = new System.Drawing.Point(146, 29);
this.lblDC1.Location = new System.Drawing.Point(141, 24);
this.lblDC1.Name = "lblDC1";
this.lblDC1.Size = new System.Drawing.Size(19, 13);
this.lblDC1.TabIndex = 14;
@@ -829,7 +817,7 @@
// lblDC2
//
this.lblDC2.AutoSize = true;
this.lblDC2.Location = new System.Drawing.Point(172, 29);
this.lblDC2.Location = new System.Drawing.Point(167, 24);
this.lblDC2.Name = "lblDC2";
this.lblDC2.Size = new System.Drawing.Size(19, 13);
this.lblDC2.TabIndex = 15;
@@ -838,7 +826,7 @@
// lblDC3
//
this.lblDC3.AutoSize = true;
this.lblDC3.Location = new System.Drawing.Point(198, 29);
this.lblDC3.Location = new System.Drawing.Point(193, 24);
this.lblDC3.Name = "lblDC3";
this.lblDC3.Size = new System.Drawing.Size(19, 13);
this.lblDC3.TabIndex = 16;
@@ -847,7 +835,7 @@
// lblDC4
//
this.lblDC4.AutoSize = true;
this.lblDC4.Location = new System.Drawing.Point(224, 29);
this.lblDC4.Location = new System.Drawing.Point(219, 24);
this.lblDC4.Name = "lblDC4";
this.lblDC4.Size = new System.Drawing.Size(19, 13);
this.lblDC4.TabIndex = 17;
@@ -856,7 +844,7 @@
// lblDC5
//
this.lblDC5.AutoSize = true;
this.lblDC5.Location = new System.Drawing.Point(250, 29);
this.lblDC5.Location = new System.Drawing.Point(245, 24);
this.lblDC5.Name = "lblDC5";
this.lblDC5.Size = new System.Drawing.Size(19, 13);
this.lblDC5.TabIndex = 18;
@@ -865,7 +853,7 @@
// lblDC6
//
this.lblDC6.AutoSize = true;
this.lblDC6.Location = new System.Drawing.Point(276, 29);
this.lblDC6.Location = new System.Drawing.Point(271, 24);
this.lblDC6.Name = "lblDC6";
this.lblDC6.Size = new System.Drawing.Size(19, 13);
this.lblDC6.TabIndex = 19;
@@ -874,7 +862,7 @@
// lblDC7
//
this.lblDC7.AutoSize = true;
this.lblDC7.Location = new System.Drawing.Point(302, 29);
this.lblDC7.Location = new System.Drawing.Point(297, 24);
this.lblDC7.Name = "lblDC7";
this.lblDC7.Size = new System.Drawing.Size(19, 13);
this.lblDC7.TabIndex = 20;
@@ -883,7 +871,7 @@
// lblDC8
//
this.lblDC8.AutoSize = true;
this.lblDC8.Location = new System.Drawing.Point(328, 29);
this.lblDC8.Location = new System.Drawing.Point(323, 24);
this.lblDC8.Name = "lblDC8";
this.lblDC8.Size = new System.Drawing.Size(19, 13);
this.lblDC8.TabIndex = 21;
@@ -892,7 +880,7 @@
// lblDC9
//
this.lblDC9.AutoSize = true;
this.lblDC9.Location = new System.Drawing.Point(354, 29);
this.lblDC9.Location = new System.Drawing.Point(349, 24);
this.lblDC9.Name = "lblDC9";
this.lblDC9.Size = new System.Drawing.Size(19, 13);
this.lblDC9.TabIndex = 22;
@@ -901,7 +889,7 @@
// lblExtra0
//
this.lblExtra0.AutoSize = true;
this.lblExtra0.Location = new System.Drawing.Point(120, 47);
this.lblExtra0.Location = new System.Drawing.Point(115, 42);
this.lblExtra0.Name = "lblExtra0";
this.lblExtra0.Size = new System.Drawing.Size(13, 13);
this.lblExtra0.TabIndex = 23;
@@ -910,7 +898,7 @@
// lblExtra1
//
this.lblExtra1.AutoSize = true;
this.lblExtra1.Location = new System.Drawing.Point(146, 47);
this.lblExtra1.Location = new System.Drawing.Point(141, 42);
this.lblExtra1.Name = "lblExtra1";
this.lblExtra1.Size = new System.Drawing.Size(13, 13);
this.lblExtra1.TabIndex = 24;
@@ -919,7 +907,7 @@
// lblExtra2
//
this.lblExtra2.AutoSize = true;
this.lblExtra2.Location = new System.Drawing.Point(172, 47);
this.lblExtra2.Location = new System.Drawing.Point(167, 42);
this.lblExtra2.Name = "lblExtra2";
this.lblExtra2.Size = new System.Drawing.Size(13, 13);
this.lblExtra2.TabIndex = 25;
@@ -928,7 +916,7 @@
// lblExtra3
//
this.lblExtra3.AutoSize = true;
this.lblExtra3.Location = new System.Drawing.Point(198, 47);
this.lblExtra3.Location = new System.Drawing.Point(193, 42);
this.lblExtra3.Name = "lblExtra3";
this.lblExtra3.Size = new System.Drawing.Size(13, 13);
this.lblExtra3.TabIndex = 26;
@@ -937,7 +925,7 @@
// lblExtra4
//
this.lblExtra4.AutoSize = true;
this.lblExtra4.Location = new System.Drawing.Point(224, 47);
this.lblExtra4.Location = new System.Drawing.Point(219, 42);
this.lblExtra4.Name = "lblExtra4";
this.lblExtra4.Size = new System.Drawing.Size(13, 13);
this.lblExtra4.TabIndex = 27;
@@ -946,7 +934,7 @@
// lblExtra5
//
this.lblExtra5.AutoSize = true;
this.lblExtra5.Location = new System.Drawing.Point(250, 47);
this.lblExtra5.Location = new System.Drawing.Point(245, 42);
this.lblExtra5.Name = "lblExtra5";
this.lblExtra5.Size = new System.Drawing.Size(13, 13);
this.lblExtra5.TabIndex = 28;
@@ -955,7 +943,7 @@
// lblExtra6
//
this.lblExtra6.AutoSize = true;
this.lblExtra6.Location = new System.Drawing.Point(276, 47);
this.lblExtra6.Location = new System.Drawing.Point(271, 42);
this.lblExtra6.Name = "lblExtra6";
this.lblExtra6.Size = new System.Drawing.Size(13, 13);
this.lblExtra6.TabIndex = 29;
@@ -964,7 +952,7 @@
// lblExtra7
//
this.lblExtra7.AutoSize = true;
this.lblExtra7.Location = new System.Drawing.Point(302, 47);
this.lblExtra7.Location = new System.Drawing.Point(297, 42);
this.lblExtra7.Name = "lblExtra7";
this.lblExtra7.Size = new System.Drawing.Size(13, 13);
this.lblExtra7.TabIndex = 30;
@@ -973,7 +961,7 @@
// lblExtra8
//
this.lblExtra8.AutoSize = true;
this.lblExtra8.Location = new System.Drawing.Point(328, 47);
this.lblExtra8.Location = new System.Drawing.Point(323, 42);
this.lblExtra8.Name = "lblExtra8";
this.lblExtra8.Size = new System.Drawing.Size(13, 13);
this.lblExtra8.TabIndex = 31;
@@ -982,7 +970,7 @@
// lblExtra9
//
this.lblExtra9.AutoSize = true;
this.lblExtra9.Location = new System.Drawing.Point(354, 47);
this.lblExtra9.Location = new System.Drawing.Point(349, 42);
this.lblExtra9.Name = "lblExtra9";
this.lblExtra9.Size = new System.Drawing.Size(13, 13);
this.lblExtra9.TabIndex = 32;
@@ -1003,8 +991,6 @@
((System.ComponentModel.ISupportInitialize)(this.spellsDataGridView)).EndInit();
this.characterTab.ResumeLayout(false);
this.characterTab.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.groupBox1.ResumeLayout(false);
@@ -1068,7 +1054,6 @@
private System.Windows.Forms.MaskedTextBox txtStrength;
private System.Windows.Forms.ComboBox charClassComboBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;

View File

@@ -50,7 +50,8 @@ namespace d20_SRD_Spell_Lists {
ComboBox classList = (ComboBox)sender;
string charClass = classList.SelectedItem.ToString();
this.spellsDataGridView.DataSource = spells.byClass((Character.SpellCastingClasses)Enum.Parse(typeof(Character.SpellCastingClasses), charClass, true));
BindingList<Spell> spellList = new BindingList<Spell>(spells.byClass((Character.SpellCastingClasses)Enum.Parse(typeof(Character.SpellCastingClasses), charClass, true)));
this.spellsDataGridView.DataSource = spellList;
}
private void charClassComboBox_SelectedIndexChanged(object sender, EventArgs e) {
@@ -133,6 +134,7 @@ namespace d20_SRD_Spell_Lists {
private void saveToolStripButton_Click(object sender, EventArgs e) {
try {
spells.save();
character.save();
} catch (NoCharacterFileException) {
SaveFileDialog sfd = new SaveFileDialog();

View File

@@ -135,24 +135,6 @@
<metadata name="charCustomColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="prepColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="spellNameColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="componentColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="descColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="customColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="charCustomColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="mainToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View File

@@ -45,7 +45,7 @@ namespace d20_SRD_Spell_Lists.Models {
userSpellList.Add(xElement);
}
public IEnumerable<Spell> byClass(Character.SpellCastingClasses spellCastingClass) {
public IList<Spell> byClass(Character.SpellCastingClasses spellCastingClass) {
List<Spell> spells = new List<Spell>();
filterMasterSpellsByClass(spellCastingClass, spells);