Exemplo n.º 1
0
        private void InitializeTeachers()
        {
            TeachersNamesTable.Clear();
            TeacherBackup.Clear();
            TeachersInGrade = Attendance.TeachersOfGrade(ClassName);

            /*
             * if (TeachersInGrade.Count == 0)
             * {
             *  NotFoundStack.IsVisible = true;
             * }*/

            int    count  = 0;
            string filter = StudentSearch.Text == null ? "" : StudentSearch.Text.Trim().ToLower();

            foreach (var t in TeachersInGrade)
            {
                ViewCell cell = new ViewCell()
                {
                    Height = 70,
                };

                StackLayout sl = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal, BackgroundColor = Color.FromHex("#FFFFFF")
                };
                sl.Padding = new Thickness(0, 0, 10, 0);
                sl.Children.Add(new Label()
                {
                    Text = t.Key, IsVisible = false
                });

                sl.Children.Add(GetPhoto(t, false));

                CheckBox cb = new CheckBox()
                {
                    HorizontalOptions = LayoutOptions.EndAndExpand
                };

                Label l = new Label()
                {
                    Text                  = t.Value,
                    VerticalOptions       = LayoutOptions.Center,
                    VerticalTextAlignment = TextAlignment.Center,
                    TextColor             = Color.Black,
                    FontSize              = 16,
                    Padding               = new Thickness(30, 0, 0, 0)
                };
                cell.Tapped += TableCell_Tapped;

                sl.Children.Add(l);
                sl.Children.Add(cb);

                cell.View = sl;

                TeacherBackup.Add(cell);

                if (Attendance.TeacherAttendedToday(t.Key, DatePicker.Date))
                {
                    cb.IsChecked = true;
                }
                else
                {
                    cb.IsChecked = false;
                }

                if (t.Value.ToLower().Contains(filter))
                {
                    TeachersNamesTable.Add(cell);
                    count++;
                }
            }
            NamesTableRoot.Clear();
            TeachersNamesTable.Add(new ViewCell()
            {
                View = new Label {
                    BackgroundColor = Color.LightGray
                }
            });
            NamesTableRoot.Add(TeachersNamesTable);
        }