Esempio n. 1
0
        public void LoadConfig(ConfigViewModel config)
        {
            if (config == null)
            {
                SB.Logger.LogError(Components.ConfigManager, "The config to load cannot be null", true);
                return;
            }

            try
            {
                SBIOManager.CheckRequiredPlugins(SB.BlockPlugins.Select(b => b.Name), config.Config);
            }
            catch (Exception ex)
            {
                SB.Logger.LogError(Components.ConfigManager, ex.Message, true);
                return;
            }

            // Set the config as current
            vm.CurrentConfig = config;

            if (vm.CurrentConfig.Remote)
            {
                SB.Logger.LogError(Components.ConfigManager, "The config was pulled from a remote source and cannot be edited!", true);
                vm.CurrentConfig = null;
                return;
            }

            SB.Logger.LogInfo(Components.ConfigManager, "Loading config: " + vm.CurrentConfig.Name);

            SB.MainWindow.ConfigsPage.menuOptionStacker.IsEnabled      = true;
            SB.MainWindow.ConfigsPage.menuOptionOtherOptions.IsEnabled = true;

            var newStackerVM = new StackerViewModel(vm.CurrentConfig);

            // Preserve the old stacker test data and proxy
            if (SB.MainWindow.ConfigsPage.StackerPage != null)
            {
                newStackerVM.TestData  = SB.Stacker.TestData;
                newStackerVM.TestProxy = SB.Stacker.TestProxy;
                newStackerVM.ProxyType = SB.Stacker.ProxyType;
            }

            SB.Stacker = newStackerVM;
            SB.MainWindow.ConfigsPage.StackerPage = new Stacker();                 // Create a Stacker instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance");
            SB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance");
            SB.MainWindow.ConfigsPage.ConfigOcrSettings = new ConfigOcrSettings(); // Create an Ocr Testing instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Ocr Testing instance");
            SB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null);     // Switch to Stacker

            // Save the last state of the config
            SB.MainWindow.ConfigsPage.StackerPage.SetScript();
            SaveState();
        }
Esempio n. 2
0
        public void startButton_Click(object sender, RoutedEventArgs e)
        {
            switch (vm.Master.Status)
            {
            case WorkerStatus.Idle:
                // Check if the required plugins are present
                try
                {
                    SBIOManager.CheckRequiredPlugins(SB.BlockPlugins.Select(b => b.Name), vm.Config);
                }
                catch (Exception ex)
                {
                    SB.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
                startButtonLabel.Text = "STOP";
                startButtonIcon.Kind  = PackIconMaterialKind.StopCircleOutline;
                if (SB.Settings.RLSettings.General.DisableBotsListView)
                {
                    botsListView.ItemsSource = null;
                }
                else
                {
                    botsListView.SetBinding(ItemsControl.ItemsSourceProperty, new Binding()
                    {
                        Source = vm.Bots
                    });
                }
                vm.Start();
                break;

            case WorkerStatus.Running:
                vm.Stop();
                startButtonLabel.Text = "HARD ABORT"; startButtonIcon.Kind = PackIconMaterialKind.StopCircleOutline;
                break;

            case WorkerStatus.Stopping:
                vm.ForceStop();
                startButtonLabel.Text = "START"; startButtonIcon.Kind = PackIconMaterialKind.PlayCircleOutline;
                SaveRecord();
                break;
            }
        }