Пример #1
0
        private void Configuration_Load(object sender, EventArgs e)
        {
            startup = true;

            // enable disable relevbant hardware tabs
            if (MainV2.APMFirmware == MainV2.Firmwares.ArduPlane)
            {
                ConfigTabs.SelectedIndex = 0;
                TabAPM2.Enabled          = true;
                TabAC2.Enabled           = false;
            }
            else
            {
                ConfigTabs.SelectedIndex = 1;
                TabAPM2.Enabled          = false;
                TabAC2.Enabled           = true;
            }

            // read tooltips
            if (tooltips.Count == 0)
            {
                readToolTips();
            }

            // prefill all fields
            param = MainV2.comPort.param;
            processToScreen();



            // setup up camera button states
            if (MainV2.cam != null)
            {
                BUT_videostart.Enabled = false;
                CHK_hudshow.Checked    = GCSViews.FlightData.myhud.hudon;
            }
            else
            {
                BUT_videostart.Enabled = true;
            }

            // setup speech states
            if (MainV2.config["speechenable"] != null)
            {
                CHK_enablespeech.Checked = bool.Parse(MainV2.config["speechenable"].ToString());
            }
            if (MainV2.config["speechwaypointenabled"] != null)
            {
                CHK_speechwaypoint.Checked = bool.Parse(MainV2.config["speechwaypointenabled"].ToString());
            }
            if (MainV2.config["speechmodeenabled"] != null)
            {
                CHK_speechmode.Checked = bool.Parse(MainV2.config["speechmodeenabled"].ToString());
            }
            if (MainV2.config["speechcustomenabled"] != null)
            {
                CHK_speechcustom.Checked = bool.Parse(MainV2.config["speechcustomenabled"].ToString());
            }
            if (MainV2.config["speechbatteryenabled"] != null)
            {
                CHK_speechbattery.Checked = bool.Parse(MainV2.config["speechbatteryenabled"].ToString());
            }
            if (MainV2.config["speechaltenabled"] != null)
            {
                CHK_speechaltwarning.Checked = bool.Parse(MainV2.config["speechaltenabled"].ToString());
            }

            // this can't fail because it set at startup
            NUM_tracklength.Value = int.Parse(MainV2.config["NUM_tracklength"].ToString());

            // get wps on connect
            if (MainV2.config["loadwpsonconnect"] != null)
            {
                CHK_loadwponconnect.Checked = bool.Parse(MainV2.config["loadwpsonconnect"].ToString());
            }

            // setup other config state
            if (MainV2.config["CHK_resetapmonconnect"] != null)
            {
                CHK_resetapmonconnect.Checked = bool.Parse(MainV2.config["CHK_resetapmonconnect"].ToString());
            }

            CMB_rateattitude.Text = MainV2.cs.rateattitude.ToString();
            CMB_rateposition.Text = MainV2.cs.rateposition.ToString();
            CMB_raterc.Text       = MainV2.cs.raterc.ToString();
            CMB_ratestatus.Text   = MainV2.cs.ratestatus.ToString();


            if (MainV2.config["CHK_GDIPlus"] != null)
            {
                CHK_GDIPlus.Checked = bool.Parse(MainV2.config["CHK_GDIPlus"].ToString());
            }

            //set hud color state
            string hudcolor = (string)MainV2.config["hudcolor"];

            CMB_osdcolor.DataSource = Enum.GetNames(typeof(KnownColor));
            if (hudcolor != null)
            {
                int index = CMB_osdcolor.Items.IndexOf(hudcolor);
                CMB_osdcolor.SelectedIndex = index;
            }
            else
            {
                int index = CMB_osdcolor.Items.IndexOf("White");
                CMB_osdcolor.SelectedIndex = index;
            }

            // set distance/speed unit states
            CMB_distunits.DataSource  = Enum.GetNames(typeof(Common.distances));
            CMB_speedunits.DataSource = Enum.GetNames(typeof(Common.speeds));
            if (MainV2.config["distunits"] != null)
            {
                CMB_distunits.Text = MainV2.config["distunits"].ToString();
            }
            if (MainV2.config["speedunits"] != null)
            {
                CMB_speedunits.Text = MainV2.config["speedunits"].ToString();
            }

            // setup language selection
            CultureInfo ci = null;

            foreach (string name in new string[] { "en-US", "zh-Hans", "zh-TW", "ru-RU", "Fr" })
            {
                ci = MainV2.getcultureinfo(name);
                if (ci != null)
                {
                    languages.Add(ci);
                }
            }

            CMB_language.DisplayMember = "DisplayName";
            CMB_language.DataSource    = languages;
            bool match = false;

            for (int i = 0; i < languages.Count && !match; i++)
            {
                ci = Thread.CurrentThread.CurrentUICulture;
                while (!ci.Equals(CultureInfo.InvariantCulture))
                {
                    if (ci.Equals(languages[i]))
                    {
                        CMB_language.SelectedIndex = i;
                        match = true;
                        break;
                    }
                    ci = ci.Parent;
                }
            }
            CMB_language.SelectedIndexChanged += CMB_language_SelectedIndexChanged;

            startup = false;
        }