问题
I am trying to write an alarm clock app that can set multiple alarms to trigger output pin on Raspberry Pi. Is there any reference project out there I can refer to? or does windows 10 alarm & clock app reference code is available for reference?
I want to find out how to save the individual alarm and display them.
do i use a DispatchTimer
to monitor the all the alarms set?
Thanks.
Updated: The alarm setting intended look like this.
portion of my code to create the appointment is as below. But i dont seem to be able to see any appoint created as the UWP appointment Sample.
private void Save_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var appointment = new Windows.ApplicationModel.Appointments.Appointment();
var recurrence = new Windows.ApplicationModel.Appointments.AppointmentRecurrence();
var scheduleTime = TimePicker.Time;
var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
var startTime = new DateTimeOffset(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, scheduleTime.Hours, scheduleTime.Minutes, 0, timeZoneOffset);
appointment.StartTime = startTime;
appointment.Duration = TimeSpan.FromMinutes(5);
if(dailyAlarm.IsOn == true)
{
recurrence.Unit = Windows.ApplicationModel.Appointments.AppointmentRecurrenceUnit.Daily;
} else
{
if (setMonday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Monday; }
if (setTuesday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Tuesday; }
if (setWednesday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Wednesday; }
if (setThursday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Thursday; }
if (setFriday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Friday; }
if (setSaturdayday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Saturday; }
if (setSunday.IsChecked == true) { recurrence.DaysOfWeek |= Windows.ApplicationModel.Appointments.AppointmentDaysOfWeek.Sunday; }
}
}
来源:https://stackoverflow.com/questions/47804888/uwp-c-sharp-windows-10-iot-alarm-clock