Esempio n. 1
0
        public SettingsForm(MainForm mainForm, ApplicationSettings settings)
        {
            InitializeComponent();

            _mainForm = mainForm;
            _settings = settings;

            numericUpDown1.Value = _settings.CheckEveryXMinutes;
            checkBoxSupply.Checked = _settings.DoSupplyClicks;
            checkBoxGoods.Checked = _settings.DoGoodsClicks;
            checkBoxMilitary.Checked = _settings.DoMilitaryUnitsClicks;
            //this.checkBoxMilitaryUnblock.Checked = _settings.DoMilitaryUnitsUnblock;
            checkBoxPlungedItemsClick.Checked = _settings.DoPlungedItemsClick;
            numericUpDown_WaitBeforeProduction.Value = _settings.WaitBeforeProductionInMillis/1000;
            //numericUpDown_Popup.Value = _settings.WaitOnPopupInMillis/1000;
            numericUpDownBotScreenWidth.Value = _settings.BotPictureWidth;
            numericUpDownBotScreenHeight.Value = _settings.BotPictureHeight;
            numericUpDown_MaxItemsClicked.Value = _settings.MaxItemsClickedInARow;
            numericUpDown_PrcRndCheck.Value = _settings.RndPercentCheckEveryXMinutes;
            numericUpDown_PrcRndClick.Value = _settings.RndPercentDontCollectInARow;
            //checkBoxVersionCheck.Checked = _settings.VersionCheck;
            checkBoxShowLogOnStartup.Checked = _settings.ShowLogWindowOnStartup;
            numericUpDownAutoLogin.Value = _settings.ReloadAfterXTimesNotRecognized;
            numericUpDownPauseCountdown.Value = _settings.PauseCountdownForXSeconds;
            numericUpDownAutoRefresh.Value = _settings.AutoRefreshAfterXMinutes;
            tb_UserAgent.Text = _settings.BrowserUserAgent;

            string name = _settings.SupplyItemCoords.Name;
            if (name == "5m")
            {
                radioButton5m.Checked = true;
            }
            else if (name == "15m")
            {
                radioButton15m.Checked = true;
            }
            else if (name == "1h")
            {
                radioButton1h.Checked = true;
            }
            else if (name == "4h")
            {
                radioButton4h.Checked = true;
            }
            else if (name == "8h")
            {
                radioButton8h.Checked = true;
            }
            else if (name == "1d")
            {
                radioButton1d.Checked = true;
            }
            else
            {
                //MessageBox.Show("error initializing settings: supply item type");
            }
            name = _settings.GoodsItemCoords.Name;
            if (name == "4h")
            {
                radioButtonGoods4h.Checked = true;
            }
            else if (name == "8h")
            {
                radioButtonGoods8h.Checked = true;
            }
            else if (name == "1d")
            {
                radioButtonGoods1d.Checked = true;
            }
            else if (name == "2d")
            {
                radioButtonGoods2d.Checked = true;
            }
            else
            {
                //MessageBox.Show("error initializing settings: goods item type");
            }

            var language = _settings.ApplicationLanguage;
            switch (language)
            {
                case "it-IT":
                    comboBoxLanguage.SelectedIndex = 2;
                    break;
                case "en-US":
                    comboBoxLanguage.SelectedIndex = 0;
                    break;
                case "de-DE":
                    comboBoxLanguage.SelectedIndex = 1;
                    break;
                case "ru-RU":
                    comboBoxLanguage.SelectedIndex = 3;
                    break;
                case "pl-PL":
                    comboBoxLanguage.SelectedIndex = 4;
                    break;
                default:
                    comboBoxLanguage.SelectedIndex = 0;
                    //MessageBox.Show("error initializing settings: application language");
                    break;
            }

            crdSupplyItem = _settings.SupplyItemCoords;
            numericUpDownCollectDistance.Value = _settings.CollectDistanceY;
            _oldCollectDistanceY = _settings.CollectDistanceY;
            numericUpDownSypplyDistance.Value = _settings.SupplyDistanceY;
            _oldSupplyDistanceY = _settings.SupplyDistanceY;
            numericUpDownSypplyDistanceX.Value = _settings.SupplyDistanceX;
            _oldSupplyDistanceX = _settings.SupplyDistanceX;
            checkBoxSaveScanResults.Checked = _settings.SaveScanResults;
            int index = comboBoxFoEServer.FindStringExact(_settings.FoEServer);
            comboBoxFoEServer.SelectedIndex = index < 0 ? 0 : index;
        }
Esempio n. 2
0
        private static void Main(string []args)
        {
            Application.ThreadException +=
                new ThreadExceptionEventHandler(Application_ThreadException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool autoLogin = false, autoStartBot = false, pressAutoReloadButton = false;
            foreach (var arg in args)
            {
                if (arg.ToLowerInvariant().Trim() == "autologin")
                    autoLogin = true;
                else if (arg.ToLowerInvariant().Trim() == "autostartbot")
                    autoStartBot = true;
                else if (arg.ToLowerInvariant().Trim() == "buttonautoreload")
                    pressAutoReloadButton = true;
            }

            Check4BSOD(ref autoLogin, ref autoStartBot,ref pressAutoReloadButton);
            bool restartApp = false ;
            using (var form = new MainForm(autoLogin, autoStartBot, pressAutoReloadButton))
            {
                form.ShowDialog();
                restartApp = form.PerformApplicationRestart;
                pressAutoReloadButton = form.KeepAutoReloadButton;
            }
            if (restartApp)
                RestartApplication(pressAutoReloadButton);

            //try
            //{
            //    Application.Run(new MainForm(autoLogin,autoStartBot));
            //}
            //catch (RestartApplicationNeededException restartNeededEx)
            //{
            //    RestartApplication();
            //}
            //catch (Exception ex)
            //{
            //    LogException(ex);
            //}
        }