public RootObject API_Call(string APIREQUEST, List <Accident> _danger)// Sends API request and Deserializes it into the classes { var client = new WebClient(); var content = client.DownloadString(APIREQUEST); RootObject directions = Newtonsoft.Json.JsonConvert.DeserializeObject <RootObject>(content); GeoCoordinate currLoc = functions1.GetLocationProperty(); var functions = new functions1(); List <GeoCoordinate> Extrap = new List <GeoCoordinate>(); List <GeoCoordinate> PrevLoc = functions.CoordFetch(directions); Extrap = CordFetchExtra(directions, .014619f, currLoc); DangerZones = SearchDangerZones(Extrap, _danger, PrevLoc, currLoc); return(directions); }
public static void draw(Graphics g, Control c, int joyX, int joyY) { if (joyX != 0 || joyY != 0) { if (DateTime.Now.Subtract(pre).TotalMilliseconds > 300) //friends { pre = DateTime.Now.AddSeconds(2); //Left if (joyX > 256) { if (trig) { synthesizerA.readDistanceMan("Friends", 4); substate = 0; } else { Console.WriteLine("JOYX > 256"); trig = true; state = 0; } } //Right if (joyX < -256) //fun { if (trig) { synthesizerA.readDistanceMan("Fun", 4); substate = 2; } else { Console.WriteLine("JOYX < -256"); trig = true; state = 2; } } //Up if (joyY > 256) //food { if (trig) { synthesizerA.readDistanceMan("Food", 4); substate = 1; } else { Console.WriteLine("JOYY > 256"); trig = true; state = 1; } } //Down if (joyY < -256) { if (trig) { substate = 3; state = 3; } else { Console.WriteLine("JOYY < =256"); trig = false; state = 3; } } } } else { pre = DateTime.Now; } g.FillEllipse(Brushes.White, x, y, 150, 150); g.FillEllipse(Brushes.Red, (x + 100 / 2) - ((joyX / 512) * 20), (y + 100 / 2) - ((joyY / 512) * 20), 50, 50); string[] left = { "Julian", "Arby's", "Oaks Mall", "Friends" }; string[] up = { "Peyton", "Chuy's", "Universal Studios", "Food" }; string[] right = { "Tristan", "Hurrican BTW", "Gatorz Bowling", "Fun" }; g.DrawString(left[state], f, Brushes.Red, x - 50, y + 60); g.DrawString(up[state], f, Brushes.Red, x + 45, y); g.DrawString(right[state], f, Brushes.Red, x + 120, y + 60); string[] food = { "1405+SW+13th+St+Gainesville", "3410+SW+Archer+Rd+Gainesville", "1404+W.+Univeresity+Avenue+suites+Gainesville+FL" }; string[] fun = { "6419+W+NewBerry+Rd+Gainsville", "6000+Universal+Blvd+Orlando", "2606+NE+Waldo+Rd+Gainesville" }; if (trig) { if (joyX != 0 || joyY != 0) { if (DateTime.Now.Subtract(pre2).TotalMilliseconds > 300) { pre2 = DateTime.Now.AddSeconds(10); if (joyX > 256) { substate = 0; } //Right if (joyX < -256) { substate = 2; } //Up if (joyY > 256) { substate = 1; } //Down if (joyY < -256) { substate = 3; state = 3; } switch (state) { case 0: //Call someone trig = false; state = 3; substate = 3; break; case 1: var functions = new functions1(); GeoCoordinate coord = functions1.GetLocationProperty(); string APIREQUEST = functions.API_request(coord, food[substate]); ActDataB dataB = new ActDataB(); List <Accident> danger = dataB.dangerSpots(); functions.API_Call(APIREQUEST, danger); trig = false; state = 3; substate = 3; break; case 2: trig = false; state = 3; substate = 3; break; default: state = 3; substate = 3; trig = false; break; } } } else { pre2 = DateTime.Now; } } }
private void button4_Click(object sender, EventArgs e) { var functions = new functions1(); //functions.GetLocation(); }