Пример #1
0
        public TakeAttendancePage()
        {
            //declare here date time picker
            try
            {
                TakeAttendanceViewModel.AttendanceType = UserType.attendanceType.Take;
                _takeAttendanceViewModel = new TakeAttendanceViewModel();
                double _imageFOBY = 0.9;
                this.Title = "Take Attendance";
                //switch (Device.RuntimePlatform)
                //{
                //    case Device.iOS:
                //        _Toppadding = 5;
                //        break;
                //    default:
                //        _imageFOBY = 0.9;
                //        break;
                //}

                var datePicker = new DatePicker()
                {
                    //Date = DateTime.Now,
                    BackgroundColor   = Color.White,
                    TextColor         = Color.Black,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Format            = "dd/MMM/yyyy",
                    WidthRequest      = 130
                };
                datePicker.Date = _takeAttendanceViewModel.Date;
                datePicker.SetBinding(DatePicker.DateProperty, new Binding("Date"));
                //declare here refresh button
                var refreshButton = new ImageButtonRefresh()
                {
                    Source = ImageSource.FromFile("RefreshIcon.png"),
                    //Margin = new Thickness(15),
                    HorizontalOptions = LayoutOptions.Center,
                    BackgroundColor   = Color.Transparent,
                    Aspect            = Aspect.Fill,
                };
                //declare here submitt button
                var SubmittButton = new Button()
                {
                    Margin            = new Thickness(0, 0, 0, 3),
                    BackgroundColor   = App.BrandColor,
                    BorderWidth       = 1,
                    BorderColor       = Color.White,
                    BorderRadius      = 20,
                    TextColor         = Color.White,
                    Text              = "Take",
                    FontFamily        = App.fontFamilyHead,
                    WidthRequest      = 300,
                    FontSize          = 16,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Command           = _takeAttendanceViewModel.SubmitCommand
                };
                //declare here FOB Button
                var FOBButton = new ImageButtonFOB()
                {
                    Source            = ImageSource.FromFile("iconFOB.png"),
                    Margin            = new Thickness(15),
                    VerticalOptions   = LayoutOptions.EndAndExpand,
                    HorizontalOptions = LayoutOptions.EndAndExpand,
                    BackgroundColor   = Color.Transparent,
                    Aspect            = Aspect.Fill,
                    WidthRequest      = 72,
                    HeightRequest     = 72
                };
                //here we are declare tap gesuture

                var tapgesture = new TapGestureRecognizer();
                tapgesture.Tapped += (sender, e) =>
                {
                    OnImageClicked_ChangeMeals();
                };
                tapgesture.NumberOfTapsRequired = 1;
                FOBButton.GestureRecognizers.Add(tapgesture);
                //end
                listView = new ListView()
                {
                    BackgroundColor = Color.DarkGray,
                    HasUnevenRows   = true,
                };
                IList <ItemCell> _itemList = new List <ItemCell>();

                // _itemList.Add(new ItemCell { ImageUri = sname, id = "10102", name = "Shivam Singh" });
                //_itemList.Add(new ItemCell { ImageUri = "logo.png", id = "10103", name = "Sonu Nagar" });
                //_itemList.Add(new ItemCell { ImageUri = "workprogress.png", id = "10104", name = "Arun Singh" });


                //DataBindation.listModelAttendance;

                //listitems = new SelectableObservableCollection<ItemCell>(_itemList);
                //listView.ItemsSource = listitems;

                listView.ItemsSource            = _takeAttendanceViewModel.StudentList;
                listView.ItemTemplate           = new DataTemplate(typeof(SelectableViewCell));
                listView.IsPullToRefreshEnabled = true;
                listView.VerticalOptions        = LayoutOptions.Fill;
                //listView.HasUnevenRows =true;
                listView.Refreshing   += OnRefresh;
                listView.ItemTapped   += OnTapped;
                listView.ItemSelected += OnSelected;

                MultiSelectListView.SetIsMultiSelect(listView, true);

                AbsoluteLayout.SetLayoutFlags(listView, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(listView, Rectangle.FromLTRB(0, 0, 1, 1));

                AbsoluteLayout.SetLayoutFlags(FOBButton, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(FOBButton, new Rectangle(1.0, _imageFOBY, -1, -1));

                var absoluteLayout = new AbsoluteLayout
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Margin          = new Thickness(0, 0, 0, 0),
                    Children        = { listView, FOBButton }
                };

                var grid = new Grid();
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(500, GridUnitType.Star)
                });
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(50, GridUnitType.Star)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });


                grid.Children.Add(datePicker, 0, 0);
                Grid.SetColumnSpan(datePicker, 2);
                grid.Children.Add(refreshButton, 1, 0);
                grid.Children.Add(absoluteLayout, 0, 1);
                Grid.SetColumnSpan(absoluteLayout, 2);
                grid.Children.Add(SubmittButton, 0, 2);
                Grid.SetColumnSpan(SubmittButton, 2);
                Content = new StackLayout
                {
                    Children =
                    {
                        grid
                    }
                };

                BindingContext = _takeAttendanceViewModel;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                UserDialogs.Instance.HideLoading();
                UserDialogs.Instance.Toast(ex.Message);
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Пример #2
0
        public ShowAttendancePage()
        {
            //declare here date time picker
            TakeAttendanceViewModel.AttendanceType = UserType.attendanceType.Show;
            _ShowAttendanceViewModel = new TakeAttendanceViewModel();
            try
            {
                double _imageFOBY = 0.9;
                this.Title = "Show Attendance";
                //switch (Device.RuntimePlatform)
                //{
                //    case Device.iOS:
                //        _Toppadding = 5;
                //        break;
                //    default:
                //        _imageFOBY = 0.9;
                //        break;
                //}

                var datePicker = new DatePicker()
                {
                    //Date = DateTime.Now,
                    BackgroundColor   = Color.White,
                    TextColor         = Color.Black,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Format            = "dd/MMM/yyyy",
                    WidthRequest      = 130
                };
                //datePicker.SetBinding(DatePicker.DateProperty, new Binding("Date"));
                datePicker.Date = _ShowAttendanceViewModel.Date;
                //declare here refresh button
                var refreshButton = new ImageButtonRefresh()
                {
                    Source = ImageSource.FromFile("RefreshIcon.png"),
                    //Margin = new Thickness(15),
                    HorizontalOptions = LayoutOptions.Center,
                    BackgroundColor   = Color.Transparent,
                    Aspect            = Aspect.Fill,
                };
                //declare here total present & total absent
                var totalPresentANDtotalabsent = new Label()
                {
                    Margin            = new Thickness(0, 0, 0, 3),
                    BackgroundColor   = App.BrandColor,
                    TextColor         = Color.White,
                    Text              = "Total Present & Total absent",
                    FontFamily        = App.fontFamilyHead,
                    WidthRequest      = 300,
                    FontSize          = 16,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                };
                totalPresentANDtotalabsent.Text = _ShowAttendanceViewModel.Total;
                //declare here FOB Button
                var FOBButton = new ImageButtonFOB()
                {
                    Source            = ImageSource.FromFile("iconFOB.png"),
                    Margin            = new Thickness(15),
                    VerticalOptions   = LayoutOptions.EndAndExpand,
                    HorizontalOptions = LayoutOptions.EndAndExpand,
                    BackgroundColor   = Color.Transparent,
                    Aspect            = Aspect.Fill,
                    WidthRequest      = 72,
                    HeightRequest     = 72
                };
                var tapgesture = new TapGestureRecognizer();
                tapgesture.Tapped += (sender, e) =>
                {
                    OnImageClicked_ChangeMeals();
                };

                tapgesture.NumberOfTapsRequired = 1;
                FOBButton.GestureRecognizers.Add(tapgesture);

                ListView listView = new ListView()
                {
                    BackgroundColor = Color.DarkGray,
                    HasUnevenRows   = true,
                };
                //IList<ItemCell> _itemList = new List<ItemCell>();
                //_itemList.Add(new ItemCell { ImageUri = "shivam.png", id = "10102", name = "Shivam Singh" ,status="Present" });
                ////_itemList.Add(new ItemCell { ImageUri = "logo.png", id = "10103", name = "Sonu Nagar", status = "Absent" });
                //_itemList.Add(new ItemCell { ImageUri = "workprogress.png", id = "10104", name = "Arun Singh", status = "Present" });

                //listView.ItemsSource = new ObservableCollection<ItemCell>(_itemList);

                listView.ItemsSource = _ShowAttendanceViewModel.StudentListShow;

                listView.ItemTemplate           = new DataTemplate(typeof(NonSelectableViewCell));
                totalPresentANDtotalabsent.Text = Global_Method_Propertise.Static_method.getTotalPresentandAbsentStudent(_ShowAttendanceViewModel.StudentListShow);

                //listView.ItemsSource = listitems;
                listView.IsPullToRefreshEnabled = true;
                listView.VerticalOptions        = LayoutOptions.Fill;
                listView.Refreshing            += OnRefresh;
                listView.ItemTapped            += OnTapped;
                listView.ItemSelected          += OnSelected;

                AbsoluteLayout.SetLayoutFlags(listView, AbsoluteLayoutFlags.All);
                AbsoluteLayout.SetLayoutBounds(listView, Rectangle.FromLTRB(0, 0, 1, 1));

                AbsoluteLayout.SetLayoutFlags(FOBButton, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(FOBButton, new Rectangle(1.0, _imageFOBY, -1, -1));

                var tapgestureRefreshButton = new TapGestureRecognizer();
                tapgestureRefreshButton.Tapped += (sender, e) =>
                {
                    _ShowAttendanceViewModel.Date = datePicker.Date;
                    TakeAttendanceViewModel.bindShowAttendanceData();
                    totalPresentANDtotalabsent.Text = Global_Method_Propertise.Static_method.getTotalPresentandAbsentStudent(_ShowAttendanceViewModel.StudentListShow);
                };
                tapgestureRefreshButton.NumberOfTapsRequired = 1;
                refreshButton.GestureRecognizers.Add(tapgestureRefreshButton);

                var absoluteLayout = new AbsoluteLayout
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Margin          = new Thickness(0, 0, 0, 0),
                    Children        = { listView, FOBButton }
                };

                var grid = new Grid();
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(500, GridUnitType.Star)
                });
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(50, GridUnitType.Star)
                });

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });


                grid.Children.Add(datePicker, 0, 0);
                Grid.SetColumnSpan(datePicker, 2);
                grid.Children.Add(refreshButton, 1, 0);
                grid.Children.Add(absoluteLayout, 0, 1);
                Grid.SetColumnSpan(absoluteLayout, 2);
                grid.Children.Add(totalPresentANDtotalabsent, 0, 2);
                Grid.SetColumnSpan(totalPresentANDtotalabsent, 2);
                Content = new StackLayout
                {
                    Children =
                    {
                        grid
                    }
                };
            }
            catch (Exception ex)
            {
            }
        }