public Login() { InitializeComponent(); FillComboBox(); IniRead(); _parser = new IniParser("config.ini"); _login.DoWork += worker_DoWork; _login.RunWorkerCompleted += worker_RunWorkerCompleted; }
private void IniRead() { while (true) { if (File.Exists("config.ini")) { using (var reader = new StreamReader("config.ini")) { if (!reader.ReadToEnd().Contains("DELAYENABLED")) { reader.Close(); var parserFix = new IniParser("config.ini"); parserFix.AddSetting("AUTODICE", "DELAYENABLED", "False"); parserFix.AddSetting("AUTODICE", "DELAYTIME", "10"); parserFix.SaveSettings(); } } var parserStart = new IniParser("config.ini"); chkLogin.IsChecked = bool.Parse(parserStart.GetSetting("AUTODICE", "SAVELOGINDATA")); if ((bool) chkLogin.IsChecked) { txtUsername.Text = parserStart.GetSetting("AUTODICE", "USERNAME"); txtPassword.Password = parserStart.GetSetting("AUTODICE", "PASSWORD"); txt2fa.Text = parserStart.GetSetting("AUTODICE", "2FA"); } cmbSite.SelectedIndex = int.Parse(parserStart.GetSetting("AUTODICE", "WEBSITE")); ChangeAppStyle(int.Parse(parserStart.GetSetting("AUTODICE", "WINDOWTHEME")), int.Parse(parserStart.GetSetting("AUTODICE", "WINDOWCOLOR"))); } else { using (var writer = new StreamWriter("config.ini")) { writer.WriteLine("[AUTODICE]"); writer.WriteLine("SAVELOGINDATA=False"); writer.WriteLine("USERNAME="******"PASSWORD="******"2FA="); writer.WriteLine("WINDOWTHEME=0"); writer.WriteLine("WINDOWCOLOR=1"); writer.WriteLine("WEBSITE=0"); writer.WriteLine("DELAYENABLED=False"); writer.WriteLine("DELAYTIME=10"); } cmbSite.SelectedIndex = 0; continue; } break; } }
private void LoadStratConfig(string filename) { try { var parser = new IniParser(filename); #region Initial Settings NumStartingBet.Value = double.Parse(parser.GetSetting("INITIAL_SETTINGS", "_NumStartingBet").Replace(",", "."), CultureInfo.InvariantCulture); NumStartingChance.Value = double.Parse(parser.GetSetting("INITIAL_SETTINGS", "_NumStartingChange").Replace(",", "."), CultureInfo.InvariantCulture); _RollOverUnder = parser.GetSetting("INITIAL_SETTINGS", "_RollOverUnder"); if (_RollOverUnder.ToLower().Equals("over")) { RadRollOver.IsChecked = true; } else { RadRollUnder.IsChecked = true; } _martingale = bool.Parse(parser.GetSetting("INITIAL_SETTINGS", "_martingale")); _fibonacci = bool.Parse(parser.GetSetting("INITIAL_SETTINGS", "_fibonacci")); if (_martingale) { TabMartingale.IsSelected = true; } else if (_fibonacci) { TabFibonacci.IsSelected = true; } #endregion #region Stop Conditions ChkBalanceLimit.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkBalanceLimit")); NumBalanceLimit.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumBalanceLimit").Replace(",", "."), CultureInfo.InvariantCulture); ChkBalanceLowerLimit.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkBalanceLowerLimit")); NumBalanceLowerLimit.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumBalanceLowerLimit").Replace(",", "."), CultureInfo.InvariantCulture); // Losses conditions ChkStopAfterBTCLoss.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkStopAfterBTCLoss")); NumStopBTCLoss.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumStopBTCLoss").Replace(",", "."), CultureInfo.InvariantCulture); ChkStopAfterLossesInRow.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkStopAfterLossesInRow")); NumStopLosesInRow.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumStopLosesInRow").Replace(",", "."), CultureInfo.InvariantCulture); ChkResetAfterBTCLoss.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkResetAfterBTCLoss")); NumResetBTCLoss.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumResetBTCLoss").Replace(",", "."), CultureInfo.InvariantCulture); ChkResetAfterLossesInRow.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkResetAfterLossesInRow")); NumResetLosesInRow.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumResetLosesInRow").Replace(",", "."), CultureInfo.InvariantCulture); // Wons conditions ChkStopAfterBTCProfit.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkStopAfterBTCProfit")); NumStopBTCProfit.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumStopBTCProfit").Replace(",", "."), CultureInfo.InvariantCulture); ChkStopAfterWonsInRow.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkStopAfterWonsInRow")); NumStopWonsInRow.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumStopWonsInRow").Replace(",", "."), CultureInfo.InvariantCulture); ChkResetAfterBTCProfit.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkResetAfterBTCProfit")); NumResetBTCProfit.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumResetBTCProfit").Replace(",", "."), CultureInfo.InvariantCulture); ChkResetAfterWonsInRow.IsChecked = bool.Parse(parser.GetSetting("STOP_CONDITIONS", "_ChkResetAfterWonsInRow")); NumResetWonsInRow.Value = double.Parse(parser.GetSetting("STOP_CONDITIONS", "_NumResetWonsInRow").Replace(",", "."), CultureInfo.InvariantCulture); #endregion #region Martingale #region Multiply on Loss NumMultiplierLoss.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMultiplierLoss").Replace(",", "."), CultureInfo.InvariantCulture); NumMaxMultipliesLoss.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMaxMultipliesLoss").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterLoss.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterLoss").Replace(",", "."), CultureInfo.InvariantCulture); NumMultiplierAfterLoss.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMultiplierAfterLoss").Replace(",", "."), CultureInfo.InvariantCulture); RadMaxLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadMaxLoss")); RadVariableLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadVariableLoss")); RadConstrantLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadConstrantLoss")); RadChangeOnceLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadChangeOnceLoss")); ChkMultiplyOnlyOneTimeLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkMultiplyOnlyOneTimeLoss")); ChkAfterLossesInRowChangeBet.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkAfterLossesInRowChangeBet")); NumAfterXLossesInRowChangeBet.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXLossesInRowChangeBet").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterXLossesInRowChangeBetNumber.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXLossesInRowChangeBetNumber").Replace(",", "."), CultureInfo.InvariantCulture); ChkAfterLossesInRowChangeChance.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkAfterLossesInRowChangeChance")); NumAfterXLossesInRowChangeChance.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXLossesInRowChangeChance").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterXLossesInRowChangeChanceNumber.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXLossesInRowChangeChanceNumber").Replace(",", "."), CultureInfo.InvariantCulture); ChkReturnBaseBetAfterFirstLoss.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkReturnBaseBetAfterFirstLoss")); #endregion #region Multiply on Won NumMultiplierWon.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMultiplierWon").Replace(",", "."), CultureInfo.InvariantCulture); NumMaxMultipliesWon.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMaxMultipliesWon").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterWon.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterWon").Replace(",", "."), CultureInfo.InvariantCulture); NumMultiplierAfterWon.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumMultiplierAfterWon").Replace(",", "."), CultureInfo.InvariantCulture); RadMaxWon.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadMaxWon")); RadVariableWon.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadVariableWon")); RadConstrantWon.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadConstrantWon")); RadChangeOnceWon.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_RadChangeOnceWon")); ChkAfterWonsInRowChangeBet.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkAfterWonsInRowChangeBet")); NumAfterXWonsInRowChangeBet.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXWonsInRowChangeBet").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterXWonsInRowChangeBetNumber.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXWonsInRowChangeBetNumber").Replace(",", "."), CultureInfo.InvariantCulture); ChkAfterWonsInRowChangeChance.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkAfterWonsInRowChangeChance")); NumAfterXWonsInRowChangeChance.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXWonsInRowChangeChance").Replace(",", "."), CultureInfo.InvariantCulture); NumAfterXWonsInRowChangeChanceNumber.Value = double.Parse(parser.GetSetting("MARTINGALE", "_NumAfterXWonsInRowChangeChanceNumber").Replace(",", "."), CultureInfo.InvariantCulture); ChkReturnBaseBetAfterFirstWon.IsChecked = bool.Parse(parser.GetSetting("MARTINGALE", "_ChkReturnBaseBetAfterFirstWon")); #endregion #endregion #region Fibonacci ChkFibonacciLossIncrease.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciLossIncrease")); NumFibonacciIncrementLoss.Value = double.Parse(parser.GetSetting("FIBONACCI", "_NumFibonacciIncrementLoss").Replace(",", "."), CultureInfo.InvariantCulture); ChkFibonacciLossRestart.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciLossRestart")); ChkFibonacciLossStop.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciLossStop")); ChkFibonacciWonIncrease.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWonIncrease")); NumFibonacciIncrementWon.Value = double.Parse(parser.GetSetting("FIBONACCI", "_NumFibonacciIncrementWon").Replace(",", "."), CultureInfo.InvariantCulture); ChkFibonacciWonRestart.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWonRestart")); ChkFibonacciWonStop.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWonStop")); ChkFibonacciWhenLevel.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWhenLevel")); NumFibonacciWhenLevel.Value = double.Parse(parser.GetSetting("FIBONACCI", "_NumFibonacciWhenLevel").Replace(",", "."), CultureInfo.InvariantCulture); ChkFibonacciWhenLevelReset.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWhenLevelReset")); ChkFibonacciWhenLevelStop.IsChecked = bool.Parse(parser.GetSetting("FIBONACCI", "_ChkFibonacciWhenLevelStop")); #endregion } catch { ShowNormalDialog("Error", "An error occured while parsing the Config File."); } }