Example #1
0
        static void Main(string[] args)
        {
            var notebook = new NotebookCalendarService();

            var noteEvent = new NotebookEvent
            {
                ID          = 0,
                Date        = DateTime.Now,
                Description = "First",
                EventType   = Domain.Enum.NotebookEventType.Reminder,
                Name        = "First",
                Priority    = Domain.Enum.NotebookEventPriority.Low
            };

            notebook.AddEvent(noteEvent);

            noteEvent = new NotebookEvent
            {
                ID          = 1,
                Date        = DateTime.Now.AddDays(1),
                Description = "Second",
                EventType   = Domain.Enum.NotebookEventType.WithMembers,
                Name        = "Second",
                Members     = new System.Collections.Generic.List <NotebookEventMember>
                {
                    notebook.allMember[0],
                    notebook.allMember[1],
                },
                Priority = Domain.Enum.NotebookEventPriority.Medium
            };

            notebook.AddEvent(noteEvent);
        }
Example #2
0
 public override void DisableEvent(object eventId)
 {
     if (eventId is NotebookEvent)
     {
         NotebookEvent ev = (NotebookEvent)eventId;
         if (ev == NotebookEvent.CurrentTabChanged)
         {
             Widget.WillSelect -= HandleWidgetWillSelect;
         }
     }
     base.DisableEvent(eventId);
 }
Example #3
0
        /// <summary>
        /// Validate event model
        /// </summary>
        /// <returns>true if not valid, false if valid</returns>
        private void ValidateEvent(NotebookEvent notebookEvent)
        {
            if (string.IsNullOrEmpty(notebookEvent.Name) && string.IsNullOrEmpty(notebookEvent.Description) && notebookEvent.Date == null)
            {
                throw new ArgumentException($"Event not valid: {notebookEvent}. Name, description, priority, event type, day and time are required, please check.");
            }

            if (notebookEvent.EventType == Enum.NotebookEventType.WithMembers && notebookEvent.Members.Count == 0)
            {
                throw new ArgumentException($"Event not valid: {notebookEvent}. If you choose event type with members, please add members.");
            }
        }
 public override void DisableEvent(object eventId)
 {
     if (eventId is NotebookEvent)
     {
         NotebookEvent ev = (NotebookEvent)eventId;
         if (ev == NotebookEvent.CurrentTabChanged)
         {
             Widget.SwitchPage -= HandleWidgetSwitchPage;
         }
     }
     base.DisableEvent(eventId);
 }
Example #5
0
 /// <summary>
 /// Add new event into calendar
 /// </summary>
 /// <param name="notebookEvent"></param>
 public void AddEvent(NotebookEvent notebookEvent)
 {
     ValidateEvent(notebookEvent);
     events.Add(notebookEvent);
 }