Beispiel #1
0
        private void AddTranslationToData()
        {
            string ntFormat = " -nt";

            //Countries

            /*
             * foreach (string tempitem in CountriesList)
             * {
             *  CountriesLngDict.TryGetValue(tempitem, out string value);
             *
             *  if (value != null && value != "")
             *  {
             *      tempitem.CountryNameTranslated = value;
             *  }
             *  else
             *  {
             *      string CapName = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(tempitem);
             *      tempitem.CountryNameTranslated = CapName;
             *  }
             * }
             */
            //Cities
            foreach (City _city in from x in CitiesList where !x.Disabled select x)
            {
                CitiesLngDict.TryGetValue(_city.CityName, out string _translated);

                if (_translated != null && _translated != "")
                {
                    _city.CityNameTranslated = _translated;
                }
                else
                {
                    _city.CityNameTranslated = _city.CityName + ntFormat;
                }
            }

            CitiesList = CitiesList.OrderBy(x => x.CityNameTranslated).ToList();

            //Garages
            foreach (Garages _garage in GaragesList)
            {
                CitiesLngDict.TryGetValue(_garage.GarageName, out string _translated);

                if (_translated != null && _translated != "")
                {
                    _garage.GarageNameTranslated = _translated;
                }
                else
                {
                    _garage.GarageNameTranslated = _garage.GarageName + ntFormat;
                }
            }

            GaragesList = GaragesList.OrderBy(x => x.GarageNameTranslated).ToList();

            //Companies
        }
Beispiel #2
0
        //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();
        }