// Focus element of pickers set in Views - Cannot be set in viewmodel without passing entire object private void StartTimeBtn_Tapped(object sender, EventArgs e) { if (createEventViewModel.AllDay != true) { StartTimePicker.Focus(); } }
public void inicijalizacijaDialoga(Subject subject) { int rowIndex = MWindow.SelectedElement.SelectedIndex; int columnIndex = Grid.GetColumn(MWindow.SelectedElement); if (rowIndex == -1) { return; } int preracunatRowIndex = perarcunajListviewStartRowNaLeftGridStartRow(rowIndex, columnIndex); string startTime = (MWindow.LeftGrid.Children[preracunatRowIndex] as TextBlock).Text.Split('-')[0].Trim(); int rowSpan; if (this.OldTermForUpdate == null) { rowSpan = MWindow.ObservableList[columnIndex][rowIndex].RowSpan; } else { rowSpan = this.OldTermForUpdate.RowSpan; } string endTime = (MWindow.LeftGrid.Children[preracunatRowIndex + rowSpan - 1] as TextBlock).Text.Split('-')[1].Trim(); int classRoomSelectedIndex = columnIndex % NumOfClassRooms; double a = columnIndex / NumOfClassRooms; int daySelectedIndex = Convert.ToInt32(Math.Floor(a)); // floor zaokruzuje na najblizi manji broj selectSubject(subject); StartTimePicker.setHoursAndMinutes(startTime); EndTimePicker.setHoursAndMinutes(endTime); (ComboDay.Items[daySelectedIndex] as ComboBoxItem).IsSelected = true; selectClassRoom(classRoomSelectedIndex); }
private void saveClick(object sender, RoutedEventArgs e) { //MWindow.SelectedElement.SelectedItems.Clear(); //MWindow.SelectedElement = null; Classroom classroom = MWindow.Classrooms[ComboClassRoom.SelectedIndex]; Subject subject = ListSubjects[ComboSubject.SelectedIndex]; if (!MWindow.ClassroomMatchSubjectNeeds(classroom, subject)) { return; } string time1Str = StartTimePicker.getTime(); string time2Str = EndTimePicker.getTime(); TimeSpan time1; bool time1Bool = TimeSpan.TryParse(time1Str, out time1); TimeSpan time2; bool time2Bool = TimeSpan.TryParse(time2Str, out time2); TimeSpan difference = time2 - time1; if (difference.TotalMinutes < subject.MinNumOfClassesPerTerm * 45) { MessageBox.Show("Number of minimum classes is " + subject.MinNumOfClassesPerTerm + "!"); return; } if (!checkTimes(time1Bool, time2Bool, time1, time2)) { return; } int columnDay = MainWindow.GetColumnForDay(MWindow.TopTopGrid, ComboDay.Text); int columnClassRoom = MainWindow.GetColumnForClassRoom(MWindow.TopBottomGrid, ComboClassRoom.Text, columnDay, NumOfClassRooms); // ovo dodavanje crtica smo uveli da bismo znali da razlikujemo da li se radi o pocetku ili kraju termina int startRow = MainWindow.GetRowForTime(MWindow.LeftGrid, time1Str + " -"); int endRow = MainWindow.GetRowForTime(MWindow.LeftGrid, "- " + time2Str); int rowSpan = endRow - startRow + 1; int preracunatStartRow = perarcunajStartRowNaListviewStartRow(startRow, columnClassRoom); int preracunatEndRow = preracunatStartRow + rowSpan - 1; if (daLiJeZauzetNekiDeoTermina(preracunatStartRow, preracunatEndRow, columnClassRoom)) { return; } if (this.OldTermForUpdate != null) { MWindow.obrisiTerminiUbaciPrazneTermine(this.OldTermForUpdate, this.OldTermForUpdateRow, this.OldTermForUpdateColumn); ComputerCentre.context.SaveChanges(); preracunatStartRow = perarcunajStartRowNaListviewStartRow(startRow, columnClassRoom); } Term oldTerm = MWindow.ObservableList[columnClassRoom][preracunatStartRow]; Term newTerm = new Term(time1, time2, subject, oldTerm.Day, oldTerm.ClassroomIndex, rowSpan); obrisiPrazneTermine(columnClassRoom, preracunatStartRow, rowSpan); newTerm = ComputerCentre.context.Terms.Add(newTerm); ComputerCentre.context.SaveChanges(); MWindow.ObservableList[columnClassRoom].Insert(preracunatStartRow, newTerm); this.Close(); }