private CircleImage GetPhoto(KeyValuePair <string, string> s, bool isStudent)
        {
            Stream studentstream;

            if (isStudent)
            {
                studentstream = Attendance.GetStudentPhoto(s.Key);
            }
            else
            {
                studentstream = Attendance.GetTeacherPhoto(s.Key);
            }

            CircleImage profilePicture = new CircleImage
            {
                Source = ImageSource.FromStream(() =>
                {
                    return(studentstream);
                }),
                HeightRequest = 50,
                WidthRequest  = 50
            };

            if (studentstream == null)
            {
                profilePicture = new CircleImage {
                    Source = "blankprofile.png", HeightRequest = 50, WidthRequest = 50
                };
            }
            return(profilePicture);
        }
Esempio n. 2
0
        public EditAddStudent(HymnsAttendance attendance, string id, string name, string className, bool add)
        {
            ToolbarItem item = new ToolbarItem();

            if (!add)
            {
                item.Text = name;
            }
            else
            {
                item.Text = "Add Student";
                SwitchToTeacher.IsVisible = true;
            }

            // "this" refers to a Page object
            this.ToolbarItems.Add(item);
            InitializeComponent();

            Picture.Source = ImageSource.FromStream(() =>
            {
                var stream = Attendance.GetStudentPhoto(id);
                return(stream);
            });


            //add and edit cases
            name           = name == null ? "" : Capitalize(name);
            Add            = add;
            ClassName      = className;
            Attendance     = attendance;
            NameEntry.Text = name;
            this.id        = id;

            Classes.ItemsSource = ClassesToInterface(HymnsAttendance.OrderedClasses);

            if (!add)
            {
                string[] info = Attendance.GetStudentInfo(id);
                //name, phone, grade, parentName, parentPhone, birthday, photo, later
                //string num = info[1];
                //string parsed = num.Length == 0 ? "" : "(" + num.Substring(0, 3)
                //    + ")-" + num.Substring(3, 3) + "-" + num.Substring(6);

                StdPhoneEntry.Text = info[1];
                GradeEntry.Text    = info[2];

                ParentNameEntry.Text = info[3];
                //num = info[4];
                //parsed = num.Length == 0 ? "" : "(" + num.Substring(0, 3)
                //    + ")-" + num.Substring(3, 3) + "-" + num.Substring(6);
                ParentPhoneEntry.Text = info[4];

                //MM/dd
                int slash = info[5].IndexOf("/");

                BirthdayMonth.Text = info[5].Substring(0, slash);
                BirthdayDay.Text   = info[5].Substring(slash + 1);

                Classes.SelectedItem = parseName(ClassName);
            }
        }
Esempio n. 3
0
        private void InitGrid()
        {
            var students = Attendance.StudentsOfGrade(ClassName);

            InfoStack.Children.Clear();
            InitTeachers();

            //Students
            for (int i = 0; i < students.Count; i++)
            {
                var stream = Attendance.GetStudentPhoto(students[i].Key);

                CircleImage profilePicture = new CircleImage
                {
                    Source = ImageSource.FromStream(() =>
                    {
                        return(stream);
                    }),
                    HeightRequest = 50,
                    WidthRequest  = 50
                };

                if (stream == null)
                {
                    profilePicture = new CircleImage {
                        Source = "blankprofile.png", HeightRequest = 50, WidthRequest = 50
                    };
                }

                profilePicture.HorizontalOptions = LayoutOptions.Center;
                profilePicture.VerticalOptions   = LayoutOptions.Center;

                Label nameLabel = new Label()
                {
                    Text  = students[i].Value,
                    Style = Resources["detailTablet"] as Style
                };
                string birthday = Attendance.GetStudentInfo(students[i].Key)[(int)HymnsAttendance.StudentInfo.BIRTHDAY];

                Label birthdayLabel = new Label()
                {
                    //Text = num.Length == 0 ? "" : "(" + num.Substring(0, 3) + ")-" + num.Substring(3, 3) + "-" + num.Substring(6),
                    Text  = birthday,
                    Style = Resources["detailTablet"] as Style
                };

                int days = Attendance.GetDatesForYear(students[i].Key);

                float  weeks   = DateTime.Now.DayOfYear / 7.0f;
                string percent = ((int)(100 * days / weeks)).ToString() + "%";

                Label attend = new Label()
                {
                    Text  = percent,
                    Style = Resources["detailTablet"] as Style
                };

                SwipeItem editSwipeItem = new SwipeItem
                {
                    Text             = "EDIT",
                    BackgroundColor  = Color.Red,
                    CommandParameter = new Label()
                    {
                        Text = students[i].Key + ";" + students[i].Value, IsVisible = false
                    }
                };
                editSwipeItem.Invoked += SwipeItem_Clicked;

                SwipeItem infoSwipeItem = new SwipeItem
                {
                    Text             = "INFO",
                    BackgroundColor  = Color.Green,
                    CommandParameter = new Label()
                    {
                        Text = students[i].Key + ";" + students[i].Value, IsVisible = false
                    }
                };
                infoSwipeItem.Invoked += InfoSwipeItem_Clicked;

                Grid grid = new Grid()
                {
                    ColumnDefinitions = new ColumnDefinitionCollection()
                    {
                        new ColumnDefinition()
                        {
                            Width = new GridLength(2, GridUnitType.Star)
                        },
                        new ColumnDefinition()
                        {
                            Width = new GridLength(4, GridUnitType.Star)
                        },
                        new ColumnDefinition()
                        {
                            Width = new GridLength(2, GridUnitType.Star)
                        },
                        new ColumnDefinition()
                        {
                            Width = new GridLength(2, GridUnitType.Star)
                        }
                    },
                    RowDefinitions = new RowDefinitionCollection()
                    {
                        new RowDefinition()
                        {
                            Height = new GridLength(70, GridUnitType.Absolute)
                        }
                    },
                    BackgroundColor = Color.White
                };

                grid.Children.Add(profilePicture, 0, 0);
                grid.Children.Add(nameLabel, 1, 0);
                grid.Children.Add(birthdayLabel, 2, 0);
                grid.Children.Add(attend, 3, 0);

                List <SwipeItem> swipeItems = new List <SwipeItem>()
                {
                    editSwipeItem, infoSwipeItem
                };

                SwipeView swipeView = new SwipeView
                {
                    RightItems = new SwipeItems(swipeItems),
                    Content    = grid
                };
                InfoStack.Children.Add(swipeView);
                InfoStack.Children.Add(new BoxView
                {
                    Color             = Color.LightGray,
                    BackgroundColor   = Color.LightGray,
                    HeightRequest     = 0.5,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.Center
                });
            }
        }
Esempio n. 4
0
        public StudentProfilexaml(HymnsAttendance attendance, string id, string className)
        {
            Attendance = attendance;
            Id         = id;
            ClassName  = className;
            string[] studentInfo = Attendance.GetStudentInfo(Id);
            // studentname, studentphone, grade, parentname, parentphone, birthday
            ToolbarItem item = new ToolbarItem();

            item.Text = studentInfo[0];

            InitializeComponent();


            var   stream         = Attendance.GetStudentPhoto(id);
            Image profilePicture = new Image
            {
                Source = ImageSource.FromStream(() =>
                {
                    return(stream);
                })
            };

            if (stream == null)
            {
                profilePicture = new Image {
                    Source = "blankprofile.png", HeightRequest = 500, WidthRequest = 500
                };
            }

            storeInfo.Children.Add(profilePicture);
            Label lname = new Label {
                Text = "Student's Name:", TextColor = Color.SteelBlue, FontSize = 23
            };
            var ename = new Entry {
                Text = studentInfo[0], IsReadOnly = true
            };

            storeInfo.Children.Add(lname);
            storeInfo.Children.Add(ename);

            string num           = studentInfo[1];
            string parsed        = num.Length == 0 ? "" : "(" + num.Substring(0, 3) + ")-" + num.Substring(3, 3) + "-" + num.Substring(6);
            Label  lstudentPhone = new Label {
                Text = "Student's Phone Number:", TextColor = Color.SteelBlue, FontSize = 23
            };
            var estudentPhone = new Entry {
                Text = studentInfo[1], IsReadOnly = true
            };

            storeInfo.Children.Add(lstudentPhone);
            storeInfo.Children.Add(estudentPhone);

            Label lgrade = new Label {
                Text = "Grade:", TextColor = Color.SteelBlue, FontSize = 23
            };
            var egrade = new Entry {
                Text = studentInfo[2], IsReadOnly = true
            };

            storeInfo.Children.Add(lgrade);
            storeInfo.Children.Add(egrade);

            Label lparentName = new Label {
                Text = "Parent Name:", TextColor = Color.SteelBlue, FontSize = 23
            };
            var eParentName = new Entry {
                Text = studentInfo[3], IsReadOnly = true
            };

            storeInfo.Children.Add(lparentName);
            storeInfo.Children.Add(eParentName);

            Label lPhone = new Label {
                Text = "Parent's Phone Number:", TextColor = Color.SteelBlue, FontSize = 23
            };

            num    = studentInfo[4];
            parsed = num.Length == 0 ? "" : "(" + num.Substring(0, 3) + ")-" + num.Substring(3, 3) + "-" + num.Substring(6);
            var ePhone = new Entry {
                Text = parsed, IsReadOnly = true
            };

            storeInfo.Children.Add(lPhone);
            storeInfo.Children.Add(ePhone);

            StackLayout slbirthday = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, Spacing = 10
            };
            int slash = studentInfo[5].IndexOf("/");

            Label lbirthday = new Label {
                Text = "Student's Birthday:", TextColor = Color.SteelBlue, FontSize = 23
            };
            var ebirthdayMonth = new Entry {
                Text = studentInfo[5].Substring(0, slash), IsReadOnly = true
            };
            Label slashText = new Label()
            {
                Text = "/", FontSize = 23, TextColor = Color.SteelBlue
            };
            var ebirthdayDay = new Entry {
                Text = studentInfo[5].Substring(slash + 1), IsReadOnly = true
            };

            slbirthday.Children.Add(ebirthdayMonth);
            slbirthday.Children.Add(slashText);
            slbirthday.Children.Add(ebirthdayDay);

            storeInfo.Children.Add(lbirthday);
            storeInfo.Children.Add(slbirthday);

            Label lclassName = new Label {
                Text = "Student's Class:", TextColor = Color.SteelBlue, FontSize = 23
            };
            //for the edit
            var eclassName = new Entry {
                Text = parseName(ClassName), IsReadOnly = true
            };

            storeInfo.Children.Add(lclassName);
            storeInfo.Children.Add(eclassName);
        }