Пример #1
0
        public CalendarDayView()
        {
            if (FixParams.FromOut && FixParams.ActiveDate != "")
            {
                _ActiveDate = FixParams.ActiveDate;
                _ActiveWeekDay = CalendarClass.WeekDay(FixParams.ActiveDate);
                FixParams.FromOut = false;
                FixParams.ActiveDate = "";
                showbtmbar = false;
            }
            else
            {
                _ActiveDate = CalendarClass.TodayDate();
                _ActiveWeekDay = CalendarClass.WeekDay(CalendarClass.TodayDate());
            }

            MonthName.Text = CalendarClass.MonthName(_ActiveDate) + " ماه " + CalendarClass.YearName(_ActiveDate);
            DayNumber.Text = CalendarClass.DayNumber(_ActiveDate);
            DayName.Text = CalendarClass.WeekDayName(CalendarClass.WeekDay(_ActiveDate));

            lblNote.Text = CalendarClass.Events(CalendarClass.DateToDateTime(_ActiveDate));

            grdWeekDays = CreateWeekGrid(_ActiveDate, _ActiveWeekDay);

            _layout.Children.Clear();           

            _layout.Children.Add(DayNumber,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width - (65 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 5 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 60 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 55 * FixParams.AspectRate;
                                })
                            );

            _layout.Children.Add(MonthName,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width - (180 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 1 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 120 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 30 * FixParams.AspectRate;
                                })
                            );

            _layout.Children.Add(DayName,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width - (180 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 25 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 120 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 30 * FixParams.AspectRate;
                                })
                            );

            _layout.Children.Add(grdWeekDays,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 10 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return DayNumber.Height;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width - (20 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 75 * FixParams.AspectRate;
                                })
                            );

            grdPryingTimes = CreatePryingTimeGrid(_ActiveDate);

            _layout.Children.Add(grdPryingTimes,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 10 * FixParams.AspectRate;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Height - (100 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width - (20 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 50 * FixParams.AspectRate;
                                })
                            );


            _layout.Children.Add(ButtomLayout,
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 0;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Height - (40 * FixParams.AspectRate);
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return _layout.Width;
                                }),
                                Constraint.RelativeToParent((p) =>
                                {
                                    return 40 * FixParams.AspectRate;
                                })
                            );

            Button btnGotoWeekView = new Button()
            {
                BackgroundColor = FixParams.PanelColor,
                Text = "هفته",
                FontSize = FixParams.StandardSize,
                TextColor = FixParams.FontColor,
                HeightRequest = 40 * FixParams.AspectRate,                
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };

            btnGotoWeekView.Clicked += OnWeekClicked;

            if (showbtmbar)
                ButtomLayout.Children.Insert(0, btnGotoWeekView);

            CreatePanel(_layout, _ActiveDate);

            Task.Run(() =>
            {
                CalendarMenu cm = new CalendarMenu();
                cm.CreateYearDays();
                App.YearDays = cm.CalendarDataList;

                cm.CreateWeekLayout(App.YearDays);
                App.GridOfWeeks = cm.GridList;

                wv = new CalendarWeekView();
            });
            
            Content = _layout;
        }
Пример #2
0
        public CalendarDayView()
        {
            if (FixParams.FromOut && FixParams.ActiveDate != "")
            {
                _ActiveDate          = FixParams.ActiveDate;
                _ActiveWeekDay       = CalendarClass.WeekDay(FixParams.ActiveDate);
                FixParams.FromOut    = false;
                FixParams.ActiveDate = "";
                showbtmbar           = false;
            }
            else
            {
                _ActiveDate    = CalendarClass.TodayDate();
                _ActiveWeekDay = CalendarClass.WeekDay(CalendarClass.TodayDate());
            }

            MonthName.Text = CalendarClass.MonthName(_ActiveDate) + " ماه " + CalendarClass.YearName(_ActiveDate);
            DayNumber.Text = CalendarClass.DayNumber(_ActiveDate);
            DayName.Text   = CalendarClass.WeekDayName(CalendarClass.WeekDay(_ActiveDate));

            lblNote.Text = CalendarClass.Events(CalendarClass.DateToDateTime(_ActiveDate));

            grdWeekDays = CreateWeekGrid(_ActiveDate, _ActiveWeekDay);

            _layout.Children.Clear();

            _layout.Children.Add(DayNumber,
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width - (65 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(5 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(60 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(55 * FixParams.AspectRate);
            })
                                 );

            _layout.Children.Add(MonthName,
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width - (180 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(1 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(120 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(30 * FixParams.AspectRate);
            })
                                 );

            _layout.Children.Add(DayName,
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width - (180 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(25 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(120 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(30 * FixParams.AspectRate);
            })
                                 );

            _layout.Children.Add(grdWeekDays,
                                 Constraint.RelativeToParent((p) =>
            {
                return(10 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(DayNumber.Height);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width - (20 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(75 * FixParams.AspectRate);
            })
                                 );

            grdPryingTimes = CreatePryingTimeGrid(_ActiveDate);

            _layout.Children.Add(grdPryingTimes,
                                 Constraint.RelativeToParent((p) =>
            {
                return(10 * FixParams.AspectRate);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Height - (100 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width - (20 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(50 * FixParams.AspectRate);
            })
                                 );


            _layout.Children.Add(ButtomLayout,
                                 Constraint.RelativeToParent((p) =>
            {
                return(0);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Height - (40 * FixParams.AspectRate));
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(_layout.Width);
            }),
                                 Constraint.RelativeToParent((p) =>
            {
                return(40 * FixParams.AspectRate);
            })
                                 );

            Button btnGotoWeekView = new Button()
            {
                BackgroundColor   = FixParams.PanelColor,
                Text              = "هفته",
                FontSize          = FixParams.StandardSize,
                TextColor         = FixParams.FontColor,
                HeightRequest     = 40 * FixParams.AspectRate,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };

            btnGotoWeekView.Clicked += OnWeekClicked;

            if (showbtmbar)
            {
                ButtomLayout.Children.Insert(0, btnGotoWeekView);
            }

            CreatePanel(_layout, _ActiveDate);

            Task.Run(() =>
            {
                CalendarMenu cm = new CalendarMenu();
                cm.CreateYearDays();
                App.YearDays = cm.CalendarDataList;

                cm.CreateWeekLayout(App.YearDays);
                App.GridOfWeeks = cm.GridList;

                wv = new CalendarWeekView();
            });

            Content = _layout;
        }