Exemplo n.º 1
0
        private async void btnSaveStockpile_Click(object sender, EventArgs e)
        {
            Stockpile sks    = new Stockpile(dgvStockpile);
            var       ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester");

            try
            {
                UICore.SetHotkeyTimer(false);
                //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(() => { saveStockpile(sks, StockpileManager_UISide.CurrentStockpile.Filename); });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    ghForm?.CloseSubForm();
                    UICore.UnlockInterface();
                    UICore.SetHotkeyTimer(true);
                });
            }
        }
Exemplo n.º 2
0
        private void NetCoreSpec_ServerConnectionLost(object sender, EventArgs e)
        {
            if (UICore.isClosing || UICore.FirstConnect)
            {
                return;
            }

            SyncObjectSingleton.FormExecute(() =>
            {
                if (S.GET <RTC_ConnectionStatus_Form>() != null && !S.GET <RTC_ConnectionStatus_Form>()
                    .IsDisposed)
                {
                    S.GET <RTC_ConnectionStatus_Form>()
                    .lbConnectionStatus.Text =
                        $"{(string)AllSpec.VanguardSpec?[VSPEC.NAME] ?? "Vanguard"} connection timed out";

                    UICore.LockInterface();
                    UI_DefaultGrids.connectionStatus.LoadToMain();
                }

                S.GET <RTC_VmdAct_Form>()
                .cbAutoAddDump.Checked = false;
                GameProtection.WasAutoCorruptRunning = CorruptCore.RtcCore.AutoCorrupt;
                S.GET <UI_CoreForm>().AutoCorrupt    = false;
            });
            GameProtection.Stop(false);

            if (S.GET <UI_CoreForm>()
                .cbUseAutoKillSwitch.Checked&& AllSpec.VanguardSpec != null)
            {
                AutoKillSwitch.KillEmulator();
            }
        }
Exemplo n.º 3
0
        public async void btnSaveStockpileAs_Click(object sender, EventArgs e)
        {
            if (dgvStockpile.Rows.Count == 0)
            {
                MessageBox.Show("You cannot save the Stockpile because it is empty");
                return;
            }

            var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester");

            try
            {
                UICore.SetHotkeyTimer(false);
                string         path            = "";
                SaveFileDialog saveFileDialog1 = new SaveFileDialog
                {
                    DefaultExt       = "sks",
                    Title            = "Save Stockpile File",
                    Filter           = "SKS files|*.sks",
                    RestoreDirectory = true
                };

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    path = saveFileDialog1.FileName;
                }
                else
                {
                    return;
                }

                Stockpile sks = new Stockpile(dgvStockpile);
                //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(() =>
                {
                    saveStockpile(sks, path);
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    ghForm?.CloseSubForm();
                    UICore.UnlockInterface();
                    UICore.SetHotkeyTimer(true);
                });
            }
        }
Exemplo n.º 4
0
        private async void loadSavestateList(bool import = false, string fileName = null)
        {
            if (fileName == null)
            {
                OpenFileDialog ofd = new OpenFileDialog
                {
                    DefaultExt       = "ssk",
                    Title            = "Open Savestate Keys File",
                    Filter           = "SSK files|*.ssk",
                    RestoreDirectory = true
                };
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    fileName = ofd.FileName;
                }
                else
                {
                    return;
                }
            }
            if (!File.Exists(fileName))
            {
                MessageBox.Show("The Savestate Keys file wasn't found");
                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(() =>
                {
                    loadSSK(import, fileName);
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    ghForm?.CloseSubForm();
                    UICore.UnlockInterface();
                });
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        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();
                });
            }
        }
Exemplo n.º 7
0
        private async void btnSaveSavestateList_Click(object sender, EventArgs e)
        {
            string         filename;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                DefaultExt       = "ssk",
                Title            = "Savestate Keys File",
                Filter           = "SSK files|*.ssk",
                RestoreDirectory = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filename = saveFileDialog1.FileName;
            }
            else
            {
                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(() =>
                {
                    saveSSK(filename);
                });
            }
            finally
            {
                SyncObjectSingleton.FormExecute(() =>
                {
                    ghForm?.CloseSubForm();
                    UICore.UnlockInterface();
                });
            }
        }
Exemplo n.º 8
0
        private async void btnImportStockpile_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog
            {
                DefaultExt       = "*",
                Title            = "Select stockpile to import",
                Filter           = "Any file|*.sks",
                RestoreDirectory = true
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var ghForm = UI_CanvasForm.GetExtraForm("Glitch Harvester");
                try
                {
                    UICore.SetHotkeyTimer(false);
                    //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.Import(ofd.FileName, dgvStockpile))
                        {
                            UnsavedEdits = true;
                        }
                    });
                }
                finally
                {
                    SyncObjectSingleton.FormExecute(() =>
                    {
                        ghForm?.CloseSubForm();
                        UICore.UnlockInterface();
                        UICore.SetHotkeyTimer(true);
                        RefreshNoteIcons();
                    });
                }
            }
        }
Exemplo n.º 9
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();
                });
            }
        }
Exemplo n.º 10
0
        private void NetCoreSpec_ServerConnectionLost(object sender, EventArgs e)
        {
            UIConnector.ConnectionLostLockout.WaitOne();
            Console.WriteLine("Thread id {0} got Mutex...  (specconnectionlost)", System.Threading.Thread.CurrentThread.ManagedThreadId);

            if (UICore.isClosing || UICore.FirstConnect)
            {
                return;
            }
            SyncObjectSingleton.FormExecute(() =>
            {
                if (S.GET <RTC_ConnectionStatus_Form>() != null && !S.GET <RTC_ConnectionStatus_Form>()
                    .IsDisposed)
                {
                    S.GET <RTC_ConnectionStatus_Form>()
                    .lbConnectionStatus.Text =
                        $"{(string) AllSpec.VanguardSpec?[VSPEC.NAME] ?? "Vanguard"} connection timed out";

                    UICore.LockInterface();
                    UI_DefaultGrids.connectionStatus.LoadToMain();
                }

                S.GET <RTC_VmdAct_Form>()
                .cbAutoAddDump.Checked = false;
                GameProtection.WasAutoCorruptRunning = CorruptCore.RtcCore.AutoCorrupt;
                S.GET <UI_CoreForm>().AutoCorrupt    = false;
            });
            GameProtection.Stop(false);

            if (S.GET <UI_CoreForm>()
                .cbUseAutoKillSwitch.Checked&& AllSpec.VanguardSpec != null)
            {
                AutoKillSwitch.KillEmulator();
            }

            UIConnector.ConnectionLostLockout.ReleaseMutex();
            Console.WriteLine("Thread id {0} released Mutex (specconnectionlost)...", Thread.CurrentThread.ManagedThreadId);
        }
Exemplo n.º 11
0
 private void Button1_Click_1(object sender, EventArgs e)
 {
     UICore.LockInterface();
     UI_DefaultGrids.connectionStatus.LoadToMain();
 }