コード例 #1
0
        private void StudentSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            if ((e.OldTextValue ?? "").Length > (e.NewTextValue ?? "").Length)
            {
                InGrade = Attendance.StudentsOfGrade(ClassName);
                InitializeTeachers();
                InitializeStudents();
            }
            else
            {
                NamesTable = new TableSection();
                List <ViewCell> visible = new List <ViewCell>();
                string          filter  = StudentSearch.Text.Trim().ToLower();
                int             count   = 0;
                foreach (ViewCell c in Backup)
                {
                    StackLayout s = c.View as StackLayout;
                    Label       l = s.Children[2] as Label;
                    if (l.Text.ToLower().Contains(filter))
                    {
                        // make visible
                        s.Children[1] = GetPhoto(new KeyValuePair <string, string>((s.Children[0] as Label).Text, l.Text), true);
                        visible.Add(c);
                        count++;
                    }
                }
                foreach (ViewCell v in visible)
                {
                    NamesTable.Add(v);
                }

                if (count == 0)
                {
                    // there are no students that match this filter
                    NotFoundStack.IsVisible = true;
                }
                else
                {
                    NotFoundStack.IsVisible = false;
                }
                NamesTableRoot.Clear();
                NamesTableRoot.Add(NamesTable);
                Scroll.ScrollToAsync(0, 0, false);
            }
        }
コード例 #2
0
        private void InitializeStudents()
        {
            NamesTable.Clear();
            Backup.Clear();

            if (InGrade.Count == 0 && TeachersInGrade.Count == 0)
            {
                NotFoundStack.IsVisible = true;
            }
            else
            {
                NotFoundStack.IsVisible = false;
            }

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

            foreach (var s in InGrade)
            {
                ViewCell cell = new ViewCell()
                {
                    Height = 70
                };

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

                CircleImage ci = GetPhoto(s, true);

                sl.Children.Add(ci);

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

                Label l = new Label()
                {
                    Text                  = s.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;

                Backup.Add(cell);

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

                if (s.Value.ToLower().Contains(filter))
                {
                    // make visible
                    NamesTable.Add(cell);
                    count++;
                }
            }
            //NamesTableRoot.Clear();
            NamesTableRoot.Add(NamesTable);
        }
コード例 #3
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);
        }