示例#1
0
 private void UpdateView()
 {
     ClearEventDetails();
     ForceUpdate();
     UpdateTodaysEvents(_calendar.GetControl().SelectionStart);
     ToggleButtons();
     TodaysEventsListBox.Refresh();
 }
示例#2
0
        private void UpdateEventDetails()
        {
            try
            {
                string id = ((SavedEvent)Todays_Events.SelectedIndex())?.Id;
                if (!string.IsNullOrEmpty(id))
                {
                    SavedEvent @event = _events.GetEvent(id);

                    if (@event != null)
                    {
                        TodaysEventsListBox.Refresh();
                        DateAndTime currDate = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());

                        SetEventDetails(@event);
                        ToggleViewButtons(true, TimeAndDateUtility.IsBeforeRange(@event.ActivationDate, currDate));
                    }
                }
            }
            catch (Exception)
            {
                // Log
            }
        }
示例#3
0
        private void TodaysEventsListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            TodaysEventsListBox.SuspendLayout();

            Font     font;
            Brush    brush;
            Brush    selectedBrush = new SolidBrush(Color.White);
            int      status        = -1;
            string   title         = string.Empty;
            Graphics g             = e.Graphics;
            ListBox  lb            = (ListBox)sender;
            int      index         = e.Index;

            if (index > -1)
            {
                SavedEvent @event = null;
                try { @event = (SavedEvent)lb.Items[index]; } catch (Exception) { /*Something happened*/ }

                if (@event != null)
                {
                    DateAndTime currDate       = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());
                    DateAndTime eventStartDate = @event.ActivationDate;
                    DateAndTime eventEndDate   = @event.DeactivationDate;

                    status = @event.Completed ?
                             4 : TimeAndDateUtility.IsBeforeRange(eventStartDate, currDate) ?
                             1 : TimeAndDateUtility.IsWithinRange(eventStartDate, currDate, eventEndDate) ?
                             2 : 3;

                    title = @event.Title;
                }
            }

            switch (status)
            {
            case 1:
                e.DrawBackground();
                font  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                brush = Brushes.DarkSlateGray;
                break;

            case 2:
                e.DrawBackground();
                font  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Italic);
                brush = Brushes.DarkSlateBlue;
                break;

            case 3:
                e.DrawBackground();
                font  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
                brush = Brushes.DarkRed;
                break;

            case 4:
                e.DrawBackground();
                font  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold | FontStyle.Italic);
                brush = Brushes.DarkGreen;
                break;

            default:
                font  = e.Font;
                brush = Brushes.Black;
                break;
            }

            if (index > -1 && lb.SelectedIndex == index)
            {
                g.FillRectangle(Brushes.Blue, e.Bounds);
                g.DrawString(title, font, selectedBrush, e.Bounds, StringFormat.GenericDefault);
            }
            else
            {
                g.FillRectangle(Brushes.White, e.Bounds);
                g.DrawString(title, font, brush, e.Bounds, StringFormat.GenericDefault);
            }

            TodaysEventsListBox.ResumeLayout();
        }
示例#4
0
 private void TodaysEvents_SelectedIndexChanged(object sender, EventArgs e)
 {
     UpdateEventDetails();
     TodaysEventsListBox.Refresh();
 }