public MainPresenter (Factory factory) { _mainViewModel = factory.Get<MainViewModel> (); Localaizer= factory.Get<LocalizeService> (); Localaizer.LoadLocalization ("en"); MainPage = new NavigationPage (new LoginPresenter (factory, Localaizer)); }
public VTSListPresenter (Factory factory, ILocalizeService localaize) { _vtsListViewModel = factory.Get<VTSViewModel> (); _vtsListViewModel.Server = ConfigurationManager.SERVER; Label header = new Label { Text = localaize.Data.vacations,// "Vacations", Font = Font.SystemFontOfSize (30), TextColor = Color.FromHex ("#000"), HorizontalOptions = LayoutOptions.Center }; _listView = new ListView { ItemsSource = null, ItemTemplate = new DataTemplate (typeof(VTSListViewTemplate)) }; this.Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5); this.Content = new StackLayout { BackgroundColor = Color.FromHex ("#FFF"), Children = { header, _listView } }; changeListView(); }
public LoginPresenter(Factory factory, ILocalizeService localaize) { _localize = localaize; _factory = factory; _loginViewModel = factory.Get<LoginViewModel> (); _image = new Image { Source = "logo.png" }; _userName = new Entry { Placeholder = _localize.Data.username }; _password = new Entry { IsPassword = true, Placeholder = _localize.Data.password }; _loginButton = new Button { Text = _localize.Data.login }; _error = new Label { //Text = _loginViewModel.errorMessage,//_localize.Data.loginError, //TextColor = Color.Red,//FromHex ("#FA8072"), XAlign = TextAlignment.Center, IsVisible = false }; _loginButton.Clicked += onLoginButtonClicked; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Padding = 50, Children ={ _image, _userName, _password, _loginButton, _error } }; }
public void simulate() { if (lagstring == "None") { } if (lagstring == "Small (50-150ms)") { lowerlag = 50; upperlag = 150; } if (lagstring == "Med (125-225ms)") { lowerlag = 125; upperlag = 225; } logging = true; var jobtext = ""; var statweighttext = ""; var fightlengthtext = ""; //bucket clear bucketlist.Clear(); this.Dispatcher.Invoke((Action)(() => { jobtext = job.Text; statweighttext = statweights.Text; fightlengthtext = fightLengthInput.Text; })); stopwatch.Start(); Factory fact = new Factory(); Report r = new Report(); var playerjob = fact.Get(jobtext); var p = playerjob; Trace.Assert(playerjob.name != null, "No job selected. ERROR 1"); //assert failure of factory set. p = playerjob; string swselected = Convert.ToString(statweighttext); p.statforweights = swselected; // TODO: steps and delta... int step = 5; int delta = 50; int newdelta = delta; // TODO: add negative and positive delta selection. Currently we're doing positive only. StatWeight swenum = StatWeight.None; if (swselected == "None") { swenum = StatWeight.None; newdelta = 0; } else { newdelta *= 2; } if (swselected == "Weapon Damage") { swenum = StatWeight.WeaponDamage; } if (swselected == "Magic Damage") { swenum = StatWeight.MagicDamage; } if (swselected == "Dexterity") { swenum = StatWeight.Dexterity; } if (swselected == "Strength") { swenum = StatWeight.Strength; } if (swselected == "Mind") { swenum = StatWeight.Mind; } if (swselected == "Piety") { swenum = StatWeight.Piety; } if (swselected == "Intelligence") { swenum = StatWeight.Intelligence; } if (swselected == "Accuracy") { swenum = StatWeight.Accuracy; } if (swselected == "Crit") { swenum = StatWeight.Crit; } if (swselected == "Determination") { swenum = StatWeight.Determination; } if (swselected == "Skill Speed") { swenum = StatWeight.SkillSpeed; } if (swselected == "Spell Speed") { swenum = StatWeight.SpellSpeed; } //subtract an extra step because one gets added initially. //buckets for dpstimeline for (int x = 0; x < 50; x++) { bucketlist.Add(0); } List<double> DPSarray = new List<double>(); List<double> WeightArray = new List<double>(); List<double> WeightDiff = new List<double>(); for (int y = 0; y <= newdelta; y += step) { //progress bar incrementing here.. for stat weights if (swselected != "None") { this.Dispatcher.Invoke((Action)(() => { progressBar.Value = (int)((100) - ((newdelta) - (y))); })); } //start iterations (needs threading!!!) for (int x = 1; x <= iterations; ++x) { int ticknumber = 0; iterationum = x; servertick = randtick.Next(1, 4); //alt progress bar for iterations only if (swselected == "None") { this.Dispatcher.Invoke((Action)(() => { this.progressBar.Value = (int)(((double)x / (double)iterations) * 100); })); } p.getStats(this); switch (swenum) { case StatWeight.WeaponDamage: p.WEP = p.WEP - (delta - y); break; case StatWeight.MagicDamage: p.MDMG = p.MDMG - (delta - y); break; case StatWeight.Dexterity: p.DEX = p.DEX - (delta - y); break; case StatWeight.Strength: p.STR = p.STR - (delta - y); break; case StatWeight.Intelligence: p.INT = p.INT - (delta - y); break; case StatWeight.Mind: p.MND = p.MND - (delta - y); break; case StatWeight.Piety: p.PIE = p.PIE - (delta - y); break; case StatWeight.Accuracy: p.ACC = p.ACC - (delta - y); break; case StatWeight.Determination: p.DTR = p.DTR - (delta - y); break; case StatWeight.Crit: p.CRIT = p.CRIT - (delta - y); break; case StatWeight.SkillSpeed: p.SKS = p.SKS - (delta - y); break; case StatWeight.SpellSpeed: p.SPS = p.SPS - (delta - y); break; } p.resetAbilities(); resetSim(); fightlength = (Convert.ToInt32(fightlengthtext)) + (d100(0, (int)Math.Floor(Convert.ToInt16(fightlengthtext) * 0.1)) - (int)Math.Floor(Convert.ToInt16(fightlengthtext) * 0.05)); if ((x == 1) && (y == 0)) { r.dpstimeline.Select(i => 0); r.dpstimelinecount.Select(i => 0); } debug(); //have option to disable TODO: //actual simming while (time <= fightlength) { handler(ref p); tickevent(); time = nextTime(p.nextinstant, p.nextability, servertime, p.nextauto, p.OOT, p.OOM); //add timeline stuff if ((y == 0 && time == servertime)) { if (r.dpstimeline.Count < ticknumber + 1) { r.dpstimeline.Add(0); } if (r.dpstimelinecount.Count < ticknumber + 1) { r.dpstimelinecount.Add(0); } if (r.tptimeline.Count < ticknumber + 1) { r.tptimeline.Add(0); } if (r.tptimelinecount.Count < ticknumber + 1) { r.tptimelinecount.Add(0); } if (r.mptimeline.Count < ticknumber + 1) { r.mptimeline.Add(0); } if (r.mptimelinecount.Count < ticknumber + 1) { r.mptimelinecount.Add(0); } r.dpstimeline[ticknumber] += p.totaldamage / time; r.dpstimelinecount[ticknumber] += 1; r.tptimeline[ticknumber] += p.TP; r.tptimelinecount[ticknumber] += 1; r.mptimeline[ticknumber] += p.MP; r.mptimelinecount[ticknumber] += 1; ticknumber += 1; } } DPSarray.Add((p.totaldamage / fightlength)); //first iteration reporting if (x == 1 && y == 0) { p.report(); // first iteration of abilities writeLog(); readLog(); } else { logging = false; } } //end iteration set DPSarray.Sort(); p.averagedps = DPSarray.Average(); var dpsmin = DPSarray.Min(); var dpsmax = DPSarray.Max(); dpsminlist = dpsmin; dpsmaxlist = dpsmax; var dpsdiff = dpsmax - dpsmin; var numbuckets = 50; var dpsdiv = dpsdiff / numbuckets; foreach (var it in DPSarray) { for (var x = 0; x <= numbuckets; ++x) { if (it >= dpsmin + (dpsdiv * x) && it <= dpsmin + (dpsdiv * (x + 1))) { bucketlist[x] += 1; break; } } } // calculate last difference of array var beforelast = 0.0; if (swselected != "None") { if (p.passoverweight > 0.0) { //probably a better way to do this, but it stores the first attempt, then adds it as the subtractive weight beforelast = p.passoverweight; WeightDiff.Add((double)(beforelast - p.averagedps)); p.passoverweight = 0.0; } else { if (WeightDiff.Count > 0) { beforelast = WeightArray.Last(); WeightDiff.Add((double)(beforelast - p.averagedps)); } else { p.passoverweight = p.averagedps; } } } // for avg difference of array used for calculating weight. // avgoflist / steps for weight (non normalized) - no full calcs yet, but this is the method. WeightArray.Add(Math.Round((p.averagedps * 100)) / 100); //array of all DPSavg's from all sets of iterations DPSarray.Clear(); } //end statweight set WeightArray.Sort(); p.DPSarray = WeightArray; //print stat weight if calculating weights. if (swselected != "None") { p.weight = ((WeightDiff.Average()* -1) / step); } stopwatch.Stop(); double simulationtime = (double)stopwatch.ElapsedMilliseconds; p.simulationtime = simulationtime / 1000; for (var x = 0; x < r.dpstimeline.Count; x++) { r.dpstimeline[x] = r.dpstimeline[x] / r.dpstimelinecount[x]; r.tptimeline[x] = r.tptimeline[x] / r.tptimelinecount[x]; r.mptimeline[x] = r.mptimeline[x] / r.mptimelinecount[x]; } // Parse HTML log r.parse(p); stopwatch.Reset(); this.Dispatcher.Invoke((Action)(() => { //refresh the html page this.htmlReport.Focus(); this.browser.Navigate(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "report.html")); this.WEP.IsEnabled = true; this.MDMG.IsEnabled = true; this.AADMG.IsEnabled = true; this.DELAY.IsEnabled = true; this.STR.IsEnabled = true; this.DEX.IsEnabled = true; this.VIT.IsEnabled = true; this.INT.IsEnabled = true; this.MND.IsEnabled = true; this.PIE.IsEnabled = true; this.CRIT.IsEnabled = true; this.DTR.IsEnabled = true; this.ACC.IsEnabled = true; this.SKSPD.IsEnabled = true; this.SPSPD.IsEnabled = true; this.iterationsinput.IsEnabled = true; this.fightLengthInput.IsEnabled = true; this.disembowelbox.IsEnabled = true; this.selenebox.IsEnabled = true; this.job.IsEnabled = true; this.simulateButton.IsEnabled = true; this.statweights.IsEnabled = true; this.inputlag.IsEnabled = true; this.progressBar.Value = 100; //this.StatGrwth.IsEnabled = true; // TODO: RENAME THESE RIGHT //this.Delta.IsEnabled = true; })); }