Esempio n. 1
0
        /// <summary>
        /// Sets the radius drop down selected item to the one that is set in fsx.cfg
        /// </summary>
        public void SelectCurrentRadius(ComboBox comboBox, [Optional]string radius)
        {
            // Method variables
            string formattedRadius;

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>fsx.cfg</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                iniFile.IniPath = iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg";

                if (radius != null)
                {
                    // Format the radius
                    using (Format format = new Format())
                        formattedRadius = format.Compact(radius);

                    // Set the current selected item
                    comboBox.SelectedIndex = comboBox.FindString(formattedRadius, -1);

                    // Set the index to the first
                    if (comboBox.SelectedIndex == -1)
                        comboBox.SelectedIndex = 0;

                }
                else
                {
                    using (Format format = new Format())
                    {
                        // Set the radius to the current one in fsx.cfg
                        comboBox.SelectedIndex = comboBox.FindString(format.Compact(iniFile.ReadValue("TERRAIN", "LOD_RADIUS")), -1);

                        // Set the index to the first
                        if (comboBox.SelectedIndex == -1)
                            comboBox.SelectedIndex = 0;
                    }
                }
            }
        }