Example #1
0
        // ---------------------------------------------------------------------
        public EventsForm(EventsCollection events, Color colorHighlightDate)
        {
            InitializeComponent();

            weekdayComboBox.Items.AddRange
                (DateTimeFormatInfo.CurrentInfo.DayNames);

            monthComboBox.Items.AddRange(Event.AbbreviatedMonthNames);

            recurringComboBox.DataSource    = RecurringEventNameValue.List();
            recurringComboBox.DisplayMember = "Name";
            recurringComboBox.ValueMember   = "Value";

            weekComboBox.Items.AddRange(Event.WeekNumbers());

            specialComboBox.DataSource    = SpecialEventNameValue.List();
            specialComboBox.DisplayMember = "Name";
            specialComboBox.ValueMember   = "Value";

            if (events != null)
            {
                eventsListBox.Items.AddRange(events.GetEvents());

                if (eventsListBox.Items.Count != 0)
                {
                    eventsListBox.SelectedIndex = 0;
                }
            }

            pictureBoxHighlightColor.BackColor = colorHighlightDate;
        }
Example #2
0
        // ---------------------------------------------------------------------
        public override string ToString()
        {
            var date      = string.Empty;
            var recurring = string.Empty;

            switch (EventType)
            {
            case EventType.Recurring:
                var year = (Year == 0) ? DateTime.Today.Year : Year;
                var d    = new DateTime(year, Month, Day);
                date = d.ToShortDateString();

                if (Recurring != RecurringEvent.Annually)
                {
                    recurring = "(" + RecurringEventNameValue.GetName(Recurring) + ")";
                }

                break;

            case EventType.Movable:
                var week =
                    (Week > 0 && Week <= WeekNumbers().Length)
                            ? WeekNumbers()[Week - 1]
                            : "Out of range";

                date = string.Format(CultureInfo.CurrentCulture,
                                     "{0} {1} {2}",
                                     week,
                                     DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(Weekday),
                                     GetAbbreviatedMonthName(Month));

                break;

            case EventType.Special:
                date = SpecialEventNameValue.GetName(Special) +
                       ((Days < 0) ? " - " : " + ") +
                       Math.Abs(Days).ToString(CultureInfo.CurrentCulture);

                break;

            default:
                break;
            }

            return(string.Format(CultureInfo.CurrentCulture,
                                 "{0,-15}\t {1} {2}", date, Description, recurring));
        }