示例#1
0
        public SettingsForm(BotPage botPage)
        {
            this.botPage = botPage;
            InitializeComponent();

            LoadSettings();

            saveButton.Click += (s, e) =>
            {
                botPage.Settings.CollectorEnabled  = enableCollectorBox.Checked;
                botPage.Settings.CollectBonusBoxes = bbBox.Checked;
                botPage.Settings.CollectEventBoxes = ebBox.Checked;
                botPage.Settings.HPLimit           = hpSlider.Value;

                if (repairBase.Checked)
                {
                    botPage.Settings.RepairAt = 1;
                }
                else if (repairPortal.Checked)
                {
                    botPage.Settings.RepairAt = 2;
                }
                else if (repairBattle.Checked)
                {
                    botPage.Settings.RepairAt = 3;
                }

                botPage.Settings.Reload();
                Close();
            };

            hpSlider.ValueChanged += (s, e) => repairLabel.Text = $"Repair when HP less than {hpSlider.Value}%";
        }
示例#2
0
        private void Init()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                Text = $"PolskaBot {ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(4)}";
            }

            string swfPath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Fade.swf";

            Task serverTask = new Task(() =>
            {
                using (var client = new WebClient())
                {
                    _ip = client.DownloadString("https://www.muzari.com/pb/server.txt");
                    flashEmbed.LoadMovie(0, swfPath);
                }
            });

            serverTask.Start();

            proxy        = new FadeProxy(flashEmbed);
            proxy.Ready += (s, e) => loginButton.Enabled = true;

            AcceptButton       = loginButton;
            loginButton.Click += (s, e) =>
            {
                if (!usernameBox.Text.Equals("") || !passwordBox.Text.Equals(""))
                {
                    var botPage = new BotPage(_ip, proxy.CreateClient(), usernameBox.Text, passwordBox.Text);
                    pages.Add(botPage);
                    botTabs.Controls.Add(botPage);
                    botTabs.SelectedIndex = ++AccountsCount;
                    usernameBox.Text      = "";
                    passwordBox.Text      = "";
                }
            };

            botTabs.SelectedIndexChanged += (s, e) =>
            {
                if (botTabs.SelectedIndex == 0)
                {
                    startButton.Enabled    = false;
                    stopButton.Enabled     = false;
                    closeButton.Enabled    = false;
                    settingsButton.Enabled = false;
                }
                else
                {
                    startButton.Enabled    = !pages[botTabs.SelectedIndex - 1].Running;
                    stopButton.Enabled     = pages[botTabs.SelectedIndex - 1].Running;
                    closeButton.Enabled    = true;
                    settingsButton.Enabled = true;
                }
            };

            startButton.Click += (s, e) =>
            {
                pages[botTabs.SelectedIndex - 1].Running = true;
                startButton.Enabled = !pages[botTabs.SelectedIndex - 1].Running;
                stopButton.Enabled  = pages[botTabs.SelectedIndex - 1].Running;
            };

            stopButton.Click += (s, e) =>
            {
                pages[botTabs.SelectedIndex - 1].Running = false;
                startButton.Enabled = !pages[botTabs.SelectedIndex - 1].Running;
                stopButton.Enabled  = pages[botTabs.SelectedIndex - 1].Running;
            };

            closeButton.Click += (s, e) =>
            {
                pages[botTabs.SelectedIndex - 1].Stop();
                pages.RemoveAt(botTabs.SelectedIndex - 1);
                botTabs.Controls.RemoveAt(botTabs.SelectedIndex);
                AccountsCount--;
            };

            settingsButton.Click += (s, e) =>
            {
                SettingsForm settingsForm = new SettingsForm(pages[botTabs.SelectedIndex - 1]);
                settingsForm.Show();
            };
        }