//Create a new sector when the user clicks the enter key public void NewSector(object sender, KeyEventArgs e) { if (Keyboard.IsKeyDown(Key.Enter)) { //Set up a new sector field sectorPosition++; teamNumber = 1; ShiftLine newShift = new ShiftLine(currentShift); newShift.getSectorNameTextBox().KeyDown += NewSector; RowDefinition sectorRowDefinition = new RowDefinition(); sectorRowDefinition.Height = new GridLength(50); Shifts_grid.RowDefinitions.Add(sectorRowDefinition); Shifts_grid.Children.Add(newShift.getSectorNameTextBox()); Grid.SetRow(newShift.getSectorNameTextBox(), sectorPosition); sectorMap.Add("Sector" + (sectorPosition - 1).ToString(), newShift.getSectorNameTextBox()); //Add a new row of teams Shifts_grid.Children.Add(newShift.getTeamNameTextBox()); Grid.SetRow(newShift.getTeamNameTextBox(), sectorPosition); Grid.SetColumn(newShift.getTeamNameTextBox(), 1); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorPosition - 1).ToString(), newShift.getTeamNameTextBox()); for (int i = 0; i < columnPosition - 1; i++) { teamNumber++; ShiftLine newShift3 = new ShiftLine(currentShift); Shifts_grid.Children.Add(newShift3.getTeamNameTextBox()); Grid.SetColumn(newShift3.getTeamNameTextBox(), i + 2); Grid.SetRow(newShift3.getTeamNameTextBox(), sectorPosition); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorPosition - 1).ToString(), newShift3.getTeamNameTextBox()); } } }
//Initialize the shift form private void PopulateShiftForm() { //Set up default shift properties currentShift = new Shift("-", "-", shiftDuration); shiftline = new ShiftLine(currentShift); shiftline.getStartTimeButton().Click += NextShiftTime; shiftline.getSectorNameTextBox().KeyDown += NewSector; RowDefinition sectorRowDefinition = new RowDefinition(); sectorRowDefinition.Height = new GridLength(50); Shifts_grid.RowDefinitions.Add(sectorRowDefinition); //populate sector Shifts_grid.Children.Add(shiftline.getSectorNameTextBox()); Grid.SetColumn(shiftline.getSectorNameTextBox(), 0); Grid.SetRow(shiftline.getSectorNameTextBox(), rowPosition); Grid.SetColumn(shiftline.getSectorNameBorder(), 0); Grid.SetRow(shiftline.getSectorNameBorder(), rowPosition); sectorMap.Add("Sector" + (rowPosition - 1).ToString(), shiftline.getSectorNameTextBox()); //populate team Shifts_grid.Children.Add(shiftline.getTeamNameTextBox()); Grid.SetColumn(shiftline.getTeamNameTextBox(), columnPosition); Grid.SetRow(shiftline.getTeamNameTextBox(), rowPosition); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorPosition - 1), shiftline.getTeamNameTextBox()); //populate time Shifts_grid.Children.Add(shiftline.getStartTimeBorder()); Grid.SetColumn(shiftline.getStartTimeBorder(), columnPosition); Grid.SetRow(shiftline.getStartTimeBorder(), 1); shiftStartTimeMap.Add("Start Time " + (columnPosition).ToString(), TextBoxHandler.textboxArray(shiftline.getStartTimeHHTextBox(), shiftline.getStartTimeMMTextBox())); }