コード例 #1
0
 private void autoDrive_Click(object sender, RoutedEventArgs e)
 {
     autoDriveOn = !autoDriveOn;
     if (!autoDriveOn)
     {
         currentAutoDriveState = AutoDriveState.None;
         driveStatus.Text = currentAutoDriveState.ToString();
     }
 }
コード例 #2
0
 public MainWindow()
 {
     InitializeComponent();
     currentAutoDriveState = AutoDriveState.None;
 }
コード例 #3
0
        private void SwitchAutoDriveStates(AutoDriveState newDriveState)
        {
            if (newDriveState != AutoDriveState.None)
            {
                bufferCommandList.AddLast(newDriveState);
                if (bufferCommandList.Count > NUM_VALID_FRAMES)
                    bufferCommandList.RemoveFirst();

                if (newDriveState == AutoDriveState.Stop)
                    currentAutoDriveState = AutoDriveState.Stop;

                if (newDriveState == AutoDriveState.Forward)
                {
                    bool allForward = true;
                    foreach (var item in bufferCommandList)
                    {
                        if (item != AutoDriveState.Forward)
                        {
                            allForward = false;
                            break;
                        }
                    }
                    if (allForward == true)
                        currentAutoDriveState = AutoDriveState.Forward;
                }
            }
            else
                currentAutoDriveState = AutoDriveState.None;
        }