//全体键盘托管 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(); }