상속: System.Windows.Controls.Label
예제 #1
0
 public void loadAllPairs(PairMapper pairmapper)
 {
     GridPairs.Children.Clear();
     List<Model.Pair> pairs = pairmapper.FindAllUnplanned();
     int i = 0;
     foreach (Model.Pair pair in pairs)
     {
         CustomLabel label = new CustomLabel();
         label.Id = pair.ID;
         string content = "";
         if (pair.Student2 != null)
         {
             content = pair.Student1.Firstname + " " + pair.Student1.Surname + "\n" +
                              pair.Student2.Firstname + " " + pair.Student2.Surname + "\n\n";
         }
         else
         {
             content = pair.Student1.Firstname + " " + pair.Student1.Surname + "\n\n";
         }
         string teachers = "";
         string experts = "";
         foreach (Model.User attachment in pair.Attachments)
         {//TODO: find out why attachment shows up if there isnt any...
             string name = attachment.Firstname + " " + attachment.Surname + "\n";
             if (attachment.User_type == "teacher")
                 teachers += name;
             else
                 experts += name;
         }
         label.Content = content + teachers + "\n" + experts;
         label.BorderBrush = Brushes.LightGray;
         label.BorderThickness = new Thickness(2);
         label.Margin = new Thickness(1, 1, 1, 1);
         label.MouseMove += new MouseEventHandler(pair_MouseMove);
         Grid.SetRow(label, i);
         if (GridPairs.RowDefinitions.Count != pairs.Count)
         {
             RowDefinition row = new RowDefinition();
             GridLength height = new GridLength(145);
             row.Height = height;
             GridPairs.RowDefinitions.Add(row);
         }
         GridPairs.Children.Add(label);
         i++;
     }
 }
예제 #2
0
        public static void CheckAvailability(CustomLabel currentSession, bool isSession)
        {
            //getting all blocked timeslots of all users
            List<Blocked_timeslot> blockedSlots = new List<Blocked_timeslot>();
            if (isSession)
            {
                Session s = _controller.SessionMapper.Find(currentSession.Id);
                foreach (User u in s.Pair.Participants)
                {
                    foreach (Blocked_timeslot b in u.BlockedTimeslots)
                    {
                        blockedSlots.Add(b);
                    }
                }
            }
            else
            {
                Pair p = _controller.PairMapper.Find(currentSession.Id);
                foreach (User u in p.Participants)
                {
                    foreach (Blocked_timeslot b in u.BlockedTimeslots)
                    {
                        blockedSlots.Add(b);
                    }

                }
            }

            foreach (KeyValuePair<string, Grid> keyValue in dateGrids)
            {
                Grid dateGrid = keyValue.Value;

                for (int row = 1; row <= 4; row++)
                {
                    Brush background = null;

                    foreach (Blocked_timeslot b in blockedSlots)
                    {
                        if (b.Daytime.Date.ToShortDateString() == keyValue.Key && b.Daytime.Timeslot == row)
                        {
                            //A blocked timeslot found and its a hardblock
                            if (b.Hardblock == true)
                            {
                                background = Brushes.Red;
                            }
                            //A blocked timeslot found and its not a hardblock
                            else
                            {
                                background = Brushes.Orange;
                            }

                            blockedSlots.Remove(b);
                        }
                        //if there is a blocked timslot, stop looking
                        if (background != null)
                            break;
                    }

                    //not blocked timeslots found, so all are available
                    if (background == null)
                        background = Brushes.LightGreen;

                    //set the color for the timeslot
                    for (int i = 0; i < 8; i++)
                    {
                        Label session = dateGrid.Children[i + ((row - 1) * 8)] as Label;
                        if (session != currentSession)
                        {

                            session.Background = background;
                        }
                    }
                }
            }
        }
예제 #3
0
 public void removeSessionLabel(CustomLabel session)
 {
     session.Id = 0;
     session.Content = null;
     session.ToolTip = null;
     session.BorderBrush = null;
     session.BorderThickness = new Thickness(0);
     session.MouseMove -= session_MouseMove;
     session.ContextMenu = null;
     session.AllowDrop = true;
     session.Drop += new DragEventHandler(Session_Drop);
 }
예제 #4
0
 public void removeSession(CustomLabel session)
 {
     _controller.SessionMapper.Delete(session.Id);
     removeSessionLabel(session);
 }
예제 #5
0
 public Grid HasSession(CustomLabel session)
 {
     foreach (KeyValuePair<string, Grid> pair in dateGrids)
     {
         if (pair.Value.Children.Contains(session))
             return pair.Value;
     }
     return null;
 }
예제 #6
0
        public void createCalendar(Ini.IniFile ini, List<Classroom> classrooms, PAZController controller)
        {
            _controller = controller;
            DateTime startDate = DateTime.Parse(ini["DATES"]["startdate"]);
            DateTime stopDate = DateTime.Parse(ini["DATES"]["enddate"]);
            Brush headerColor = Brushes.LightGray;
            int interval = 1;
            int rows = 0;

            //Firste column color rec
            Rectangle recC = new Rectangle();
            recC.Fill = headerColor;
            Grid.SetColumn(recC, 0);
            Grid.SetRow(recC, 0);
            Children.Add(recC);

            //Defining rowdef & row height
            RowDefinition row = new RowDefinition();
            GridLength height = new GridLength(140);

            for (DateTime dateTime = startDate; dateTime <= stopDate; dateTime += TimeSpan.FromDays(interval))
            {
                if (dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday)
                {
                    //Adding color
                    Rectangle rec = new Rectangle();
                    rec.Fill = headerColor;
                    Grid.SetColumn(rec, 0);
                    Grid.SetRow(rec, rows);
                    Grid.SetColumnSpan(rec, classrooms.Count + 1);
                    Children.Add(rec);
                    //Add labels
                    for (int c = 0; c < classrooms.Count + 1; c++)
                    {
                        if (ColumnDefinitions.Count != classrooms.Count + 1)
                        {
                            //making columns
                            ColumnDefinition column = new ColumnDefinition();
                            GridLength width;
                            if (c == 0)
                                width = new GridLength(75);
                            else
                                width = new GridLength(120);
                            column.Width = width;
                            ColumnDefinitions.Add(column);
                        }
                        //making labels
                        Label header = new Label();
                        if (c == 0)
                            header.Content = dateTime.ToString("dddd",
                      new CultureInfo("nl-NL")) + "\n" + dateTime.ToShortDateString();
                        else
                            header.Content = classrooms[c - 1].Room_number;
                        header.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                        header.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        Grid.SetColumn(header, c);
                        Grid.SetRow(header, rows);
                        Children.Add(header);
                    }

                    List<Timeslot> timeslots = controller.Timeslots;

                    //Making rows
                    for (int block = 0; block < timeslots.Count ; ++block)
                    {
                        row = new RowDefinition();
                        //blok 0 = row for headers(classrooms,date)
                        if (block == 0)
                            row.Height = new GridLength(60);
                        else
                            row.Height = height;
                        RowDefinitions.Add(row);
                        rows++;

                        Label blk = new Label();
                        blk.Content = timeslots[block].Time;
                        blk.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                        blk.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        Grid.SetColumn(blk, 0);
                        Grid.SetRow(blk, rows);
                        Children.Add(blk);
                    }

                    //Maken dateGrids
                    Grid dateGrid = new Grid();
                    for (int i = 0; i < ColumnDefinitions.Count - 1; i++)
                    {
                        ColumnDefinition column = new ColumnDefinition();
                        GridLength width = new GridLength(120);
                        column.Width = width;
                        dateGrid.ColumnDefinitions.Add(column);
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        row = new RowDefinition();
                        row.Height = height;
                        dateGrid.RowDefinitions.Add(row);
                    }

                    for (int j = 0; j < 4; j++)
                    {
                        for (int i = 0; i < dateGrid.ColumnDefinitions.Count; i++)
                        {
                            CustomLabel emptySession = new CustomLabel();
                            Grid.SetColumn(emptySession, i);
                            Grid.SetRow(emptySession, j);
                            emptySession.AllowDrop = true;
                            emptySession.Drop += new DragEventHandler(Session_Drop);
                            dateGrid.Children.Add(emptySession);
                        }
                    }
                    Grid.SetColumn(dateGrid, 1);
                    Grid.SetColumnSpan(dateGrid, dateGrid.ColumnDefinitions.Count);
                    Grid.SetRow(dateGrid, rows - 3);
                    Grid.SetRowSpan(dateGrid, dateGrid.RowDefinitions.Count);
                    dateGrid.ShowGridLines = true;
                    dateGrids.Add(dateTime.ToShortDateString(), dateGrid);
                    Children.Add(dateGrid);

                    //row block 4
                    row = new RowDefinition();
                    row.Height = height;
                    RowDefinitions.Add(row);
                    rows++;
                }
            }
            //set first column color over all rows
            Grid.SetRowSpan(recC, rows);
        }
예제 #7
0
        public static void CheckAvailability(CustomLabel currentSession, bool isSession)
        {
            //getting all blocked timeslots of all users
            List <Blocked_timeslot> blockedSlots = new List <Blocked_timeslot>();

            if (isSession)
            {
                Session s = _controller.SessionMapper.Find(currentSession.Id);
                foreach (User u in s.Pair.Participants)
                {
                    foreach (Blocked_timeslot b in u.BlockedTimeslots)
                    {
                        blockedSlots.Add(b);
                    }
                }
            }
            else
            {
                Pair p = _controller.PairMapper.Find(currentSession.Id);
                foreach (User u in p.Participants)
                {
                    foreach (Blocked_timeslot b in u.BlockedTimeslots)
                    {
                        blockedSlots.Add(b);
                    }
                }
            }


            foreach (KeyValuePair <string, Grid> keyValue in dateGrids)
            {
                Grid dateGrid = keyValue.Value;

                for (int row = 1; row <= 4; row++)
                {
                    Brush background = null;

                    foreach (Blocked_timeslot b in blockedSlots)
                    {
                        if (b.Daytime.Date.ToShortDateString() == keyValue.Key && b.Daytime.Timeslot == row)
                        {
                            //A blocked timeslot found and its a hardblock
                            if (b.Hardblock == true)
                            {
                                background = Brushes.Red;
                            }
                            //A blocked timeslot found and its not a hardblock
                            else
                            {
                                background = Brushes.Orange;
                            }

                            blockedSlots.Remove(b);
                        }
                        //if there is a blocked timslot, stop looking
                        if (background != null)
                        {
                            break;
                        }
                    }


                    //not blocked timeslots found, so all are available
                    if (background == null)
                    {
                        background = Brushes.LightGreen;
                    }

                    //set the color for the timeslot
                    for (int i = 0; i < 8; i++)
                    {
                        Label session = dateGrid.Children[i + ((row - 1) * 8)] as Label;
                        if (session != currentSession)
                        {
                            session.Background = background;
                        }
                    }
                }
            }
        }
예제 #8
0
 public void removeSession(CustomLabel session)
 {
     _controller.SessionMapper.Delete(session.Id);
     removeSessionLabel(session);
 }
예제 #9
0
        public void addSessionLabel(Session session, int newId)
        {
            CustomLabel s = addSessionLabel(session);

            s.Id = newId;
        }
예제 #10
0
        public CustomLabel addSessionLabel(Session session)
        {
            CustomLabel sessionLabel = dateGrids[session.Daytime.Date.ToShortDateString()].Children[(session.Classroom.Id - 1) + ((session.Daytime.Timeslot - 1) * 8)] as CustomLabel;

            sessionLabel.Id = session.Id;
            string[] students = new string[1];
            string[] teachers = new string[1];
            string[] experts  = new string[1];
            foreach (User user in session.Pair.Participants)
            {
                string name = user.Firstname + " " + user.Surname + ",";
                if (user.User_type == "teacher")
                {
                    teachers[0] += name;
                }
                else if (user.User_type == "student")
                {
                    students[0] += name;
                }
                else
                {
                    experts[0] += name;
                }
            }

            students = students[0].Split(',');
            if (experts[0] != null)
            {
                experts = experts[0].Split(',');
            }
            else
            {
                experts = new string[] { "GEEN EXPERTS", "" }
            };

            if (teachers[0] != null)
            {
                teachers = teachers[0].Split(',');
            }
            else
            {
                teachers = new string[] { "GEEN DOCENTEN", "" }
            };

            sessionLabel.Content         = students[0] + "\n" + students[1] + "\n\n" + teachers[0] + "\n" + teachers[1] + "\n\n" + experts[0] + "\n" + experts[1];
            sessionLabel.ToolTip         = "Studenten\n\nDocenten\n\nExperts";
            sessionLabel.BorderBrush     = Brushes.LightGray;
            sessionLabel.BorderThickness = new Thickness(2);
            sessionLabel.MouseMove      += new System.Windows.Input.MouseEventHandler(session_MouseMove);
            sessionLabel.AllowDrop       = false;
            sessionLabel.Drop           -= Session_Drop;
            sessionLabel.Background      = Brushes.White;

            //Context Menu
            System.Windows.Controls.ContextMenu editMenu = new ContextMenu();
            //edit menu
            MenuItem edit = new MenuItem();

            edit.Header = "Wijzigen";
            edit.Click += new RoutedEventHandler(edit_Click);
            editMenu.Items.Add(edit);
            //delete menu
            MenuItem delete = new MenuItem();

            delete.Header = "Verwijderen";
            delete.Click += new RoutedEventHandler(delete_Click);
            editMenu.Items.Add(delete);
            sessionLabel.ContextMenu = editMenu;
            return(sessionLabel);
        }
예제 #11
0
        public void createCalendar(Ini.IniFile ini, List <Classroom> classrooms, PAZController controller)
        {
            _controller = controller;
            DateTime startDate   = DateTime.Parse(ini["DATES"]["startdate"]);
            DateTime stopDate    = DateTime.Parse(ini["DATES"]["enddate"]);
            Brush    headerColor = Brushes.LightGray;
            int      interval    = 1;
            int      rows        = 0;

            //Firste column color rec
            Rectangle recC = new Rectangle();

            recC.Fill = headerColor;
            Grid.SetColumn(recC, 0);
            Grid.SetRow(recC, 0);
            Children.Add(recC);

            //Defining rowdef & row height
            RowDefinition row    = new RowDefinition();
            GridLength    height = new GridLength(140);

            for (DateTime dateTime = startDate; dateTime <= stopDate; dateTime += TimeSpan.FromDays(interval))
            {
                if (dateTime.DayOfWeek != DayOfWeek.Sunday && dateTime.DayOfWeek != DayOfWeek.Saturday)
                {
                    //Adding color
                    Rectangle rec = new Rectangle();
                    rec.Fill = headerColor;
                    Grid.SetColumn(rec, 0);
                    Grid.SetRow(rec, rows);
                    Grid.SetColumnSpan(rec, classrooms.Count + 1);
                    Children.Add(rec);
                    //Add labels
                    for (int c = 0; c < classrooms.Count + 1; c++)
                    {
                        if (ColumnDefinitions.Count != classrooms.Count + 1)
                        {
                            //making columns
                            ColumnDefinition column = new ColumnDefinition();
                            GridLength       width;
                            if (c == 0)
                            {
                                width = new GridLength(75);
                            }
                            else
                            {
                                width = new GridLength(120);
                            }
                            column.Width = width;
                            ColumnDefinitions.Add(column);
                        }
                        //making labels
                        Label header = new Label();
                        if (c == 0)
                        {
                            header.Content = dateTime.ToString("dddd",
                                                               new CultureInfo("nl-NL")) + "\n" + dateTime.ToShortDateString();
                        }
                        else
                        {
                            header.Content = classrooms[c - 1].Room_number;
                        }
                        header.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                        header.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        Grid.SetColumn(header, c);
                        Grid.SetRow(header, rows);
                        Children.Add(header);
                    }

                    List <Timeslot> timeslots = controller.Timeslots;

                    //Making rows
                    for (int block = 0; block < timeslots.Count; ++block)
                    {
                        row = new RowDefinition();
                        //blok 0 = row for headers(classrooms,date)
                        if (block == 0)
                        {
                            row.Height = new GridLength(60);
                        }
                        else
                        {
                            row.Height = height;
                        }
                        RowDefinitions.Add(row);
                        rows++;

                        Label blk = new Label();
                        blk.Content = timeslots[block].Time;
                        blk.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                        blk.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                        Grid.SetColumn(blk, 0);
                        Grid.SetRow(blk, rows);
                        Children.Add(blk);
                    }


                    //Maken dateGrids
                    Grid dateGrid = new Grid();
                    for (int i = 0; i < ColumnDefinitions.Count - 1; i++)
                    {
                        ColumnDefinition column = new ColumnDefinition();
                        GridLength       width  = new GridLength(120);
                        column.Width = width;
                        dateGrid.ColumnDefinitions.Add(column);
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        row        = new RowDefinition();
                        row.Height = height;
                        dateGrid.RowDefinitions.Add(row);
                    }

                    for (int j = 0; j < 4; j++)
                    {
                        for (int i = 0; i < dateGrid.ColumnDefinitions.Count; i++)
                        {
                            CustomLabel emptySession = new CustomLabel();
                            Grid.SetColumn(emptySession, i);
                            Grid.SetRow(emptySession, j);
                            emptySession.AllowDrop = true;
                            emptySession.Drop     += new DragEventHandler(Session_Drop);
                            dateGrid.Children.Add(emptySession);
                        }
                    }
                    Grid.SetColumn(dateGrid, 1);
                    Grid.SetColumnSpan(dateGrid, dateGrid.ColumnDefinitions.Count);
                    Grid.SetRow(dateGrid, rows - 3);
                    Grid.SetRowSpan(dateGrid, dateGrid.RowDefinitions.Count);
                    dateGrid.ShowGridLines = true;
                    dateGrids.Add(dateTime.ToShortDateString(), dateGrid);
                    Children.Add(dateGrid);

                    //row block 4
                    row        = new RowDefinition();
                    row.Height = height;
                    RowDefinitions.Add(row);
                    rows++;
                }
            }
            //set first column color over all rows
            Grid.SetRowSpan(recC, rows);
        }