Exemple #1
0
 public Booking(TimeSlot Time, List<Room> Rooms, Subject Subject, List<Student> Students, Teacher Teacher, BookingType BookingType)
 {
     TimeSlot = Time;
     this.Rooms = Rooms;
     this.Subject = Subject;
     this.Students = Students;
     this.Teacher = Teacher;
     this.BookingType = BookingType;
 }
        public TimetableTile(Booking Booking, TimeSlot Time, Room Room, User CurrentUser)
        {
            // Sets UI bindings to reference this object
            DataContext = this;

            this.Booking = Booking;
            this.Time = Time;
            this.Room = Room;

            // Set the default brightness function to the default
            BrightnessCurve = DefaultBrightnessCurve;

            // Default to the background window colour
            Brush = SystemColors.WindowBrush;
            if (Booking != null) // If there's actually a booking in this slot, use its colour
                Brush = new SolidColorBrush(Booking.Subject.Colour);
            Background = Brush;

            // Initialise the UI
            InitializeComponent();

            // Hook up mouse events
            MouseEnter += TimetableTile_MouseEnter;
            MouseLeave += TimetableTile_MouseLeave;

            // If there's a booking in this slot
            if (Booking != null && CurrentUser != null)
            {
                // If the current user is somehow involved in the booking (either
                // as a student or teacher)
                if (((CurrentUser is Student) && Booking.Students.Any(s => s.Id == CurrentUser.Id)) ||
                    ((CurrentUser is Teacher) && Booking.Teacher.Id == CurrentUser.Id))
                {
                    // Do a simple animation on the tiles to draw attention
                    Storyboard PulseEffect = (Storyboard)Resources["PulseEffect"];
                    PulseEffect.Begin(Outer);
                }
            }
        }
Exemple #3
0
 public override void Update(DataModel Other)
 {
     // Copy data from other item into this
     Booking b = (Booking)Other;
     Ticks = b.Ticks;
     BookingType = b.BookingType;
     TimeSlot = b.TimeSlot;
     Rooms = b.Rooms;
     Subject = b.Subject;
     Students.Clear();
     Students.AddRange(b.Students);
     Teacher = b.Teacher;
 }
Exemple #4
0
        // Deserialise from an input stream
        protected override void Deserialise(Reader In)
        {
            base.Deserialise(In);

            Ticks = In.ReadInt64();
            BookingType = (BookingType)In.ReadInt32();
            TimeSlot = new TimeSlot() { Id = In.ReadInt32() };
            Rooms = new List<Room>(In.ReadInt32());
            for (int x = 0; x < Rooms.Capacity; x++)
                Rooms.Add(new Room() { Id = In.ReadInt32() });
            Subject = new Subject() { Id = In.ReadInt32() };
            Students = new List<Student>(In.ReadInt32());
            for (int x = 0; x < Students.Capacity; x++)
                Students.Add(new Student() { Id = In.ReadInt32() });
            Teacher = new Teacher() { Id = In.ReadInt32() };
        }
Exemple #5
0
 // Obtain references to related objects
 public override bool Expand(IDataRepository Repo)
 {
     try
     {
         TimeSlot = Repo.Periods.SingleOrDefault(t => t.Id == TimeSlot.Id);
         for (int x = 0; x < Rooms.Count; x++)
             Rooms[x] = Repo.Rooms.SingleOrDefault(r => Rooms[x].Id == r.Id);
         Subject = Repo.Subjects.SingleOrDefault(s => s.Id == Subject.Id);
         for (int x = 0; x < Students.Count; x++)
             Students[x] = (Student)Repo.Users.SingleOrDefault(s => Students[x].Id == s.Id);
         Teacher = (Teacher)Repo.Users.SingleOrDefault(t => t.Id == Teacher.Id);
     }
     catch
     {
         return false;
     }
     return true;
 }