Example #1
0
        private SolidColorBrush getAppointmentColorBrush(Appointment appt, AppointmentCalendar cal)
        {
            Color calColor;

            if (appt.StartTime.Date < DateTime.Now.Date)
            {
                calColor = new Color {
                    A = 180, B = cal.DisplayColor.B, R = cal.DisplayColor.R, G = cal.DisplayColor.G
                };
            }
            else
            {
                calColor = new Color
                {
                    A = cal.DisplayColor.A,
                    B = cal.DisplayColor.B,
                    R = cal.DisplayColor.R,
                    G = cal.DisplayColor.G
                }
            };
            var brush = new SolidColorBrush(calColor);


            return(brush);
        }
Example #2
0
        /// <summary>
        /// Creates a new calendar or updates the name and color of an existing one.
        /// </summary>
        /// <param name="calendar">The calendar to create/update</param>
        /// <exception cref="System.ArgumentException">Calendar does not exist on device or is read-only</exception>
        /// <exception cref="System.UnauthorizedAccessException">Calendar access denied</exception>
        /// <exception cref="Plugin.Calendars.Abstractions.PlatformException">Unexpected platform-specific error</exception>
        public async Task AddOrUpdateCalendarAsync(Calendar calendar)
        {
            await EnsureInitializedAsync().ConfigureAwait(false);

            AppointmentCalendar existingCalendar = null;

            if (!string.IsNullOrEmpty(calendar.ExternalID))
            {
                existingCalendar = await GetAndValidateLocalCalendarAsync(calendar.ExternalID).ConfigureAwait(false);
            }

            // Note: DisplayColor is read-only, we cannot set/update it.

            if (existingCalendar == null)
            {
                // Create new calendar
                //
                var appCalendar = await CreateAppCalendarAsync(calendar.Name).ConfigureAwait(false);

                calendar.ExternalID = appCalendar.LocalId;
                calendar.Color      = appCalendar.DisplayColor.ToString();
            }
            else
            {
                // Edit existing calendar
                //
                existingCalendar.DisplayName = calendar.Name;

                await existingCalendar.SaveAsync().ConfigureAwait(false);
            }
        }
Example #3
0
        public async Task GetCalendarAsync()
        {
            if (appointmentStore == null)
            {
                await GetStoreAsync();
            }
            try
            {
                var Cals = (await appointmentStore.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.IncludeHidden)).Where(x => x.DisplayName == Const.CalendarName);
                if (Cals.Count() == 0)
                {
                    CalendarToUse = await appointmentStore.CreateAppointmentCalendarAsync(Const.CalendarName);
                }
                else if (Cals.Count() > 0)
                {
                    foreach (var item in Cals.TakeLast(Cals.Count() - 1))
                    {
                        await item.DeleteAsync();
                    }
                    CalendarToUse = Cals.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
            }

            if (CalendarToUse != null)
            {
                CalendarToUse.CanCreateOrUpdateAppointments = true;
                CalendarToUse.DisplayColor = Windows.UI.Color.FromArgb(0xFF, 0xB3, 0xE5, 0xB8); //{#FFB3E5B8}
            }
        }
Example #4
0
        /// <summary>
        /// Gets all events for a calendar within the specified time range.
        /// </summary>
        /// <param name="calendar">Calendar containing events</param>
        /// <param name="start">Start of event range</param>
        /// <param name="end">End of event range</param>
        /// <returns>Calendar events</returns>
        /// <exception cref="System.ArgumentException">Calendar does not exist on device</exception>
        /// <exception cref="System.UnauthorizedAccessException">Calendar access denied</exception>
        /// <exception cref="Plugin.Calendars.Abstractions.PlatformException">Unexpected platform-specific error</exception>
        public async Task <IList <CalendarEvent> > GetEventsAsync(Calendar calendar, DateTime start, DateTime end)
        {
            await EnsureInitializedAsync().ConfigureAwait(false);

            AppointmentCalendar deviceCalendar = null;

            try
            {
                deviceCalendar = await _apptStore.GetAppointmentCalendarAsync(calendar.ExternalID).ConfigureAwait(false);
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException("Specified calendar not found on device", ex);
            }

            // Not all properties are populated by default
            //
            var options = new FindAppointmentsOptions {
                IncludeHidden = false
            };

            options.FetchProperties.Add(AppointmentProperties.Subject);
            options.FetchProperties.Add(AppointmentProperties.Details);
            options.FetchProperties.Add(AppointmentProperties.StartTime);
            options.FetchProperties.Add(AppointmentProperties.Duration);
            options.FetchProperties.Add(AppointmentProperties.AllDay);
            options.FetchProperties.Add(AppointmentProperties.Location);

            var appointments = await deviceCalendar.FindAppointmentsAsync(start, end - start, options).ConfigureAwait(false);

            var events = appointments.Select(a => a.ToCalendarEvent()).ToList();

            return(events);
        }
        /// <summary>
        /// Add new event to a calendar or update an existing event.
        /// If a new event was added, the ExternalID property will be set on the CalendarEvent object,
        /// to support future queries/updates.
        /// Throws if Calendar ID is empty, calendar does not exist, or calendar is read-only.
        /// </summary>
        /// <param name="calendar">Destination calendar</param>
        /// <param name="calendarEvent">Event to add or update</param>
        /// <exception cref="System.ArgumentException">Calendar is not specified, does not exist on device, or is read-only</exception>
        /// <exception cref="System.UnauthorizedAccessException">Calendar access denied</exception>
        /// <exception cref="System.InvalidOperationException">Editing recurring events is not supported</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Windows does not support multiple reminders</exception>
        /// <exception cref="Plugin.Calendars.Abstractions.PlatformException">Unexpected platform-specific error</exception>
        public async Task AddOrUpdateEventAsync(Calendar calendar, CalendarEvent calendarEvent)
        {
            await EnsureInitializedAsync().ConfigureAwait(false);

            AppointmentCalendar appCalendar = null;

            if (string.IsNullOrEmpty(calendar.ExternalID))
            {
                throw new ArgumentException("Missing calendar identifier", "calendar");
            }
            else
            {
                appCalendar = await GetAndValidateLocalCalendarAsync(calendar.ExternalID).ConfigureAwait(false);
            }


            // Android/iOS support multiple reminders, but Windows only allows one
            if (calendarEvent.Reminders?.Count > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(calendarEvent), "Windows does not support multiple reminders");
            }

            Appointment appt = null;

            // If Event already corresponds to an existing Appointment in the target
            // Calendar, then edit that instead of creating a new one.
            //
            if (!string.IsNullOrEmpty(calendarEvent.ExternalID))
            {
                var existingAppt = await _localApptStore.GetAppointmentAsync(calendarEvent.ExternalID);

                if (existingAppt?.Recurrence != null)
                {
                    throw new InvalidOperationException("Editing recurring events is not supported");
                }

                if (existingAppt != null && existingAppt.CalendarId == appCalendar.LocalId)
                {
                    appt = existingAppt;
                }
            }

            if (appt == null)
            {
                appt = new Appointment();
            }

            appt.Subject   = calendarEvent.Name;
            appt.Details   = calendarEvent.Description ?? string.Empty;
            appt.StartTime = calendarEvent.Start;
            appt.Duration  = calendarEvent.End - calendarEvent.Start;
            appt.AllDay    = calendarEvent.AllDay;
            appt.Location  = calendarEvent.Location ?? string.Empty;
            appt.Reminder  = calendarEvent.Reminders?.FirstOrDefault()?.TimeBefore;

            await appCalendar.SaveAppointmentAsync(appt);

            calendarEvent.ExternalID = appt.LocalId;
        }
Example #6
0
 private static bool IsCalendarHidden(AppointmentCalendar calendar)
 {
     if (calendar == null)
     {
         throw new ArgumentNullException("calendar");
     }
     return(App.ViewModel.SettingsViewModel.HiddenCalendars.Any(id => id == calendar.LocalId));
 }
 internal static async Task DeleteCalendarAsync()
 {
     await EnsureAvailabilityAsync();
     var appCalendars = await _store.FindAppointmentCalendarsAsync();
     foreach (AppointmentCalendar calendar in appCalendars)
         await calendar.DeleteAsync();
     _calendar = null;
     CalendarOwner = null;
 }
Example #8
0
        public static async Task deleteAllAppointments(AppointmentCalendar cal)
        {
            var aps = await cal.FindAppointmentsAsync(DateTime.Now.AddYears(-10), TimeSpan.FromDays(365 * 20));

            foreach (var a in aps)
            {
                await cal.DeleteAppointmentAsync(a.LocalId);
            }
        }
 private void BackButton_OnClick(object sender, RoutedEventArgs e)
 {
     CalendarListView.Visibility     = Visibility.Visible;
     AppointmentSection.Visibility   = Visibility.Collapsed;
     BackButton.Visibility           = Visibility.Collapsed;
     AppointmentListView.ItemsSource = null;
     _appointmentCalendar            = null;
     AppointmentListView.Header      = string.Empty;
 }
        public static async Task updateCalendar()
        {
            Debug.WriteLine("[Appointment] calendar begin");

            //TODO: possible duplication, lock?
            var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);

            var current_semester = await DataAccess.getSemester(getNextSemester : false);

            var next_semester = await DataAccess.getSemester(getNextSemester : true);

            if (current_semester.semesterEname == semester_in_system_calendar)
            {
                return;
            }

            //get Calendar object
            AppointmentCalendar cal = null;

            if (DataAccess.getLocalSettings()[cal_storedKey] != null)
            {
                cal = await store.GetAppointmentCalendarAsync(
                    DataAccess.getLocalSettings()[cal_storedKey].ToString());
            }

            if (cal == null)
            {
                cal = await store.CreateAppointmentCalendarAsync(cal_cal_name);

                DataAccess.setLocalSettings(cal_storedKey, cal.LocalId);
            }

            var aps = await cal.FindAppointmentsAsync(DateTime.Now.AddYears(-10), TimeSpan.FromDays(365 * 20));

            foreach (var a in aps)
            {
                await cal.DeleteAppointmentAsync(a.LocalId);
            }

            foreach (var ev in getAppointments(current_semester))
            {
                await cal.SaveAppointmentAsync(ev);
            }

            if (next_semester.id != current_semester.id)
            {
                foreach (var ev in getAppointments(next_semester))
                {
                    await cal.SaveAppointmentAsync(ev);
                }
            }

            semester_in_system_calendar = current_semester.semesterEname;

            Debug.WriteLine("[Appointment] calendar finish");
        }
        public static async Task updateTimetable(bool forceRemote = false)
        {
            Debug.WriteLine("[Appointment] update start");

            //TODO: request calendar access?

            Timetable timetable = await DataAccess.getTimetable(forceRemote);

            if (timetable.Count == 0)
            {
                throw new Exception();
            }

            var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);


            AppointmentCalendar cal = null;

            if (DataAccess.getLocalSettings()[class_storedKey] != null)
            {
                cal = await store.GetAppointmentCalendarAsync(
                    DataAccess.getLocalSettings()[class_storedKey].ToString());
            }

            if (cal == null)
            {
                cal = await store.CreateAppointmentCalendarAsync(class_cal_name);

                DataAccess.setLocalSettings(class_storedKey, cal.LocalId);
            }


            //TODO: don't delete all and re-insert all
            //
            var aps = await cal.FindAppointmentsAsync(DateTime.Now.AddYears(-10), TimeSpan.FromDays(365 * 20));

            foreach (var ddl_ap in aps)
            {
                await cal.DeleteAppointmentAsync(ddl_ap.LocalId);
            }


            var list = new List <Windows.ApplicationModel.Appointments.Appointment>();

            foreach (var ev in timetable)
            {
                list.Add(getAppointment(ev));
            }
            list = mergeAppointments(list);
            foreach (var e in list)
            {
                await cal.SaveAppointmentAsync(e);
            }

            Debug.WriteLine("[Appointment] update finished");
        }
Example #12
0
    private async Task <Appointment> GetAppointmentAsync(string id)
    {
        AppointmentCalendar calendar = await GetAsync();

        if (calendar != null)
        {
            return(await calendar.GetAppointmentAsync(id));
        }
        return(null);
    }
        static XElement SerializeCalendar(AppointmentCalendar calendar)
        {
            var ele = new XElement("Calendar");

            foreach (var property in typeof(AppointmentCalendar).GetProperties())
            {
                ele.Add(new XElement(property.Name, property.GetValue(calendar)));
            }
            return(ele);
        }
 /// <summary>
 /// Creates a new Calendars.Plugin.Abstractions.Calendar from an AppointmentCalendar
 /// </summary>
 /// <param name="apptCalendar">Source AppointmentCalendar</param>
 /// <param name="writeable">Whether or not the calendar is writeable (this isn't part of AppointmentCalendar)</param>
 /// <returns>Corresponding Calendars.Plugin.Abstractions.Calendar</returns>
 public static Calendar ToCalendar(this AppointmentCalendar apptCalendar, bool writeable)
 {
     return(new Calendar
     {
         Name = apptCalendar.DisplayName,
         Color = apptCalendar.DisplayColor.ToString(),
         ExternalID = apptCalendar.LocalId,
         CanEditCalendar = writeable,
         CanEditEvents = writeable
     });
 }
        private async void ListView_OnItemClick(object sender, ItemClickEventArgs e)
        {
            var appointmentCalendar = (AppointmentCalendar)e.ClickedItem;

            CalendarListView.Visibility   = Visibility.Collapsed;
            AppointmentSection.Visibility = Visibility.Visible;
            BackButton.Visibility         = Visibility.Visible;
            _appointmentCalendar          = appointmentCalendar;
            AppointmentListView.Header    = _appointmentCalendar.DisplayName;
            await LoadAppointments();
        }
        internal static async Task CreateNewCalendarAsync(User requester)
        {
            await DeleteCalendarAsync();
            
            AppointmentCalendar calendar = await _store.CreateAppointmentCalendarAsync("Academics Calendar");
            calendar.OtherAppReadAccess = AppointmentCalendarOtherAppReadAccess.SystemOnly;
            calendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.None;
            await calendar.SaveAsync();

            _calendar = calendar;
            CalendarOwner = requester.RegNo;
        }
Example #17
0
 public CalendarUc()
 {
     InitializeComponent();
     DataContextChanged += (sender, args) =>
     {
         if (args.NewValue is AppointmentCalendarAdapter appointmentCalendarAdapter &&
             appointmentCalendarAdapter != _appointmentCalendarAdapter)
         {
             _appointmentCalendarAdapter = appointmentCalendarAdapter;
             _appointmentCalendar        = _appointmentCalendarAdapter.AppointmentCalendar;
             Bindings.Update();
         }
     };
 }
Example #18
0
    private async Task <IReadOnlyList <Appointment> > ListAppointmentsAsync(DateTimeOffset start, TimeSpan range)
    {
        AppointmentStore store = await Store();

        if (store != null)
        {
            AppointmentCalendar calendar = await GetAsync();

            if (calendar != null)
            {
                return(await calendar.FindAppointmentsAsync(start, range));
            }
        }
        return(null);
    }
        private async Task CreateOrOpenCalendarAsync()
        {
            const string _calendarName = "Sample Calendar";

            AppointmentStore store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);

            var calendars = await store.FindAppointmentCalendarsAsync();

            if (!calendars.Any(i => i.DisplayName == _calendarName))
            {
                calendar = await store.CreateAppointmentCalendarAsync(_calendarName);
            }
            else
            {
                calendar = calendars.First(i => i.DisplayName == _calendarName);
            }
        }
Example #20
0
        /// <summary>
        /// Add new event to a calendar or update an existing event.
        /// Throws if Calendar ID is empty, calendar does not exist, or calendar is read-only.
        /// </summary>
        /// <param name="calendar">Destination calendar</param>
        /// <param name="calendarEvent">Event to add or update</param>
        /// <exception cref="System.ArgumentException">Calendar is not specified, does not exist on device, or is read-only</exception>
        /// <exception cref="System.UnauthorizedAccessException">Calendar access denied</exception>
        /// <exception cref="Calendars.Plugin.Abstractions.PlatformException">Unexpected platform-specific error</exception>
        public async Task AddOrUpdateEventAsync(Calendar calendar, CalendarEvent calendarEvent)
        {
            await EnsureInitializedAsync().ConfigureAwait(false);

            AppointmentCalendar appCalendar = null;

            if (string.IsNullOrEmpty(calendar.ExternalID))
            {
                throw new ArgumentException("Missing calendar identifier", "calendar");
            }
            else
            {
                appCalendar = await GetAndValidateLocalCalendarAsync(calendar.ExternalID).ConfigureAwait(false);
            }

            Appointment appt = null;

            // If Event already corresponds to an existing Appointment in the target
            // Calendar, then edit that instead of creating a new one.
            //
            if (!string.IsNullOrEmpty(calendarEvent.ExternalID))
            {
                var existingAppt = await _localApptStore.GetAppointmentAsync(calendarEvent.ExternalID);

                if (existingAppt != null && existingAppt.CalendarId == appCalendar.LocalId)
                {
                    appt = existingAppt;
                }
            }

            if (appt == null)
            {
                appt = new Appointment();
            }

            appt.Subject   = calendarEvent.Name;
            appt.Details   = calendarEvent.Description ?? string.Empty;
            appt.StartTime = calendarEvent.Start;
            appt.Duration  = calendarEvent.End - calendarEvent.Start;
            appt.AllDay    = calendarEvent.AllDay;
            appt.Location  = calendarEvent.Location ?? string.Empty;

            await appCalendar.SaveAppointmentAsync(appt);

            calendarEvent.ExternalID = appt.LocalId;
        }
Example #21
0
    public async Task <bool> AddAsync(AppBarButton button, ResourceDictionary resources)
    {
        Appointment appointment = await Dialog(new Appointment(), resources);

        if (appointment != null)
        {
            AppointmentCalendar calendar = await GetAsync();

            if (calendar != null)
            {
                await calendar.SaveAppointmentAsync(appointment);

                return(true);
            }
        }
        return(false);
    }
Example #22
0
    public async Task <bool> DeleteAsync(AppBarButton button)
    {
        Item        item        = (Item)button.Tag;
        Appointment appointment = await GetAppointmentAsync(item.Id);

        if (appointment != null)
        {
            AppointmentCalendar calendar = await GetAsync();

            if (calendar != null)
            {
                await calendar.DeleteAppointmentAsync(item.Id);

                return(true);
            }
        }
        return(false);
    }
        //Return true if the day is an appointment day
        //This converter is used to highlight appointment days in the patient calendar
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length < 2 || values[0] == null || values[1] == null)
            {
                return(false);
            }
            var targetDate = (DateTime)values[0];
            AppointmentCalendar calendarControl = values[1] as AppointmentCalendar;

            if (targetDate == null || calendarControl == null)
            {
                return(false);
            }
            if (calendarControl.PatientAppointmentDates != null && calendarControl.PatientAppointmentDates.Contains(targetDate))
            {
                return(true);
            }
            return(false);
        }
Example #24
0
        private static async Task CreateNewCalendarAsync()
        {
            await EnsureAvailabilityAsync();

            var appCalendars = await _store.FindAppointmentCalendarsAsync();

            foreach (AppointmentCalendar cal in appCalendars)
            {
                await cal.DeleteAsync();
            }

            AppointmentCalendar calendar = await _store.CreateAppointmentCalendarAsync("Home Automation Calendar");

            calendar.OtherAppReadAccess  = AppointmentCalendarOtherAppReadAccess.SystemOnly;
            calendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.None;
            await calendar.SaveAsync();

            _calendar = calendar;
        }
Example #25
0
        private static async Task <bool> TryLoadCalendarAsync()
        {
            if (_calendar != null)
            {
                return(true);
            }
            try
            {
                await EnsureAvailabilityAsync();

                _calendar = (await _store.FindAppointmentCalendarsAsync())[0];
                return(true);
            }
            catch
            {
                _calendar = null;
                return(false);
            }
        }
Example #26
0
        private async void InitializeAppointmentCalendar()
        {
            var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);

            _calendar = await store.CreateAppointmentCalendarAsync("节目提醒");

            LoggingService.Debug("Service", $"成功获得日历对象");
#if DEBUG
            // 在调试状态下每次都清空节目提醒
            await DeleteAllAppointments();
#endif
            // 同步字典与日历内容,处理用户自行将提醒删除的情况
            foreach (var program in _container.Values.Keys)
            {
                if (await _calendar.GetAppointmentAsync(_container.Values[program] as string) == null)
                {
                    _container.Values.Remove(program);
                }
            }
        }
Example #27
0
    private async Task <AppointmentCalendar> GetAsync()
    {
        AppointmentCalendar result = null;
        AppointmentStore    store  = await Store();

        if (store != null)
        {
            IReadOnlyList <AppointmentCalendar> list = await store.FindAppointmentCalendarsAsync();

            if (list.Count == 0)
            {
                result = await store.CreateAppointmentCalendarAsync(app_title);
            }
            else
            {
                result = list.FirstOrDefault(s => s.DisplayName == app_title);
            }
        }
        return(result);
    }
Example #28
0
        public static async Task updateLectures()   //always force remote
        {
            Debug.WriteLine("[Appointment] lecture begin");

            //TODO: possible duplication, lock?

            var lectures = await Remote.getHostedLectures();

            //get Calendar object
            AppointmentCalendar cal = await getAppointmentCalendar(lec_cal_name, lec_storedKey);

            await deleteAllAppointments(cal);

            foreach (var lec in lectures)
            {
                await cal.SaveAppointmentAsync(getAppointment(lec));
            }

            Debug.WriteLine("[Appointment] lecture finish");
        }
Example #29
0
        /// <summary>
        /// The main purpose of this is just to throw an appropriate exception on failure.
        /// </summary>
        /// <param name="id">Local calendar ID</param>
        /// <returns>App calendar with write access (will not return null)</returns>
        /// <exception cref="System.ArgumentException">Calendar ID does not refer to an app-owned calendar</exception>
        private async Task <AppointmentCalendar> GetAndValidateLocalCalendarAsync(string id)
        {
            AppointmentCalendar appCalendar       = null;
            Exception           platformException = null;

            try
            {
                appCalendar = await GetLocalCalendarAsync(id).ConfigureAwait(false);
            }
            catch (ArgumentException ex)
            {
                platformException = ex;
            }

            if (appCalendar == null)
            {
                throw new ArgumentException("Specified calendar does not exist or is not writeable", platformException);
            }

            return(appCalendar);
        }
Example #30
0
        static async Task <AppointmentCalendar> getAppointmentCalendar(string name, string key)
        {
            var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);

            AppointmentCalendar cal = null;

            if (DataAccess.getLocalSettings()[key] != null)
            {
                cal = await store.GetAppointmentCalendarAsync(
                    DataAccess.getLocalSettings()[key].ToString());
            }

            if (cal == null)
            {
                cal = await store.CreateAppointmentCalendarAsync(name);

                DataAccess.setLocalSettings(key, cal.LocalId);
            }

            return(cal);
        }
        private async void init()
        {
            this.appointmentStore = await AppointmentManager.RequestStoreAsync
                                        (AppointmentStoreAccessType.AppCalendarsReadWrite);

            IReadOnlyList <AppointmentCalendar> appCalendars =
                await this.appointmentStore.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.IncludeHidden);

            // Apps can create multiple calendars. This example creates only one.
            if (appCalendars.Count == 0)
            {
                this.appCalendar = await appointmentStore.CreateAppointmentCalendarAsync("Example App Calendar");
            }
            else
            {
                this.appCalendar = appCalendars[0];
            }
            this.appCalendar.OtherAppReadAccess  = AppointmentCalendarOtherAppReadAccess.Full;
            this.appCalendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.SystemOnly;
            // This app will show the details for the appointment. Use System to let the system show the details.
            this.appCalendar.SummaryCardView = AppointmentSummaryCardView.App;
        }
Example #32
0
    public async Task <bool> EditAsync(AppBarButton button, ResourceDictionary resources)
    {
        Item        item        = (Item)button.Tag;
        Appointment appointment = await GetAppointmentAsync(item.Id);

        if (appointment != null)
        {
            appointment = await Dialog(appointment, resources);

            if (appointment != null)
            {
                AppointmentCalendar calendar = await GetAsync();

                if (calendar != null)
                {
                    await calendar.SaveAppointmentAsync(appointment);

                    return(true);
                }
            }
        }
        return(false);
    }
        public static async Task LoadCalendarAsync()
        {
            if (UserManager.CurrentUser == null)
                throw new InvalidOperationException("There is no calendar to get.");

            if (CalendarOwner != UserManager.CurrentUser.RegNo)
                await CreateNewCalendarAsync(UserManager.CurrentUser);

            if (_calendar != null)
                return;

            await EnsureAvailabilityAsync();
            _calendar = (await _store.FindAppointmentCalendarsAsync())[0];
        }
Example #34
0
        private static async Task CheckForAndCreateAppointmentCalendars()
        {
            var appCalendars = await _appointmentStore.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.IncludeHidden);
            AppointmentCalendar appCalendar;

            if (appCalendars.Count == 0)
            {
                // TODO make generic!
                appCalendar = await _appointmentStore.CreateAppointmentCalendarAsync("CalendarName");
            }
            else
            {
                appCalendar = appCalendars[0];
            }

            appCalendar.OtherAppReadAccess = AppointmentCalendarOtherAppReadAccess.Full;
            appCalendar.OtherAppWriteAccess = AppointmentCalendarOtherAppWriteAccess.None;
            appCalendar.SummaryCardView = AppointmentSummaryCardView.System;

            await appCalendar.SaveAsync();

            _currentAppCalendar = appCalendar;
        }