/// <summary>
        /// This method delete alarm time form list and database.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">RoutedEventArgs</param>
        private void ButtonDeleteAlarm_Click(object sender, RoutedEventArgs e)
        {
            if (itemTimeToDelete != null)
            {
                // Call Remove to unregister the scheduled action with the service.
                ScheduledActionService.Remove(itemTimeToDelete.ItemAlarmName);
                ScheduledActionService.Remove(itemTimeToDelete.ItemReminderName);

                TimeItems.Remove(itemTimeToDelete);
                ComponentDB.TimeItems.DeleteOnSubmit(itemTimeToDelete);

                // Set to null itemTimeToDelete
                itemTimeToDelete = null;

                // Save changes to the database.
                ComponentDB.SubmitChanges();

                // Checking if any element is in lists
                CheckAddedElements();
            }
        }
 /// <summary>
 /// This method select current object from list and marked selected item.
 /// </summary>
 /// <param name="sender">object</param>
 /// <param name="e">SelectionChangedEventArgs</param>
 private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         var mySelectedItem = e.AddedItems[0] as TimeItem;
         if (mySelectedItem != null)
         {
             itemTimeToDelete = mySelectedItem;
         }
     }
 }
        /// <summary>
        /// This method save selected time to remainder and alarm.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">EventArgs</param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // Generate a unique name for the new notification. You can choose a
            // name that is meaningful for your app, or just use a GUID.
            String nameReminder = System.Guid.NewGuid().ToString();
            String nameAlarm = System.Guid.NewGuid().ToString();

            // Get the begin time for the notification by combining the DatePicker
            // value and the TimePicker value.
            DateTime time = (DateTime)timePicker.Value;

            // if time of the day already passed, set alarm for next day
            if ( time < DateTime.Now ) time = time.AddDays(1);

            // which page alarm should be navigated to after displaying
            Uri navigationUri = new Uri("/ShowSeizeDay.xaml", UriKind.Relative);

            Reminder reminder = new Reminder(nameReminder);

            reminder.Title = "“Determination is the wake-up call to the human will”";
            reminder.BeginTime = time.AddSeconds(6);         //beginTime;
            reminder.ExpirationTime = time.AddMinutes(2);    //expirationTime;
            reminder.NavigationUri = navigationUri;

            // Register the reminder with the system.
            ScheduledActionService.Add(reminder);

            Alarm alarm = new Alarm(nameAlarm);

            if (alarmSound == null)
            {
                alarm.Sound = new Uri("/Ringtones/sensitivewalk.wma", UriKind.Relative);
            }
            else
            {
                alarm.Sound = new Uri(alarmSound, UriKind.Relative);
            }

            alarm.BeginTime = time;                         // beginTime;
            alarm.ExpirationTime = time.AddMinutes(2);      // expirationTime;

            // Register the alarm with the system.
            ScheduledActionService.Add(alarm);

            // Get vaule from AddAlarm page

            // Create a new to-do item based on the string.
            TimeItem newTimeItem = new TimeItem
            {
                ItemAlarmName = nameAlarm,
                ItemReminderName = nameReminder,
                DateField = time.ToString()
            };

            // Connect to the database and instantiate data context.
            Component ComponentDB = new Component(Component.DBConnectionString);

            // Add a alarm item to the local database.
            ComponentDB.TimeItems.InsertOnSubmit(newTimeItem);

            // Save changes to the database.
            ComponentDB.SubmitChanges();

            // Navigate back to the main page.
            NavigationService.Navigate(new Uri("/mainPage.xaml", UriKind.Relative)); ;
        }