private void MainForm_Load(object sender, EventArgs e)
        {
            #region Load Form Parameters from setup file.
            /* Load setup parameters for this form. */
            FormSetup.SFP my_setup = new FormSetup.SFP();
            FormSetup.SFP.FormParameters sfp = new FormSetup.SFP.FormParameters();
            /* Set setup file name. */

            my_setup.SetupFileFileName = "setup.xml";
            /* Read setup file. */
            sfp = my_setup.ReadSetupFile(this);
            if (sfp != null)
            {
                this.Left = sfp.FormPosition_Left;
                this.Top = sfp.FormPosition_Top;
                this.Height = sfp.FormHeight;
                this.Width = sfp.FormWidth;
                this.CurrentComPortName = sfp.FormComPortName;
            }
            #endregion

            #region Scan current Com ports and set Com Port name.
            /* Scan all serial ports. */
            try
            {
                /* Get list of avialabled com-ports.*/
                string[] availablePorts = SerialPort.GetPortNames();
                /* Add list of com-ports to combo box. */
                int PortIndex = 0;
                foreach (string port in availablePorts)
                {
                    if (this.CurrentComPortName == port)
                    {
                        PortIndex = comboBox1.Items.Count;
                    }
                    comboBox1.Items.Add(port);
                }
                comboBox1.Text = comboBox1.Items[PortIndex].ToString();
            }
            catch (Exception e9)
            {
                MessageBox.Show(e9.Message);
            }
            #endregion
        }
 private void Form_3D_Load(object sender, EventArgs e)
 {
     FormSetup.SFP my_setup = new FormSetup.SFP();
     FormSetup.SFP.FormParameters sfp = new FormSetup.SFP.FormParameters();
     /* Set setup file name. */
     my_setup.SetupFileFileName = "setup.xml";
     /* Read setup file. */
     sfp = my_setup.ReadSetupFile(this);
     if (sfp != null)
     {
         this.Left = sfp.FormPosition_Left;
         this.Top = sfp.FormPosition_Top;
         this.Height = sfp.FormHeight;
         this.Width = sfp.FormWidth;
     }
 }