Esempio n. 1
0
        public EnterPeriodPanel()
        {
            InitializeComponent();
            CaptionFont = new Font(FontFamily.GenericSansSerif, 13);
            TextFont    = new Font(FontFamily.GenericSansSerif, 10);
            DateRecord dr;

            DateTime d = DateTime.Now;

            dr = new DateRecord()
            {
                Title = "Year " + d.Year
            };
            dr.StartDate = new GregorianDateTime(DateTime.Now.Year, 1, 1);
            dr.EndDate   = new GregorianDateTime(DateTime.Now.Year, 12, 31);
            dr.UpdateSubtitle();
            listBox1.Items.Add(dr);

            dr = new DateRecord()
            {
                Title = "Year " + (d.Year + 1).ToString()
            };
            dr.StartDate = new GregorianDateTime(DateTime.Now.Year + 1, 1, 1);
            dr.EndDate   = new GregorianDateTime(DateTime.Now.Year + 1, 12, 31);
            dr.UpdateSubtitle();
            listBox1.Items.Add(dr);

            dr = new DateRecord();
            if (d.Month == 12)
            {
                dr.Title = string.Format("{0} {1} - {2} {3}", GregorianDateTime.GetMonthAbreviation(12), d.Year,
                                         GregorianDateTime.GetMonthAbreviation(1), d.Year + 1);
                dr.StartDate = new GregorianDateTime(d.Year, 12, 1);
                dr.EndDate   = new GregorianDateTime(d.Year + 1, 1, 31);
            }
            else
            {
                dr.Title = string.Format("{0} - {1} {2}", GregorianDateTime.GetMonthAbreviation(d.Month),
                                         GregorianDateTime.GetMonthAbreviation(d.Month + 1), d.Year);
                dr.StartDate = new GregorianDateTime(d.Year, d.Month, 1);
                dr.EndDate   = new GregorianDateTime(d.Year, d.Month + 1, GregorianDateTime.GetMonthMaxDays(d.Year, d.Month + 1));
            }
            dr.UpdateSubtitle();
            listBox1.Items.Add(dr);

            dr          = new DateRecord();
            dr.Title    = "Custom Date Range";
            dr.Subtitle = "Enter start date manually";
            listBox1.Items.Add(dr);
        }