private void buttonMoveDriversOut_Click(object sender, EventArgs e)
        {
            // Get the checked nodes.
            List <TreeNode> checked_nodes = CheckedNodes(treeViewSavedDrivers, false);

            if (checked_nodes.Count() != 0)
            {
                foreach (TreeNode tempD in checked_nodes)
                {
                    if (tempD != null)
                    {
                        Garages tempG    = MainForm.GaragesList[MainForm.GaragesList.FindIndex(x => x.GarageName == tempD.Parent.Name)];
                        string  driverNL = tempD.Name;

                        if (driverNL != MainForm.PlayerProfileData.UserDriver)
                        {
                            tempG.Drivers[tempG.Drivers.FindIndex(x => x == driverNL)] = null;
                            MainForm.extraDrivers.Add(driverNL);
                            MainForm.extraVehicles.Add(null);
                        }

                        checked_nodes.RemoveAt(0);
                        if (checked_nodes.Count() == 0)
                        {
                            goto NoMoreDrivers;
                        }
                    }
                }
NoMoreDrivers:
                FillTreeView();
            }
        }
        private void buttonMoveTrucksOut_Click(object sender, EventArgs e)
        {
            // Get the checked nodes.
            List <TreeNode> checked_nodes = CheckedNodes(treeViewSavedTrucks);

            if (checked_nodes.Count() != 0)
            {
                foreach (TreeNode tempT in checked_nodes)
                {
                    if (tempT != null)
                    {
                        Garages tempG   = MainForm.GaragesList[MainForm.GaragesList.FindIndex(x => x.GarageName == tempT.Parent.Name)];
                        string  truckNL = tempT.Name;

                        tempG.Vehicles[tempG.Vehicles.FindIndex(x => x == truckNL)] = null;
                        MainForm.extraVehicles.Add(truckNL);
                        MainForm.extraDrivers.Add(null);

                        checked_nodes.RemoveAt(0);
                        if (checked_nodes.Count() == 0)
                        {
                            goto NoMoreTrucks;
                        }
                    }
                }
NoMoreTrucks:
                FillTreeView();
            }
        }
        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();
        }
        private void FillUserCompanyTrucksList()
        {
            DataTable  combDT = new DataTable();
            DataColumn dc     = new DataColumn("UserTruckNameless", typeof(string));

            combDT.Columns.Add(dc);

            //dc = new DataColumn("UserTruckName", typeof(string));
            //combDT.Columns.Add(dc);
            //

            dc = new DataColumn("TruckType", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("TruckName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("GarageName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("DriverName", typeof(string));
            combDT.Columns.Add(dc);

            DataColumn dcDisplay = new DataColumn("DisplayMember");

            dcDisplay.Expression = string.Format("IIF(UserTruckNameless <> '', '[' + {0} +'] ' + IIF(GarageName <> '', {1} +' || ','') + {2} + IIF(DriverName <> 'null', ' || In use - ' + {3},'')," +
                                                 "'-- NONE --')",
                                                 "TruckType", "GarageName", "TruckName", "DriverName");
            combDT.Columns.Add(dcDisplay);
            //

            foreach (KeyValuePair <string, UserCompanyTruckData> UserTruck in UserTruckDictionary)
            {
                string truckname = "";

                try
                {
                    string templine = UserTruck.Value.Parts.Find(x => x.PartType == "truckbrandname").PartData.Find(xline => xline.StartsWith(" data_path:"));
                    truckname = templine.Split(new char[] { '"' })[1].Split(new char[] { '/' })[4];
                }
                catch { }

                TruckBrandsLngDict.TryGetValue(truckname, out string trucknamevalue);
                //
                string tmpTruckType = "", tmpTruckName = "", tmpGarageName = "", tmpDriverName = "";

                if (UserTruckDictionary[UserTruck.Key].Users)
                {
                    tmpTruckType = "U";

                    tmpGarageName = GaragesList.Find(x => x.Vehicles.Contains(UserTruck.Key)).GarageNameTranslated;
                }
                else
                {
                    tmpTruckType = "Q";
                }
                //
                if (trucknamevalue != null && trucknamevalue != "")
                {
                    tmpTruckName = trucknamevalue;
                }
                else
                {
                    tmpTruckName = truckname;
                }

                Garages tmpGrg = GaragesList.Where(tX => tX.Vehicles.Contains(UserTruck.Key))?.SingleOrDefault() ?? null;

                if (tmpGrg != null)
                {
                    tmpDriverName = tmpGrg.Drivers[tmpGrg.Vehicles.IndexOf(UserTruck.Key)];
                }
                else
                {
                    tmpDriverName = UserDriverDictionary.Where(tX => tX.Value.AssignedTruck == UserTruck.Key)?.SingleOrDefault().Key ?? "null";
                }

                if (tmpDriverName != null && tmpDriverName != "null")
                {
                    if (PlayerDataData.UserDriver == tmpDriverName)
                    {
                        tmpDriverName = "> " + Utilities.TextUtilities.FromHexToString(Globals.SelectedProfile);
                    }
                    else
                    {
                        DriverNames.TryGetValue(tmpDriverName, out string _resultvalue);

                        if (_resultvalue != null && _resultvalue != "")
                        {
                            tmpDriverName = _resultvalue.TrimStart(new char[] { '+' });
                        }
                    }
                }

                combDT.Rows.Add(UserTruck.Key, tmpTruckType, tmpTruckName, tmpGarageName, tmpDriverName);
            }

            bool noTrucks = false;

            if (combDT.Rows.Count == 0)
            {
                combDT.Rows.Add("null");//, "-- NONE --"); //none
                noTrucks = true;
            }

            comboBoxUserTruckCompanyTrucks.ValueMember   = "UserTruckNameless";
            comboBoxUserTruckCompanyTrucks.DisplayMember = "DisplayMember";
            comboBoxUserTruckCompanyTrucks.DataSource    = combDT;

            if (!noTrucks)
            {
                //combDT.DefaultView.Sort = "UserTruckName ASC";
                comboBoxUserTruckCompanyTrucks.Enabled       = true;
                comboBoxUserTruckCompanyTrucks.SelectedValue = PlayerDataData.UserCompanyAssignedTruck;
            }
            else
            {
                comboBoxUserTruckCompanyTrucks.Enabled       = false;
                comboBoxUserTruckCompanyTrucks.SelectedValue = "null";
            }
        }