private void UpdateComponents()
        {
            var culture            = Language.GetSpecificCulture();
            var dateTimeFormatInfo = culture.GetDateFormat();
            var minDateTime        = dateTimeFormatInfo.Calendar.MinSupportedDateTime;
            var maxDateTime        = dateTimeFormatInfo.Calendar.MaxSupportedDateTime;

            if (DisplayDate < minDateTime)
            {
                SetDisplayDateOfCalendar(minDateTime);

                // return to avoid second formatting of the same value
                return;
            }

            if (DisplayDate > maxDateTime)
            {
                SetDisplayDateOfCalendar(maxDateTime);

                // return to avoid second formatting of the same value
                return;
            }

            ComponentOneContent   = DisplayDate.ToString(dateTimeFormatInfo.MonthDayPattern.Replace("MMMM", "MMM"), culture).ToTitleCase(culture); //Day Month following culture order. We don't want the month to take too much space
            ComponentTwoContent   = DisplayDate.ToString("ddd,", culture).ToTitleCase(culture);                                                    // Day of week first
            ComponentThreeContent = DisplayDate.ToString("yyyy", culture).ToTitleCase(culture);                                                    // Year always top
        }
        private void UpdateTitle()
        {
            if (mBtnTitle == null)
            {
                return;
            }
            switch (DisplayMode)
            {
            case CalendarMode.Month:
                mBtnTitle.Content = DisplayDate.ToString("yyyy-MM");
                break;

            case CalendarMode.Year:
                mBtnTitle.Content = DisplayDate.ToString("yyyy");
                break;

            case CalendarMode.Decade:
                var beginY = DisplayDate.Year - (DisplayDate.Year % 10);
                var endY   = beginY + 9;
                mBtnTitle.Content = beginY + "-" + endY;
                break;

            default:
                break;
            }
        }
Example #3
0
        //FrameworkElement.LanguageProperty.OverrideMetadata(typeof (Calendar), (PropertyMetadata) new FrameworkPropertyMetadata(new PropertyChangedCallback(Calendar.OnLanguageChanged)));
        private void UpdateComponents()
        {
            var culture            = Language.GetSpecificCulture();
            var dateTimeFormatInfo = culture.GetDateFormat();

            ComponentOneContent   = DisplayDate.ToString(dateTimeFormatInfo.MonthDayPattern.Replace("MMMM", "MMM"), culture).ToTitleCase(culture); //Day Month folowing culture order. We don't want the month to take too much space
            ComponentTwoContent   = DisplayDate.ToString("ddd,", culture).ToTitleCase(culture);                                                    // Day of week first
            ComponentThreeContent = DisplayDate.ToString("yyyy", culture).ToTitleCase(culture);                                                    // Year always top
        }
        //FrameworkElement.LanguageProperty.OverrideMetadata(typeof (Calendar), (PropertyMetadata) new FrameworkPropertyMetadata(new PropertyChangedCallback(Calendar.OnLanguageChanged)));
        private void UpdateComponents()
        {
            var dateTimeFormatInfo = CultureInfo.CurrentUICulture.GetDateFormat();

            foreach (var component in dateTimeFormatInfo.ShortDatePattern.Split(new[] { dateTimeFormatInfo.DateSeparator },
                                                                                StringSplitOptions.RemoveEmptyEntries).Select((s, index) => new { code = s.ToLower()[0], index }))
            {
                if (component.index == 0)
                {
                    IsDayInFirstComponent = component.code == 'd';
                }
                _setters[component.index](DisplayDate.ToString(_formats[component.code], CultureInfo.CurrentUICulture).ToTitleCase());
            }
        }
Example #5
0
        void WriteTitle(HtmlTextWriter writer, bool enabled)
        {
            TableCell cellNextPrev = null;
            TableCell titleCell    = new TableCell();
            Table     tableTitle   = new Table();

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            titleCell.ColumnSpan = HasWeekSelectors(SelectionMode) ? 8 : 7;

            if (titleStyle != null && !titleStyle.IsEmpty && !titleStyle.BackColor.IsEmpty)
            {
                titleCell.BackColor = titleStyle.BackColor;
            }
            else
            {
                titleCell.BackColor = Color.Silver;
            }

            titleCell.RenderBeginTag(writer);

            // Table
            tableTitle.Width = Unit.Percentage(100);
            if (titleStyle != null && !titleStyle.IsEmpty)
            {
                tableTitle.ApplyStyle(titleStyle);
            }

            tableTitle.RenderBeginTag(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            if (ShowNextPrevMonth)               // Previous Table Data
            {
                cellNextPrev = new TableCell();
                cellNextPrev.ApplyStyle(nextPrevStyle);
                cellNextPrev.Width = Unit.Percentage(15);

                DateTime date = GetGlobalCalendar().AddMonths(DisplayDate, -1);
                date = GetGlobalCalendar().AddDays(date, -date.Day + 1);
                cellNextPrev.RenderBeginTag(writer);
                writer.Write(BuildLink("V" + GetDaysFromZenith(date), GetNextPrevFormatText(date, false), cellNextPrev.ForeColor, enabled));
                cellNextPrev.RenderEndTag(writer);
            }

            // Current Month Table Data
            {
                DateTimeFormatInfo dti = DateInfo;
                string             str;
                TableCell          cellMonth = new TableCell();
                cellMonth.Width           = Unit.Percentage(70);
                cellMonth.HorizontalAlign = HorizontalAlign.Center;

                cellMonth.RenderBeginTag(writer);

                if (TitleFormat == TitleFormat.MonthYear)
                {
                    str = DisplayDate.ToString(dti.YearMonthPattern, dti);
                }
                else
                {
                    str = dti.GetMonthName(GetGlobalCalendar().GetMonth(DisplayDate));
                }

                writer.Write(str);
                cellMonth.RenderEndTag(writer);
            }

            if (ShowNextPrevMonth)               // Next Table Data
            {
                DateTime date = GetGlobalCalendar().AddMonths(DisplayDate, +1);
                date = GetGlobalCalendar().AddDays(date, -date.Day + 1);

                cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
                cellNextPrev.RenderBeginTag(writer);
                writer.Write(BuildLink("V" + GetDaysFromZenith(date), GetNextPrevFormatText(date, true), cellNextPrev.ForeColor, enabled));
                cellNextPrev.RenderEndTag(writer);
            }

            writer.RenderEndTag();
            tableTitle.RenderEndTag(writer);
            titleCell.RenderEndTag(writer);
            writer.RenderEndTag();              //tr
        }
Example #6
0
 private void UpdateYearLabel()
 {
     YearLabel = DisplayDate.ToString("yyyy", DateTimeFormatInfo);
 }
Example #7
0
 private void UpdateYearMonthLabel()
 {
     YearMonthLabel = DisplayDate.ToString("Y", DateTimeFormatInfo);
 }