private void autoDrive_Click(object sender, RoutedEventArgs e) { autoDriveOn = !autoDriveOn; if (!autoDriveOn) { currentAutoDriveState = AutoDriveState.None; driveStatus.Text = currentAutoDriveState.ToString(); } }
public MainWindow() { InitializeComponent(); currentAutoDriveState = AutoDriveState.None; }
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; }