コード例 #1
0
 public void setGameDefinition(GameDefinition gameDefinition)
 {
     spotter = null;
     mapped  = false;
     if (gameDefinition == null)
     {
         Console.WriteLine("No game definition selected");
     }
     else
     {
         Console.WriteLine("Using game definition " + gameDefinition.friendlyName);
         UserSettings.GetUserSettings().setProperty("last_game_definition", gameDefinition.gameEnum.ToString());
         UserSettings.GetUserSettings().saveUserSettings();
         CrewChief.gameDefinition = gameDefinition;
         //I think we shuld add it here
         if (gameDefinition.gameEnum == GameEnum.ASSETTO_32BIT ||
             gameDefinition.gameEnum == GameEnum.ASSETTO_64BIT ||
             gameDefinition.gameEnum == GameEnum.RF1 ||
             gameDefinition.gameEnum == GameEnum.RF2_64BIT)
         {
             PluginInstaller pluginInstaller = new PluginInstaller();
             pluginInstaller.InstallOrUpdatePlugins(gameDefinition);
         }
     }
 }
コード例 #2
0
 private static Preferences getOverridablePreferencesDefaults()
 {
     var overridableOptions = new Preferences() { spotterVehicleLength = 4.5f, spotterVehicleWidth = 1.8f, enableStockCarsMode = false };
     var settings = UserSettings.GetUserSettings();
     // Global overridable options:
     overridableOptions.enableStockCarsMode = settings.getBoolean("enable_stockcars_mode");
     // Per-game overridable options:
     switch (CrewChief.gameDefinition.gameEnum)
     {
         case GameEnum.PCARS_64BIT:
         case GameEnum.PCARS_32BIT:
         case GameEnum.PCARS_NETWORK:
             overridableOptions.spotterVehicleLength = settings.getFloat("pcars_spotter_car_length");
             break;
         case GameEnum.RF1:
             overridableOptions.spotterVehicleLength = settings.getFloat("rf1_spotter_car_length");
             break;
         case GameEnum.ASSETTO_64BIT:
         case GameEnum.ASSETTO_32BIT:
             overridableOptions.spotterVehicleLength = settings.getFloat("acs_spotter_car_length");
             break;
         case GameEnum.RF2_64BIT:
             overridableOptions.spotterVehicleLength = settings.getFloat("rf2_spotter_car_length");
             break;
         case GameEnum.RACE_ROOM:
             overridableOptions.spotterVehicleLength = settings.getFloat("r3e_spotter_car_length");
             break;
         default:
             Debug.Assert(false, "Please fix this.");
             overridableOptions.spotterVehicleLength = 4.5f;
             break;
     }
     return overridableOptions;
 }
コード例 #3
0
 public void save()
 {
     foreach (var control in this.flowLayoutPanel1.Controls)
     {
         if (control.GetType() == typeof(StringPropertyControl))
         {
             StringPropertyControl stringControl = (StringPropertyControl)control;
             UserSettings.GetUserSettings().setProperty(stringControl.propertyId,
                                                        stringControl.getValue());
         }
         else if (control.GetType() == typeof(IntPropertyControl))
         {
             IntPropertyControl intControl = (IntPropertyControl)control;
             UserSettings.GetUserSettings().setProperty(intControl.propertyId,
                                                        intControl.getValue());
         }
         if (control.GetType() == typeof(FloatPropertyControl))
         {
             FloatPropertyControl floatControl = (FloatPropertyControl)control;
             UserSettings.GetUserSettings().setProperty(floatControl.propertyId,
                                                        floatControl.getValue());
         }
         if (control.GetType() == typeof(BooleanPropertyControl))
         {
             BooleanPropertyControl boolControl = (BooleanPropertyControl)control;
             UserSettings.GetUserSettings().setProperty(boolControl.propertyId,
                                                        boolControl.getValue());
         }
     }
     UserSettings.GetUserSettings().saveUserSettings();
     PropertiesForm.hasChanges = false;
 }
コード例 #4
0
        public void saveSettings()
        {
            foreach (ButtonAssignment buttonAssignment in buttonAssignments)
            {
                String actionId = "";
                if (buttonAssignment.action == CHANNEL_OPEN_FUNCTION)
                {
                    actionId = "CHANNEL_OPEN_FUNCTION";
                }
                else if (buttonAssignment.action == TOGGLE_RACE_UPDATES_FUNCTION)
                {
                    actionId = "TOGGLE_RACE_UPDATES_FUNCTION";
                }
                else if (buttonAssignment.action == TOGGLE_SPOTTER_FUNCTION)
                {
                    actionId = "TOGGLE_SPOTTER_FUNCTION";
                }
                else if (buttonAssignment.action == TOGGLE_READ_OPPONENT_DELTAS)
                {
                    actionId = "TOGGLE_READ_OPPONENT_DELTAS";
                }
                else if (buttonAssignment.action == REPEAT_LAST_MESSAGE_BUTTON)
                {
                    actionId = "REPEAT_LAST_MESSAGE_BUTTON";
                }
                else if (buttonAssignment.action == VOLUME_UP)
                {
                    actionId = "VOLUME_UP";
                }
                else if (buttonAssignment.action == VOLUME_DOWN)
                {
                    actionId = "VOLUME_DOWN";
                }
                else if (buttonAssignment.action == PRINT_TRACK_DATA)
                {
                    actionId = "PRINT_TRACK_DATA";
                }
                else if (buttonAssignment.action == TOGGLE_YELLOW_FLAG_MESSAGES)
                {
                    actionId = "TOGGLE_YELLOW_FLAG_MESSAGES";
                }

                if (buttonAssignment.controller != null && (buttonAssignment.joystick != null || buttonAssignment.controller.guid == UDP_NETWORK_CONTROLLER_GUID) && buttonAssignment.buttonIndex != -1)
                {
                    UserSettings.GetUserSettings().setProperty(actionId + "_button_index", buttonAssignment.buttonIndex);
                    UserSettings.GetUserSettings().setProperty(actionId + "_device_guid", buttonAssignment.controller.guid.ToString());
                }
                else
                {
                    UserSettings.GetUserSettings().setProperty(actionId + "_button_index", -1);
                    UserSettings.GetUserSettings().setProperty(actionId + "_device_guid", "");
                }
            }
            UserSettings.GetUserSettings().saveUserSettings();
        }
コード例 #5
0
 public void setGameDefinition(GameDefinition gameDefinition)
 {
     spotter = null;
     mapped  = false;
     if (gameDefinition == null)
     {
         Console.WriteLine("No game definition selected");
     }
     else
     {
         Console.WriteLine("Using game definition " + gameDefinition.friendlyName);
         UserSettings.GetUserSettings().setProperty("last_game_definition", gameDefinition.gameEnum.ToString());
         UserSettings.GetUserSettings().saveUserSettings();
         CrewChief.gameDefinition = gameDefinition;
     }
 }
コード例 #6
0
        public void loadSettings(System.Windows.Forms.Form parent)
        {
            int    channelOpenButtonIndex      = UserSettings.GetUserSettings().getInt("CHANNEL_OPEN_FUNCTION_button_index");
            String channelOpenButtonDeviceGuid = UserSettings.GetUserSettings().getString("CHANNEL_OPEN_FUNCTION_device_guid");

            if (channelOpenButtonIndex != -1 && channelOpenButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, CHANNEL_OPEN_FUNCTION, channelOpenButtonIndex, channelOpenButtonDeviceGuid);
            }

            int    toggleRaceUpdatesButtonIndex      = UserSettings.GetUserSettings().getInt("TOGGLE_RACE_UPDATES_FUNCTION_button_index");
            String toggleRaceUpdatesButtonDeviceGuid = UserSettings.GetUserSettings().getString("TOGGLE_RACE_UPDATES_FUNCTION_device_guid");

            if (toggleRaceUpdatesButtonIndex != -1 && toggleRaceUpdatesButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_RACE_UPDATES_FUNCTION, toggleRaceUpdatesButtonIndex, toggleRaceUpdatesButtonDeviceGuid);
            }

            int    toggleSpotterFunctionButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_SPOTTER_FUNCTION_button_index");
            String toggleSpotterFunctionDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_SPOTTER_FUNCTION_device_guid");

            if (toggleSpotterFunctionButtonIndex != -1 && toggleSpotterFunctionDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_SPOTTER_FUNCTION, toggleSpotterFunctionButtonIndex, toggleSpotterFunctionDeviceGuid);
            }

            int    toggleReadOpponentDeltasButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_READ_OPPONENT_DELTAS_button_index");
            String toggleReadOpponentDeltasDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_READ_OPPONENT_DELTAS_device_guid");

            if (toggleReadOpponentDeltasButtonIndex != -1 && toggleReadOpponentDeltasDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_READ_OPPONENT_DELTAS, toggleReadOpponentDeltasButtonIndex, toggleReadOpponentDeltasDeviceGuid);
            }

            int    repeatLastMessageButtonIndex = UserSettings.GetUserSettings().getInt("REPEAT_LAST_MESSAGE_BUTTON_button_index");
            String repeatLastMessageDeviceGuid  = UserSettings.GetUserSettings().getString("REPEAT_LAST_MESSAGE_BUTTON_device_guid");

            if (repeatLastMessageButtonIndex != -1 && repeatLastMessageDeviceGuid.Length > 0)
            {
                loadAssignment(parent, REPEAT_LAST_MESSAGE_BUTTON, repeatLastMessageButtonIndex, repeatLastMessageDeviceGuid);
            }
        }
コード例 #7
0
        public List <ControllerData> scanControllers()
        {
            List <ControllerData> controllers = new List <ControllerData>();

            foreach (DeviceType deviceType in supportedDeviceTypes)
            {
                foreach (var deviceInstance in directInput.GetDevices(deviceType, DeviceEnumerationFlags.AllDevices))
                {
                    Guid joystickGuid = deviceInstance.InstanceGuid;
                    if (joystickGuid != Guid.Empty)
                    {
                        try
                        {
                            var    joystick    = new Joystick(directInput, joystickGuid);
                            String productName = "";
                            try
                            {
                                productName = ": " + joystick.Properties.ProductName;
                            }
                            catch (Exception)
                            {
                                // ignore - some devices don't have a product name
                            }
                            asyncDispose(deviceType, joystick);
                            controllers.Add(new ControllerData(productName, deviceType, joystickGuid));
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Failed to get device info: " + e.Message);
                        }
                    }
                }
            }
            String propVal = ControllerData.createPropValue(controllers);

            UserSettings.GetUserSettings().setProperty(ControllerData.PROPERTY_CONTAINER, propVal);
            UserSettings.GetUserSettings().saveUserSettings();
            return(controllers);
        }
コード例 #8
0
        public void InstallOrUpdatePlugins(GameDefinition gameDefinition)
        {
            //appInstallPath is also used to check if the user allready was asked to update
            string gameInstallPath = "";

            if (gameDefinition.gameEnum == GameEnum.RF2_64BIT)
            {
                gameInstallPath = UserSettings.GetUserSettings().getString("rf2_install_path");
            }
            else if (gameDefinition.gameEnum == GameEnum.ASSETTO_32BIT || gameDefinition.gameEnum == GameEnum.ASSETTO_64BIT)
            {
                gameInstallPath = UserSettings.GetUserSettings().getString("acs_install_path");
            }
            else if (gameDefinition.gameEnum == GameEnum.RF1)
            {
                //special case here, will figure something clever out so we dont need to have Dan's dll included in every plugin folder.
                if (gameDefinition.gameInstallDirectory.Equals("Automobilista"))
                {
                    gameInstallPath = UserSettings.GetUserSettings().getString("ams_install_path");
                }
                if (gameDefinition.gameInstallDirectory.Equals("rFactor"))
                {
                    gameInstallPath = UserSettings.GetUserSettings().getString("rf1_install_path");
                }
            }
            //try to get the install folder from steam common install folders.
            if (!Directory.Exists(gameInstallPath))
            {
                //Present a messagebox to the user asking if they want to install plugins
                if (presentInstallMessagebox())
                {
                    List <string> steamLibs = getSteamLibraryFolders();
                    foreach (string lib in steamLibs)
                    {
                        string commonPath = Path.Combine(lib, @"steamapps\common\" + gameDefinition.gameInstallDirectory);
                        if (Directory.Exists(commonPath))
                        {
                            gameInstallPath = commonPath;
                            break;
                        }
                    }
                }
            }
            //Not found in steam folders ask the user to locate the directory
            if (!Directory.Exists(gameInstallPath))
            {
                //Present a messagebox to the user asking if they want to install plugins
                if (presentInstallMessagebox())
                {
                    FolderBrowserDialog dialog = new FolderBrowserDialog();
                    dialog.ShowNewFolderButton = false;
                    dialog.Description         = Configuration.getUIString("install_plugin_select_directory_start") + " " +
                                                 gameDefinition.gameInstallDirectory + " " + Configuration.getUIString("install_plugin_select_directory_end");

                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK && dialog.SelectedPath.Length > 0)
                    {
                        //This should now take care of checking against the main .exe instead of the folder name, special case for rFactor 2 as its has the file installed in ..\Bin64
                        if (gameDefinition.gameEnum == GameEnum.RF2_64BIT)
                        {
                            if (File.Exists(Path.Combine(dialog.SelectedPath, @"Bin64", gameDefinition.processName + ".exe")))
                            {
                                gameInstallPath = dialog.SelectedPath;
                            }
                        }
                        else if (File.Exists(Path.Combine(dialog.SelectedPath, gameDefinition.processName + ".exe")))
                        {
                            gameInstallPath = dialog.SelectedPath;
                        }
                        else
                        {
                            //present again if user didn't select the correct folder
                            InstallOrUpdatePlugins(gameDefinition);
                        }
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
            //we have a gameInstallPath so we can go on with installation/updating assuming that the user wants to enable the plugin.
            if (Directory.Exists(gameInstallPath))
            {
                installOrUpdatePlugin(Path.Combine(Configuration.getDefaultFileLocation("plugins"), gameDefinition.gameInstallDirectory), gameInstallPath);
                if (gameDefinition.gameEnum == GameEnum.RF2_64BIT)
                {
                    UserSettings.GetUserSettings().setProperty("rf2_install_path", gameInstallPath);

                    try
                    {
                        string configPath = Path.Combine(gameInstallPath, @"UserData\player\CustomPluginVariables.JSON");
                        if (File.Exists(configPath))
                        {
                            string json = File.ReadAllText(configPath);
                            Dictionary <string, Dictionary <string, int> > plugins = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, int> > >(json);
                            if (plugins.ContainsKey(rf2PluginFileName))
                            {
                                //the whitespace is intended, this is how the game writes it.
                                if (plugins[rf2PluginFileName][" Enabled"] == 0)
                                {
                                    if (presentEnableMessagebox())
                                    {
                                        plugins[rf2PluginFileName][" Enabled"] = 1;
                                        json = JsonConvert.SerializeObject(plugins, Formatting.Indented);
                                        File.WriteAllText(configPath, json);
                                    }
                                }
                            }
                            else
                            {
                                if (presentEnableMessagebox())
                                {
                                    plugins.Add(rf2PluginFileName, new Dictionary <string, int>()
                                    {
                                        { " Enabled", 1 }
                                    });
                                    json = JsonConvert.SerializeObject(plugins, Formatting.Indented);
                                    File.WriteAllText(configPath, json);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Failed to enable plugin" + e.Message);
                    }
                }
                else if (gameDefinition.gameEnum == GameEnum.ASSETTO_32BIT || gameDefinition.gameEnum == GameEnum.ASSETTO_64BIT)
                {
                    UserSettings.GetUserSettings().setProperty("acs_install_path", gameInstallPath);
                    string pythonConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Assetto Corsa\cfg", @"python.ini");
                    if (File.Exists(pythonConfigPath))
                    {
                        string valueActive = ReadValue("CREWCHIEFEX", "ACTIVE", pythonConfigPath, "0");
                        if (!valueActive.Equals("1"))
                        {
                            if (presentEnableMessagebox())
                            {
                                WriteValue("CREWCHIEFEX", "ACTIVE", "1", pythonConfigPath);
                            }
                        }
                    }
                }
                else if (gameDefinition.gameEnum == GameEnum.RF1)
                {
                    if (gameDefinition.gameInstallDirectory.Equals("Automobilista"))
                    {
                        UserSettings.GetUserSettings().setProperty("ams_install_path", gameInstallPath);
                    }
                    if (gameDefinition.gameInstallDirectory.Equals("rFactor"))
                    {
                        UserSettings.GetUserSettings().setProperty("rf1_install_path", gameInstallPath);
                    }
                }
                UserSettings.GetUserSettings().saveUserSettings();
            }
        }
コード例 #9
0
 public List <ControllerData> loadControllers()
 {
     return(ControllerData.parse(UserSettings.GetUserSettings().getString(ControllerData.PROPERTY_CONTAINER)));
 }
コード例 #10
0
        public void loadSettings(System.Windows.Forms.Form parent)
        {
            int    channelOpenButtonIndex      = UserSettings.GetUserSettings().getInt("CHANNEL_OPEN_FUNCTION_button_index");
            String channelOpenButtonDeviceGuid = UserSettings.GetUserSettings().getString("CHANNEL_OPEN_FUNCTION_device_guid");

            if (channelOpenButtonIndex != -1 && channelOpenButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, CHANNEL_OPEN_FUNCTION, channelOpenButtonIndex, channelOpenButtonDeviceGuid);
            }

            int    toggleRaceUpdatesButtonIndex      = UserSettings.GetUserSettings().getInt("TOGGLE_RACE_UPDATES_FUNCTION_button_index");
            String toggleRaceUpdatesButtonDeviceGuid = UserSettings.GetUserSettings().getString("TOGGLE_RACE_UPDATES_FUNCTION_device_guid");

            if (toggleRaceUpdatesButtonIndex != -1 && toggleRaceUpdatesButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_RACE_UPDATES_FUNCTION, toggleRaceUpdatesButtonIndex, toggleRaceUpdatesButtonDeviceGuid);
            }

            int    toggleSpotterFunctionButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_SPOTTER_FUNCTION_button_index");
            String toggleSpotterFunctionDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_SPOTTER_FUNCTION_device_guid");

            if (toggleSpotterFunctionButtonIndex != -1 && toggleSpotterFunctionDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_SPOTTER_FUNCTION, toggleSpotterFunctionButtonIndex, toggleSpotterFunctionDeviceGuid);
            }

            int    toggleReadOpponentDeltasButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_READ_OPPONENT_DELTAS_button_index");
            String toggleReadOpponentDeltasDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_READ_OPPONENT_DELTAS_device_guid");

            if (toggleReadOpponentDeltasButtonIndex != -1 && toggleReadOpponentDeltasDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_READ_OPPONENT_DELTAS, toggleReadOpponentDeltasButtonIndex, toggleReadOpponentDeltasDeviceGuid);
            }

            int    toggleBlockMessagesInHardPartsButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_BLOCK_MESSAGES_IN_HARD_PARTS_button_index");
            String toggleBlockMessagesInHardPartsDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_BLOCK_MESSAGES_IN_HARD_PARTS_device_guid");

            if (toggleBlockMessagesInHardPartsButtonIndex != -1 && toggleBlockMessagesInHardPartsDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_BLOCK_MESSAGES_IN_HARD_PARTS, toggleBlockMessagesInHardPartsButtonIndex, toggleBlockMessagesInHardPartsDeviceGuid);
            }

            int    repeatLastMessageButtonIndex = UserSettings.GetUserSettings().getInt("REPEAT_LAST_MESSAGE_BUTTON_button_index");
            String repeatLastMessageDeviceGuid  = UserSettings.GetUserSettings().getString("REPEAT_LAST_MESSAGE_BUTTON_device_guid");

            if (repeatLastMessageButtonIndex != -1 && repeatLastMessageDeviceGuid.Length > 0)
            {
                loadAssignment(parent, REPEAT_LAST_MESSAGE_BUTTON, repeatLastMessageButtonIndex, repeatLastMessageDeviceGuid);
            }

            int    volumeUpButtonIndex = UserSettings.GetUserSettings().getInt("VOLUME_UP_button_index");
            String volumeUpDeviceGuid  = UserSettings.GetUserSettings().getString("VOLUME_UP_device_guid");

            if (volumeUpButtonIndex != -1 && volumeUpDeviceGuid.Length > 0)
            {
                loadAssignment(parent, VOLUME_UP, volumeUpButtonIndex, volumeUpDeviceGuid);
            }

            int    volumeDownButtonIndex = UserSettings.GetUserSettings().getInt("VOLUME_DOWN_button_index");
            String volumeDownDeviceGuid  = UserSettings.GetUserSettings().getString("VOLUME_DOWN_device_guid");

            if (volumeDownButtonIndex != -1 && volumeDownDeviceGuid.Length > 0)
            {
                loadAssignment(parent, VOLUME_DOWN, volumeDownButtonIndex, volumeDownDeviceGuid);
            }

            int    printTrackDataButtonIndex = UserSettings.GetUserSettings().getInt("PRINT_TRACK_DATA_button_index");
            String printTrackDataDeviceGuid  = UserSettings.GetUserSettings().getString("PRINT_TRACK_DATA_device_guid");

            if (printTrackDataButtonIndex != -1 && printTrackDataDeviceGuid.Length > 0)
            {
                loadAssignment(parent, PRINT_TRACK_DATA, printTrackDataButtonIndex, printTrackDataDeviceGuid);
            }

            int    toggleYellowFlagMessagesButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_YELLOW_FLAG_MESSAGES_button_index");
            String toggleYellowFlagMessagesDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_YELLOW_FLAG_MESSAGES_device_guid");

            if (toggleYellowFlagMessagesButtonIndex != -1 && toggleYellowFlagMessagesDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_YELLOW_FLAG_MESSAGES, toggleYellowFlagMessagesButtonIndex, toggleYellowFlagMessagesDeviceGuid);
            }

            int    getFuelStatusButtonIndex = UserSettings.GetUserSettings().getInt("GET_FUEL_STATUS_button_index");
            String getFuelStatusDeviceGuid  = UserSettings.GetUserSettings().getString("GET_FUEL_STATUS_device_guid");

            if (getFuelStatusButtonIndex != -1 && getFuelStatusDeviceGuid.Length > 0)
            {
                loadAssignment(parent, GET_FUEL_STATUS, getFuelStatusButtonIndex, getFuelStatusDeviceGuid);
            }

            int    toggleManualFormationLapButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_MANUAL_FORMATION_LAP_button_index");
            String toggleManualFormationLapDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_MANUAL_FORMATION_LAP_device_guid");

            if (toggleManualFormationLapButtonIndex != -1 && toggleManualFormationLapDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_MANUAL_FORMATION_LAP, toggleManualFormationLapButtonIndex, toggleManualFormationLapDeviceGuid);
            }

            int    readCornerNamesForLapButtonIndex = UserSettings.GetUserSettings().getInt("READ_CORNER_NAMES_FOR_LAP_button_index");
            String readCornerNamesForLapDeviceGuid  = UserSettings.GetUserSettings().getString("READ_CORNER_NAMES_FOR_LAP_device_guid");

            if (readCornerNamesForLapButtonIndex != -1 && readCornerNamesForLapDeviceGuid.Length > 0)
            {
                loadAssignment(parent, READ_CORNER_NAMES_FOR_LAP, readCornerNamesForLapButtonIndex, readCornerNamesForLapDeviceGuid);
            }

            int    getStatusButtonIndex = UserSettings.GetUserSettings().getInt("GET_STATUS_button_index");
            String getStatusDeviceGuid  = UserSettings.GetUserSettings().getString("GET_STATUS_device_guid");

            if (getStatusButtonIndex != -1 && getStatusDeviceGuid.Length > 0)
            {
                loadAssignment(parent, GET_STATUS, getStatusButtonIndex, getStatusDeviceGuid);
            }

            int    getDamageReportButtonIndex = UserSettings.GetUserSettings().getInt("GET_DAMAGE_REPORT_button_index");
            String getDamageReportDeviceGuid  = UserSettings.GetUserSettings().getString("GET_DAMAGE_REPORT_device_guid");

            if (getDamageReportButtonIndex != -1 && getDamageReportDeviceGuid.Length > 0)
            {
                loadAssignment(parent, GET_DAMAGE_REPORT, getDamageReportButtonIndex, getDamageReportDeviceGuid);
            }

            int    getCarStatusButtonIndex = UserSettings.GetUserSettings().getInt("GET_CAR_STATUS_button_index");
            String getCarStatusDeviceGuid  = UserSettings.GetUserSettings().getString("GET_CAR_STATUS_device_guid");

            if (getCarStatusButtonIndex != -1 && getCarStatusDeviceGuid.Length > 0)
            {
                loadAssignment(parent, GET_CAR_STATUS, getCarStatusButtonIndex, getCarStatusDeviceGuid);
            }

            int    getSessionStatusButtonIndex = UserSettings.GetUserSettings().getInt("GET_SESSION_STATUS_button_index");
            String getSessionStatusDeviceGuid  = UserSettings.GetUserSettings().getString("GET_SESSION_STATUS_device_guid");

            if (getSessionStatusButtonIndex != -1 && getSessionStatusDeviceGuid.Length > 0)
            {
                loadAssignment(parent, GET_SESSION_STATUS, getSessionStatusButtonIndex, getSessionStatusDeviceGuid);
            }

            int    togglePaceNotesPlaybackButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_PACE_NOTES_PLAYBACK_button_index");
            String togglePaceNotesPlaybackDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_PACE_NOTES_PLAYBACK_device_guid");

            if (togglePaceNotesPlaybackButtonIndex != -1 && togglePaceNotesPlaybackDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_PACE_NOTES_PLAYBACK, togglePaceNotesPlaybackButtonIndex, togglePaceNotesPlaybackDeviceGuid);
            }

            int    togglePaceNotesRecordingButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_PACE_NOTES_RECORDING_button_index");
            String togglePaceNotesRecordingDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_PACE_NOTES_RECORDING_device_guid");

            if (togglePaceNotesRecordingButtonIndex != -1 && togglePaceNotesRecordingDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_PACE_NOTES_RECORDING, togglePaceNotesRecordingButtonIndex, togglePaceNotesRecordingDeviceGuid);
            }
            int    toggleTrackLandmarkButtonIndex         = UserSettings.GetUserSettings().getInt("TOGGLE_TRACK_LANDMARKS_RECORDING_button_index");
            String toggleTrackLandmarkRecordingDeviceGuid = UserSettings.GetUserSettings().getString("TOGGLE_TRACK_LANDMARKS_RECORDING_device_guid");

            if (toggleTrackLandmarkButtonIndex != -1 && toggleTrackLandmarkRecordingDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_TRACK_LANDMARKS_RECORDING, toggleTrackLandmarkButtonIndex, toggleTrackLandmarkRecordingDeviceGuid);
            }
            int    addTracklandmarkButtonIndex = UserSettings.GetUserSettings().getInt("ADD_TRACK_LANDMARK_button_index");
            String addTracklandmarkDeviceGuid  = UserSettings.GetUserSettings().getString("ADD_TRACK_LANDMARK_device_guid");

            if (addTracklandmarkButtonIndex != -1 && addTracklandmarkDeviceGuid.Length > 0)
            {
                loadAssignment(parent, ADD_TRACK_LANDMARK, addTracklandmarkButtonIndex, addTracklandmarkDeviceGuid);
            }

            int    pitPredictionButtonIndex = UserSettings.GetUserSettings().getInt("PIT_PREDICTION_button_index");
            String pitPredictionDeviceGuid  = UserSettings.GetUserSettings().getString("PIT_PREDICTION_device_guid");

            if (pitPredictionButtonIndex != -1 && pitPredictionDeviceGuid.Length > 0)
            {
                loadAssignment(parent, PIT_PREDICTION, pitPredictionButtonIndex, pitPredictionDeviceGuid);
            }
        }
コード例 #11
0
 public void saveSettings()
 {
     foreach (ButtonAssignment buttonAssignment in buttonAssignments)
     {
         String actionId = "";
         if (buttonAssignment.action == CHANNEL_OPEN_FUNCTION)
         {
             actionId = "CHANNEL_OPEN_FUNCTION";
         }
         else if (buttonAssignment.action == TOGGLE_RACE_UPDATES_FUNCTION)
         {
             actionId = "TOGGLE_RACE_UPDATES_FUNCTION";
         }
         else if (buttonAssignment.action == TOGGLE_SPOTTER_FUNCTION)
         {
             actionId = "TOGGLE_SPOTTER_FUNCTION";
         }
         else if (buttonAssignment.action == TOGGLE_READ_OPPONENT_DELTAS)
         {
             actionId = "TOGGLE_READ_OPPONENT_DELTAS";
         }
         else if (buttonAssignment.action == TOGGLE_BLOCK_MESSAGES_IN_HARD_PARTS)
         {
             actionId = "TOGGLE_BLOCK_MESSAGES_IN_HARD_PARTS";
         }
         else if (buttonAssignment.action == REPEAT_LAST_MESSAGE_BUTTON)
         {
             actionId = "REPEAT_LAST_MESSAGE_BUTTON";
         }
         else if (buttonAssignment.action == VOLUME_UP)
         {
             actionId = "VOLUME_UP";
         }
         else if (buttonAssignment.action == VOLUME_DOWN)
         {
             actionId = "VOLUME_DOWN";
         }
         else if (buttonAssignment.action == PRINT_TRACK_DATA)
         {
             actionId = "PRINT_TRACK_DATA";
         }
         else if (buttonAssignment.action == TOGGLE_YELLOW_FLAG_MESSAGES)
         {
             actionId = "TOGGLE_YELLOW_FLAG_MESSAGES";
         }
         else if (buttonAssignment.action == GET_FUEL_STATUS)
         {
             actionId = "GET_FUEL_STATUS";
         }
         else if (buttonAssignment.action == TOGGLE_MANUAL_FORMATION_LAP)
         {
             actionId = "TOGGLE_MANUAL_FORMATION_LAP";
         }
         else if (buttonAssignment.action == READ_CORNER_NAMES_FOR_LAP)
         {
             actionId = "READ_CORNER_NAMES_FOR_LAP";
         }
         else if (buttonAssignment.action == GET_CAR_STATUS)
         {
             actionId = "GET_CAR_STATUS";
         }
         else if (buttonAssignment.action == GET_DAMAGE_REPORT)
         {
             actionId = "GET_DAMAGE_REPORT";
         }
         else if (buttonAssignment.action == GET_SESSION_STATUS)
         {
             actionId = "GET_SESSION_STATUS";
         }
         else if (buttonAssignment.action == GET_STATUS)
         {
             actionId = "GET_STATUS";
         }
         else if (buttonAssignment.action == TOGGLE_PACE_NOTES_PLAYBACK)
         {
             actionId = "TOGGLE_PACE_NOTES_PLAYBACK";
         }
         else if (buttonAssignment.action == TOGGLE_PACE_NOTES_RECORDING)
         {
             actionId = "TOGGLE_PACE_NOTES_RECORDING";
         }
         else if (buttonAssignment.action == TOGGLE_TRACK_LANDMARKS_RECORDING)
         {
             actionId = "TOGGLE_TRACK_LANDMARKS_RECORDING";
         }
         else if (buttonAssignment.action == ADD_TRACK_LANDMARK)
         {
             actionId = "ADD_TRACK_LANDMARK";
         }
         else if (buttonAssignment.action == PIT_PREDICTION)
         {
             actionId = "PIT_PREDICTION";
         }
         if (buttonAssignment.controller != null && (buttonAssignment.joystick != null || buttonAssignment.controller.guid == UDP_NETWORK_CONTROLLER_GUID) && buttonAssignment.buttonIndex != -1)
         {
             UserSettings.GetUserSettings().setProperty(actionId + "_button_index", buttonAssignment.buttonIndex);
             UserSettings.GetUserSettings().setProperty(actionId + "_device_guid", buttonAssignment.controller.guid.ToString());
         }
         else
         {
             UserSettings.GetUserSettings().setProperty(actionId + "_button_index", -1);
             UserSettings.GetUserSettings().setProperty(actionId + "_device_guid", "");
         }
     }
     UserSettings.GetUserSettings().saveUserSettings();
 }
コード例 #12
0
        public Boolean Run(String filenameToRun, int interval, Boolean dumpToFile)
        {
            loadDataFromFile = false;
            audioPlayer.mute = false;
            if (filenameToRun != null && System.Diagnostics.Debugger.IsAttached)
            {
                loadDataFromFile = true;
                spotterEnabled   = false;
                if (interval > 0)
                {
                    _timeInterval    = TimeSpan.FromMilliseconds(interval);
                    audioPlayer.mute = false;
                }
                else
                {
                    _timeInterval    = TimeSpan.Zero;
                    audioPlayer.mute = true;
                }
                dumpToFile = false;
            }

            gameStateMapper = GameStateReaderFactory.getInstance().getGameStateMapper(gameDefinition);
            gameStateMapper.setSpeechRecogniser(speechRecogniser);
            gameDataReader = GameStateReaderFactory.getInstance().getGameStateReader(gameDefinition);
            gameDataReader.ResetGameDataFromFile();

            gameDataReader.dumpToFile = System.Diagnostics.Debugger.IsAttached && dumpToFile;
            if (gameDefinition.spotterName != null)
            {
                spotter = (Spotter)Activator.CreateInstance(Type.GetType(gameDefinition.spotterName),
                                                            audioPlayer, spotterEnabled);
            }
            else
            {
                Console.WriteLine("No spotter defined for game " + gameDefinition.friendlyName);
                spotter = null;
            }
            running = true;
            DateTime nextRunTime = DateTime.Now;

            if (!audioPlayer.initialised)
            {
                Console.WriteLine("Failed to initialise audio player");
                return(false);
            }
            audioPlayer.startMonitor();
            Boolean attemptedToRunGame = false;

            Console.WriteLine("Polling for shared data every " + _timeInterval.Milliseconds + "ms");
            Boolean sessionFinished = false;

            while (running)
            {
                DateTime now = DateTime.Now;
                if (now > nextRunTime)
                {
                    // ensure the updates don't get synchronised with the spotter / UDP receiver
                    int updateTweak = random.Next(10) - 5;
                    nextRunTime = DateTime.Now.Add(_timeInterval);
                    nextRunTime.Add(TimeSpan.FromMilliseconds(updateTweak));
                    if (!loadDataFromFile)
                    {
                        if (gameDefinition.processName == null || Utilities.IsGameRunning(gameDefinition.processName))
                        {
                            if (!mapped)
                            {
                                mapped = gameDataReader.Initialise();
                            }
                        }
                        else if (UserSettings.GetUserSettings().getBoolean(gameDefinition.gameStartEnabledProperty) && !attemptedToRunGame)
                        {
                            Utilities.runGame(UserSettings.GetUserSettings().getString(gameDefinition.gameStartCommandProperty),
                                              UserSettings.GetUserSettings().getString(gameDefinition.gameStartCommandOptionsProperty));
                            attemptedToRunGame = true;
                        }
                    }

                    if (loadDataFromFile || mapped)
                    {
                        stateCleared = false;
                        Object rawGameData;
                        if (loadDataFromFile)
                        {
                            rawGameData = gameDataReader.ReadGameDataFromFile(filenameToRun);
                            if (rawGameData == null)
                            {
                                Console.WriteLine("Reached the end of the data file, sleeping to clear queued messages");
                                Thread.Sleep(5000);
                                audioPlayer.purgeQueues();
                                running = false;
                                continue;
                            }
                        }
                        else
                        {
                            rawGameData = gameDataReader.ReadGameData(false);
                        }
                        gameStateMapper.versionCheck(rawGameData);

                        GameStateData nextGameState = null;
                        try
                        {
                            nextGameState = gameStateMapper.mapToGameStateData(rawGameData, currentGameState);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Error mapping game data: " + e.StackTrace);
                        }
                        // if we're paused or viewing another car, the mapper will just return the previous game state so we don't lose all the
                        // persistent state information. If this is the case, don't process any stuff
                        if (nextGameState != null && nextGameState != currentGameState)
                        {
                            previousGameState = currentGameState;
                            currentGameState  = nextGameState;
                            if (!sessionFinished && currentGameState.SessionData.SessionPhase == SessionPhase.Finished &&
                                previousGameState != null)
                            {
                                Console.WriteLine("Session finished");
                                audioPlayer.purgeQueues();
                                if (displaySessionLapTimes)
                                {
                                    Console.WriteLine("Session lap times:");
                                    Console.WriteLine(String.Join(";", currentGameState.SessionData.formattedPlayerLapTimes));
                                }
                                sessionEndMessages.trigger(previousGameState.SessionData.SessionRunningTime, previousGameState.SessionData.SessionType, currentGameState.SessionData.SessionPhase,
                                                           previousGameState.SessionData.SessionStartPosition, previousGameState.SessionData.Position, previousGameState.SessionData.NumCarsAtStartOfSession, previousGameState.SessionData.CompletedLaps,
                                                           previousGameState.SessionData.IsDisqualified);

                                sessionFinished = true;
                                audioPlayer.disablePearlsOfWisdom = false;
                                if (loadDataFromFile)
                                {
                                    Thread.Sleep(2000);
                                }
                            }
                            float prevTime = previousGameState == null ? 0 : previousGameState.SessionData.SessionRunningTime;
                            if (currentGameState.SessionData.IsNewSession)
                            {
                                Console.WriteLine("New session");
                                audioPlayer.disablePearlsOfWisdom = false;
                                displayNewSessionInfo(currentGameState);
                                sessionFinished = false;
                                if (!stateCleared)
                                {
                                    Console.WriteLine("Clearing game state...");
                                    audioPlayer.purgeQueues();

                                    foreach (KeyValuePair <String, AbstractEvent> entry in eventsList)
                                    {
                                        entry.Value.clearState();
                                    }
                                    faultingEvents.Clear();
                                    faultingEventsCount.Clear();
                                    stateCleared = true;
                                }
                                if (enableDriverNames)
                                {
                                    List <String> rawDriverNames = currentGameState.getRawDriverNames();
                                    if (currentGameState.SessionData.DriverRawName != null && currentGameState.SessionData.DriverRawName.Length > 0 &&
                                        !rawDriverNames.Contains(currentGameState.SessionData.DriverRawName))
                                    {
                                        rawDriverNames.Add(currentGameState.SessionData.DriverRawName);
                                    }
                                    if (rawDriverNames.Count > 0)
                                    {
                                        List <String> usableDriverNames = DriverNameHelper.getUsableDriverNames(rawDriverNames);
                                        if (speechRecogniser != null && speechRecogniser.initialised)
                                        {
                                            speechRecogniser.addOpponentSpeechRecognition(usableDriverNames, enableDriverNames);
                                        }
                                    }
                                }
                            }
                            // TODO: for AC free practice sessions, the SessionRunningTime is set to 1 hour in the mapper and stays there so this block never triggers
                            else if (!sessionFinished && previousGameState != null &&
                                     (currentGameState.SessionData.SessionRunningTime > previousGameState.SessionData.SessionRunningTime ||
                                      (previousGameState.SessionData.SessionPhase != currentGameState.SessionData.SessionPhase)) ||
                                     ((gameDefinition.gameEnum == GameEnum.PCARS_32BIT || gameDefinition.gameEnum == GameEnum.PCARS_64BIT || gameDefinition.gameEnum == GameEnum.PCARS_NETWORK) &&
                                      currentGameState.SessionData.SessionHasFixedTime && currentGameState.SessionData.SessionTotalRunTime == -1))
                            {
                                if (spotter != null)
                                {
                                    if (currentGameState.FlagData.isFullCourseYellow)
                                    {
                                        spotter.pause();
                                    }
                                    else
                                    {
                                        spotter.unpause();
                                    }
                                }
                                if (currentGameState.SessionData.IsNewLap)
                                {
                                    currentGameState.display();
                                }
                                stateCleared = false;
                                foreach (KeyValuePair <String, AbstractEvent> entry in eventsList)
                                {
                                    if (entry.Value.isApplicableForCurrentSessionAndPhase(currentGameState.SessionData.SessionType, currentGameState.SessionData.SessionPhase))
                                    {
                                        triggerEvent(entry.Key, entry.Value, previousGameState, currentGameState);
                                    }
                                }
                                if (spotter != null && spotterEnabled && !spotterIsRunning && !loadDataFromFile)
                                {
                                    Console.WriteLine("********** starting spotter***********");
                                    spotter.clearState();
                                    startSpotterThread();
                                }
                                else if (spotterIsRunning && !spotterEnabled)
                                {
                                    runSpotterThread = false;
                                }
                            }
                            else if (spotter != null)
                            {
                                spotter.pause();
                            }
                        }
                    }
                }
                else
                {
                    // ensure the updates don't get synchronised with the spotter / UDP receiver
                    int threadSleepTime = 5 + random.Next(10);
                    Thread.Sleep(threadSleepTime);
                    continue;
                }
            }
            foreach (KeyValuePair <String, AbstractEvent> entry in eventsList)
            {
                entry.Value.clearState();
            }
            if (spotter != null)
            {
                spotter.clearState();
            }
            stateCleared      = true;
            currentGameState  = null;
            previousGameState = null;
            sessionFinished   = false;
            Console.WriteLine("Stopping queue monitor");
            audioPlayer.stopMonitor();
            audioPlayer.disablePearlsOfWisdom = false;
            if (gameDataReader != null && gameDataReader.dumpToFile)
            {
                gameDataReader.DumpRawGameData();
            }
            gameDataReader.stop();
            return(true);
        }
コード例 #13
0
        public void loadSettings(System.Windows.Forms.Form parent)
        {
            int    channelOpenButtonIndex      = UserSettings.GetUserSettings().getInt("CHANNEL_OPEN_FUNCTION_button_index");
            String channelOpenButtonDeviceGuid = UserSettings.GetUserSettings().getString("CHANNEL_OPEN_FUNCTION_device_guid");

            if (channelOpenButtonIndex != -1 && channelOpenButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, CHANNEL_OPEN_FUNCTION, channelOpenButtonIndex, channelOpenButtonDeviceGuid);
            }

            int    toggleRaceUpdatesButtonIndex      = UserSettings.GetUserSettings().getInt("TOGGLE_RACE_UPDATES_FUNCTION_button_index");
            String toggleRaceUpdatesButtonDeviceGuid = UserSettings.GetUserSettings().getString("TOGGLE_RACE_UPDATES_FUNCTION_device_guid");

            if (toggleRaceUpdatesButtonIndex != -1 && toggleRaceUpdatesButtonDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_RACE_UPDATES_FUNCTION, toggleRaceUpdatesButtonIndex, toggleRaceUpdatesButtonDeviceGuid);
            }

            int    toggleSpotterFunctionButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_SPOTTER_FUNCTION_button_index");
            String toggleSpotterFunctionDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_SPOTTER_FUNCTION_device_guid");

            if (toggleSpotterFunctionButtonIndex != -1 && toggleSpotterFunctionDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_SPOTTER_FUNCTION, toggleSpotterFunctionButtonIndex, toggleSpotterFunctionDeviceGuid);
            }

            int    toggleReadOpponentDeltasButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_READ_OPPONENT_DELTAS_button_index");
            String toggleReadOpponentDeltasDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_READ_OPPONENT_DELTAS_device_guid");

            if (toggleReadOpponentDeltasButtonIndex != -1 && toggleReadOpponentDeltasDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_READ_OPPONENT_DELTAS, toggleReadOpponentDeltasButtonIndex, toggleReadOpponentDeltasDeviceGuid);
            }

            int    repeatLastMessageButtonIndex = UserSettings.GetUserSettings().getInt("REPEAT_LAST_MESSAGE_BUTTON_button_index");
            String repeatLastMessageDeviceGuid  = UserSettings.GetUserSettings().getString("REPEAT_LAST_MESSAGE_BUTTON_device_guid");

            if (repeatLastMessageButtonIndex != -1 && repeatLastMessageDeviceGuid.Length > 0)
            {
                loadAssignment(parent, REPEAT_LAST_MESSAGE_BUTTON, repeatLastMessageButtonIndex, repeatLastMessageDeviceGuid);
            }

            int    volumeUpButtonIndex = UserSettings.GetUserSettings().getInt("VOLUME_UP_button_index");
            String volumeUpDeviceGuid  = UserSettings.GetUserSettings().getString("VOLUME_UP_device_guid");

            if (volumeUpButtonIndex != -1 && volumeUpDeviceGuid.Length > 0)
            {
                loadAssignment(parent, VOLUME_UP, volumeUpButtonIndex, volumeUpDeviceGuid);
            }

            int    volumeDownButtonIndex = UserSettings.GetUserSettings().getInt("VOLUME_DOWN_button_index");
            String volumeDownDeviceGuid  = UserSettings.GetUserSettings().getString("VOLUME_DOWN_device_guid");

            if (volumeDownButtonIndex != -1 && volumeDownDeviceGuid.Length > 0)
            {
                loadAssignment(parent, VOLUME_DOWN, volumeDownButtonIndex, volumeDownDeviceGuid);
            }

            int    printTrackDataButtonIndex = UserSettings.GetUserSettings().getInt("PRINT_TRACK_DATA_button_index");
            String printTrackDataDeviceGuid  = UserSettings.GetUserSettings().getString("PRINT_TRACK_DATA_device_guid");

            if (printTrackDataButtonIndex != -1 && printTrackDataDeviceGuid.Length > 0)
            {
                loadAssignment(parent, PRINT_TRACK_DATA, printTrackDataButtonIndex, printTrackDataDeviceGuid);
            }

            int    toggleYellowFlagMessagesButtonIndex = UserSettings.GetUserSettings().getInt("TOGGLE_YELLOW_FLAG_MESSAGES_button_index");
            String toggleYellowFlagMessagesDeviceGuid  = UserSettings.GetUserSettings().getString("TOGGLE_YELLOW_FLAG_MESSAGES_device_guid");

            if (toggleYellowFlagMessagesButtonIndex != -1 && toggleYellowFlagMessagesDeviceGuid.Length > 0)
            {
                loadAssignment(parent, TOGGLE_YELLOW_FLAG_MESSAGES, toggleYellowFlagMessagesButtonIndex, toggleYellowFlagMessagesDeviceGuid);
            }
        }
コード例 #14
0
        public PropertiesForm(System.Windows.Forms.Form parent)
        {
            hasChanges  = false;
            this.parent = parent;
            InitializeComponent();
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.button1.Text = "Save (manual restart required)";
            }
            int widgetCount = 0;

            foreach (SettingsProperty strProp in UserSettings.GetUserSettings().getProperties(typeof(String), null, null))
            {
                this.flowLayoutPanel1.Controls.Add(new StringPropertyControl(strProp.Name, Configuration.getUIString(strProp.Name) + " " + Configuration.getUIString("text_prop_type"),
                                                                             UserSettings.GetUserSettings().getString(strProp.Name), (String)strProp.DefaultValue,
                                                                             Configuration.getUIString(strProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty boolProp in UserSettings.GetUserSettings().getProperties(typeof(Boolean), "enable", null))
            {
                Boolean defaultValue;
                Boolean.TryParse((String)boolProp.DefaultValue, out defaultValue);
                this.flowLayoutPanel1.Controls.Add(new BooleanPropertyControl(boolProp.Name, Configuration.getUIString(boolProp.Name) + " " + Configuration.getUIString("boolean_prop_type"),
                                                                              UserSettings.GetUserSettings().getBoolean(boolProp.Name), defaultValue,
                                                                              Configuration.getUIString(boolProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty intProp in UserSettings.GetUserSettings().getProperties(typeof(int), "frequency", null))
            {
                int defaultValue;
                int.TryParse((String)intProp.DefaultValue, out defaultValue);
                this.flowLayoutPanel1.Controls.Add(new IntPropertyControl(intProp.Name, Configuration.getUIString(intProp.Name) + " " + Configuration.getUIString("integer_prop_type"),
                                                                          UserSettings.GetUserSettings().getInt(intProp.Name), defaultValue,
                                                                          Configuration.getUIString(intProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty boolProp in UserSettings.GetUserSettings().getProperties(typeof(Boolean), null, "enable"))
            {
                Boolean defaultValue;
                Boolean.TryParse((String)boolProp.DefaultValue, out defaultValue);
                this.flowLayoutPanel1.Controls.Add(new BooleanPropertyControl(boolProp.Name, Configuration.getUIString(boolProp.Name) + " " + Configuration.getUIString("boolean_prop_type"),
                                                                              UserSettings.GetUserSettings().getBoolean(boolProp.Name), defaultValue,
                                                                              Configuration.getUIString(boolProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty intProp in UserSettings.GetUserSettings().getProperties(typeof(int), null, "frequency"))
            {
                int defaultValue;
                int.TryParse((String)intProp.DefaultValue, out defaultValue);
                this.flowLayoutPanel1.Controls.Add(new IntPropertyControl(intProp.Name, Configuration.getUIString(intProp.Name) + " " + Configuration.getUIString("integer_prop_type"),
                                                                          UserSettings.GetUserSettings().getInt(intProp.Name), defaultValue,
                                                                          Configuration.getUIString(intProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty floatProp in UserSettings.GetUserSettings().getProperties(typeof(float), null, null))
            {
                float defaultValue;
                float.TryParse((String)floatProp.DefaultValue, out defaultValue);
                this.flowLayoutPanel1.Controls.Add(new FloatPropertyControl(floatProp.Name, Configuration.getUIString(floatProp.Name) + " " + Configuration.getUIString("real_number_prop_type"),
                                                                            UserSettings.GetUserSettings().getFloat(floatProp.Name), defaultValue,
                                                                            Configuration.getUIString(floatProp.Name + "_help")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
        }
コード例 #15
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
            this.consoleTextBox = new System.Windows.Forms.RichTextBox();
            this.consoleTextBoxBackgroundPanel = new System.Windows.Forms.Panel();
            this.startApplicationButton        = new System.Windows.Forms.Button();
            this.forceVersionCheckButton       = new System.Windows.Forms.Button();
            this.saveConsoleOutputButton       = new System.Windows.Forms.Button();
            this.buttonActionSelect            = new System.Windows.Forms.ListBox();
            this.controllersList       = new System.Windows.Forms.ListBox();
            this.assignButtonToAction  = new System.Windows.Forms.Button();
            this.deleteAssigmentButton = new System.Windows.Forms.Button();
            this.label1                         = new System.Windows.Forms.Label();
            this.label2                         = new System.Windows.Forms.Label();
            this.propertiesButton               = new System.Windows.Forms.Button();
            this.aboutButton                    = new System.Windows.Forms.Button();
            this.helpButton                     = new System.Windows.Forms.Button();
            this.scanControllersButton          = new System.Windows.Forms.Button();
            this.groupBox1                      = new System.Windows.Forms.GroupBox();
            this.alwaysOnButton                 = new System.Windows.Forms.RadioButton();
            this.toggleButton                   = new System.Windows.Forms.RadioButton();
            this.holdButton                     = new System.Windows.Forms.RadioButton();
            this.voiceDisableButton             = new System.Windows.Forms.RadioButton();
            this.triggerWordButton              = new System.Windows.Forms.RadioButton();
            this.button2                        = new System.Windows.Forms.Button();
            this.messagesVolumeSlider           = new System.Windows.Forms.TrackBar();
            this.messagesAudioDeviceBox         = new System.Windows.Forms.ComboBox();
            this.speechRecognitionDeviceBox     = new System.Windows.Forms.ComboBox();
            this.backgroundAudioDeviceBox       = new System.Windows.Forms.ComboBox();
            this.label3                         = new System.Windows.Forms.Label();
            this.backgroundVolumeSlider         = new System.Windows.Forms.TrackBar();
            this.label4                         = new System.Windows.Forms.Label();
            this.gameDefinitionList             = new System.Windows.Forms.ListBox();
            this.label5                         = new System.Windows.Forms.Label();
            this.personalisationLabel           = new System.Windows.Forms.Label();
            this.filenameTextbox                = new System.Windows.Forms.TextBox();
            this.filenameLabel                  = new System.Windows.Forms.Label();
            this.recordSession                  = new System.Windows.Forms.CheckBox();
            this.playbackInterval               = new System.Windows.Forms.TextBox();
            this.app_version                    = new System.Windows.Forms.Label();
            this.soundPackProgressBar           = new System.Windows.Forms.ProgressBar();
            this.downloadSoundPackButton        = new System.Windows.Forms.Button();
            this.downloadDriverNamesButton      = new System.Windows.Forms.Button();
            this.downloadPersonalisationsButton = new System.Windows.Forms.Button();
            this.driverNamesProgressBar         = new System.Windows.Forms.ProgressBar();
            this.personalisationsProgressBar    = new System.Windows.Forms.ProgressBar();
            this.personalisationBox             = new System.Windows.Forms.ComboBox();
            this.spotterNameLabel               = new System.Windows.Forms.Label();
            this.messagesAudioDeviceLabel       = new System.Windows.Forms.Label();
            this.speechRecognitionDeviceLabel   = new System.Windows.Forms.Label();
            this.backgroundAudioDeviceLabel     = new System.Windows.Forms.Label();
            this.spotterNameBox                 = new System.Windows.Forms.ComboBox();
            this.donateLink                     = new System.Windows.Forms.LinkLabel();
            this.smokeTestTextBox               = new System.Windows.Forms.TextBox();
            this.buttonSmokeTest                = new System.Windows.Forms.Button();
            this.chiefNameLabel                 = new System.Windows.Forms.Label();
            this.chiefNameBox                   = new System.Windows.Forms.ComboBox();
            this.myNameBoxTooltip               = new System.Windows.Forms.ToolTip();
            this.chiefNameBoxTooltip            = new System.Windows.Forms.ToolTip();
            this.spotterNameBoxTooltip          = new System.Windows.Forms.ToolTip();
            this.groupBox1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.messagesVolumeSlider)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.backgroundVolumeSlider)).BeginInit();
            this.SuspendLayout();

            this.consoleTextBoxBackgroundPanel.Location    = new System.Drawing.Point(41, 215);
            this.consoleTextBoxBackgroundPanel.Size        = new System.Drawing.Size(MainWindow.soundTestMode ? 793 : 1093, 285);
            this.consoleTextBoxBackgroundPanel.BorderStyle = BorderStyle.FixedSingle;
            //
            // consoleTextBox
            //
            this.consoleTextBox.Location    = new System.Drawing.Point(41, 215);
            this.consoleTextBox.MaxLength   = 99999999;
            this.consoleTextBox.Multiline   = true;
            this.consoleTextBox.Name        = "textBox1";
            this.consoleTextBox.ReadOnly    = true;
            this.consoleTextBox.Size        = new System.Drawing.Size(MainWindow.soundTestMode ? 793 : 1093, 285);
            this.consoleTextBox.TabIndex    = 200;
            this.consoleTextBox.BorderStyle = BorderStyle.None;
            this.consoleTextBox.Dock        = DockStyle.Fill;
            this.consoleTextBoxBackgroundPanel.Controls.Add(this.consoleTextBox);

            //
            // startApplicationButton
            //
            this.startApplicationButton.Location = new System.Drawing.Point(41, 28);
            this.startApplicationButton.Name     = "startApplicationButton";
            this.startApplicationButton.Size     = new System.Drawing.Size(137, 38);
            this.startApplicationButton.TabIndex = 40;
            this.startApplicationButton.Text     = Configuration.getUIString("start_application");
            this.startApplicationButton.UseVisualStyleBackColor = true;
            this.startApplicationButton.Click += new System.EventHandler(this.startApplicationButton_Click);
            //
            // buttonActionSelect
            //
            this.buttonActionSelect.FormattingEnabled = true;
            this.buttonActionSelect.Location          = new System.Drawing.Point(295, 520);
            this.buttonActionSelect.Name                  = "buttonActionSelect";
            this.buttonActionSelect.Size                  = new System.Drawing.Size(528, 115);
            this.buttonActionSelect.TabIndex              = 230;
            this.buttonActionSelect.SelectedIndexChanged += new System.EventHandler(this.buttonActionSelect_SelectedIndexChanged);
            //
            // controllersList
            //
            this.controllersList.FormattingEnabled = true;
            this.controllersList.Location          = new System.Drawing.Point(41, 520);
            this.controllersList.Name                  = "controllersList";
            this.controllersList.Size                  = new System.Drawing.Size(248, 85);
            this.controllersList.TabIndex              = 210;
            this.controllersList.SelectedIndexChanged += new System.EventHandler(this.controllersList_SelectedIndexChanged);
            //
            // assignButtonToAction
            //
            this.assignButtonToAction.Location = new System.Drawing.Point(830, 520);
            this.assignButtonToAction.Name     = "assignButtonToAction";
            this.assignButtonToAction.Size     = new System.Drawing.Size(130, 39);
            this.assignButtonToAction.TabIndex = 240;
            this.assignButtonToAction.Text     = Configuration.getUIString("assign_control");
            this.assignButtonToAction.UseVisualStyleBackColor = true;
            this.assignButtonToAction.Click += new System.EventHandler(this.assignButtonToActionClick);
            //
            // deleteAssigmentButton
            //
            this.deleteAssigmentButton.Location = new System.Drawing.Point(830, 564);
            this.deleteAssigmentButton.Name     = "deleteAssigmentButton";
            this.deleteAssigmentButton.Size     = new System.Drawing.Size(130, 40);
            this.deleteAssigmentButton.TabIndex = 250;
            this.deleteAssigmentButton.Text     = Configuration.getUIString("delete_assignment");
            this.deleteAssigmentButton.UseVisualStyleBackColor = true;
            this.deleteAssigmentButton.Click += new System.EventHandler(this.deleteAssignmentButtonClicked);
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font     = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(38, 500);
            this.label1.Name     = "label1";
            this.label1.Size     = new System.Drawing.Size(138, 17);
            this.label1.TabIndex = 209;
            this.label1.Text     = Configuration.getUIString("available_controllers");

            this.scanControllersButton.Location = new System.Drawing.Point(38, 610);
            this.scanControllersButton.Name     = "scan_controllers_button";
            this.scanControllersButton.Size     = new System.Drawing.Size(143, 30);
            this.scanControllersButton.TabIndex = 220;
            this.scanControllersButton.Text     = Configuration.getUIString("scan_controllers");
            this.scanControllersButton.UseVisualStyleBackColor = true;
            this.scanControllersButton.Click += new System.EventHandler(this.scanControllersButtonClicked);
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font     = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(323, 501);
            this.label2.Name     = "label2";
            this.label2.Size     = new System.Drawing.Size(117, 17);
            this.label2.TabIndex = 229;
            this.label2.Text     = Configuration.getUIString("available_actions");
            //
            // button1
            //
            this.propertiesButton.Location = new System.Drawing.Point(961, 105);
            this.propertiesButton.Name     = "properties";
            this.propertiesButton.Size     = new System.Drawing.Size(173, 31);
            this.propertiesButton.TabIndex = 110;
            this.propertiesButton.Text     = Configuration.getUIString("properties");
            this.propertiesButton.UseVisualStyleBackColor = true;
            this.propertiesButton.Click += new System.EventHandler(this.editPropertiesButtonClicked);

            //
            // help button
            //
            this.helpButton.Location = new System.Drawing.Point(961, 137);
            this.helpButton.Name     = "help";
            this.helpButton.Size     = new System.Drawing.Size(173, 31);
            this.helpButton.TabIndex = 120;
            this.helpButton.Text     = Configuration.getUIString("help");
            this.helpButton.UseVisualStyleBackColor = true;
            this.helpButton.Click += new System.EventHandler(this.helpButtonClicked);

            //
            // about button
            //
            this.aboutButton.Location = new System.Drawing.Point(961, 169);
            this.aboutButton.Name     = "about";
            this.aboutButton.Size     = new System.Drawing.Size(173, 31);
            this.aboutButton.TabIndex = 130;
            this.aboutButton.Text     = Configuration.getUIString("about");
            this.aboutButton.UseVisualStyleBackColor = true;
            this.aboutButton.Click += new System.EventHandler(this.aboutButtonClicked);

            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.voiceDisableButton);
            this.groupBox1.Controls.Add(this.holdButton);
            this.groupBox1.Controls.Add(this.toggleButton);
            this.groupBox1.Controls.Add(this.alwaysOnButton);
            this.groupBox1.Controls.Add(this.triggerWordButton);
            this.groupBox1.Location = new System.Drawing.Point(970, 519);
            this.groupBox1.Name     = "groupBox1";
            this.groupBox1.Size     = new System.Drawing.Size(164, 124);
            this.groupBox1.TabIndex = 260;
            this.groupBox1.TabStop  = false;
            this.groupBox1.Text     = Configuration.getUIString("voice_recognition_mode");
            ToolTip voiceRecognitionToolTip = new ToolTip();

            voiceRecognitionToolTip.SetToolTip(this.groupBox1, Configuration.getUIString("voice_recognition_mode_help"));
            //
            // alwaysOnButton
            //
            this.alwaysOnButton.AutoSize = true;
            this.alwaysOnButton.Location = new System.Drawing.Point(7, 82);
            this.alwaysOnButton.Name     = "alwaysOnButton";
            this.alwaysOnButton.Size     = new System.Drawing.Size(75, 17);
            this.alwaysOnButton.TabStop  = true;
            this.alwaysOnButton.Text     = Configuration.getUIString("always_on");
            this.alwaysOnButton.UseVisualStyleBackColor = true;
            this.alwaysOnButton.CheckedChanged         += new System.EventHandler(this.alwaysOnButton_CheckedChanged);
            ToolTip voiceRecognitionAlwaysOnToolTip = new ToolTip();

            voiceRecognitionAlwaysOnToolTip.SetToolTip(this.alwaysOnButton, Configuration.getUIString("voice_recognition_always_on_help"));
            //
            // toggleButton
            //
            this.toggleButton.AutoSize = true;
            this.toggleButton.Location = new System.Drawing.Point(7, 60);
            this.toggleButton.Name     = "toggleButton";
            this.toggleButton.Size     = new System.Drawing.Size(90, 17);
            this.toggleButton.TabStop  = true;
            this.toggleButton.Text     = Configuration.getUIString("toggle_button");
            this.toggleButton.UseVisualStyleBackColor = true;
            this.toggleButton.CheckedChanged         += new System.EventHandler(this.toggleButton_CheckedChanged);
            ToolTip voiceRecognitionToggleButtonToolTip = new ToolTip();

            voiceRecognitionToggleButtonToolTip.SetToolTip(this.toggleButton, Configuration.getUIString("voice_recognition_toggle_button_help"));
            //
            // holdButton
            //
            this.holdButton.AutoSize = true;
            this.holdButton.Location = new System.Drawing.Point(7, 39);
            this.holdButton.Name     = "holdButton";
            this.holdButton.Size     = new System.Drawing.Size(81, 17);
            this.holdButton.TabStop  = true;
            this.holdButton.Text     = Configuration.getUIString("hold_button");
            this.holdButton.UseVisualStyleBackColor = true;
            this.holdButton.CheckedChanged         += new System.EventHandler(this.holdButton_CheckedChanged);
            ToolTip voiceRecognitionHoldButtonToolTip = new ToolTip();

            voiceRecognitionHoldButtonToolTip.SetToolTip(this.holdButton, Configuration.getUIString("voice_recognition_hold_button_help"));
            //
            // voiceDisableButton
            //
            this.voiceDisableButton.AutoSize = true;
            this.voiceDisableButton.Location = new System.Drawing.Point(7, 16);
            this.voiceDisableButton.Name     = "voiceDisableButton";
            this.voiceDisableButton.Size     = new System.Drawing.Size(64, 17);
            this.voiceDisableButton.TabStop  = true;
            this.voiceDisableButton.Text     = Configuration.getUIString("disabled");
            this.voiceDisableButton.UseVisualStyleBackColor = true;
            this.voiceDisableButton.CheckedChanged         += new System.EventHandler(this.voiceDisableButton_CheckedChanged);
            ToolTip voiceRecognitionDisabledToolTip = new ToolTip();

            voiceRecognitionDisabledToolTip.SetToolTip(this.voiceDisableButton, Configuration.getUIString("voice_recognition_disabled_help"));
            //
            // triggerWordButton
            //
            this.triggerWordButton.AutoSize = true;
            this.triggerWordButton.Location = new System.Drawing.Point(7, 104);
            this.triggerWordButton.Name     = "triggerWordButton";
            this.triggerWordButton.Size     = new System.Drawing.Size(64, 17);
            this.triggerWordButton.TabStop  = true;
            this.triggerWordButton.Text     = Configuration.getUIString("trigger_word") + " (\"" + UserSettings.GetUserSettings().getString("trigger_word_for_always_on_sre") + "\")";
            this.triggerWordButton.UseVisualStyleBackColor = true;
            this.triggerWordButton.CheckedChanged         += new System.EventHandler(this.triggerWordButton_CheckedChanged);
            ToolTip voiceRecognitionTriggerWordToolTip = new ToolTip();

            voiceRecognitionTriggerWordToolTip.SetToolTip(this.triggerWordButton, Configuration.getUIString("voice_recognition_trigger_word_help"));
            //
            // button2
            //
            this.button2.Location = new System.Drawing.Point(184, 28);
            this.button2.Name     = "button2";
            this.button2.Size     = new System.Drawing.Size(137, 38);
            this.button2.TabIndex = 50;
            this.button2.Text     = Configuration.getUIString("clear_console");
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.clearConsole);
            //
            // messagesVolumeSlider
            //
            this.messagesVolumeSlider.Minimum       = 0;
            this.messagesVolumeSlider.Maximum       = 100;
            this.messagesVolumeSlider.TickFrequency = 10;
            this.messagesVolumeSlider.Location      = new System.Drawing.Point(327, 28);
            this.messagesVolumeSlider.Name          = "messagesVolumeSlider";
            this.messagesVolumeSlider.Size          = new System.Drawing.Size(176, 45);
            this.messagesVolumeSlider.TabIndex      = 60;
            this.messagesVolumeSlider.Scroll       += new System.EventHandler(this.messagesVolumeSlider_Scroll);
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(367, 12);
            this.label3.Name     = "label3";
            this.label3.Size     = new System.Drawing.Size(94, 13);
            this.label3.TabIndex = 59;
            this.label3.Text     = Configuration.getUIString("messages_volume");
            //
            // backgroundVolumeSlider
            //
            this.backgroundVolumeSlider.Minimum       = 0;
            this.backgroundVolumeSlider.Maximum       = 100;
            this.backgroundVolumeSlider.TickFrequency = 10;
            this.backgroundVolumeSlider.Location      = new System.Drawing.Point(558, 28);
            this.backgroundVolumeSlider.Name          = "backgroundVolumeSlider";
            this.backgroundVolumeSlider.Size          = new System.Drawing.Size(184, 45);
            this.backgroundVolumeSlider.TabIndex      = 70;
            this.backgroundVolumeSlider.Scroll       += new System.EventHandler(this.backgroundVolumeSlider_Scroll);
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(567, 11);
            this.label4.Name     = "label4";
            this.label4.Size     = new System.Drawing.Size(104, 13);
            this.label4.TabIndex = 69;
            this.label4.Text     = Configuration.getUIString("background_volume");
            //
            // gameDefinitionList
            //
            this.gameDefinitionList.AllowDrop         = true;
            this.gameDefinitionList.FormattingEnabled = true;
            this.gameDefinitionList.Items.AddRange(GameDefinition.getGameDefinitionFriendlyNames());
            this.gameDefinitionList.Location              = new System.Drawing.Point(782, 28);
            this.gameDefinitionList.Name                  = "gameDefinitionList";
            this.gameDefinitionList.MinimumSize           = new System.Drawing.Size(170, 173);
            this.gameDefinitionList.MaximumSize           = new System.Drawing.Size(170, 173);
            this.gameDefinitionList.TabIndex              = 80;
            this.gameDefinitionList.SelectedValueChanged += new System.EventHandler(this.updateSelectedGameDefinition);
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(779, 9);
            this.label5.Name     = "label5";
            this.label5.Size     = new System.Drawing.Size(33, 13);
            this.label5.TabIndex = 79;
            this.label5.Text     = Configuration.getUIString("game");

            //
            // filenameTextbox
            //
            this.filenameTextbox.Location = new System.Drawing.Point(150, 2);
            this.filenameTextbox.Name     = "filenameTextbox";
            this.filenameTextbox.Size     = new System.Drawing.Size(108, 20);
            this.filenameTextbox.TabIndex = 20;

            //
            // filenameLabel
            //
            this.filenameLabel.AutoSize = true;
            this.filenameLabel.Location = new System.Drawing.Point(68, 5);
            this.filenameLabel.Name     = "filenameLabel";
            this.filenameLabel.Size     = new System.Drawing.Size(82, 13);
            this.filenameLabel.TabIndex = 19;  // Setting accelerator key on a Label, sets focus on the next control in the tab order.
            this.filenameLabel.Text     = "File &name to run";

            //
            // recordSession
            //
            this.recordSession.AutoSize = true;
            this.recordSession.Location = new System.Drawing.Point(7, 4);
            this.recordSession.Name     = "recordSession";
            this.recordSession.Size     = new System.Drawing.Size(61, 17);
            this.recordSession.TabIndex = 10;
            this.recordSession.Text     = "&Record";
            this.recordSession.UseVisualStyleBackColor = true;
            //
            // playbackInterval
            //
            this.playbackInterval.Location     = new System.Drawing.Point(261, 2);
            this.playbackInterval.Name         = "playbackInterval";
            this.playbackInterval.Size         = new System.Drawing.Size(100, 20);
            this.playbackInterval.TabIndex     = 30;
            this.playbackInterval.TextChanged += new System.EventHandler(this.playbackIntervalChanged);
            //
            // app_version
            //
            this.app_version.AutoSize = true;
            this.app_version.Location = new System.Drawing.Point(1045, 650);
            this.app_version.Name     = "app_version";
            this.app_version.Size     = new System.Drawing.Size(65, 13);
            this.app_version.Text     = Configuration.getUIString("app_version");
            //
            // reset_app_version
            //
            this.forceVersionCheckButton.AutoSize = true;
            this.forceVersionCheckButton.Location = new System.Drawing.Point(1030, 665);
            this.forceVersionCheckButton.Name     = "forceVersionCheckButton";
            this.forceVersionCheckButton.Size     = new System.Drawing.Size(65, 13);
            this.forceVersionCheckButton.TabIndex = 290;
            this.forceVersionCheckButton.Text     = Configuration.getUIString("check_for_updates");
            this.forceVersionCheckButton.UseVisualStyleBackColor = true;
            this.forceVersionCheckButton.Click += new System.EventHandler(this.forceVersionCheckButtonClicked);
            //
            // save_console_output
            //
            this.saveConsoleOutputButton.AutoSize = true;
            this.saveConsoleOutputButton.Location = new System.Drawing.Point(925, 665);
            this.saveConsoleOutputButton.Name     = "saveConsoleOutputButton";
            this.saveConsoleOutputButton.Size     = new System.Drawing.Size(65, 13);
            this.saveConsoleOutputButton.TabIndex = 280;
            this.saveConsoleOutputButton.Text     = Configuration.getUIString("save_console_output");
            this.saveConsoleOutputButton.UseVisualStyleBackColor = true;
            this.saveConsoleOutputButton.Click += new System.EventHandler(this.saveConsoleOutputButtonClicked);
            //
            // soundPackProgressBar
            //
            this.soundPackProgressBar.Location = new System.Drawing.Point(39, 176);
            this.soundPackProgressBar.Name     = "soundPackProgressBar";
            this.soundPackProgressBar.Size     = new System.Drawing.Size(220, 23);
            //
            // downloadSoundPackButton
            //
            this.downloadSoundPackButton.Enabled  = false;
            this.downloadSoundPackButton.Location = new System.Drawing.Point(39, 123);
            this.downloadSoundPackButton.Name     = "downloadSoundPackButton";
            this.downloadSoundPackButton.Size     = new System.Drawing.Size(220, 37);
            this.downloadSoundPackButton.TabIndex = 170;
            this.downloadSoundPackButton.Text     = Configuration.getUIString("sound_pack_is_up_to_date");
            this.downloadSoundPackButton.UseVisualStyleBackColor = true;
            this.downloadSoundPackButton.Click += new System.EventHandler(this.downloadSoundPackButtonPress);
            //
            // downloadDriverNamesButton
            //
            this.downloadDriverNamesButton.Enabled  = false;
            this.downloadDriverNamesButton.Location = new System.Drawing.Point(295, 123);
            this.downloadDriverNamesButton.Name     = "downloadDriverNamesButton";
            this.downloadDriverNamesButton.Size     = new System.Drawing.Size(220, 37);
            this.downloadDriverNamesButton.TabIndex = 180;
            this.downloadDriverNamesButton.Text     = Configuration.getUIString("driver_names_are_up_to_date");
            this.downloadDriverNamesButton.UseVisualStyleBackColor = true;
            this.downloadDriverNamesButton.Click += new System.EventHandler(this.downloadDriverNamesButtonPress);
            //
            // driverNamesProgressBar
            //
            this.driverNamesProgressBar.Location = new System.Drawing.Point(295, 176);
            this.driverNamesProgressBar.Name     = "driverNamesProgressBar";
            this.driverNamesProgressBar.Size     = new System.Drawing.Size(220, 23);
            //
            // downloadPersonalisationsButton
            //
            this.downloadPersonalisationsButton.Enabled  = false;
            this.downloadPersonalisationsButton.Location = new System.Drawing.Point(550, 123);
            this.downloadPersonalisationsButton.Name     = "downloadPersonalisationsButton";
            this.downloadPersonalisationsButton.Size     = new System.Drawing.Size(220, 37);
            this.downloadPersonalisationsButton.TabIndex = 190;
            this.downloadPersonalisationsButton.Text     = Configuration.getUIString("personalisations_are_up_to_date");
            this.downloadPersonalisationsButton.UseVisualStyleBackColor = true;
            this.downloadPersonalisationsButton.Click += new System.EventHandler(this.downloadPersonalisationsButtonPress);
            //
            // personalisationsProgressBar
            //
            this.personalisationsProgressBar.Location = new System.Drawing.Point(550, 176);
            this.personalisationsProgressBar.Name     = "personalisationsProgressBar";
            this.personalisationsProgressBar.Size     = new System.Drawing.Size(220, 23);
            //
            // personalisationLabel
            //
            this.personalisationLabel.AutoSize = true;
            this.personalisationLabel.Location = new System.Drawing.Point(961, 11);
            this.personalisationLabel.Name     = "personalisationLabel";
            this.personalisationLabel.Size     = new System.Drawing.Size(33, 13);
            this.personalisationLabel.TabIndex = 89;
            this.personalisationLabel.Text     = Configuration.getUIString("personalisation_label");
            this.myNameBoxTooltip.SetToolTip(this.personalisationLabel, Configuration.getUIString("personalisation_tooltip"));

            this.personalisationBox.Location         = new System.Drawing.Point(1027, 9);
            this.personalisationBox.IntegralHeight   = false;
            this.personalisationBox.MaxDropDownItems = 5;
            this.personalisationBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.personalisationBox.Name             = "personalisationBox";
            this.personalisationBox.Size             = new System.Drawing.Size(106, 400);
            this.personalisationBox.TabIndex         = 90;
            this.myNameBoxTooltip.SetToolTip(this.personalisationBox, Configuration.getUIString("personalisation_tooltip"));

            this.chiefNameLabel.AutoSize = true;
            this.chiefNameLabel.Location = new System.Drawing.Point(961, 43);
            this.chiefNameLabel.Name     = "chiefNameLabel";
            this.chiefNameLabel.Size     = new System.Drawing.Size(33, 13);
            this.chiefNameLabel.TabIndex = 94;
            this.chiefNameLabel.Text     = Configuration.getUIString("chief_name_label");
            this.chiefNameBoxTooltip.SetToolTip(this.chiefNameLabel, Configuration.getUIString("chief_name_tooltip"));

            this.chiefNameBox.Location         = new System.Drawing.Point(1027, 41);
            this.chiefNameBox.IntegralHeight   = false;
            this.chiefNameBox.MaxDropDownItems = 5;
            this.chiefNameBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.chiefNameBox.Name             = "chiefNameBox";
            this.chiefNameBox.Size             = new System.Drawing.Size(106, 400);
            this.chiefNameBox.TabIndex         = 95;
            this.chiefNameBoxTooltip.SetToolTip(this.chiefNameBox, Configuration.getUIString("chief_name_tooltip"));

            this.spotterNameLabel.AutoSize = true;
            this.spotterNameLabel.Location = new System.Drawing.Point(961, 75);
            this.spotterNameLabel.Name     = "spotterNameLabel";
            this.spotterNameLabel.Size     = new System.Drawing.Size(33, 13);
            this.spotterNameLabel.TabIndex = 99;
            this.spotterNameLabel.Text     = Configuration.getUIString("spotter_name_label");
            this.spotterNameBoxTooltip.SetToolTip(this.spotterNameLabel, Configuration.getUIString("spotter_name_tooltip"));

            this.spotterNameBox.Location         = new System.Drawing.Point(1027, 73);
            this.spotterNameBox.IntegralHeight   = false;
            this.spotterNameBox.MaxDropDownItems = 5;
            this.spotterNameBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.spotterNameBox.Name             = "spotterNameBox";
            this.spotterNameBox.Size             = new System.Drawing.Size(106, 400);
            this.spotterNameBox.TabIndex         = 100;
            this.spotterNameBoxTooltip.SetToolTip(this.spotterNameBox, Configuration.getUIString("spotter_name_tooltip"));

            this.donateLink.Location = new System.Drawing.Point(35, 650);
            this.donateLink.Size     = new System.Drawing.Size(250, 15);
            this.donateLink.Text     = Configuration.getUIString("donate_link_text");
            this.donateLink.Click   += new System.EventHandler(this.internetPanHandler);
            this.donateLink.TabIndex = 270;

            this.speechRecognitionDeviceLabel.AutoSize = true;
            this.speechRecognitionDeviceLabel.Location = new System.Drawing.Point(115, 70);
            this.speechRecognitionDeviceLabel.Name     = "speechRecognitionDeviceLabel";
            this.speechRecognitionDeviceLabel.Size     = new System.Drawing.Size(100, 13);
            this.speechRecognitionDeviceLabel.TabIndex = 139;
            this.speechRecognitionDeviceLabel.Text     = Configuration.getUIString("speech_recognition_device_label");
            this.speechRecognitionDeviceLabel.Visible  = false;

            this.speechRecognitionDeviceBox.Location         = new System.Drawing.Point(115, 90);
            this.speechRecognitionDeviceBox.IntegralHeight   = false;
            this.speechRecognitionDeviceBox.MaxDropDownItems = 5;
            this.speechRecognitionDeviceBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.speechRecognitionDeviceBox.Name             = "speechRecognitionDeviceBox";
            this.speechRecognitionDeviceBox.Size             = new System.Drawing.Size(190, 400);
            this.speechRecognitionDeviceBox.TabIndex         = 140;
            this.speechRecognitionDeviceBox.Visible          = false;
            this.speechRecognitionDeviceBox.Enabled          = false;

            this.messagesAudioDeviceBox.Location         = new System.Drawing.Point(330, 90);
            this.messagesAudioDeviceBox.IntegralHeight   = false;
            this.messagesAudioDeviceBox.MaxDropDownItems = 5;
            this.messagesAudioDeviceBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.messagesAudioDeviceBox.Name             = "messagesAudioDeviceBox";
            this.messagesAudioDeviceBox.Size             = new System.Drawing.Size(190, 400);
            this.messagesAudioDeviceBox.TabIndex         = 150;
            this.messagesAudioDeviceBox.Visible          = false;
            this.messagesAudioDeviceBox.Enabled          = false;

            this.messagesAudioDeviceLabel.AutoSize = true;
            this.messagesAudioDeviceLabel.Location = new System.Drawing.Point(330, 70);
            this.messagesAudioDeviceLabel.Name     = "messagesAudioDeviceLabel";
            this.messagesAudioDeviceLabel.Size     = new System.Drawing.Size(100, 13);
            this.messagesAudioDeviceLabel.TabIndex = 149;
            this.messagesAudioDeviceLabel.Text     = Configuration.getUIString("messages_audio_device_label");
            this.messagesAudioDeviceLabel.Visible  = false;

            this.backgroundAudioDeviceLabel.AutoSize = true;
            this.backgroundAudioDeviceLabel.Location = new System.Drawing.Point(550, 70);
            this.backgroundAudioDeviceLabel.Name     = "backgroundAudioDeviceLabel";
            this.backgroundAudioDeviceLabel.Size     = new System.Drawing.Size(100, 13);
            this.backgroundAudioDeviceLabel.TabIndex = 159;
            this.backgroundAudioDeviceLabel.Text     = Configuration.getUIString("background_audio_device_label");
            this.backgroundAudioDeviceLabel.Visible  = false;

            this.backgroundAudioDeviceBox.Location         = new System.Drawing.Point(550, 90);
            this.backgroundAudioDeviceBox.IntegralHeight   = false;
            this.backgroundAudioDeviceBox.MaxDropDownItems = 5;
            this.backgroundAudioDeviceBox.DropDownStyle    = ComboBoxStyle.DropDownList;
            this.backgroundAudioDeviceBox.Name             = "backgroundAudioDeviceBox";
            this.backgroundAudioDeviceBox.Size             = new System.Drawing.Size(190, 400);
            this.backgroundAudioDeviceBox.TabIndex         = 160;
            this.backgroundAudioDeviceBox.Visible          = false;
            this.backgroundAudioDeviceBox.Enabled          = false;
            // the handler for this is added when we initialise
            //
            // consoleTextBox
            //
            this.smokeTestTextBox.Location   = new System.Drawing.Point(847, 215);
            this.smokeTestTextBox.MaxLength  = 99999999;
            this.smokeTestTextBox.Multiline  = true;
            this.smokeTestTextBox.Name       = "smokeTestTextBox";
            this.smokeTestTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.smokeTestTextBox.Size       = new System.Drawing.Size(283, 270);
            this.smokeTestTextBox.TabIndex   = 502;
            this.smokeTestTextBox.Visible    = false;
            //
            // buttonSmokeTest
            //
            this.buttonSmokeTest.Location = new System.Drawing.Point(847, 485);
            this.buttonSmokeTest.Name     = "buttonSmokeTest";
            this.buttonSmokeTest.Size     = new System.Drawing.Size(283, 23);
            this.buttonSmokeTest.TabIndex = 501;
            this.buttonSmokeTest.Text     = "Test Sounds";
            this.buttonSmokeTest.UseVisualStyleBackColor = true;
            this.buttonSmokeTest.Click  += new System.EventHandler(this.playSmokeTestSounds);
            this.buttonSmokeTest.Visible = false;

            //
            // MainWindow
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize          = new System.Drawing.Size(1146, 692);
            this.MaximizeBox         = false;
            this.Controls.Add(this.driverNamesProgressBar);
            this.Controls.Add(this.downloadDriverNamesButton);
            this.Controls.Add(this.downloadSoundPackButton);
            this.Controls.Add(this.downloadPersonalisationsButton);
            this.Controls.Add(this.soundPackProgressBar);
            this.Controls.Add(this.personalisationsProgressBar);
            this.Controls.Add(this.app_version);
            this.Controls.Add(this.playbackInterval);
            this.Controls.Add(this.recordSession);
            this.Controls.Add(this.filenameLabel);
            this.Controls.Add(this.filenameTextbox);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.gameDefinitionList);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.backgroundVolumeSlider);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.messagesVolumeSlider);
            this.Controls.Add(this.messagesAudioDeviceBox);
            this.Controls.Add(this.speechRecognitionDeviceBox);
            this.Controls.Add(this.backgroundAudioDeviceBox);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.propertiesButton);
            this.Controls.Add(this.helpButton);
            this.Controls.Add(this.aboutButton);
            this.Controls.Add(this.scanControllersButton);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.deleteAssigmentButton);
            this.Controls.Add(this.assignButtonToAction);
            this.Controls.Add(this.controllersList);
            this.Controls.Add(this.buttonActionSelect);
            this.Controls.Add(this.startApplicationButton);
            this.Controls.Add(this.forceVersionCheckButton);
            this.Controls.Add(this.saveConsoleOutputButton);
            this.Controls.Add(this.consoleTextBoxBackgroundPanel);
            this.Controls.Add(this.personalisationBox);
            this.Controls.Add(this.spotterNameBox);
            this.Controls.Add(this.personalisationLabel);
            this.Controls.Add(this.spotterNameLabel);
            this.Controls.Add(this.messagesAudioDeviceLabel);
            this.Controls.Add(this.speechRecognitionDeviceLabel);
            this.Controls.Add(this.backgroundAudioDeviceLabel);
            this.Controls.Add(this.donateLink);
            this.Controls.Add(this.buttonSmokeTest);
            this.Controls.Add(this.smokeTestTextBox);
            this.Controls.Add(this.chiefNameLabel);
            this.Controls.Add(this.chiefNameBox);
            this.Name        = "MainWindow";
            this.Text        = "Crew Chief V4";
            this.Icon        = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.stopApp);
            this.Load       += new System.EventHandler(this.FormMain_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.messagesVolumeSlider)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.backgroundVolumeSlider)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
コード例 #16
0
        // Note: vast majority of startup time is in ShowDialog.  Looks like pretty much the only way to speed it up is by reducing
        // number of controls or splitting in tabs.
        public PropertiesForm(System.Windows.Forms.Form parent)
        {
            if (MainWindow.forceMinWindowSize)
            {
                this.MinimumSize = new System.Drawing.Size(995, 745);
            }

            hasChanges  = false;
            this.parent = parent;

            InitializeComponent();
            if (CrewChief.Debugging)
            {
                this.saveButton.Text = "Save (manual restart required)";
            }

            this.SuspendLayout();
            this.propertiesFlowLayoutPanel.SuspendLayout();

            int widgetCount = 0;

            foreach (SettingsProperty strProp in UserSettings.GetUserSettings().getProperties(typeof(String), null, null))
            {
                if (strProp.Name.EndsWith(PropertiesForm.listPropPostfix) && ListPropertyValues.getListBoxLabels(strProp.Name) != null)
                {
                    this.propertiesFlowLayoutPanel.Controls.Add(new ListPropertyControl(strProp.Name, Configuration.getUIString(strProp.Name) + " " + Configuration.getUIString("text_prop_type"),
                                                                                        UserSettings.GetUserSettings().getString(strProp.Name), (String)strProp.DefaultValue,
                                                                                        Configuration.getUIString(strProp.Name + "_help"), Configuration.getUIStringStrict(strProp.Name + "_filter"),
                                                                                        Configuration.getUIStringStrict(strProp.Name + "_category"), Configuration.getUIStringStrict(strProp.Name + "_type")));
                }
                else
                {
                    this.propertiesFlowLayoutPanel.Controls.Add(new StringPropertyControl(strProp.Name, Configuration.getUIString(strProp.Name) + " " + Configuration.getUIString("text_prop_type"),
                                                                                          UserSettings.GetUserSettings().getString(strProp.Name), (String)strProp.DefaultValue,
                                                                                          Configuration.getUIString(strProp.Name + "_help"), Configuration.getUIStringStrict(strProp.Name + "_filter"),
                                                                                          Configuration.getUIStringStrict(strProp.Name + "_category")));
                }
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty boolProp in UserSettings.GetUserSettings().getProperties(typeof(Boolean), "enable", null))
            {
                Boolean defaultValue;
                Boolean.TryParse((String)boolProp.DefaultValue, out defaultValue);
                this.propertiesFlowLayoutPanel.Controls.Add(new BooleanPropertyControl(boolProp.Name, Configuration.getUIString(boolProp.Name) + " " + Configuration.getUIString("boolean_prop_type"),
                                                                                       UserSettings.GetUserSettings().getBoolean(boolProp.Name), defaultValue,
                                                                                       Configuration.getUIString(boolProp.Name + "_help"), Configuration.getUIStringStrict(boolProp.Name + "_filter"),
                                                                                       Configuration.getUIStringStrict(boolProp.Name + "_category")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty intProp in UserSettings.GetUserSettings().getProperties(typeof(int), "frequency", null))
            {
                int defaultValue;
                int.TryParse((String)intProp.DefaultValue, out defaultValue);
                this.propertiesFlowLayoutPanel.Controls.Add(new IntPropertyControl(intProp.Name, Configuration.getUIString(intProp.Name) + " " + Configuration.getUIString("integer_prop_type"),
                                                                                   UserSettings.GetUserSettings().getInt(intProp.Name), defaultValue,
                                                                                   Configuration.getUIString(intProp.Name + "_help"), Configuration.getUIStringStrict(intProp.Name + "_filter"),
                                                                                   Configuration.getUIStringStrict(intProp.Name + "_category")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty boolProp in UserSettings.GetUserSettings().getProperties(typeof(Boolean), null, "enable"))
            {
                Boolean defaultValue;
                Boolean.TryParse((String)boolProp.DefaultValue, out defaultValue);
                this.propertiesFlowLayoutPanel.Controls.Add(new BooleanPropertyControl(boolProp.Name, Configuration.getUIString(boolProp.Name) + " " + Configuration.getUIString("boolean_prop_type"),
                                                                                       UserSettings.GetUserSettings().getBoolean(boolProp.Name), defaultValue,
                                                                                       Configuration.getUIString(boolProp.Name + "_help"), Configuration.getUIStringStrict(boolProp.Name + "_filter"),
                                                                                       Configuration.getUIStringStrict(boolProp.Name + "_category")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty intProp in UserSettings.GetUserSettings().getProperties(typeof(int), null, "frequency"))
            {
                int defaultValue;
                int.TryParse((String)intProp.DefaultValue, out defaultValue);
                this.propertiesFlowLayoutPanel.Controls.Add(new IntPropertyControl(intProp.Name, Configuration.getUIString(intProp.Name) + " " + Configuration.getUIString("integer_prop_type"),
                                                                                   UserSettings.GetUserSettings().getInt(intProp.Name), defaultValue,
                                                                                   Configuration.getUIString(intProp.Name + "_help"), Configuration.getUIStringStrict(intProp.Name + "_filter"),
                                                                                   Configuration.getUIStringStrict(intProp.Name + "_category")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;
            foreach (SettingsProperty floatProp in UserSettings.GetUserSettings().getProperties(typeof(float), null, null))
            {
                float defaultValue;
                float.TryParse((String)floatProp.DefaultValue, out defaultValue);
                this.propertiesFlowLayoutPanel.Controls.Add(new FloatPropertyControl(floatProp.Name, Configuration.getUIString(floatProp.Name) + " " + Configuration.getUIString("real_number_prop_type"),
                                                                                     UserSettings.GetUserSettings().getFloat(floatProp.Name), defaultValue,
                                                                                     Configuration.getUIString(floatProp.Name + "_help"), Configuration.getUIStringStrict(floatProp.Name + "_filter"),
                                                                                     Configuration.getUIStringStrict(floatProp.Name + "_category")));
                widgetCount++;
            }
            pad(widgetCount);
            widgetCount = 0;

            this.searchTextPrev               = DEFAULT_SEARCH_TEXT;
            this.gameFilterPrev               = GameEnum.UNKNOWN;
            this.specialFilterPrev            = SpecialFilter.UNKNOWN;
            this.categoryFilterPrev           = PropertyCategory.ALL; // Initialize this here, so that initial game filtering works.
            this.includeCommonPreferencesPrev = true;

            this.searchTextBox.Text       = DEFAULT_SEARCH_TEXT;
            this.searchTextBox.ForeColor  = Color.Gray;
            this.searchTextBox.GotFocus  += SearchTextBox_GotFocus;
            this.searchTextBox.LostFocus += SearchTextBox_LostFocus;
            this.searchTextBox.KeyDown   += SearchTextBox_KeyDown;
            this.exitButton.Select();

            this.KeyPreview = true;
            this.KeyDown   += PropertiesForm_KeyDown;

            this.DoubleBuffered = true;

            // Filtering setup.
            this.filterBox.Items.Clear();
            this.filterBox.Items.Add(new ComboBoxItem <SpecialFilter>()
            {
                Label = Configuration.getUIString("all_preferences_label"),
                Value = SpecialFilter.ALL_PREFERENCES
            });

            this.filterBox.Items.Add(new ComboBoxItem <SpecialFilter>()
            {
                Label = Configuration.getUIString("common_preferences_label"),
                Value = SpecialFilter.COMMON_PREFERENCES
            });

            lock (MainWindow.instanceLock)
            {
                if (MainWindow.instance != null)
                {
                    var currSelectedGameFriendlyName = MainWindow.instance.gameDefinitionList.Text;
                    foreach (var game in MainWindow.instance.gameDefinitionList.Items)
                    {
                        var friendlyGameName = game.ToString();
                        this.filterBox.Items.Add(new ComboBoxItem <GameEnum>()
                        {
                            Label = friendlyGameName,
                            Value = GameDefinition.getGameDefinitionForFriendlyName(friendlyGameName).gameEnum
                        });

                        if (friendlyGameName == currSelectedGameFriendlyName)
                        {
                            this.filterBox.SelectedIndex = this.filterBox.Items.Count - 1;
                        }
                    }
                }
            }

            // Special case for no game selected.
            if (this.filterBox.SelectedIndex == -1)
            {
                this.filterBox.SelectedIndex = 0;
                // No need to filter.
                this.specialFilterPrev = SpecialFilter.ALL_PREFERENCES;
            }

            // Category filter:
            this.categoriesBox.Items.Clear();
            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("all_categories_label"),
                Value = PropertyCategory.ALL
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("ui_startup_and_paths_category_label"),
                Value = PropertyCategory.UI_STARTUP_AND_PATHS
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("audio_voice_and_controllers_category_label"),
                Value = PropertyCategory.AUDIO_VOICE_AND_CONTROLLERS
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("spotter_category_label"),
                Value = PropertyCategory.SPOTTER
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("flags_and_rules_category_label"),
                Value = PropertyCategory.FLAGS_AND_RULES
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("message_frequences_category_label"),
                Value = PropertyCategory.MESSAGE_FREQUENCES
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("fuel_temps_and_damages_category_label"),
                Value = PropertyCategory.FUEL_TEMPS_AND_DAMAGES
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("timings_category_label"),
                Value = PropertyCategory.TIMINGS
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("pit_stops_and_multiclass_category_label"),
                Value = PropertyCategory.PIT_STOPS_AND_MULTICLASS
            });

            this.categoriesBox.Items.Add(new ComboBoxItem <PropertyCategory>()
            {
                Label = Configuration.getUIString("misc_category_label"),
                Value = PropertyCategory.MISC
            });

            this.categoriesBox.SelectedIndex = 0;

            this.categoriesBox.SelectedValueChanged += this.CategoriesBox_SelectedValueChanged;

            this.propertiesFlowLayoutPanel.ResumeLayout(false);
            this.ResumeLayout(false);
        }