Esempio n. 1
0
        protected override bool OnBackButtonPressed()
        {
            bool isBack = true;

            Device.BeginInvokeOnMainThread(async() =>
            {
                //isBack = await DisplayAlert(string.Empty, "Do you want to logout?", Messages.Yes, Messages.No);

                isBack = await UserDialogs.Instance.ConfirmAsync(null, "Do you want to logout?", Messages.Yes, Messages.No);

                if (isBack)
                {
                    SchoolManagementContext.Clear();
                    Navigation.PushModalAsync(App.LoginPage());
                }
            });

            base.OnBackButtonPressed();
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Menu Page Layout.
        /// </summary>
        public void MenuLayout()
        {
            //var listView = new ListView { RowHeight = 40,  };
            Menu = new MenuListView();

            var menuLabel = new ContentView
            {
                Padding = new Thickness(10, 36, 0, 5),
                Content = new Label
                {
                    TextColor = Color.Black,
                    Text      = "Hello," + SchoolManagementContext.UserName,
                }
            };

            var layout = new StackLayout
            {
                Spacing         = 0,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            layout.Children.Add(menuLabel);
            layout.Children.Add(Menu);

            //listView.ItemsSource = MenuModel.ListCategoryMenu();
            //listView.ItemTemplate = new DataTemplate(() => new TextItemCell());

            //Menu.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as SchoolManagement.Core.Models.MenuItem);

            Menu.ItemSelected += (sender, e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                SchoolManagement.Core.Models.MenuItem objMenu = (SchoolManagement.Core.Models.MenuItem)e.SelectedItem;

                ((ListView)sender).SelectedItem = null;

                //Page displayPage = (Page)Activator.CreateInstance(objMenu.TargetType);

                //Navigation.PushAsync(displayPage);
                if (SchoolManagementContext.TokenResponseModel.UserType == Convert.ToInt32(UserType.Teacher))
                {
                    if (objMenu.itemNumber == 1)
                    {
                        Navigation.PushAsync(App.FillUpAttendance());
                    }
                    else if (objMenu.itemNumber == 2)
                    {
                        Navigation.PushAsync(App.HomeWorkPage());
                    }
                    else if (objMenu.itemNumber == 3)
                    {
                        Navigation.PushAsync(App.StudentBehaviourNotice());
                    }
                    else if (objMenu.itemNumber == 4)
                    {
                        Navigation.PushAsync(App.LogbookFillup());
                    }
                    else if (objMenu.itemNumber == 5)
                    {
                        Navigation.PushAsync(App.ApplyLeave());
                    }
                    else if (objMenu.itemNumber == 6)
                    {
                        Navigation.PushAsync(App.TodaysSchedule());
                    }
                    else if (objMenu.itemNumber == 7)
                    {
                        Navigation.PushAsync(App.EnterStudentMark());
                    }
                    else if (objMenu.itemNumber == 8)
                    {
                        Navigation.PushAsync(App.UploadSamplePaper());
                    }
                    else if (objMenu.itemNumber == 9)
                    {
                        Navigation.PushAsync(App.ViewActivityNotice());
                    }
                    else if (objMenu.itemNumber == 10)
                    {
                        SchoolManagementContext.Clear();
                        Navigation.PushModalAsync(App.LoginPage());
                    }
                }

                else if (SchoolManagementContext.TokenResponseModel.UserType == Convert.ToInt32(UserType.Parents))
                {
                    if (objMenu.itemNumber == 1)
                    {
                        Navigation.PushAsync(App.ViewAttendance());
                    }
                    else if (objMenu.itemNumber == 2)
                    {
                        Navigation.PushAsync(App.ViewAttendanceSummary());
                    }
                    else if (objMenu.itemNumber == 3)
                    {
                        Navigation.PushAsync(App.ExamTimetable());
                    }
                    else if (objMenu.itemNumber == 4)
                    {
                        Navigation.PushAsync(App.ViewResult());
                    }
                    else if (objMenu.itemNumber == 5)
                    {
                        Navigation.PushAsync(App.ViewCompain());
                    }
                    else if (objMenu.itemNumber == 6)
                    {
                        Navigation.PushAsync(App.HomeWork());
                    }
                    else if (objMenu.itemNumber == 7)
                    {
                        Navigation.PushAsync(App.Notification());
                    }
                    else if (objMenu.itemNumber == 8)
                    {
                        Navigation.PushAsync(App.CompainBox());
                    }
                    else if (objMenu.itemNumber == 9)
                    {
                        SchoolManagementContext.Clear();
                        Navigation.PushModalAsync(App.LoginPage());
                    }
                }
            };
            //this.Content.BackgroundColor = Color.White;
            //Content = layout;
            this.Content = new StackLayout
            {
                BackgroundColor = Color.White,
                Children        = { layout }
            };
        }
Esempio n. 3
0
        public void DashboardLayout()
        {
            try
            {
                Grid grid = new Grid {
                    BackgroundColor = Color.Gray, ColumnSpacing = 2, RowSpacing = 2
                };

                int noOfCol = 3;

                int totaLoop = (int)Math.Ceiling((double)_MenuItem.Count / noOfCol);
                for (int i = 0; i < totaLoop; i++)
                {
                    string d1 = string.Empty;
                    for (int j = 0; j < noOfCol; j++)
                    {
                        int index = (i * noOfCol) + j;
                        if (_MenuItem.Count <= index)
                        {
                            //need to add empty
                            var image = new Image
                            {
                                VerticalOptions = LayoutOptions.Center,
                            };

                            var cell = new StackLayout
                            {
                                Children =
                                {
                                    image,
                                },
                                Orientation       = StackOrientation.Vertical,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                                BackgroundColor   = Color.White
                            };

                            grid.Children.Add(cell, j, i);
                        }
                        else
                        {
                            // d1 += _MenuItem[index].MobileName + ",";

                            var label = new Label
                            {
                                Text      = _MenuItem[index].MobileName,
                                TextColor = Color.Black,
                                XAlign    = TextAlignment.Center,
                                YAlign    = TextAlignment.End
                            };

                            var labelLayout = new StackLayout
                            {
                                Children        = { label },
                                VerticalOptions = LayoutOptions.End,
                                //HorizontalOptions = LayoutOptions.CenterAndExpand
                            };

                            var image = new Image
                            {
                                Source          = _MenuItem[index].ImageUrl,
                                VerticalOptions = LayoutOptions.Center,
                            };

                            var imageLayout = new StackLayout
                            {
                                Children = { image },
                                Padding  = new Thickness(0, 20, 0, 20)
                            };

                            var cell = new StackLayout
                            {
                                Children =
                                {
                                    imageLayout,
                                    labelLayout
                                },
                                Orientation       = StackOrientation.Vertical,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                                BackgroundColor   = Color.White
                            };

                            var menuClick = new TapGestureRecognizer();
                            menuClick.NumberOfTapsRequired = 1; // single-tap
                            menuClick.Tapped += (s, e) =>
                            {
                                int pageNumber = _MenuItem.Where(x => x.MobileName == _MenuItem[index].MobileName).FirstOrDefault().itemNumber;

                                if (SchoolManagementContext.TokenResponseModel.UserType == Convert.ToInt32(UserType.Teacher))
                                {
                                    if (pageNumber == 1)
                                    {
                                        Navigation.PushAsync(App.FillUpAttendance());
                                    }
                                    else if (pageNumber == 2)
                                    {
                                        Navigation.PushAsync(App.HomeWorkPage());
                                    }
                                    else if (pageNumber == 3)
                                    {
                                        Navigation.PushAsync(App.StudentBehaviourNotice());
                                    }
                                    else if (pageNumber == 4)
                                    {
                                        Navigation.PushAsync(App.LogbookFillup());
                                    }
                                    else if (pageNumber == 5)
                                    {
                                        Navigation.PushAsync(App.ApplyLeave());
                                    }
                                    else if (pageNumber == 6)
                                    {
                                        Navigation.PushAsync(App.TodaysSchedule());
                                    }
                                    else if (pageNumber == 7)
                                    {
                                        Navigation.PushAsync(App.EnterStudentMark());
                                    }
                                    else if (pageNumber == 8)
                                    {
                                        Navigation.PushAsync(App.UploadSamplePaper());
                                    }
                                    else if (pageNumber == 9)
                                    {
                                        Navigation.PushAsync(App.ViewActivityNotice());
                                    }
                                    else if (pageNumber == 10)
                                    {
                                        SchoolManagementContext.Clear();
                                        Navigation.PushModalAsync(App.LoginPage());
                                    }
                                }

                                else if (SchoolManagementContext.TokenResponseModel.UserType == Convert.ToInt32(UserType.Parents))
                                {
                                    if (pageNumber == 1)
                                    {
                                        Navigation.PushAsync(App.ViewAttendance());
                                    }
                                    else if (pageNumber == 2)
                                    {
                                        Navigation.PushAsync(App.ViewAttendanceSummary());
                                    }
                                    else if (pageNumber == 3)
                                    {
                                        Navigation.PushAsync(App.ExamTimetable());
                                    }
                                    else if (pageNumber == 4)
                                    {
                                        Navigation.PushAsync(App.ViewResult());
                                    }
                                    else if (pageNumber == 5)
                                    {
                                        Navigation.PushAsync(App.ViewCompain());
                                    }
                                    else if (pageNumber == 6)
                                    {
                                        Navigation.PushAsync(App.HomeWork());
                                    }
                                    else if (pageNumber == 7)
                                    {
                                        Navigation.PushAsync(App.Notification());
                                    }
                                    else if (pageNumber == 8)
                                    {
                                        Navigation.PushAsync(App.CompainBox());
                                    }
                                    else if (pageNumber == 9)
                                    {
                                        SchoolManagementContext.Clear();
                                        Navigation.PushModalAsync(App.LoginPage());
                                    }
                                }
                            };
                            cell.GestureRecognizers.Add(menuClick);
                            labelLayout.GestureRecognizers.Add(menuClick);
                            image.GestureRecognizers.Add(menuClick);

                            grid.Children.Add(cell, j, i);
                        }
                    }
                }

                StackLayout dashboardLayout = new StackLayout
                {
                    Children        = { grid },
                    Padding         = new Thickness(0, 10, 0, 10),
                    BackgroundColor = LayoutHelper.PageBackgroundColor,
                };

                dashboardLayout.Padding = LayoutHelper.IOSPadding(0, 20, 0, 0);

                // Build the page.
                ScrollView scrollDashboardLayout = new ScrollView
                {
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Content           = dashboardLayout
                };
                Content = scrollDashboardLayout;
            }
            catch (Exception ex)
            {
            }
        }