Beispiel #1
0
        private void SetUpdateEventSettings(CalendarEventUpdater eventUpdater)
        {
            CalendarEvent ev = eventUpdater.CalendarEvent;

            recurrence = eventUpdater.Recurrence == null ? recurrence : eventUpdater.Recurrence;

            // Set general events settings
            Title    = ev.Title;
            Content  = ev.Content;
            Location = ev.Location;

            IsFullDayEvent   = ev.IsFullDateEvent;
            IsRecurringEvent = ev.IsRecurrenceEvent;

            StartDate        = ev.Start;
            StartTimeHours   = ev.Start.Hour;
            StartTimeMinutes = ev.Start.Minute;

            DateTime end = ev.End ?? ev.Start;

            EndDate        = end;
            EndTimeHours   = end.Hour;
            EndTimeMinutes = end.Minute;

            // Disable recurrence settings if update single instace option was selected
            if (eventUpdater.Type == GoogleCalendar.ActionType.single && IsRecurringEvent)
            {
                IsRecurringEvent    = false;
                IsRecurrenceEnabled = false;
                return;
            }

            SetUpdateEventRecurrenceSettings();
        }
Beispiel #2
0
        public EventsCreateViewModel(IGoogleCalendar googleCalendar, IRecurrenceSettings recurrenceSettings, IRepository commonRepository, IMessanger commonMessanger)
        {
            try
            {
                log.Debug("Loading EventsCreate view model...");

                calendar   = googleCalendar;
                repository = commonRepository;
                messanger  = commonMessanger;
                recurrence = recurrenceSettings;

                CreateEventCommand       = new RelayCommand(CreateEvent);
                UpdateEventCommand       = new RelayCommand(UpdateEvent);
                QuickActionCommand       = new RelayCommand(QuickAction);
                CancelUpdateEventCommand = new RelayCommand(CancelUpdateEvent);

                // For Update Events
                eventUpdater = repository.GetEventUpdater();
                if (eventUpdater.Type != GoogleCalendar.ActionType.none)
                {
                    IsUpdate = true;
                    SetUpdateEventSettings(eventUpdater);
                }

                log.Debug("EventsCreate view model was succssfully loaded");
            }
            catch (Exception ex)
            {
                log.Error("Failed to load EventsCreate view model:", ex);
            }
        }
Beispiel #3
0
        private void CancelUpdate()
        {
            CalendarEventUpdater updateEvent = new CalendarEventUpdater();

            repository.SetEventUpdater(updateEvent);
            CloseWindow();
        }
Beispiel #4
0
        private void UpdateOnlyInstance()
        {
            CalendarEventUpdater updateEvent = new CalendarEventUpdater(GoogleCalendar.ActionType.single, selectedEvent);

            repository.SetEventUpdater(updateEvent);
            CloseWindow();
        }
Beispiel #5
0
        private void UpdateAllEvents()
        {
            recurrence = calendar.GetRecurrenceSettings(selectedEvent);
            CalendarEventUpdater updateEvent = new CalendarEventUpdater(GoogleCalendar.ActionType.all, selectedEvent, recurrence);

            repository.SetEventUpdater(updateEvent);
            CloseWindow();
        }
Beispiel #6
0
        private void UpdateEvent(UpdateType updateType)
        {
            if (SelectedEvent.IsFake)
            {
                return;
            }

            repository.SetCurrentEvent(SelectedEvent);

            if (SelectedEvent.IsRecurrenceEvent)
            {
                var updateEventOptionsWindow = new Views.UpdateEventOptionsView();
                updateEventOptionsWindow.ShowDialog();
            }
            else
            {
                CalendarEventUpdater updateEvent = new CalendarEventUpdater(GoogleCalendar.ActionType.single, SelectedEvent);
                repository.SetEventUpdater(updateEvent);
            }

            if (repository.GetEventUpdater().Type == GoogleCalendar.ActionType.none)
            {
                return;
            }

            if (repository.GetEventUpdater().Type != GoogleCalendar.ActionType.none && updateType == UpdateType.full)
            {
                var updateEventWindow = new Views.UpdateEventView();
                updateEventWindow.ShowDialog();
                RefreshEventsList();
            }
            else
            {
                CalendarEventUpdater eventUpdater = repository.GetEventUpdater();
                eventUpdater.CalendarEvent.Confirmed = updateType == UpdateType.confirm ? true : false;
                eventUpdater.CalendarEvent.RRule     = calendar.GetRecurrenceSettings(eventUpdater.CalendarEvent).ToString();
                if (calendar.UpdateEvent(eventUpdater.CalendarEvent, eventUpdater.Type))
                {
                    RefreshEventsList();
                    messanger.Success("Event status changed", false);
                }
                else
                {
                    messanger.Error("Failed to change event status. Please check log file for a detailed information about the error.", false);
                }
            }
        }
Beispiel #7
0
 public void SetEventUpdater(CalendarEventUpdater calEventUpdater)
 {
     eventUpdater = calEventUpdater;
 }