我正在开发Windows手机v8中的应用程序。它需要添加60个警报(每天2个警报),但msdn article中描述了50个警报的限制 点击按钮,我必须在循环中创建所有60个警报,或者我可以添加10个可能的警报,以便在上次警报开始或结束时再添加10个警报。我搜索过但没有找到任何解决方案。 警报对话框打开或警报启动时是否有任何事件我可以检查警报是否是最后一次然后我可以再添加10个警报并删除或替换以前的警报。有什么建议 ? 这是我的代码
QList的值来自数据库
for (int i = 0; i < QList.Count; i++)
{
//double seconds = 60.0 * (double)i;
string alarmName = "Sehar Alert " + i.ToString();
Alarm alarm = new Alarm(alarmName);
alarm.Content = "Its Sehar time in " + Cityname + " City. " + i.ToString();
var reminder = ScheduledActionService.Find(alarmName);
if (reminder != null)
{
ScheduledActionService.Remove(alarmName);
}
string datetime = QList[i].date +" "+ QList[i].Sehar;
DateTime sherTime = Convert.ToDateTime(datetime);
if (sherTime > sherT)
{
// DateTime seharTime = new DateTime(2014, 6, 10, 10, 12, 0);
alarm.BeginTime = sherTime;// DateTime.Now.AddSeconds(seconds);
alarm.Sound = new Uri("Assets/Sounds/azan1.mp3", UriKind.Relative);
// alarm.ExpirationTime = alarm.BeginTime.AddSeconds(10.0);
alarm.RecurrenceType = RecurrenceInterval.None;
ScheduledActionService.Add(alarm);
}
// Aftar time in Different City
string IftarName = "Iftar Alert " + i.ToString();
Alarm Ifatealarm = new Alarm(IftarName);
Ifatealarm.Content = "Its Aftar time in " + Cityname + " City. " + i.ToString();
var Iftarreminder = ScheduledActionService.Find(IftarName);
if (Iftarreminder != null)
{
ScheduledActionService.Remove(IftarName);
}
string Iftardatetime = QList[i].date + " " + QList[i].Iftar;
DateTime IfTarTime = Convert.ToDateTime(Iftardatetime);
if (IfTarTime > sherT)
{
// DateTime seharTime = new DateTime(2014, 6, 10, 10, 12, 0);
Ifatealarm.BeginTime = sherTime;// DateTime.Now.AddSeconds(seconds);
Ifatealarm.Sound = new Uri("Assets/Sounds/azan1.mp3", UriKind.Relative);
// alarm.ExpirationTime = alarm.BeginTime.AddSeconds(10.0);
Ifatealarm.RecurrenceType = RecurrenceInterval.None;
ScheduledActionService.Add(Ifatealarm);
}
}
答案 0 :(得分:1)
在App.Xaml.cs
内,您可以订阅RootFrame的Obscured
和Unobscured
个事件。
RootFrame.Obscured += new EventHandler<ObscuredEventArgs>(RootFrame_Obscured);
RootFrame.Unobscured += new EventHandler(RootFrame_Unobscured);
当闹钟弹出时,RootFrame_Unobscured
会被触发;解雇后,RootFrame_Obscured
将被解雇。