예제 #1
0
        public void CreateYearDays()
        {
            try
            {
                var curyear   = int.Parse(CalendarClass.YearName(CalendarClass.TodayDate()));
                var curday    = 1;
                var curmonth  = 1;
                var curweekno = 1;

                var curweekday = CalendarClass.WeekDay(curyear + "/01/01");
                var isleapyear = CalendarClass.IsLeapYear(curyear);
                int yeardays;
                if (isleapyear)
                {
                    yeardays = 366;
                }
                else
                {
                    yeardays = 365;
                }

                for (int i = 1; i <= yeardays; i++)
                {
                    AddItem(i, curday, curmonth, CalendarClass.MonthNameByCode(curmonth),
                            curyear, curweekday, CalendarClass.WeekDayName(curweekday), curweekno);
                    curday++;
                    curweekday++;

                    if (curmonth <= 6 && curday > 31)
                    {
                        curmonth++;
                        curday = 1;
                    }

                    if (curmonth > 6 && curday > 30)
                    {
                        curmonth++;
                        curday = 1;
                    }

                    if (curweekday > 6)
                    {
                        curweekday = 0;
                        curweekno++;
                    }
                    ;
                }
            }
            catch (Exception ex)
            {
                var er = ex.Message;
            }
        }
예제 #2
0
        protected override ContentPage CreateDefault(object item)
        {
            var   currentInt = (int)item;
            Label MonthName  = new Label
            {
                TextColor = FixParams.FontColor,
                Text      = CalendarClass.MonthNameByCode(currentInt) + " ماه " + CalendarClass.YearName("1394/01/01"),
                XAlign    = TextAlignment.Center,
                YAlign    = TextAlignment.Center,
                FontSize  = FixParams.MediumSize
            };

            Grid grdCalendar = new Grid();

            StackLayout layout = new StackLayout()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = FixParams.PanelColor,
                Padding           = 2 * FixParams.AspectRate
            };

            grdCalendar = CreateCalendar(1394, currentInt);
            layout.Children.Add(MonthName);
            layout.Children.Add(grdCalendar);

            _ActiveDate = "1394/" + CalendarClass.FullMonthCode((currentInt - 1).ToString()) + "/05";

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

            Button btnGotoYearView = new Button()
            {
                BackgroundColor   = FixParams.PanelColor,
                Text              = "سال",
                FontSize          = FixParams.StandardSize,
                TextColor         = FixParams.FontColor,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.EndAndExpand,
            };

            btnGotoWeekView.Clicked += OnWeekClicked;

            StackLayout ButtomLayout = new StackLayout
            {
                Children =
                {
                    btnGotoWeekView,
                    btnGotoYearView
                },
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = FixParams.PanelColor,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            Entry PerisianDate = new Entry
            {
                Text            = _ActiveDate,
                TextColor       = FixParams.FontColor,
                BackgroundColor = FixParams.BackgroundColor
            };

            Image btnCalendar = new Image
            {
                Source        = ImageSource.FromFile("Calendar.png"),
                HeightRequest = 40,
                WidthRequest  = 40,
            };

            Label lblPersianDate = new Label
            {
                Text      = "تاریخ جلالی",
                FontSize  = FixParams.SmallSize,
                TextColor = FixParams.FontColor
            };

            var grdPersianDate = new Grid();

            grdPersianDate.RowDefinitions.Add(new RowDefinition());
            grdPersianDate.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 40
            });
            grdPersianDate.ColumnDefinitions.Add(new ColumnDefinition());
            grdPersianDate.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = 50
            });

            grdPersianDate.Children.Add(lblPersianDate, 2, 0);
            grdPersianDate.Children.Add(PerisianDate, 1, 0);
            grdPersianDate.Children.Add(btnCalendar, 0, 0);

            StackLayout ConvertLayout = new StackLayout
            {
                Children =
                {
                    new StackLayout
                    {
                        Children =
                        {
                            new BoxView()
                            {
                                Color = FixParams.AlterFontColor, HeightRequest = 1
                            },
                            grdPersianDate,
                            new BoxView()
                            {
                                Color = FixParams.AlterFontColor, HeightRequest = 1
                            },
                        },
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                    },
                },
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = FixParams.PanelColor,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            layout.Children.Add(ButtomLayout);
            return(new ContentPage
            {
                Content = layout
            });
        }