Пример #1
0
        private async void LoadStockpile(string fileName)
        {
            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
                UICore.SetHotkeyTimer(false);
                UICore.LockInterface(false, true);
                S.GET <UI_SaveProgress_Form>().Dock = DockStyle.Fill;
                UI_CoreForm.cfForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>());

                StockpileManager_UISide.ClearCurrentStockpile();

                //Clear out the DGVs
                S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Clear(); // Clear the stockpile manager
                dgvStockpile.Rows.Clear();                                     // Clear the stockpile player

                var r = await Task.Run(() => Stockpile.Load(fileName));

                if (r.Failed)
                {
                    MessageBox.Show($"Loading the stockpile failed!\n" +
                                    $"{r.GetErrorsFormatted()}");
                }
                else
                {
                    var sks = r.Result;
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        foreach (StashKey key in sks.StashKeys) //Populate the dgv
                        {
                            dgvStockpile?.Rows.Add(key, key.GameName, key.SystemName, key.SystemCore, key.Note);
                        }
                    });
                }

                List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells["Item"].Value).ToList();
                foreach (var sk in keys)
                {
                    StockpileManager_UISide.CheckAndFixMissingReference(sk, false, keys);
                }

                dgvStockpile.ClearSelection();
                RefreshNoteIcons();
            }
            finally
            {
                UI_CoreForm.cfForm?.CloseSubForm();
                UICore.UnlockInterface();
                UICore.SetHotkeyTimer(true);
            }
        }
Пример #2
0
        private async void loadStockpile(string fileName)
        {
            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;
                    UI_CoreForm.cfForm?.OpenSubForm(S.GET <UI_SaveProgress_Form>());
                });

                await Task.Run(() =>
                {
                    if (Stockpile.Load(dgvStockpile, fileName))
                    {
                        SyncObjectSingleton.FormExecute(() => S.GET <RTC_StockpileManager_Form>().dgvStockpile.Rows.Clear());
                    }

                    SyncObjectSingleton.FormExecute(() =>
                    {
                        List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells["Item"].Value).ToList();
                        foreach (var sk in keys)
                        {
                            StockpileManager_UISide.CheckAndFixMissingReference(sk, false, keys);
                        }

                        dgvStockpile.ClearSelection();
                        RefreshNoteIcons();
                    });
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    UI_CoreForm.cfForm?.CloseSubForm();
                    UICore.UnlockInterface();
                });
            }
        }
Пример #3
0
        private void dgvStockpile_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {
                S.GET <RTC_StashHistory_Form>().btnAddStashToStockpile.Enabled = false;
                dgvStockpile.Enabled     = false;
                btnStockpileUP.Enabled   = false;
                btnStockpileDOWN.Enabled = false;

                // Stockpile Note handling
                if (e != null)
                {
                    var senderGrid = (DataGridView)sender;

                    if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                        e.RowIndex >= 0)
                    {
                        StashKey sk = (StashKey)senderGrid.Rows[e.RowIndex].Cells["Item"].Value;
                        S.SET(new RTC_NoteEditor_Form(sk, senderGrid.Rows[e.RowIndex].Cells["Note"]));
                        S.GET <RTC_NoteEditor_Form>().Show();

                        return;
                    }
                }

                S.GET <RTC_StashHistory_Form>().lbStashHistory.ClearSelected();
                S.GET <RTC_StockpilePlayer_Form>().dgvStockpile.ClearSelection();

                S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI();

                if (dgvStockpile.SelectedRows.Count == 0)
                {
                    return;
                }

                StockpileManager_UISide.CurrentStashkey = (dgvStockpile.SelectedRows[0].Cells[0].Value as StashKey);

                List <StashKey> keys = dgvStockpile.Rows.Cast <DataGridViewRow>().Select(x => (StashKey)x.Cells[0].Value).ToList();
                if (!StockpileManager_UISide.CheckAndFixMissingReference(StockpileManager_UISide.CurrentStashkey, false, keys))
                {
                    return;
                }

                if (!S.GET <RTC_GlitchHarvesterBlast_Form>().LoadOnSelect)
                {
                    return;
                }

                // Merge Execution
                if (dgvStockpile.SelectedRows.Count > 1)
                {
                    List <StashKey> sks = new List <StashKey>();

                    foreach (DataGridViewRow row in dgvStockpile.SelectedRows)
                    {
                        sks.Add((StashKey)row.Cells[0].Value);
                    }
                    //dgv is stupid since it selects rows backwards
                    sks.Reverse();
                    StockpileManager_UISide.MergeStashkeys(sks);

                    if (Render.RenderAtLoad && S.GET <RTC_GlitchHarvesterBlast_Form>().loadBeforeOperation)
                    {
                        Render.StartRender();
                    }

                    S.GET <RTC_StashHistory_Form>().RefreshStashHistory();
                    return;
                }

                S.GET <RTC_GlitchHarvesterBlast_Form>().OneTimeExecute();
            }
            finally
            {
                S.GET <RTC_StashHistory_Form>().btnAddStashToStockpile.Enabled = true;
                dgvStockpile.Enabled     = true;
                btnStockpileUP.Enabled   = true;
                btnStockpileDOWN.Enabled = true;
            }

            S.GET <RTC_GlitchHarvesterBlast_Form>().RedrawActionUI();
        }