示例#1
0
        /// <summary>
        /// Changes the position of window elements based on the type of driver.
        /// </summary>
        private void PrepLayout()
        {
            chkBoxDriveWheel.Hide();
            rbCAN.Hide();
            rbPWM.Hide();

            if (cmbJointDriver.SelectedIndex <= 0)      //If the joint is not driven
            {
                grpDriveOptions.Visible = false;
                tabsMeta.TabPages.Clear();
            }
            else
            {
                JointDriverType cType = typeOptions[cmbJointDriver.SelectedIndex - 1];
                lblPort.Text     = cType.GetPortType(rbCAN.Checked) + " Port" + (cType.HasTwoPorts() ? "s" : "");
                txtPort2.Visible = cType.HasTwoPorts();

                txtPort1.Maximum        = txtPort2.Maximum = cType.GetPortMax(rbCAN.Checked);
                grpDriveOptions.Visible = true;

                if (cType.IsMotor())
                {
                    tabsMeta.Visible = true;
                    tabsMeta.TabPages.Clear();
                    tabsMeta.TabPages.Add(metaWheel);
                    tabsMeta.TabPages.Add(metaGearing);
                    tabsMeta.TabPages.Add(metaBrake);
                    tabsMeta.TabPages.Add(metaMotorType);
                    chkBoxDriveWheel.Show();
                    rbCAN.Show();
                    rbPWM.Show();
                }
                else if (cType.IsPneumatic())
                {
                    tabsMeta.Visible = true;
                    tabsMeta.TabPages.Clear();
                    tabsMeta.TabPages.Add(metaPneumatic);
                    tabsMeta.TabPages.Add(metaBrake);
                }
                else if (cType.IsElevator())
                {
                    tabsMeta.Visible = true;
                    tabsMeta.TabPages.Clear();
                    tabsMeta.TabPages.Add(metaBrake);
                    chkBoxHasBrake.Show();

                    rbCAN.Show();
                    rbPWM.Show();
                }
                else if (cType.IsWormScrew())
                {
                    rbCAN.Show();
                    rbPWM.Show();
                }
                else
                {
                    tabsMeta.TabPages.Clear();
                    tabsMeta.Visible = false;
                }
            }
            // Set window size
            tabsMeta.Visible = tabsMeta.TabPages.Count > 0;
        }
示例#2
0
 /// <summary>
 /// Changes the position of window elements based on the type of driver.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void DriveChooser_Layout(object sender, LayoutEventArgs e)
 {
     chkBoxDriveWheel.Hide();
     chkBoxHasBrake.Hide();
     rbCAN.Hide();
     rbPWM.Hide();
     if (cmbJointDriver.SelectedIndex <= 0)      //If the joint is not driven
     {
         grpDriveOptions.Visible = false;
         tabsMeta.TabPages.Clear();
     }
     else
     {
         JointDriverType cType = typeOptions[cmbJointDriver.SelectedIndex - 1];
         lblPort.Text            = cType.GetPortType() + " Port" + (cType.HasTwoPorts() ? "s" : "");
         txtPortB.Visible        = cType.HasTwoPorts();
         txtPortA.Maximum        = txtPortB.Maximum = cType.GetPortMax();
         grpDriveOptions.Visible = true;
         if (cType.IsMotor())
         {
             tabsMeta.Visible = true;
             tabsMeta.TabPages.Clear();
             tabsMeta.TabPages.Add(metaWheel);
             tabsMeta.TabPages.Add(metaGearing);
             chkBoxDriveWheel.Show();
             rbCAN.Show();
             rbPWM.Show();
             rbPWM.Checked = true;
         }
         else if (cType.IsPneumatic())
         {
             tabsMeta.Visible = true;
             tabsMeta.TabPages.Clear();
             tabsMeta.TabPages.Add(metaPneumatic);
         }
         else if (cType.IsElevator())
         {
             tabsMeta.Visible     = true;
             lblBrakePort.Enabled = false;
             brakePortA.Enabled   = false;
             brakePortB.Enabled   = false;
             tabsMeta.TabPages.Clear();
             chkBoxHasBrake.Show();
             tabsMeta.TabPages.Add(metaElevatorBrake);
             tabsMeta.TabPages.Add(metaElevatorStages);
             tabsMeta.TabPages.Add(metaGearing);
             if (cmbStages.SelectedIndex == -1)
             {
                 cmbStages.SelectedIndex = 0;
             }
         }
         else
         {
             tabsMeta.TabPages.Clear();
             tabsMeta.Visible = false;
         }
     }
     // Set window size
     tabsMeta.Visible = tabsMeta.TabPages.Count > 0;
     btnSave.Top      = tabsMeta.TabPages.Count > 0 ? tabsMeta.Bottom + 3 : (grpDriveOptions.Visible ? grpDriveOptions.Bottom + 3 : grpChooseDriver.Bottom + 3);
     base.Height      = btnSave.Bottom + 3 + (base.Height - base.ClientSize.Height);
 }