private void UpdateTrailerPanelLicensePlate() { UserTrailerDictionary.TryGetValue(comboBoxUserTrailerCompanyTrailers.SelectedValue.ToString(), out UserCompanyTruckData SelectedUserCompanyTrailer); string LicensePlate = SelectedUserCompanyTrailer.Parts.Find(xp => xp.PartType == "trailerdata").PartData.Find(xl => xl.StartsWith(" license_plate:")).Split(new char[] { '"' })[1]; SCS.SCSLicensePlate thisLP = new SCS.SCSLicensePlate(LicensePlate, SCS.SCSLicensePlate.LPtype.Truck); //Find label control Label lpText = groupBoxUserTrailerTrailerDetails.Controls.Find("labelLicensePlateTrailer", true).FirstOrDefault() as Label; if (lpText != null) { lpText.Text = thisLP.LicensePlateTXT + " | "; string value = null; CountriesLngDict.TryGetValue(thisLP.SourceLPCountry, out value); if (value != null && value != "") { lpText.Text += value; } else { string CapName = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(thisLP.SourceLPCountry); lpText.Text += CapName; } } // Panel lpPanel = groupBoxUserTrailerTrailerDetails.Controls.Find("TrailerLicensePlateIMG", true).FirstOrDefault() as Panel; if (lpPanel != null) { lpPanel.BackgroundImage = Utilities.TS_Graphics.ResizeImage(thisLP.LicensePlateIMG, LicensePlateWidth[GameType], 32); //ETS - 128x32 or ATS - 128x64 | 64x32 } }
//Translate CB private void RefreshComboboxes() { int savedindex = 0, j = 0; string savedvalue = "", ntFormat = " -nt"; DataTable temptable = new DataTable(); //Countries ComboBoxes temptable = comboBoxFreightMarketCountries.DataSource as DataTable; if (temptable != null) { savedindex = comboBoxFreightMarketCountries.SelectedIndex; if (savedindex != -1) { savedvalue = comboBoxFreightMarketCountries.SelectedValue.ToString(); } comboBoxFreightMarketCountries.SelectedIndexChanged -= comboBoxCountries_SelectedIndexChanged; //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); CountriesLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { string CapName = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(source); temp[1] = CapName; } } DataTable sortedDT = temptable.DefaultView.Table.Copy(); DataView dv = sortedDT.DefaultView; dv.Sort = "CountryName ASC"; sortedDT = dv.ToTable(); sortedDT.DefaultView.Sort = ""; //Shift All DataRow sourceRow = sortedDT.Select("Country = '+all'")[0]; int rowi = sortedDT.Rows.IndexOf(sourceRow); DataRow row = sortedDT.NewRow(); row.ItemArray = sourceRow.ItemArray; sortedDT.Rows.RemoveAt(rowi); sortedDT.Rows.InsertAt(row, 0); //Shift Unsorted try { sourceRow = sortedDT.Select("Country = '+unsorted'")[0]; rowi = sortedDT.Rows.IndexOf(sourceRow); row = sortedDT.NewRow(); row.ItemArray = sourceRow.ItemArray; sortedDT.Rows.RemoveAt(rowi); sortedDT.Rows.InsertAt(row, 1); } catch { } comboBoxFreightMarketCountries.DataSource = sortedDT; if (savedindex != -1) { comboBoxFreightMarketCountries.SelectedValue = savedvalue; } else { comboBoxFreightMarketCountries.SelectedValue = "+all"; } comboBoxFreightMarketCountries.SelectedIndexChanged += comboBoxCountries_SelectedIndexChanged; } //Companies temptable = comboBoxFreightMarketCompanies.DataSource as DataTable; if (temptable != null) { savedindex = comboBoxFreightMarketCompanies.SelectedIndex; if (savedindex != -1) { savedvalue = comboBoxFreightMarketCompanies.SelectedValue.ToString(); } comboBoxFreightMarketCompanies.SelectedIndexChanged -= comboBoxCompanies_SelectedIndexChanged; //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); CompaniesLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { temp[1] = source + ntFormat; } } DataTable sortedDT = temptable.DefaultView.Table.Copy(); DataView dv = sortedDT.DefaultView; dv.Sort = "CompanyName ASC"; sortedDT = dv.ToTable(); sortedDT.DefaultView.Sort = ""; DataRow sourceRow = sortedDT.Select("Company = '+all'")[0]; int rowi = sortedDT.Rows.IndexOf(sourceRow); DataRow row = sortedDT.NewRow(); row.ItemArray = sourceRow.ItemArray; sortedDT.Rows.RemoveAt(rowi); sortedDT.Rows.InsertAt(row, 0); comboBoxFreightMarketCompanies.DataSource = sortedDT; if (savedindex != -1) { comboBoxFreightMarketCompanies.SelectedValue = savedvalue; } else { comboBoxFreightMarketCompanies.SelectedValue = "+all"; } comboBoxFreightMarketCompanies.SelectedIndexChanged += comboBoxCompanies_SelectedIndexChanged; } ////// //Cities ComboBoxes ComboBox[] CitiesCB = { comboBoxFreightMarketSourceCity, comboBoxFreightMarketDestinationCity, comboBoxUserCompanyHQcity, comboBoxCargoMarketSourceCity }; EventHandler[] CitiesCBeh = { comboBoxSourceCity_SelectedIndexChanged, comboBoxDestinationCity_SelectedIndexChanged, comboBoxUserCompanyHQcity_SelectedIndexChanged, comboBoxSourceCityCM_SelectedIndexChanged }; j = 0; foreach (ComboBox tempCB in CitiesCB) { temptable = tempCB.DataSource as DataTable; if (temptable != null) { savedindex = tempCB.SelectedIndex; if (savedindex != -1) { savedvalue = tempCB.SelectedValue.ToString(); } tempCB.SelectedIndexChanged -= CitiesCBeh[j]; //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); CitiesLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { temp[1] = source + ntFormat; } } if (savedindex != -1) { tempCB.SelectedValue = savedvalue; } tempCB.SelectedIndexChanged += CitiesCBeh[j]; j++; } } ////// //Companies ComboBoxes ComboBox[] CompaniesCB = { comboBoxFreightMarketSourceCompany, comboBoxFreightMarketDestinationCompany, comboBoxSourceCargoMarketCompany }; EventHandler[] CompaniesCBeh = { comboBoxSourceCompany_SelectedIndexChanged, comboBoxDestinationCompany_SelectedIndexChanged, comboBoxSourceCompanyCM_SelectedIndexChanged }; j = 0; foreach (ComboBox tempCB in CompaniesCB) { temptable = tempCB.DataSource as DataTable; if (temptable != null) { savedindex = tempCB.SelectedIndex; if (savedindex != -1) { savedvalue = tempCB.SelectedValue.ToString(); } tempCB.SelectedIndexChanged -= CompaniesCBeh[j]; //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); CompaniesLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { temp[1] = source + ntFormat; } } if (savedindex != -1) { tempCB.SelectedValue = savedvalue; } tempCB.SelectedIndexChanged += CompaniesCBeh[j]; j++; } } //Freight Market //Cargo temptable = comboBoxFreightMarketCargoList.DataSource as DataTable; if (temptable != null) { savedindex = comboBoxFreightMarketCargoList.SelectedIndex; if (savedindex != -1) { savedvalue = comboBoxFreightMarketCargoList.SelectedValue.ToString(); } comboBoxFreightMarketCargoList.SelectedIndexChanged -= comboBoxCargoList_SelectedIndexChanged; //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); CargoLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { temp[1] = source + ntFormat; } } if (savedindex != -1) { comboBoxFreightMarketCargoList.SelectedValue = savedvalue; } comboBoxFreightMarketCargoList.SelectedIndexChanged += comboBoxCargoList_SelectedIndexChanged; } //Urgency temptable = comboBoxFreightMarketUrgency.DataSource as DataTable; if (temptable != null) { //i = 0; foreach (DataRow temp in temptable.Rows) { string source = temp[0].ToString(); UrgencyLngDict.TryGetValue(source, out string value); if (value != null && value != "") { temp[1] = value; } else { temp[1] = source + ntFormat; } } } ////// //ListBoxes FillVisitedCities(listBoxVisitedCities.TopIndex); FillGaragesList(listBoxGarages.TopIndex); listBoxFreightMarketAddedJobs.Refresh(); }