Exemplo n.º 1
0
        private void Control_ConnectToStage(object sender, EventArgs e)
        {
            if (stage.TryAutoConnect())
            {
                DisplayStageErrors();

                //Show buttons
                setEnableStageControls(true);
                UpdateAllStageValues();

                bool homed;
                if (stage.TrySendCommand(new MotorizedStage.Commands.Home(1, true), out homed))
                {
                    DisplayStageErrors();
                    if (homed == false)
                    {
                        //Hasn't been homed, ask user if they wish to home.
                        if (MessageBox.Show("Stage has not been homed yet, would you like to home it now?", "Stage Not Homed", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            if (stage.FindHome() == HomingStatus.Initiated)
                            {
                                MessageBox.Show("Homed successfully!");
                            }
                            else
                            {
                                MessageBox.Show("Something went wrong.");
                            }
                            return;                             //No matter what happenes, the user already knowns it was connected, so dont prompt again.
                        }
                    }
                }

                MessageBox.Show("Connected!");
            }
            else
            {
                MessageBox.Show("Unable to connect.");
            }
        }