示例#1
0
        private void Save()
        {
            alarm.Name = txtName.Text;
            if (pickerTime.Time.Hours.ToString().Length == 1)
            {
                alarm.Hour = "0" + pickerTime.Time.Hours.ToString();
            }
            else
            {
                alarm.Hour = pickerTime.Time.Hours.ToString();
            }
            if (pickerTime.Time.Minutes.ToString().Length == 1)
            {
                alarm.Minute = "0" + pickerTime.Time.Minutes.ToString();
            }
            else
            {
                alarm.Minute = pickerTime.Time.Minutes.ToString();
            }
            alarm.Day   = pickerDate.Date.Day;
            alarm.Month = pickerDate.Date.Month;
            alarm.Year  = pickerDate.Date.Year;
            FileManager fileManager = new FileManager();

            fileManager.SaveAlarm(alarm);
            if (alarm.Status)
            {
                XAlarmManager alarmManager = new XAlarmManager();
                alarmManager.CancelAlarm(alarm);
                alarmManager.SetAlarm(alarm);
            }
            Navigation.PopAsync();
        }
示例#2
0
        private void ImageButton_Clicked(object sender, EventArgs e)
        {
            var btn = ((ImageButton)sender);

            //alarmsButtonList.SelectedItem = null;

            for (int i = 0; i < alarms.Length; i++)
            {
                if (alarms[i].ClassID == btn.ClassId)
                {
                    alarms[i].Toggle();
                    if (alarms[i].Status)
                    {
                        XAlarmManager alarmManager = new XAlarmManager();
                        alarmManager.SetAlarm(alarms[i]);
                    }
                    else
                    {
                        XAlarmManager alarmManager = new XAlarmManager();
                        alarmManager.CancelAlarm(alarms[i]);
                    }
                    FileManager fileManager = new FileManager();
                    fileManager.SaveAlarm(alarms[i]);
                    btn.Source        = alarms[i].ImageName;
                    btn.HeightRequest = 120;
                    btn.WidthRequest  = 120;
                    break;
                }
            }
        }
示例#3
0
        private async void ImageButton_ClickedDelete(object sender, EventArgs e)
        {
            var btn = ((ImageButton)sender);

            var result = await DisplayAlert("Warning", "Are You Sure You Want To Delete This Alarm", "Yes", "No");

            if (result)
            {
                FileManager  fileManager = new FileManager();
                List <Alarm> lstalarms   = new List <Alarm>(fileManager.GetAlarms());

                for (int i = 0; i < lstalarms.Count; i++)
                {
                    if (alarms[i].ClassID == btn.ClassId)
                    {
                        fileManager.DeleteAlarm(lstalarms[i]);
                        XAlarmManager alarmManager = new XAlarmManager();
                        alarmManager.CancelAlarm(lstalarms[i]);
                    }
                }
            }

            SetUp();
        }