public WindowClassroomList(RentTable r, WindowIndex ff) { InitializeComponent(); rentTable = r; father = ff; }
private RentTable rentTable; //教室使用情况 #endregion Fields #region Constructors public Classroom(int id, string name, Building building, RentTable rentTable = null) { this.cid = id; this.name = name; this.building = building; this.rentTable = rentTable; }
//初始化课表 private void ScheduleInitialize(Grid grid, RentTable rentTable, List <TextBlock> textBlockList, Label chosen) { foreach (TextBlock tb in textBlockList) { if (grid.Children.Contains(tb)) { grid.Children.Remove(tb); } } textBlockList.Clear(); foreach (Rent r in rentTable.Rents) { TextBlock tb = new TextBlock(); grid.Children.Add(tb); textBlockList.Add(tb); TextBlockInitialize(tb, r); } chosen.Visibility = Visibility.Visible; if (grid.Children.Contains(chosen)) { grid.Children.Remove(chosen); } grid.Children.Add(chosen); SetDateClass(CurrDate, CurrClass); }
public void RefreshSchedule() { schedule1 = DatabaseLinker.GetPersonRentTable(person.pId); ScheduleInitialize(GridSchedule1, schedule1, TextBlockRents1, RectangleChosonClass1); if (classroom != null) { schedule2 = DatabaseLinker.GetClassroomRentTable(classroom.cId); ScheduleInitialize(GridSchedule2, schedule2, TextBlockRents2, RectangleChosonClass2); } }
//按照周数更新课程表 private void ScheduleCheckoutWeek(RentTable rentTable, List <TextBlock> TBList) { DateTime date = RentTime.FirstDate + new TimeSpan(7 * (CurrWeek - 1), 0, 0, 0); if (rentTable == null) { return; } List <Rent> list = rentTable.GetFromWeek(date); foreach (TextBlock tb in TBList) { if (list.Contains((Rent)tb.Tag)) { tb.Visibility = Visibility.Visible; } else { tb.Visibility = Visibility.Collapsed; } } }
//全体键盘托管 private void Window_PreviewKeyDown_1(object sender, KeyEventArgs e) { //换肤 switch (e.Key) { case Key.F1: SetSkin(skin.Starry); break; case Key.F2: SetSkin(skin.ColorBox); break; case Key.D1: SetStatus(status.Info); break; case Key.D2: SetStatus(status.Table); break; case Key.D3: RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass)); new WindowClassroomList(rt, this).ShowDialog(); break; case Key.D4: SetStatus(status.Message); break; } switch (currStatus) { case status.Table: //课程表控制 if (!TextBoxCId.IsKeyboardFocused) { switch (e.Key) { case Key.Up: if (Schedule.CurrClass > 1) { --Schedule.CurrClass; } break; case Key.Down: if (Schedule.CurrClass < cntRow) { ++Schedule.CurrClass; } break; case Key.Left: if (Schedule.CurrDate > RentTime.FirstDate) { Schedule.CurrDate -= new TimeSpan(1, 0, 0, 0); } break; case Key.Right: if (Schedule.CurrDate < RentTime.LastDate) { Schedule.CurrDate += new TimeSpan(1, 0, 0, 0); } break; case Key.Home: Schedule.CurrClass = 1; break; case Key.End: Schedule.CurrClass = cntRow; break; case Key.PageUp: if (Schedule.CurrWeek > 1) { Schedule.CurrDate -= new TimeSpan(7, 0, 0, 0); } break; case Key.PageDown: if (Schedule.CurrWeek < 23) { Schedule.CurrDate += new TimeSpan(7, 0, 0, 0); } break; case Key.Enter: Rent r = sch1.ChosenRent; if (r == null) { break; } new WindowRent(r, this).ShowDialog(); break; } SetDateClass(Schedule.CurrDate, Schedule.CurrClass); } else //教室控制 { int b, c; if (classroom == null) { b = 0; c = 0; } else { b = classroom.Building.bId; c = classroom.cId; } switch (e.Key) { case Key.Up: while (c < Classroom.MaxCId) { ++c; if (Building.GetClassroom(c) != null) { break; } } break; case Key.Down: while (c > Classroom.MinCId) { --c; if (Building.GetClassroom(c) != null) { break; } } break; case Key.PageUp: while (b < Building.MaxBId) { ++b; if (Building.GetBuilding(b) != null) { c = Building.GetBuilding(b).Classrooms[0].cId; break; } } break; case Key.PageDown: while (b > Building.MinBId) { --b; if (Building.GetBuilding(b) != null) { c = Building.GetBuilding(b).Classrooms[0].cId; break; } } break; } SetCId(c); } break; } }
private void LabelClassroom_MouseDown(object sender, MouseButtonEventArgs e) { RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass)); new WindowClassroomList(rt, this).ShowDialog(); }
//全体键盘托管 private void Window_PreviewKeyDown_1(object sender, KeyEventArgs e) { //换肤 switch (e.Key) { case Key.F1: SetSkin(skin.Starry); break; case Key.F2: SetSkin(skin.ColorBox); break; case Key.D1: SetStatus(status.Info); break; case Key.D2: SetStatus(status.Table); break; case Key.D3: RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass)); new WindowClassroomList(rt, this).ShowDialog(); break; case Key.D4: SetStatus(status.Message); break; } switch (currStatus) { case status.Table: //课程表控制 if (!TextBoxCId.IsKeyboardFocused) { switch (e.Key) { case Key.Up: if (Schedule.CurrClass > 1) --Schedule.CurrClass; break; case Key.Down: if (Schedule.CurrClass < cntRow) ++Schedule.CurrClass; break; case Key.Left: if (Schedule.CurrDate > RentTime.FirstDate) Schedule.CurrDate -= new TimeSpan(1, 0, 0, 0); break; case Key.Right: if (Schedule.CurrDate < RentTime.LastDate) Schedule.CurrDate += new TimeSpan(1, 0, 0, 0); break; case Key.Home: Schedule.CurrClass = 1; break; case Key.End: Schedule.CurrClass = cntRow; break; case Key.PageUp: if (Schedule.CurrWeek > 1) Schedule.CurrDate -= new TimeSpan(7, 0, 0, 0); break; case Key.PageDown: if (Schedule.CurrWeek < 23) Schedule.CurrDate += new TimeSpan(7, 0, 0, 0); break; case Key.Enter: Rent r = sch1.ChosenRent; if (r == null) break; new WindowRent(r, this).ShowDialog(); break; } SetDateClass(Schedule.CurrDate, Schedule.CurrClass); } else //教室控制 { int b, c; if (classroom == null) { b = 0; c = 0; } else { b = classroom.Building.bId; c = classroom.cId; } switch (e.Key) { case Key.Up: while (c < Classroom.MaxCId) { ++c; if (Building.GetClassroom(c) != null) break; } break; case Key.Down: while (c > Classroom.MinCId) { --c; if (Building.GetClassroom(c) != null) break; } break; case Key.PageUp: while (b < Building.MaxBId) { ++b; if (Building.GetBuilding(b) != null) { c = Building.GetBuilding(b).Classrooms[0].cId; break; } } break; case Key.PageDown: while (b > Building.MinBId) { --b; if (Building.GetBuilding(b) != null) { c = Building.GetBuilding(b).Classrooms[0].cId; break; } } break; } SetCId(c); } break; } }
//设置教室。在教室发生变化的时候切换UI private void SetCId(int cId) { Classroom C = Building.GetClassroom(cId); if (null == C) return; if (classroom != null && classroom.cId == C.cId) return; classroom = C; schedule2 = DatabaseLinker.GetClassroomRentTable(cId); LabelClassroom.Content = classroom.Name + "的第" + currWeek + "周"; ScheduleInitialize(GridSchedule2, schedule2, TextBlockRents2, RectangleChosonClass2); ChosenRentControl(); }
//初始化课表 private void ScheduleInitialize(Grid grid, RentTable rentTable, List<TextBlock> textBlockList, Label chosen) { foreach (TextBlock tb in textBlockList) if (grid.Children.Contains(tb)) grid.Children.Remove(tb); textBlockList.Clear(); foreach (Rent r in rentTable.Rents) { TextBlock tb = new TextBlock(); grid.Children.Add(tb); textBlockList.Add(tb); TextBlockInitialize(tb, r); } chosen.Visibility = Visibility.Visible; if (grid.Children.Contains(chosen)) grid.Children.Remove(chosen); grid.Children.Add(chosen); SetDateClass(currDate, currClass); checkoutWeek(); }
//按照周数更新课程表 private void ScheduleCheckoutWeek(RentTable rentTable, List<TextBlock> TBList) { DateTime date = firstDate + new TimeSpan(7 * (currWeek - 1), 0, 0, 0); if (rentTable == null) return; List<Rent> list = rentTable.GetFromWeek(date); foreach (TextBlock tb in TBList) if (list.Contains((Rent)tb.Tag)) tb.Visibility = Visibility.Visible; else tb.Visibility = Visibility.Collapsed; }
//页面加载 private void Grid_Loaded_1(object sender, RoutedEventArgs e) { Building.Initialize(); headInitialize(); schedule1 = DatabaseLinker.GetPersonRentTable(person.pId); ScheduleInitialize(GridSchedule1, schedule1, TextBlockRents1, RectangleChosonClass1); if (chosenRent1 != null) SetCId(chosenRent1.cId); }