public void SetCarQueueImages() { //CAR IMAGES var temp1 = new RoadQueue { image = new UIElement[8] }; var temp2 = new RoadQueue { image = new UIElement[10] }; var temp3 = new RoadQueue { image = new UIElement[8] }; temp1.image[0] = Road1_1; temp1.image[1] = Road1_2; temp1.image[2] = Road1_3; temp1.image[3] = Road1_4; temp1.image[4] = Road1_5; temp1.image[5] = Road1_6; temp1.image[6] = Road1_7; temp1.image[7] = Road1_8; temp2.image[0] = Road2_1; temp2.image[1] = Road2_2; temp2.image[2] = Road2_3; temp2.image[3] = Road2_4; temp2.image[4] = Road2_5_down; temp2.image[5] = Road2_6_down; temp2.image[6] = Road2_7_down; //temp2.image[7] = Road2_8_down; temp2.image[7] = Road2_5_up; temp2.image[8] = Road2_6_up; temp2.image[9] = Road2_7_up; //temp2.image[11] = Road2_8_up; temp3.image[0] = Road3_1; temp3.image[1] = Road3_2; temp3.image[2] = Road3_3; temp3.image[3] = Road3_4; temp3.image[4] = Road3_5; temp3.image[5] = Road3_6; temp3.image[6] = Road3_7; temp3.image[7] = Road3_8; roadQ1 = temp1; roadQ2 = temp2; roadQ3 = temp3; }
public async Task RefreshUIFunc() { if (Light_Green_1.IsVisible) { roadQ1.flowTime = roadQ1.flowTime + 100; roadQ1.lampStatus = true; } else { roadQ1.lampStatus = false; } if (Light_Green_2.IsVisible) { roadQ2.flowTime = roadQ2.flowTime + 100; roadQ2.lampStatus = true; } else { roadQ2.lampStatus = false; } if (Light_Green_3.IsVisible) { roadQ3.flowTime = roadQ3.flowTime + 100; roadQ3.lampStatus = true; } else { roadQ3.lampStatus = false; } var x = new RoadQueue[3]; x[0] = roadQ1; x[1] = roadQ2; x[2] = roadQ3; var temp = x.Max(p => p.flowTime); if (temp == x[0].flowTime) { BiggestFlowTime = 1; } if (temp == x[1].flowTime) { BiggestFlowTime = 2; } if (temp == x[2].flowTime) { BiggestFlowTime = 3; } //Images ResetQueueImages(); //Queue for (int i = 1; i <= roadQ1.carsWaiting; i++) { if (i >= 5) { break; } roadQ1.image[i - 1].Visibility = Visibility.Visible; } for (int i = 1; i <= roadQ2.carsWaiting; i++) { if (i >= 5) { break; } roadQ2.image[i - 1].Visibility = Visibility.Visible; } for (int i = 1; i <= roadQ3.carsWaiting; i++) { if (i >= 5) { break; } roadQ3.image[i - 1].Visibility = Visibility.Visible; } //Bridge for (int i = 0; i <= 2; i++) { if (carLoc1[i].isCarExists == true) { roadQ1.image[i + 4].Visibility = Visibility.Visible; } if (carLoc3[i].isCarExists == true) { roadQ3.image[i + 4].Visibility = Visibility.Visible; } } for (int i = 0; i <= 5; i++) { if (carLoc2[i].isCarExists == true) { if (i == 6) { } roadQ2.image[i + 4].Visibility = Visibility.Visible; } } //CAR COUNT lbl_redcars.Text = roadQ1.totalGenerated.ToString(); lbl_bluecars.Text = roadQ2.totalGenerated.ToString(); lbl_greencars.Text = roadQ3.totalGenerated.ToString(); }