private void Tmp_OnSimulationWriting(object sender, EventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(new Action <object, EventArgs>(Tmp_OnSimulationWriting), sender, e); } else { DoormatBot.Helpers.Simulation tmp = sender as DoormatBot.Helpers.Simulation; //Console.WriteLine("Simulation Progress: " + tmp.TotalBetsPlaced + " bets of " + tmp.Bets); if (tmp.TotalBetsPlaced > 0) { long ElapsedMilliseconds = SimTimer.ElapsedMilliseconds; Progress = (decimal)tmp.TotalBetsPlaced / (decimal)tmp.Bets; decimal totaltime = ElapsedMilliseconds / Progress; TimeRunning = TimeSpan.FromMilliseconds(ElapsedMilliseconds); ProjectedTime = TimeSpan.FromMilliseconds((double)totaltime); ProjectedRemaining = TimeSpan.FromMilliseconds((double)totaltime - ElapsedMilliseconds); OnPropertyChanged(nameof(Progress)); OnPropertyChanged(nameof(TimeRunning)); OnPropertyChanged(nameof(ProjectedTime)); OnPropertyChanged(nameof(ProjectedRemaining)); OnPropertyChanged(nameof(CurrentSimulation)); sesseionStats1.RefreshStats(); } } }
private void SimpleButton_Click(object sender, RoutedEventArgs e) { chrt.Reset(); CurrentSimulation = new DoormatBot.Helpers.Simulation(txtBalance.Value, (long)txtBets.Value, CurrentSite, Strategy, BetSettings, "tmp.sim", true); btnSaveFile.IsEnabled = false; CurrentSimulation.OnSimulationWriting += Tmp_OnSimulationWriting; CurrentSimulation.OnSimulationComplete += Tmp_OnSimulationComplete; CurrentSimulation.OnBetSimulated += CurrentSimulation_OnBetSimulated; SimTimer.Start(); CurrentSimulation.Start(); sesseionStats1.Stats = CurrentSimulation.Stats; }
private void Tmp_OnSimulationComplete(object sender, EventArgs e) { SimTimer.Stop(); DoormatBot.Helpers.Simulation tmp = sender as DoormatBot.Helpers.Simulation; sesseionStats1.RefreshStats(); long ElapsedMilliseconds = SimTimer.ElapsedMilliseconds; Progress = (decimal)tmp.TotalBetsPlaced / (decimal)tmp.Bets; decimal totaltime = ElapsedMilliseconds / Progress; TimeRunning = TimeSpan.FromMilliseconds(ElapsedMilliseconds); ProjectedTime = TimeSpan.FromMilliseconds((double)totaltime); ProjectedRemaining = TimeSpan.FromMilliseconds((double)totaltime - ElapsedMilliseconds); OnPropertyChanged(nameof(Progress)); OnPropertyChanged(nameof(TimeRunning)); OnPropertyChanged(nameof(ProjectedTime)); OnPropertyChanged(nameof(ProjectedRemaining)); OnPropertyChanged(nameof(CurrentSimulation)); SimTimer.Reset(); btnSaveFile.IsEnabled = true; }