Beispiel #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var d = (DateInfo)value;

                ChineseAlmanac ca      = new ChineseAlmanac();
                string         holiday = "";

                if (HolidayHelper.Instance.HolidayInfo?.ChineseHolidays != null)
                {
                    holiday = ca.GetChineseHoliday(d.DateTime, HolidayHelper.Instance.HolidayInfo.ChineseHolidays);
                }

                if (holiday != "")
                {
                    return(holiday);
                }

                if (HolidayHelper.Instance.HolidayInfo?.Holidays != null)
                {
                    holiday = ca.GetHoliday(d.DateTime, HolidayHelper.Instance.HolidayInfo.Holidays);
                }

                return(holiday);
            }
            catch (Exception)
            {
                return("");
            }
        }
Beispiel #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var d = (DateInfo)value;

                if (d.DateTime.Month != d.CurrentDate.Month)
                {
                    return(new SolidColorBrush(Color.FromArgb(80, 255, 255, 255)));
                }

                ChineseAlmanac ca      = new ChineseAlmanac();
                string         holiday = "";

                if (HolidayHelper.Instance.HolidayInfo?.ChineseHolidays != null)
                {
                    holiday = ca.GetChineseHoliday(d.DateTime, HolidayHelper.Instance.HolidayInfo.ChineseHolidays);
                }

                if (holiday != "")
                {
                    return(new SolidColorBrush(Colors.OrangeRed));
                }

                return(new SolidColorBrush(Colors.DarkOrange));
            }
            catch (Exception)
            {
                return(new SolidColorBrush(Colors.Transparent));
            }
        }
Beispiel #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var d = value as DateInfo;

            if (d == null)
            {
                return("");
            }
            GregorianCalendar gc = new GregorianCalendar();

            ChineseAlmanac ca = new ChineseAlmanac();

            var    jieqi          = d.OB.Ljq;
            var    sanfu          = ca.GetSanFuInfo(d.DateTime);
            var    shujiu         = ca.GetShuJiuInfo(d.DateTime);
            string holiday        = "";
            string chineseHoliday = "";

            if (HolidayHelper.Instance.HolidayInfo?.ChineseHolidays != null)
            {
                holiday = ca.GetChineseHoliday(d.DateTime, HolidayHelper.Instance.HolidayInfo.ChineseHolidays);
            }

            if (HolidayHelper.Instance.HolidayInfo?.Holidays != null)
            {
                chineseHoliday = ca.GetHoliday(d.DateTime, HolidayHelper.Instance.HolidayInfo.Holidays);
            }

            var result =
                $"第{d.DateTime.DayOfYear}天 第{gc.GetWeekOfYear(d.DateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday)}周";

            var info = "";

            if (jieqi != "")
            {
                info += jieqi;
            }

            if (sanfu != "")
            {
                info += info == "" ? sanfu : " " + sanfu;
            }

            if (shujiu != "")
            {
                info += info == "" ? shujiu : " " + shujiu;
            }

            if (holiday != "")
            {
                info += info == "" ? holiday : " " + holiday;
            }

            if (chineseHoliday != "")
            {
                info += info == "" ? chineseHoliday : " " + chineseHoliday;
            }

            result += $"{(info == "" ? "" : $" ({info})")}";
Beispiel #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var d = (DateInfo)value;

                if (d.OB.Ljq != "")
                {
                    return(d.OB.Ljq);
                }

                ChineseAlmanac ca = new ChineseAlmanac();

                return(ca.GetSanFuShuJiuString(d.DateTime));
            }
            catch (Exception)
            {
                return("");
            }
        }
Beispiel #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var d = value as DateInfo;

            if (d == null)
                return "";

            ChineseAlmanac ca = new ChineseAlmanac();

            return $"{d.OB.Lyear3}{d.OB.LShX2}年 {d.OB.Lmonth2}月 {d.OB.Lday2}日";
        }