private void FillTreeView() { treeViewSavedDrivers.Nodes.Clear(); treeViewSavedTrucks.Nodes.Clear(); treeViewSortingDrivers.Nodes.Clear(); treeViewSortingTrucks.Nodes.Clear(); int SpareDrvSpaces = 0, SpareVhcSpaces = 0, TotalDrv = 0, TotalVhc = 0; //Saved Drivers and Trucks foreach (Garages tempG in MainForm.GaragesList) { if (tempG.GarageStatus > 0) { int curVeh = 0, curDr = 0; foreach (string temp in tempG.Drivers) { if (temp != null) { curDr++; } } foreach (string temp in tempG.Vehicles) { if (temp != null) { curVeh++; } } SpareDrvSpaces = SpareDrvSpaces + tempG.Drivers.Count - curDr; SpareVhcSpaces = SpareVhcSpaces + tempG.Vehicles.Count - curVeh; TotalDrv += curDr; TotalVhc += curVeh; //Drivers tree treeViewSavedDrivers.Nodes.Add(tempG.GarageName, "[ " + curDr + " | " + tempG.Drivers.Count + " ] " + tempG.GarageNameTranslated); foreach (string tempD in tempG.Drivers) { if (tempD != null) { string DriverName = tempD; if (MainForm.PlayerDataV.UserDriver == DriverName) { DriverName = MainForm.FromHexToString(Globals.SelectedProfile); } else { MainForm.DriverNames.TryGetValue(DriverName, out string _resultvalue); if (_resultvalue != null && _resultvalue != "") { DriverName = _resultvalue.TrimStart(new char[] { '+' }); } } treeViewSavedDrivers.Nodes[tempG.GarageName].Nodes.Add(tempD, DriverName); } } //Trucks tree treeViewSavedTrucks.Nodes.Add(tempG.GarageName, "[ " + curVeh + " | " + tempG.Vehicles.Count + " ] " + tempG.GarageNameTranslated); foreach (string tempV in tempG.Vehicles) { if (tempV != null) { string TruckName = ""; try { string templine = MainForm.UserTruckDictionary[tempV].Parts.Find(x => x.PartType == "truckbrandname").PartData.Find(xline => xline.StartsWith(" data_path:")); TruckName = templine.Split(new char[] { '"' })[1].Split(new char[] { '/' })[4]; } catch { } MainForm.TruckBrandsLngDict.TryGetValue(TruckName, out string trucknamevalue); if (trucknamevalue != null && trucknamevalue != "") { TruckName = trucknamevalue; } treeViewSavedTrucks.Nodes[tempG.GarageName].Nodes.Add(tempV, TruckName); } } } } //Labels labelSavedDrivers.Text = "Drivers [ " + TotalDrv + " | " + (SpareDrvSpaces + TotalDrv).ToString() + " ]"; if (TotalDrv == (SpareDrvSpaces + TotalDrv)) { labelSavedDrivers.ForeColor = Color.Red; } else { labelSavedDrivers.ForeColor = DefaultForeColor; } labelSavedTrucks.Text = "Trucks [ " + TotalVhc + " | " + (SpareVhcSpaces + TotalVhc).ToString() + " ]"; if (TotalVhc == (SpareVhcSpaces + TotalVhc)) { labelSortingTrucks.ForeColor = Color.Red; } else { labelSortingDrivers.ForeColor = DefaultForeColor; } //Drivers and Trucks to sort foreach (string tempD in MainForm.extraDrivers) { if (tempD != null) { treeViewSortingDrivers.Nodes.Add(tempD, tempD); } } foreach (string tempV in MainForm.extraVehicles) { if (tempV != null) { //treeViewSortingTrucks.Nodes.Add(tempV); string TruckName = ""; try { string templine = MainForm.UserTruckDictionary[tempV].Parts.Find(x => x.PartType == "truckbrandname").PartData.Find(xline => xline.StartsWith(" data_path:")); TruckName = templine.Split(new char[] { '"' })[1].Split(new char[] { '/' })[4]; } catch { } MainForm.TruckBrandsLngDict.TryGetValue(TruckName, out string trucknamevalue); if (trucknamevalue != null && trucknamevalue != "") { TruckName = trucknamevalue; } treeViewSortingTrucks.Nodes.Add(tempV, TruckName); } } //Labels labelSortingDrivers.Text = "Drivers " + MainForm.extraDrivers.Count(x => x != null).ToString(); if (SpareDrvSpaces < MainForm.extraDrivers.Count) { labelSortingDrivers.ForeColor = Color.Red; } else { labelSortingDrivers.ForeColor = DefaultForeColor; } labelSortingTrucks.Text = "Trucks " + MainForm.extraVehicles.Count(x => x != null).ToString(); if (SpareVhcSpaces < MainForm.extraVehicles.Count) { labelSortingTrucks.ForeColor = Color.Red; } else { labelSortingDrivers.ForeColor = DefaultForeColor; } }