Add Clear All

This commit is contained in:
Kurt 2020-05-31 15:30:24 -07:00
parent c571fbb20a
commit ab16bdc694
3 changed files with 33 additions and 1 deletions

View File

@ -47,7 +47,7 @@ public void ClearAll()
{
SetIsKnown(i, false);
SetIsNew(i, false);
SetIsFavorite(i, false);
SetIsMade(i, false);
SetIsFavorite(i, false);
}
}

View File

@ -38,6 +38,7 @@ private void InitializeComponent()
this.CHK_Made = new System.Windows.Forms.CheckBox();
this.CHK_Favorite = new System.Windows.Forms.CheckBox();
this.CHK_New = new System.Windows.Forms.CheckBox();
this.B_ClearAll = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// B_Cancel
@ -150,11 +151,23 @@ private void InitializeComponent()
this.CHK_New.Text = "New";
this.CHK_New.UseVisualStyleBackColor = true;
//
// B_ClearAll
//
this.B_ClearAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.B_ClearAll.Location = new System.Drawing.Point(100, 347);
this.B_ClearAll.Name = "B_ClearAll";
this.B_ClearAll.Size = new System.Drawing.Size(82, 23);
this.B_ClearAll.TabIndex = 18;
this.B_ClearAll.Text = "Clear All";
this.B_ClearAll.UseVisualStyleBackColor = true;
this.B_ClearAll.Click += new System.EventHandler(this.B_ClearAll_Click);
//
// RecipeListEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(404, 381);
this.Controls.Add(this.B_ClearAll);
this.Controls.Add(this.CHK_New);
this.Controls.Add(this.CHK_Favorite);
this.Controls.Add(this.CHK_Made);
@ -187,5 +200,6 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox CHK_Made;
private System.Windows.Forms.CheckBox CHK_Favorite;
private System.Windows.Forms.CheckBox CHK_New;
private System.Windows.Forms.Button B_ClearAll;
}
}

View File

@ -39,12 +39,14 @@ private List<ComboItem> FillCheckBoxes()
private void FillListBox(ushort max, IReadOnlyDictionary<ushort, ushort> recipes, string[] strings, RecipeBook book)
{
Loading = true;
for (ushort i = 0; i <= max; i++)
{
var name = GetItemName(i, recipes, strings);
var text = GetEntryText(book, i, name);
LB_Recipes.Items.Add(text);
}
Loading = false;
}
private static List<ComboItem> GetJumpList(ushort max, IReadOnlyDictionary<ushort, ushort> recipes, string[] strings, List<ComboItem> gotoSource)
@ -85,6 +87,22 @@ private void B_All_Click(object sender, EventArgs e)
book.GiveAll(recipes);
LB_Recipes.Items.Clear();
FillListBox(max, recipes, strings, book);
LoadIndex(index);
LB_Recipes.SelectedIndex = index;
}
private void B_ClearAll_Click(object sender, EventArgs e)
{
var index = LB_Recipes.SelectedIndex;
var book = Book;
var recipes = RecipeList.Recipes;
var strings = GameInfo.Strings.itemlist;
const ushort max = RecipeBook.RecipeCount;
book.ClearAll();
LB_Recipes.Items.Clear();
FillListBox(max, recipes, strings, book);
LoadIndex(index);
LB_Recipes.SelectedIndex = index;
}