private void btnStockpileMoveSelectedDown_Click(object sender, EventArgs e) { var selectedRows = dgvStockpile.SelectedRows.Cast <DataGridViewRow>().ToArray(); foreach (DataGridViewRow row in selectedRows) { int pos = row.Index; int count = dgvStockpile.Rows.Count; dgvStockpile.Rows.RemoveAt(pos); if (pos == count - 1) { int newpos = 0; dgvStockpile.Rows.Insert(newpos, row); } else { int newpos = pos + 1; dgvStockpile.Rows.Insert(newpos, row); } } dgvStockpile.ClearSelection(); foreach (DataGridViewRow row in selectedRows) //I don't know. Blame DGV { row.Selected = true; } UnsavedEdits = true; StockpileManager_UISide.StockpileChanged(); S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI(); }
private async void LoadStockpile(string filename) { if (UnsavedEdits && MessageBox.Show("You have unsaved edits in the Glitch Harvester Stockpile. \n\n Are you sure you want to load without saving?", "Unsaved edits in Stockpile", MessageBoxButtons.YesNo) == DialogResult.No) { return; } var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester"); try { //We do this here and invoke because our unlock runs at the end of the awaited method, but there's a chance an error occurs //Thus, we want this to happen within the try block SyncObjectSingleton.FormExecute(() => { UICore.LockInterface(false, true); S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill; ghForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>()); }); await Task.Run(() => { if (Stockpile.Load(dgvStockpile, filename)) { SyncObjectSingleton.FormExecute(() => { btnSaveStockpile.Enabled = true; RefreshNoteIcons(); }); } SyncObjectSingleton.FormExecute(() => { S.GET <RTC_StockpilePlayer_Form>().dgvStockpile.Rows.Clear(); dgvStockpile.ClearSelection(); StockpileManager_UISide.StockpileChanged(); UnsavedEdits = false; }); }); } finally { SyncObjectSingleton.FormExecute(() => { ghForm?.CloseSubForm(); UICore.UnlockInterface(); }); } }
public void RemoveSelected(bool force = false) { if (Control.ModifierKeys == Keys.Control || (dgvStockpile.SelectedRows.Count != 0 && (MessageBox.Show("Are you sure you want to remove the selected stockpile entries?", "Delete Stockpile Entry?", MessageBoxButtons.YesNo) == DialogResult.Yes))) { foreach (DataGridViewRow row in dgvStockpile.SelectedRows) { dgvStockpile.Rows.Remove(row); } } StockpileManager_UISide.StockpileChanged(); UnsavedEdits = true; S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI(); }
private void btnRenameSelected_Click(object sender, EventArgs e) { if (!btnRenameSelected.Visible) { return; } if (dgvStockpile.SelectedRows.Count != 0) { renameStashKey(dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey); dgvStockpile.Refresh(); //lbStockpile.RefreshItemsReal(); } StockpileManager_UISide.StockpileChanged(); UnsavedEdits = true; }
public void ClearStockpile(bool force = false) { if (force || MessageBox.Show("Are you sure you want to clear the stockpile?", "Clearing stockpile", MessageBoxButtons.YesNo) == DialogResult.Yes) { dgvStockpile.Rows.Clear(); if (StockpileManager_UISide.CurrentStockpile != null) { StockpileManager_UISide.CurrentStockpile.Filename = null; StockpileManager_UISide.CurrentStockpile.ShortFilename = null; } btnSaveStockpile.Enabled = false; StockpileManager_UISide.StockpileChanged(); UnsavedEdits = false; S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI(); } }
public bool AddStashToStockpile(bool askForName = true) { if (lbStashHistory.Items.Count == 0 || lbStashHistory.SelectedIndex == -1) { MessageBox.Show("Can't add the Stash to the Stockpile because none is selected in the Stash History"); return(false); } string Name = ""; string value = ""; StashKey sk = (StashKey)lbStashHistory.SelectedItem; StockpileManager_UISide.CurrentStashkey = sk; //If we don't support mixed stockpiles if (!((bool?)AllSpec.VanguardSpec[VSPEC.SUPPORTS_MIXED_STOCKPILE] ?? false)) { if (S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Count > 0) { string firstGameName = ((StashKey)S.GET <RTC_StockpileManager_Form>().dgvStockpile[0, 0].Value).GameName; if (sk.GameName != firstGameName) { string name = (AllSpec.VanguardSpec[VSPEC.NAME] as string) ?? "Vanguard implementation"; MessageBox.Show($"{name} does not support mixed stockpiles."); return(false); } } } if (askForName) { if (GetInputBox("Glitch Harvester", "Enter the new Stash name:", ref value) == DialogResult.OK) { Name = value.Trim(); } else { return(false); } } else { Name = StockpileManager_UISide.CurrentStashkey.Alias; } if (string.IsNullOrWhiteSpace(Name)) { StockpileManager_UISide.CurrentStashkey.Alias = StockpileManager_UISide.CurrentStashkey.Key; } else { StockpileManager_UISide.CurrentStashkey.Alias = Name; } sk.BlastLayer.RasterizeVMDs(); DataGridViewRow dataRow = S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows[S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Add()]; dataRow.Cells["Item"].Value = sk; dataRow.Cells["GameName"].Value = sk.GameName; dataRow.Cells["SystemName"].Value = sk.SystemName; dataRow.Cells["SystemCore"].Value = sk.SystemCore; S.GET <RTC_StockpileManager_Form>().RefreshNoteIcons(); StockpileManager_UISide.StashHistory.Remove(sk); RefreshStashHistory(); DontLoadSelectedStash = true; lbStashHistory.ClearSelected(); DontLoadSelectedStash = false; int nRowIndex = S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Count - 1; S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection(); S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows[nRowIndex].Selected = true; StockpileManager_UISide.StockpileChanged(); S.GET <RTC_StockpileManager_Form>().UnsavedEdits = true; return(true); }