예제 #1
0
        private void SetEventDetails(SavedEvent @event)
        {
            DateAndTime currDate       = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());
            DateAndTime eventStartDate = @event.ActivationDate;
            DateAndTime eventEndDate   = @event.DeactivationDate;

            Exp_Start_Date.SetText(TimeAndDateUtility.ConvertDate_String(@event.ActivationDate.Date, true));
            Exp_Start_Time.SetText(TimeAndDateUtility.ConvertTime_String(@event.ActivationDate.Time));
            Exp_End_Date.SetText(TimeAndDateUtility.ConvertDate_String(@event.DeactivationDate.Date, true));
            Exp_End_Time.SetText(TimeAndDateUtility.ConvertTime_String(@event.DeactivationDate.Time));
            Created_Date.SetText(
                $"{TimeAndDateUtility.ConvertDate_String(@event.CreatedDate.Date, true)} {TimeAndDateUtility.ConvertTime_String(@event.CreatedDate.Time)}");

            Completion_Date.SetText(
                @event.Completed && @event.CompletedDate != null && @event.CompletedDate.Date != null && @event.CompletedDate.Time != null ?
                $"{TimeAndDateUtility.ConvertDate_String(@event.CompletedDate.Date, true)} {TimeAndDateUtility.ConvertTime_String(@event.CompletedDate.Time)}"
                    : DASH);

            Event_Status.SetText(
                @event.Completed ? "Complete"
                    : TimeAndDateUtility.IsBeforeRange(eventStartDate, currDate) ?
                "Upcoming"
                        : TimeAndDateUtility.IsWithinRange(eventStartDate, currDate, eventEndDate) ?
                "In Progress" : "Overdue");
            Event_Status.SetBackColor(
                @event.Completed ? Color.DarkGreen
                    : TimeAndDateUtility.IsBeforeRange(eventStartDate, currDate) ?
                Color.DarkGray
                        : TimeAndDateUtility.IsWithinRange(eventStartDate, currDate, eventEndDate) ?
                Color.DarkBlue : Color.DarkRed);

            User_Title.SetText(@event.Title);

            User_Comment.SetText(!string.IsNullOrEmpty(@event.Comment) ? @event.Comment : NO_COMMENT);
        }
예제 #2
0
        /// <summary>
        /// Creates a messaage
        /// </summary>
        /// <param name="message">The message to create</param>
        /// <returns>Whether the message was created</returns>
        public bool CreateMessage(AppMessage message)
        {
            bool created = false;

            if (message != null)
            {
                message.CreatedDate = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());
                created             = _messageRepo.AddMessage(message);
            }

            return(created);
        }
        public bool UpdateLastShown(string id)
        {
            bool       updated = false;
            AppMessage message = _messageController.GetMessage(id);

            if (message != null)
            {
                message.LastDisplayedDate = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());

                updated = _messageController.EditMessage(message);
            }

            return(updated);
        }
예제 #4
0
        private void MessageTicker_Tick(object sender, EventArgs e)
        {
            Time time = TimeAndDateUtility.GetCurrentTime();

            if (_delay.DateDelayed != null && _delay.DateContinued != null)
            {
                _delay.Unlock(new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime()));
            }

            if (!_delay.Lock && time.Seconds % 30 == 0)
            {
                TriggerDelayedRefresh();
            }
        }
예제 #5
0
        internal void TriggerDelayedRefresh()
        {
            MessageTicker.Stop();
            RefreshMessage.Enabled = false;
            CopyMessage.Enabled    = false;
            PromptUser.Visible     = true;
            int    i       = 0;
            string loading = "Loading\r\n";
            Timer  timer   = new Timer
            {
                Interval = 375
            };

            timer.Tick += (s, ee) =>
            {
                if (i % 2 == 0)
                {
                    PromptUser.Text = $"{loading}⏳";
                }
                else
                {
                    PromptUser.Text = $"{loading}⌛";
                }

                if (i == 7)
                {
                    PromptUser.Visible = false;
                    PromptUser.Text    = string.Empty;
                    RefreshMessageDisplay();
                    timer.Stop();
                    MessageTicker.Start();
                    RefreshMessage.Enabled = true;
                    CopyMessage.Enabled    = true;
                }

                i++;
            };

            _delay.SetDelay(30, new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime()));
            timer.Start();
        }
예제 #6
0
        private void UpdateEventDetails()
        {
            try
            {
                string id = ((SavedEvent)Todays_Events.SelectedIndex())?.Id;
                if (!string.IsNullOrEmpty(id))
                {
                    SavedEvent @event = _events.GetEvent(id);

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

                        SetEventDetails(@event);
                        ToggleViewButtons(true, TimeAndDateUtility.IsBeforeRange(@event.ActivationDate, currDate));
                    }
                }
            }
            catch (Exception)
            {
                // Log
            }
        }
        public string GetRandomMessage()
        {
            List <AppMessage> messages = _messageController.GetMessages().Where(x => x.Show).ToList();

            AppMessage message    = null;
            string     display    = string.Empty;
            bool       isNotShown = false;

            while (!isNotShown && messages.Count > 0)
            {
                if (_lastSeen.Count == messages.Count)
                {
                    _lastSeen.Clear();
                }

                message = messages.ElementAtOrDefault(_rand.Next(0, messages.Count));

                if (message != null && !_lastSeen.Any(x => x == message.Id) && _lastShown != message.Id)
                {
                    string author = string.IsNullOrEmpty(message.Author) ? "No author(s)" : message.Author;
                    string source = string.IsNullOrEmpty(message.Source) ? "No source(s)" : message.Source;

                    display    = $"\"{message.Quote}\"\r\n\r\n    - {author}\r\n\r\nSources:\r\n    {source}";
                    isNotShown = true;
                    _lastShown = message.Id;

                    _lastSeen.Add(message.Id);

                    message.LastDisplayedDate = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());

                    _messageController.EditMessage(message);
                }
            }

            return(display);
        }
예제 #8
0
        /// <summary>
        /// Creates an event
        /// </summary>
        /// <param name="event">The event created by the user</param>
        /// <returns>Whether the event was added</returns>
        public bool CreateEvent(SavedEvent @event)
        {
            @event.CreatedDate = new DateAndTime(TimeAndDateUtility.GetCurrentDate(), TimeAndDateUtility.GetCurrentTime());

            return(_eventRepo.AddEvent(@event));
        }
예제 #9
0
        private void TodaysEventsListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

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

            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:
                font  = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                brush = Brushes.DarkSlateGray;
                break;

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

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

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

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

            if (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);
            }
        }