private void renameButton_Click(object sender, RoutedEventArgs e) { RenameWindow renameWindow = new RenameWindow(fileListView.Items[fileListView.SelectedIndex].ToString()); renameWindow.ShowDialog(); if (renameWindow.change) { if (!renameWindow.newFileName.Contains(".rpg")) { renameWindow.newFileName += ".rpg"; } File.Delete(@"...\\Robot Programs\\" + fileListView.Items.GetItemAt(fileListView.SelectedIndex).ToString()); robotProgram.filePath = @"...\\Robot Programs\\" + renameWindow.newFileName; robotProgram.fileName = renameWindow.newFileName; robotProgram.SaveProgram(); InitialiseFileDisplay(); } }
public void AddCommand(int position, CommandType commandType) { string commandName = ""; if (commandType == CommandType.Move) { RenameWindow nameWindow = new RenameWindow(""); nameWindow.ShowDialog(); if (nameWindow.change) { commandName = nameWindow.newFileName; } } else { commandName = "Home"; } changed = true; if (position < 0) { position = 0; } commands.Insert(position, new Command(commandName, commandType)); switch (commandType) { case CommandType.Home: if (position > 0) { commands[position].startingPose = commands[position - 1].endingPose; } break; default: if (position > 0) { commands[position].startingPose = commands[position - 1].endingPose; } else { commands[position].startingPose = new Pose(); } commands[position].transition = new Transition(); if (position > 0) { for (int i = 0; i < 16; i++) { commands[position].endingPose.poseMatrix[i / 4, i % 4] = commands[position - 1].endingPose.poseMatrix[i / 4, i % 4]; } } else { commands[position].endingPose = new Pose(); for (int i = 0; i < 16; i++) { commands[position].endingPose.poseMatrix[i / 4, i % 4] = commands[position].startingPose.poseMatrix[i / 4, i % 4]; } } break; } }