/// <summary> /// The user has changed the name of the route in the route list /// </summary> /// /// This function is called when the name of the route changes. This /// may be called before the user has completed the change. /// /// This function will push the name back into the data store. /// /// <param name="sender"></param> /// <param name="e"></param> /// private void ProgramModeEntry_TextChanged(object sender, TextChangedEventArgs e) { AutonomousRoute mode = SelectedProgram; if (mode != null) { TextBox editBox = sender as TextBox; mode.Name = editBox.Text; ProgramPnl.ProgramNameLabel = mode.Name; } }
/// <summary> /// User requested to move current route down by one /// </summary> /// /// This function moves the current selected route down one space in /// the route list. /// /// <param name="sender"></param> /// <param name="e"></param> /// private void DownBtn_Click(object sender, RoutedEventArgs e) { if ((ProgramModeLB.SelectedIndex >= 0) && (ProgramModeLB.SelectedIndex < ProgramModeLB.Items.Count - 1)) { int index = ProgramModeLB.SelectedIndex; AutonomousRoute item = mProgramModes.AutonomousModes[index]; mProgramModes.AutonomousModes.RemoveAt(index); mProgramModes.AutonomousModes.Insert(index + 1, item); ProgramModeLB.SelectedIndex = index + 1; } }
/// <summary> /// The user has changed the selection of the auto route. /// </summary> /// /// This function will update the route steps listbox to display /// those belonging to the newly selected route. /// /// <param name="sender"></param> /// <param name="e"></param> /// private void ProgramModeLB_SelectionChanged(object sender, SelectionChangedEventArgs e) { AutonomousRoute selectedMode = SelectedProgram; // display the new program mode in the right side panel if (selectedMode != null) { ProgramPnl.ProgramNameLabel = selectedMode.Name; ProgramPnl.Commands = selectedMode.Commands; } }
/// <summary> /// Add a new route to the route list /// </summary> /// /// Adds a new empty route to the route list. The insertion /// occurs wherever the user has currently selected a route /// in the route list. If no route is currently selected /// the new route will be appended. /// /// <param name="sender"></param> /// <param name="e"></param> /// private void AddBtn_Click(object sender, RoutedEventArgs e) { AutonomousRoute mode = new AutonomousRoute("new"); if ((ProgramModeLB.SelectedIndex >= 0) && (ProgramModeLB.SelectedIndex < ProgramModeLB.Items.Count)) { mProgramModes.AutonomousModes.Insert(ProgramModeLB.SelectedIndex + 1, mode); } else { mProgramModes.AutonomousModes.Add(mode); } }
/// <summary> /// User requested to move current route up by one /// </summary> /// /// This function moves the current selected route up one space in /// the route list. /// /// <param name="sender"></param> /// <param name="e"></param> /// private void UpBtn_Click(object sender, RoutedEventArgs e) { // if the index is set and greater than the first element // move it up if (ProgramModeLB.SelectedIndex > 0) { int index = ProgramModeLB.SelectedIndex; AutonomousRoute item = mProgramModes.AutonomousModes[index]; mProgramModes.AutonomousModes.RemoveAt(index); mProgramModes.AutonomousModes.Insert(index - 1, item); ProgramModeLB.SelectedIndex = index - 1; } }