public void LoadConfig(ConfigViewModel config) { if (config == null) { OB.Logger.LogError(Components.ConfigManager, "The config to load cannot be null", true); return; } try { OBIOManager.CheckRequiredPlugins(OB.BlockPlugins.Select(b => b.Name), config.Config); } catch (Exception ex) { OB.Logger.LogError(Components.ConfigManager, ex.Message, true); return; } // Set the config as current vm.CurrentConfig = config; if (vm.CurrentConfig.Remote) { OB.Logger.LogError(Components.ConfigManager, "The config was pulled from a remote source and cannot be edited!", true); vm.CurrentConfig = null; return; } OB.Logger.LogInfo(Components.ConfigManager, "Loading config: " + vm.CurrentConfig.Name); OB.MainWindow.ConfigsPage.menuOptionStacker.IsEnabled = true; OB.MainWindow.ConfigsPage.menuOptionOtherOptions.IsEnabled = true; var newStackerVM = new StackerViewModel(vm.CurrentConfig); // Preserve the old stacker test data and proxy if (OB.MainWindow.ConfigsPage.StackerPage != null) { newStackerVM.TestData = OB.Stacker.TestData; newStackerVM.TestProxy = OB.Stacker.TestProxy; newStackerVM.ProxyType = OB.Stacker.ProxyType; } OB.Stacker = newStackerVM; OB.MainWindow.ConfigsPage.StackerPage = new Stacker(); // Create a Stacker instance OB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance"); OB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance OB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance"); OB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null); // Switch to Stacker // Save the last state of the config OB.MainWindow.ConfigsPage.StackerPage.SetScript(); SaveState(); }
public void startButton_Click(object sender, RoutedEventArgs e) { switch (vm.Master.Status) { case WorkerStatus.Idle: // Check if the required plugins are present try { OBIOManager.CheckRequiredPlugins(OB.BlockPlugins.Select(b => b.Name), vm.Config); } catch (Exception ex) { OB.Logger.LogError(Components.Runner, ex.Message, true); return; } SetupSoundPlayers(); ThreadPool.SetMinThreads(vm.BotsAmount * 2 + 1, vm.BotsAmount * 2 + 1); ServicePointManager.DefaultConnectionLimit = 10000; // This sets the default connection limit for requests on the whole application startButton.Content = "STOP"; vm.Start(); break; case WorkerStatus.Running: vm.Stop(); startButton.Content = "HARD ABORT"; break; case WorkerStatus.Stopping: vm.ForceStop(); startButton.Content = "START"; SaveRecord(); break; } }
private void saveButton_Click(object sender, RoutedEventArgs e) { OBIOManager.SaveSettings(Globals.obSettingsFile, Globals.obSettings); }