Exemple #1
0
 /// <summary>
 /// Show add user dialog
 /// </summary>
 public static void ShowAddUserDialog(string defaultName = "")
 {
     if (MainForm.API != null)
     {
         TextEditForm tef = new TextEditForm(defaultName, Translator.GetTranslation("ADD_USER"), Translator.GetTranslation("USERNAME_HINT"));
         if (tef.ShowDialog() == DialogResult.OK)
         {
             string         value       = tef.Value;
             UserConfigData user_config = Configuration.GetUserConfigData(MainForm.API.Username);
             string[]       users       = user_config.Following;
             bool           success     = true;
             if (value.ToLower() == MainForm.API.Username.ToLower())
             {
                 MessageBox.Show(Translator.GetTranslation("YOU_CAN_NOT_ADD_YOURSELF_MESSAGE"), Translator.GetTranslation("YOU_CAN_NOT_ADD_YOURSELF"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                 success = false;
             }
             foreach (string user in users)
             {
                 if (user.ToLower() == value.ToLower())
                 {
                     MessageBox.Show(Translator.GetTranslation("USERNAME_ALREADY_EXISTS_MESSAGE"), Translator.GetTranslation("USERNAME_ALREADY_EXISTS"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                     success = false;
                     break;
                 }
             }
             if (success)
             {
                 string[] found_users = Truckers2ConnectAPI.FindUsers(value);
                 success = false;
                 foreach (string found_user in found_users)
                 {
                     if (found_user.ToLower() == value.ToLower())
                     {
                         success = true;
                         break;
                     }
                 }
                 if (success)
                 {
                     List <string> u = new List <string>(users);
                     u.Add(value);
                     user_config.Following = u.ToArray();
                     u.Clear();
                     Configuration.Save();
                 }
                 else
                 {
                     MessageBox.Show(string.Format(Translator.GetTranslation("USER_NOT_FOUND_MESSAGE"), value), Translator.GetTranslation("USER_NOT_FOUND"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Find users
 /// </summary>
 private void FindUsers()
 {
     string[] found_users = Truckers2ConnectAPI.FindUsers(filterTextField.Text.Trim());
     foundUsersDataTable.Rows.Clear();
     foreach (string found_user in found_users)
     {
         DataRow row = foundUsersDataTable.NewRow();
         object[] data = new object[1];
         data[0] = found_user;
         row.ItemArray = data;
         foundUsersDataTable.Rows.Add(row);
     }
 }
Exemple #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public MainForm()
        {
            instance = this;
            InitializeComponent();
            Translator.TranslatorInterface = new TranslatorInterface();
            Translator.LoadTranslation(this);
            startGameNowTranslated          = Translator.GetTranslation("START_GAME_NOW");
            cruiseControlTranslated         = Translator.GetTranslation("CRUISE_CONTROL");
            speedLimitTranslated            = Translator.GetTranslation("SPEED_LIMIT");
            vehicleTranslated               = Translator.GetTranslation("VEHICLE");
            inTranslated                    = Translator.GetTranslation("IN");
            statusTranslated                = Translator.GetTranslation("STATUS");
            deliverCargoTranslated          = Translator.GetTranslation("DELIVER_CARGO");
            cargoTranslated                 = Translator.GetTranslation("CARGO");
            sourceTranslated                = Translator.GetTranslation("SOURCE");
            destinationTranslated           = Translator.GetTranslation("DESTINATION");
            routeTranslated                 = Translator.GetTranslation("ROUTE");
            remainingTimeTranslated         = Translator.GetTranslation("REMAINING_TIME");
            ofTranslated                    = Translator.GetTranslation("OF");
            yieldTranslated                 = Translator.GetTranslation("YIELD");
            weightTranslated                = Translator.GetTranslation("WEIGHT");
            deadlineTranslated              = Translator.GetTranslation("DEADLINE");
            deadlineAvailableTranslated     = Translator.GetTranslation("DEADLINE_AVAILABLE");
            idleTranslated                  = Translator.GetTranslation("IDLE");
            unlimitedTranslated             = Translator.GetTranslation("UNLIMITED");
            totalRouteTranslated            = Translator.GetTranslation("TOTAL_ROUTE");
            totalWeightTranslated           = Translator.GetTranslation("TOTAL_WEIGHT");
            totalYieldTranslated            = Translator.GetTranslation("TOTAL_YIELD");
            cabinTranslated                 = Translator.GetTranslation("CABIN");
            chassisTranslated               = Translator.GetTranslation("CHASSIS");
            engineTranslated                = Translator.GetTranslation("ENGINE");
            transmissionTranslated          = Translator.GetTranslation("TRANSMISSION");
            wheelsTranslated                = Translator.GetTranslation("WHEELS");
            trailerTranslated               = Translator.GetTranslation("TRAILER");
            averageTranslated               = Translator.GetTranslation("AVERAGE");
            fuelTranslated                  = Translator.GetTranslation("FUEL");
            fuelRemainingDistanceTranslated = Translator.GetTranslation("FUEL_REMAINING_DISTANCE");
            fuelStatusTranslated            = Translator.GetTranslation("FUEL_STATUS");
            pleaseRefillFuelTranslated      = Translator.GetTranslation("PLEASE_REFILL_FUEL");
            lowFuelTranslated               = Translator.GetTranslation("LOW_FUEL");
            enoughFuelTranslated            = Translator.GetTranslation("ENOUGH_FUEL");
            refillLaterTranslated           = Translator.GetTranslation("REFILL_LATER");

            MaterialSkinManager material_skin_manager = MaterialSkinManager.Instance;

            material_skin_manager.AddFormToManage(this);
            material_skin_manager.Theme       = MaterialSkinManager.Themes.DARK;
            material_skin_manager.ColorScheme = new ColorScheme(Primary.Blue700, Primary.Blue800, Primary.Blue500, Accent.LightBlue200, TextShade.WHITE);

            PluginManager.InstallPlugins();

            telemetry       = new Ets2SdkTelemetry();
            telemetry.Data += Telemetry_Data;

            speedChart.Legends[0].Title = Translator.GetTranslation(Configuration.UseMetricUnit ? "SPEED_IN_KMH" : "SPEED_IN_MPH");
            speedChart.Series[0].Name   = Translator.GetTranslation("CURRENT");
            speedChart.Series[1].Name   = Translator.GetTranslation("LIMIT");

            drivetrainImages = new Image[]
            {
                Resources.Drivetrain,
                Resources.DrivetrainSlightlyDamaged,
                Resources.DrivetrainDamaged,
                Resources.DrivetrainHeavilyDamaged,
                Resources.DrivetrainFullyDamaged
            };
            cargoImages = new Image[]
            {
                Resources.NoCargo,
                Resources.Cargo,
                Resources.CargoSlightlyDamaged,
                Resources.CargoDamaged,
                Resources.CargoHeavilyDamaged,
                Resources.CargoFullyDamaged
            };
            thread = new Thread(() =>
            {
                while (isThreadRunning)
                {
                    users = Truckers2ConnectAPI.GetUsers();
                    GroupForm.UpdateUsers();
                    Thread.Sleep(500);
                }
            });
            thread.Start();
        }