Exemple #1
0
        //Help methods for searching controls
        internal void HelpTranslateFormMethod(Control parent, ToolTip _formTooltip, CultureInfo _ci)
        {
            char[] charsToTrim = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
            foreach (Control cntrl in parent.Controls)
            {
                try
                {
                    string translatedString = ResourceManagerMain.GetString(cntrl.Name.TrimEnd(charsToTrim), _ci);
                    if (translatedString != null)
                    {
                        cntrl.Text = translatedString;
                    }

                    if (_formTooltip != null)
                    {
                        string TolltipString = ResourceManagerMain.GetString("tooltip" + cntrl.Name.TrimEnd(charsToTrim), _ci);
                        if (TolltipString != null)
                        {
                            TolltipString = TolltipString.Replace("\\r\\n", Environment.NewLine);
                            _formTooltip.SetToolTip(cntrl, TolltipString);
                        }
                    }
                }
                catch
                { }

                HelpTranslateFormMethod(cntrl, _formTooltip, _ci);
            }
        }
Exemple #2
0
        private void ChangeLanguage()
        {
            try
            {
                if (ProgSettingsV.Language != "Default")
                {
                    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ProgSettingsV.Language);//CultureInfo.GetCultureInfo("en-US");
                }
            }
            catch
            {
                LogWriter("Wrong language setting format");
            }

            CultureInfo ci = Thread.CurrentThread.CurrentUICulture;

            try
            {
                this.SuspendLayout();

                HelpTranslateFormMethod(this, toolTipMain, ci);
                HelpTranslateMenuStripMethod(menuStripMain, ResourceManagerMain, ci);

                this.ResumeLayout();

                for (int i = 0; i < 6; i++)
                {
                    string translatedString = ResourceManagerMain.GetString("labelProfileSkillName" + i.ToString(), ci);

                    foreach (Control c in groupBoxProfileSkill.Controls)
                    {
                        if (c.Name == "profileSkillsPanel" + i.ToString())
                        {
                            toolTipMain.SetToolTip(c, translatedString);
                        }
                    }
                }

                LngFileLoader("countries_translate.txt", CountriesLngDict, ProgSettingsV.Language);
                LngFileLoader("cities_translate.txt", CitiesLngDict, ProgSettingsV.Language);
                LngFileLoader("companies_translate.txt", CompaniesLngDict, ProgSettingsV.Language);
                LngFileLoader("cargo_translate.txt", CargoLngDict, ProgSettingsV.Language);
                LngFileLoader("urgency_translate.txt", UrgencyLngDict, ProgSettingsV.Language);
                //LngFileLoader("custom_strings.txt", CustomStringsDict, ProgSettingsV.Language);

                LoadTruckBrandsLng();
                LoadDriverNamesLng();

                AddTranslationToData();
                RefreshComboboxes();
                CorrectControlsPositions();
            }
            catch
            {
            }
            //rm.ReleaseAllResources();
        }
        private void listBoxGarages_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }

            // Get the ListBox and the item.
            ListBox lst = sender as ListBox;
            string  txt = "";
            Garages grg = (Garages)lst.Items[e.Index];

            // Draw the background.
            e.DrawBackground();
            Image grgicon;

            if (grg.GarageName != PlayerDataV.HQcity)
            {
                grgicon = GaragesImg[grg.GarageStatus];
            }
            else
            {
                grgicon = GaragesHQImg[grg.GarageStatus];
            }

            // Draw the picture.
            float      scale       = GaragePictureHeight / grgicon.Height;
            RectangleF source_rect = new RectangleF(0, 0, grgicon.Width, grgicon.Height);

            float picture_width = scale * grgicon.Width;

            RectangleF dest_rect = new RectangleF(e.Bounds.Left + GarageItemMargin, e.Bounds.Top + GarageItemMargin, picture_width, GaragePictureHeight);

            e.Graphics.DrawImage(grgicon, dest_rect, source_rect, GraphicsUnit.Pixel);
            ////

            // See if the item is selected.
            Brush br;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                br = SystemBrushes.HighlightText;
            }
            else
            {
                br = new SolidBrush(e.ForeColor);
            }

            int maxvehdr = 0;

            if (grg.GarageStatus == 0)
            {
                goto skipVehAndDrDraw;//"Not owned";
            }
            else if (grg.GarageStatus == 2)
            {
                maxvehdr = 3;
            }
            else if (grg.GarageStatus == 3)
            {
                maxvehdr = 5;
            }
            else if (grg.GarageStatus == 6)
            {
                maxvehdr = 1;
            }

            //Vehicles & Drivers

            int curVeh = 0, curDr = 0;

            foreach (string temp in grg.Vehicles)
            {
                if (temp != null)
                {
                    curVeh++;
                }
            }
            foreach (string temp in grg.Drivers)
            {
                if (temp != null)
                {
                    curDr++;
                }
            }

            string Vs = "", Ds = "", Ts = "";

            Vs = ResourceManagerMain.GetString("VehicleShort", Thread.CurrentThread.CurrentUICulture);
            Ds = ResourceManagerMain.GetString("DriverShort", Thread.CurrentThread.CurrentUICulture);
            Ts = ResourceManagerMain.GetString("TrailerShort", Thread.CurrentThread.CurrentUICulture);

            txt = Vs + ": " + curVeh + " / " + maxvehdr + " " + Ds + ": " + curDr + " / " + maxvehdr + " " + Ts + ": " + grg.Trailers.Count;

            Size size = TextRenderer.MeasureText(txt, this.Font);

            float x      = e.Bounds.Right - size.Width - 3;
            float y      = e.Bounds.Top + 18;
            float width  = e.Bounds.Right - 100;
            float height = e.Bounds.Bottom - 14;

            RectangleF layout_rect = new RectangleF(x, y, size.Width, height);

            // Draw the text.
            e.Graphics.DrawString(txt, this.Font, br, layout_rect);

            skipVehAndDrDraw :;

            //City and Size
            // Find the area in which to put the text.
            x           = e.Bounds.Left + picture_width + 3 * GarageItemMargin;
            y           = e.Bounds.Top + GarageItemMargin * 2;
            width       = e.Bounds.Right - GarageItemMargin - x;
            height      = e.Bounds.Bottom - GarageItemMargin - y;
            layout_rect = new RectangleF(x, y, width, height);

            //txt = lst.Items[e.Index].ToString();
            txt = grg.GarageNameTranslated + "\n" + grg.GetStatusString();
            // Draw the text.
            e.Graphics.DrawString(txt, this.Font, br, layout_rect);

            // Draw the focus rectangle if appropriate.
            e.DrawFocusRectangle();
        }