void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     apptsResult.Text = string.Format("{0} appointments found", e.Results.Count());
     if (e.Results.Count() > 1)
         apptsResult.Text += string.Format(", displaying the first match");
     appointmentLayout.DataContext = e.Results.FirstOrDefault();
 }
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            AppointmentsCount = 0;

            if (e.Results != null)
            {
                foreach (Appointment appt in e.Results)
                {
                    if (IsConfCall(appt))
                    {
                        AppointmentsCount++;
                    }
                }
            }

            // update the Tile
            ShellTile PrimaryTile = ShellTile.ActiveTiles.First();

            if (PrimaryTile != null)
            {
                IconicTileData tile = new IconicTileData();
                tile.Count          = AppointmentsCount;
                tile.Title          = "My Conference Calls";
                tile.SmallIconImage = new Uri("/ApplicationIcon.png", UriKind.Relative);
                tile.IconImage      = new Uri("/icon200.png", UriKind.Relative);
                PrimaryTile.Update(tile);
            }

            NotifyComplete();
        }
예제 #3
0
        private void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            if (e.Results != null)
            {
                foreach (Appointment appt in e.Results)
                {
                    string ConferenceId = Conference.GetId(appt);

                    if (!string.IsNullOrEmpty(ConferenceId))
                    {
                        if (appt.StartTime > DateTime.Now.Date.AddDays(1))
                        {
                            Tomorrow.Add(appt);
                        }
                        else
                        {
                            Today.Add(appt);
                        }
                    }
                }
            }

            // update the Tile
            ShellTile PrimaryTile = ShellTile.ActiveTiles.First();

            if (PrimaryTile != null)
            {
                IconicTileData tile = new IconicTileData();
                tile.Count          = Today.Count;
                tile.Title          = "My Conference Calls";
                tile.SmallIconImage = new Uri("/ApplicationIcon.png", UriKind.Relative);
                tile.IconImage      = new Uri("/AppHub/icon200.png", UriKind.Relative);
                PrimaryTile.Update(tile);
            }
        }
예제 #4
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res      = e.State as EventsResult;
            double       hours    = double.Parse(res.duration);
            DateTime     original = DateTime.Parse(res.event_date);

            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original &&
                        appointment.EndTime == original.Add(TimeSpan.FromHours(hours)) &&
                        appointment.Subject == res.name &&
                        appointment.Location == res.address &&
                        appointment.Details.Length == desc.Length)
                    {
                        res.isInCalendar = true;
                    }
                }
            }
            if (!res.isInCalendar)
            {
                data.CalendarData.result.Remove(res);
                EmsApi.SaveToPhone(JsonConvert.SerializeObject(data.CalendarData), EventsData.calendarDataKey);
            }
        }
 void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     apptsResult.Text = string.Format("{0} appointments found", e.Results.Count());
     if (e.Results.Count() > 1)
     {
         apptsResult.Text += string.Format(", displaying the first match");
     }
     appointmentControl.Content = e.Results.FirstOrDefault();
 }
        //preenche a lista com todos os eventos, email ou phone ( ambos são hotmail)
        protected void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            foreach (Appointment appt in e.Results)
            {
                ListApp.Add(appt);
            }

            AppointmentShow();
        }
        void a_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            Appointment a = e.Results.Skip(appointmentSkipCount).FirstOrDefault();

            appointmentStartDate.Text   = a.StartTime.ToLongDateString();
            appointmentStartTime.Text   = a.StartTime.ToShortTimeString();
            appointmentSubject.Text     = a.Subject;
            appointmentDetails.Text     = a.Details;
            appointmentPanel.Visibility = Visibility.Visible;
        }
        private void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            List<Slot> freeTimes = null;

            try
            {
                //Bind the results to the user interface.
                //AppointmentResultsData.DataContext = e.Results;
                var appts = e.Results;

                List<Slot> busyTimes = new List<Slot>();
                freeTimes = new List<Slot>();

                //Add logic to stop all day events?
                foreach (var appt in appts)
                {
                    busyTimes.Add(new Slot(appt.StartTime, appt.EndTime));
                }

                DateTime startTimeOfDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 0, 0);
                DateTime endTimeOfDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 0, 0);

                var slotBegin = startTimeOfDay;
                var slotEnd = endTimeOfDay < busyTimes[0].Start ? endTimeOfDay : busyTimes[0].Start;

                int endCount = 0;
                freeTimes.Add(new Slot(startTimeOfDay, slotEnd));
                for (int startCount = 1; startCount < busyTimes.Count; startCount++)
                {
                    startTimeOfDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, busyTimes[startCount].Start.Day, 8, 0, 0);
                    endTimeOfDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, busyTimes[endCount].End.Day, 23, 0, 0);

                    if (startTimeOfDay > busyTimes[endCount].End)
                        slotBegin = startTimeOfDay;
                    else
                        slotBegin = busyTimes[endCount].End;

                    if (endTimeOfDay < busyTimes[startCount].Start)
                        slotEnd = endTimeOfDay;
                    else
                        slotEnd = busyTimes[startCount].Start;

                    endCount++;
                    freeTimes.Add(new Slot(slotBegin, slotEnd));

                }
                freeTimes.Add(new Slot(busyTimes[busyTimes.Count - 1].End, endTimeOfDay));
            }
            catch (System.Exception ex)
            {
                //MessageBox.Show("");
            }

            FreeTimesAvailable(freeTimes);
        }
 void appointment_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     try
     {
         lstAppointments.DataContext = e.Results;
     }
     catch
     {
         MessageBox.Show("No appointments found !!");
     }
 }
예제 #10
0
        void buildListen(object sender, AppointmentsSearchEventArgs e)
        {
            //copy the list
            foreach (Appointment app in e.Results)
            {
                appointments.Add(app);
            }

            buildString(DateTime.Now);
            a.notify();
        }
        private void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            var proximoCompromisso = e.Results.FirstOrDefault();

            if (proximoCompromisso == null)
            {
                MessageBox.Show("Não há compromissos");
                return;
            }

            MessageBox.Show(proximoCompromisso.Subject);
        }
예제 #12
0
        private void appoints_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            IEnumerable<Event> appointEnumerable = from appoint in e.Results
                                                where appoint.Subject != null && !appoint.IsAllDayEvent
                                                select new Event {
                                                    StartTime = appoint.StartTime,
                                                    EndTime = appoint.EndTime,
                                                    Name = appoint.Subject
                                                };

            Events = appointEnumerable.ToList<Event>();

            Debug.WriteLine("events loaded, " + Events.Count);
            Callback.Invoke();
        }
예제 #13
0
 public async void finishSearch(object sender, AppointmentsSearchEventArgs e)
 {
     List<Appointment> appointments = e.Results.ToList();
     HashSet<String> appointmentsName= new HashSet<string>();
     foreach (var appointment in appointments)
     {
         if(appointment.IsPrivate)
             continue;
         if (appointment.Subject.Equals(toFind))
         {
             callback.Invoke(new Task(o => { }, appointment));
             return;
         }
     }
     callback.Invoke(new Task(o => { }, null));
 }
예제 #14
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res      = e.State as EventsResult;
            double       hours    = double.Parse(res.duration);
            DateTime     original = DateTime.Parse(res.event_date);

            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original &&
                        appointment.EndTime == original.Add(TimeSpan.FromHours(hours)) &&
                        appointment.Subject == res.name &&
                        appointment.Location == res.address &&
                        appointment.Details.Length == desc.Length)
                    {
                        MessageBox.Show(AppResources.AlreadyInTheCalendar, AppResources.InfoTitle, MessageBoxButton.OK);
                        return;
                    }
                }

                if (MessageBox.Show(AppResources.CalendarPrompt, AppResources.CalenderPromptTitle, MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();

            saveAppointmentTask.StartTime         = original;
            saveAppointmentTask.EndTime           = original.Add(TimeSpan.FromHours(hours));
            saveAppointmentTask.Subject           = res.name;
            saveAppointmentTask.Location          = res.address;
            saveAppointmentTask.Details           = res.description;
            saveAppointmentTask.IsAllDayEvent     = false;
            saveAppointmentTask.Reminder          = Reminder.EighteenHours;
            saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;

            saveAppointmentTask.Show();

            MainPage.data.CalendarData.result.Add(res);
            EmsApi.SaveToPhone(Newtonsoft.Json.JsonConvert.SerializeObject(MainPage.data.CalendarData), EventsData.calendarDataKey);
        }
예제 #15
0
        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            Dictionary <string, object> state = e.State as Dictionary <string, object>;
            List <Day> dayList   = state["dayList"] as List <Day>;
            DateTime   selectDay = (DateTime)state["selectDay"];

            //달력과 약속 데이터 합침
            dayList = VsCalendar.MergeCalendar(dayList, e.Results);
            CalendarSelector.ItemsSource = dayList;

            //날짜 선택
            IEnumerable <Day> days = from Day day in dayList
                                     where day.DateTime.ToLongDateString() == selectDay.ToLongDateString()
                                     select day;

            if (days.Any())
            {
                //오늘 날짜를 디폴트 선택값으로 설정
                CalendarSelector.SelectedItem = days.First();
                //오늘 날짜에 약속이 있으면 약속을 표시
                if (days.First().AppointmentList != null)
                {
                    IOrderedEnumerable <Appointment> appointments = days.First().AppointmentList.OrderBy(x => x.StartTime);
                    CalendarAppointmentSelector.ItemsSource  = appointments.ToList();
                    CalendarAppointmentSelector.SelectedItem = days.First();

                    var item = appointments.Where(x =>
                    {
                        if (x.StartTime.CompareTo(DateTime.Now) <= 1 && x.EndTime.CompareTo(DateTime.Now) >= 1)
                        {
                            return(true);
                        }
                        return(false);
                    });
                    //현재 시간에 걸린 아이템으로 스크롤을 옮긴다.
                    if (item.Any() && item.Count() > 2)
                    {
                        CalendarAppointmentSelector.ScrollTo(item.First());
                    }
                }
            }
            else
            {
                CalendarAppointmentSelector.ItemsSource = null;
            }
        }
        void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {         
            List<Appointment> ListApp = new List<Appointment>();

            foreach (Appointment appt in e.Results)
            {          
                ListApp.Add(appt);
            }

            for (int i = 0; i < ListApp.Count; i++)
            {
                string subject = ListApp[i].Subject.ToString();
                string time = ListApp[i].StartTime.ToString();
                string text = subject + "\n" + time + "\n";           
                MessageBox.Show(text);
            }

        }
예제 #17
0
        protected void AppointmentsSearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            var appointment = Calendar.GetAppointment(e);

            if (appointment == null)
            {
                return;
            }
            CalendarTitle.Text    = appointment.Subject;
            CalendarLocation.Text = appointment.Location;
            CalendarTime.Text     = appointment.DateAndTime;

            // Update the live tile(s)
            if (DigitalDash.Core.Classes.LiveTile.Exists())
            {
                DigitalDash.Core.Classes.LiveTile.Update(appointment.Subject, appointment.Location, appointment.DateAndTime, _battery, _appSettings);
            }
        }
예제 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public static Calendar GetAppointment(AppointmentsSearchEventArgs e)
        {
            // Make sure we have a subject otherwise we don't know what this calendar item is!
            if (e.Results.All(r => r.Subject == null))
            {
                return(null);
            }

            var appointement = new Calendar();

            // Get calendar items with a subject.
            var calendarItem = e.Results.First(r => r.Subject != null && (!r.IsAllDayEvent || (r.IsAllDayEvent && (System.DateTime.Now - r.StartTime).TotalHours < 12)));

            if (calendarItem != null)
            {
                appointement.Subject  = calendarItem.Subject;
                appointement.Location = calendarItem.Location;

                appointement.DateAndTime = string.Format("{0}", GetRelativeDate(calendarItem.StartTime));

                if (calendarItem.IsAllDayEvent)
                {
                    if (calendarItem.EndTime.Subtract(calendarItem.StartTime) > new TimeSpan(1, 0, 0, 0))
                    {
                        appointement.DateAndTime += " - " + GetRelativeDate(calendarItem.EndTime);
                    }
                    else
                    {
                        appointement.DateAndTime += ": All day";
                    }
                }
                else
                {
                    appointement.DateAndTime += ": " + calendarItem.StartTime.ToString("h:mm tt");
                    if (calendarItem.EndTime != calendarItem.StartTime)
                    {
                        appointement.DateAndTime = appointement.DateAndTime += " - " + calendarItem.EndTime.ToString("h:mm tt");
                    }
                }
            }

            return(appointement);
        }
예제 #19
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res = e.State as EventsResult;
            double hours = double.Parse(res.duration);
            DateTime original = DateTime.Parse(res.event_date);
            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original
                        && appointment.EndTime == original.Add(TimeSpan.FromHours(hours))
                        && appointment.Subject == res.name
                        && appointment.Location == res.address
                        && appointment.Details.Length == desc.Length)
                    {
                        MessageBox.Show(AppResources.AlreadyInTheCalendar, AppResources.InfoTitle, MessageBoxButton.OK);
                        return;
                    }
                }

                if (MessageBox.Show(AppResources.CalendarPrompt, AppResources.CalenderPromptTitle, MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                    return;
            }

            SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();

            saveAppointmentTask.StartTime = original;
            saveAppointmentTask.EndTime = original.Add(TimeSpan.FromHours(hours));
            saveAppointmentTask.Subject = res.name;
            saveAppointmentTask.Location = res.address;
            saveAppointmentTask.Details = res.description;
            saveAppointmentTask.IsAllDayEvent = false;
            saveAppointmentTask.Reminder = Reminder.EighteenHours;
            saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;

            saveAppointmentTask.Show();

            MainPage.data.CalendarData.result.Add(res);
            EmsApi.SaveToPhone(Newtonsoft.Json.JsonConvert.SerializeObject(MainPage.data.CalendarData), EventsData.calendarDataKey);
        }
예제 #20
0
 void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     listBoxSearchResults.DataContext = null;
     listBoxSearchResults.Items.Clear();
     if (textBoxSubject.Text.Trim() == "" || textBoxSubject.Text == "Enter subject here")
     {
         listBoxSearchResults.DataContext = e.Results;
     }
     else
     {
         foreach (Appointment a in e.Results)
         {
             if(a.Subject.Contains(textBoxSubject.Text.Trim()))
             {
                 listBoxSearchResults.Items.Add(a);
             }
         }
     }
     
 }
예제 #21
0
        protected void AppointmentsSearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            var licenseInfo = new LicenseInformation();

            if (!licenseInfo.IsTrial())
            {
                var appointment = Calendar.GetAppointment(e);
                if (appointment == null)
                {
                    return;
                }

                LiveTile.Update(appointment.Subject, appointment.Location, appointment.DateAndTime, Battery, AppSettings);
            }
            else
            {
                LiveTile.Update("Sample Calendar Item", "Get full version", "to display calendar items", Battery, AppSettings);
            }

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
예제 #22
0
        private async void finishSearchAndAddSpeach(object sender, AppointmentsSearchEventArgs e)
        {
            List<Appointment> appointments = e.Results.ToList();
            HashSet<String> appointmentsName= new HashSet<string>();

            for (int i = 0; i < appointments.Count; i++)
            {
                var appointment = appointments[i];
                if(appointment.IsPrivate)
                    continue;
                appointmentsName.Add(appointment.Subject);
            }
            foreach (string langName in VoiceCommandInfo.AvailableLanguages)
            {
                if (VoiceCommandService.InstalledCommandSets.ContainsKey(langName))
                {
                    VoiceCommandSet widgetVcs = VoiceCommandService.InstalledCommandSets[langName];
                    widgetVcs.UpdatePhraseListAsync("appointment", appointmentsName);
                }   
            }
            
        }
예제 #23
0
        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            if (!e.Results.Any())
            {
                var items = new DateStringDisplay {
                    StartTime = "Add some events to your calendar to see them here...", Subject = string.Empty
                };
                CalendarListBox.ItemsSource = new[] { items };
            }
            else
            {
                var items = e.Results.Select(i => new DateDisplay {
                    StartTime = i.StartTime, Subject = i.Subject
                });
                CalendarListBox.ItemsSource = items;
            }

            if (loading)
            {
                GlobalLoading.Instance.IsLoading   = false;
                GlobalLoading.Instance.LoadingText = null;
                loading = false;
            }
        }
예제 #24
0
        void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            StartDate.Text = e.StartTimeInclusive.ToShortDateString();
            EndDate.Text   = e.EndTimeInclusive.ToShortDateString();

            try
            {
                //Bind the results to the list box that displays them in the UI
                AppointmentResultsData.DataContext = e.Results;
            }
            catch (System.Exception)
            {
                //That's okay, no results
            }

            if (AppointmentResultsData.Items.Count > 0)
            {
                AppointmentResultsLabel.Text = "results (tap for details...)";
            }
            else
            {
                AppointmentResultsLabel.Text = "no results";
            }
        }
 void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     appointmentsList.ItemsSource = e.Results.ToList();
 }
예제 #26
0
        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            if (!e.Results.Any())
            {
                var items = new DateStringDisplay { StartTime = "Add some events to your calendar to see them here...", Subject = string.Empty };
                CalendarListBox.ItemsSource = new[] { items };
            }
            else
            {
                var items = e.Results.Select(i => new DateDisplay { StartTime = i.StartTime, Subject = i.Subject });
                CalendarListBox.ItemsSource = items;
            }

            if (loading)
            {
                GlobalLoading.Instance.IsLoading = false;
                GlobalLoading.Instance.LoadingText = null;
                loading = false;
            }
        }
예제 #27
0
        private async void finishSearch(object sender, AppointmentsSearchEventArgs e)
        {
            List<Appointment> appointments = e.Results.ToList();

            Appointment app=null;
            if(appointments.Count>0)
                app = appointments[0];

            await SayAppointment(app);
        }
예제 #28
0
        // on load, we searched the calendar for all of today's events. Now we got them as an enumerator
        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            if ((e.Results == null) || (e.Results.Count() == 0))
            {
                // error, OR no events for the day
                // display a single question mark tile
                this.currentCard = new Card("free time");
            }
            else
            {
                this.LoadCards(e.Results);

            }
            //fill in prev/current/next as unscheduled if there is nothing available for any of them
            if (prevCard == null) prevCard = new Card("free time");
            currentCards.Add(prevCard);
            if (currentCard == null) currentCard = new Card("free time");
            currentCard.height = 280;
            currentCard.width = 280;
            currentCards.Add(currentCard);
            if (nextCard == null) nextCard = new Card("free time");
            currentCards.Add(nextCard);
            IsDataLoaded = true;
        }
        void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            try
            {
                List<Appointment> appointments = new List<Appointment>(e.Results);
                List<String> show = new List<String>();
                int i = 1;
                List<DateTime> alarmtimes = new List<DateTime>();
                DateTime temp = DateTime.Now;

                while (appointments.Count >= i || 8 > i)
                {
                    temp = temp.AddDays(1);

                    Appointment app = appointments.Find(item => item.StartTime.Hour != 0 && temp.Day == item.StartTime.Day);
                    if (app != null)
                    {
                        DateTime alarmtime = app.StartTime;
                        alarmtime = alarmtime.AddHours(-hour);
                        alarmtime = alarmtime.AddMinutes(-min);
                        alarmtimes.Add(alarmtime);
                        show.Add(alarmtime.ToString());

                        String AlarmName = System.Guid.NewGuid().ToString();
                        Alarm alarm = new Alarm(AlarmName);
                        alarm.Content = alarmtime.DayOfWeek + "! " + App.quotes.getQuote();
                        alarm.Sound = mediaplayer2.Source;
                        alarm.BeginTime = alarmtime;
                        alarm.ExpirationTime = alarmtime.AddSeconds(2);
                        alarm.RecurrenceType = RecurrenceInterval.None;
                        if (alarm.BeginTime.TimeOfDay > App.settings.DefaultLateTimeSetting.TimeOfDay)
                            lateAlarmsDisplay.Add(new ListItemAlarm(alarm.Name, alarm.BeginTime, alarm.Sound));
                        ScheduledActionService.Add(alarm);

                    }
                    i++;
                }
            }
            catch (System.Exception)
            {
                //That's okay, no results
            }
            if (lateAlarmsDisplay.Count() > 0)
            {
                messagePrompt = new MessagePrompt();
                messagePrompt.Background = (Brush)Application.Current.Resources["PhoneBackgroundBrush"];
                messagePrompt.IsCancelVisible = false;
                messagePrompt.Title = "Late Alarms";
                UserControl lateAlarms = new LateAlarmsPopup();
                ViolatingAlarms = lateAlarms.GetFirstLogicalChildByType<LongListMultiSelector>(true);
                lateAlarmsDisplay = new ObservableCollection<ListItemAlarm>(lateAlarmsDisplay.OrderBy(x => x.Date));
                ViolatingAlarms.ItemsSource = lateAlarmsDisplay;
                var result2 = lateAlarms.GetFirstLogicalChildByType<TextBlock>(true);
                result2.Text = "Alarms after " + App.settings.DefaultLateTimeSetting.ToShortTimeString();
                messagePrompt.Body = lateAlarms;
                RoundButton remove_btn = new RoundButton() {ImageSource = new BitmapImage(new Uri("Icons/appbar.delete.rest.png", UriKind.Relative)), Tag="remove"};
                remove_btn.Click += removeLate_Click;
                messagePrompt.ActionPopUpButtons.Add(remove_btn);
                messagePrompt.ActionPopUpButtons.ElementAt(0).Click += confirm_Click;
                messagePrompt.ActionPopUpButtons.ElementAt(0).Tag = "confirm";
                messagePrompt.ActionPopUpButtons.ElementAt(1).Tag = "cancel";
                ViolatingAlarms.SelectionChanged += ViolatingAlarms_SelectionChanged;
                foreach (ListItemAlarm alarm in lateAlarmsDisplay)
                {
                    ViolatingAlarms.SelectedItems.Add(alarm);
                }
                messagePrompt.Show();
            }
            else
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
 void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     appointmentsList.ItemsSource = e.Results.ToList();
 }
예제 #31
0
        void Appointments_SearchCompleted_Background(object sender, AppointmentsSearchEventArgs e)
        {
            try
            {
                List<Appointment> appointments = new List<Appointment>(e.Results);
                List<String> show = new List<String>();
                int i = 1;
                List<DateTime> alarmtimes = new List<DateTime>();
                DateTime temp = DateTime.Now;
                DateTime LateAlarmTime = new DateTime(2013, 1, 1, LateHour, LateMin, 0);

                int NumberOfAlarms = 0;

                while (appointments.Count >= i || 8 > i)
                {
                    temp = temp.AddDays(1);
                    Appointment app = appointments.Find(item => item.StartTime.Hour != 0 && temp.Day == item.StartTime.Day);
                    if (app != null && app.StartTime.AddHours(-StartHour).AddMinutes(-StartMin).TimeOfDay < LateAlarmTime.TimeOfDay)
                    {
                        NumberOfAlarms++;
                    }
                    i++;
                }
                int counter;
                if (NumberOfAlarms - AlarmsSet < 0)
                    counter = 0;
                else counter = NumberOfAlarms - AlarmsSet;

                IEnumerable<ScheduledNotification> notifications = ScheduledActionService.GetActions<ScheduledNotification>();
                DateTime now = DateTime.Now;
                ScheduledNotification next = null;
                if (notifications.Count() != 0)
                {
                    next = (Alarm)notifications.ElementAt(0);
                    for (int j = 0; j < notifications.Count(); j++)
                    {
                        Alarm alarm = (Alarm)notifications.ElementAt(j);
                        if (alarm.ExpirationTime < now)
                            ScheduledActionService.Remove(alarm.Name);
                        else if (alarm.BeginTime < next.BeginTime)
                            next = alarm;
                    }
                }
                String DisplayHour = "";
                String DisplayMinute = "";
                String DisplayDay = "";

                if (next != null)
                {
                    DisplayDay = next.BeginTime.DayOfWeek.ToString() + "\n";
                    if (next.BeginTime.Hour > 9)
                        DisplayHour = next.BeginTime.Hour.ToString() + ":";
                    else
                        DisplayHour = "0" + next.BeginTime.Hour.ToString() + ":";

                    if (next.BeginTime.Minute > 9)
                        DisplayMinute = next.BeginTime.Minute.ToString();
                    else
                        DisplayMinute = "0" + next.BeginTime.Minute.ToString();
                }
                else
                    DisplayHour = "No alarms set.\nSleep well!";

                ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("flip".ToString()));

                if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
                {
                    FlipTileData oFliptile = new FlipTileData();
                    oFliptile.Title = "AutoAlarm";
                    oFliptile.Count = counter;
                    oFliptile.BackTitle = "AutoAlarm";
                    oFliptile.BackContent = DisplayDay + DisplayHour + DisplayMinute;
                    oFliptile.WideBackContent = DisplayDay + DisplayHour + DisplayMinute;
                    oFliptile.SmallBackgroundImage = new Uri("Icons/alarms300x300v3.png", UriKind.Relative);
                    oFliptile.BackgroundImage = new Uri("Icons/alarms300x300v3.png", UriKind.Relative);
                    oFliptile.BackBackgroundImage = new Uri("Icons/alarms300x300medium.png", UriKind.Relative);
                    oFliptile.WideBackgroundImage = new Uri("Icons/alarms691x300.png", UriKind.Relative);
                    oFliptile.WideBackBackgroundImage = new Uri("Icons/alarms691x300.png", UriKind.Relative);

                    oTile.Update(oFliptile);
                }
            }
            catch (System.Exception)
            {
                //That's okay, no results
            }
        }
예제 #32
0
 private void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     AppointmentNotAdded = !e.Results.Any(x => x.Subject == CurrentBand.Name);
 }
예제 #33
0
 public static void SearchAppointment(object sender, AppointmentsSearchEventArgs e)
 {
     listOfAppointment = new List<Appointment>(e.Results);
     
 }  
예제 #34
0
 void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
 {
     //Do something with the results.
     MessageBox.Show(e.Results.Count().ToString());
 }
예제 #35
0
        void appts_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            EventsResult res = e.State as EventsResult;
            double hours = double.Parse(res.duration);
            DateTime original = DateTime.Parse(res.event_date);
            original = original.AddSeconds(-original.Second);
            string desc = System.Text.RegularExpressions.Regex.Replace(res.description, "(?<!\r)\n", "\r\n");

            if (e.Results.Count() != 0)
            {
                foreach (Appointment appointment in e.Results)
                {
                    if (appointment.StartTime == original
                        && appointment.EndTime == original.Add(TimeSpan.FromHours(hours))
                        && appointment.Subject == res.name
                        && appointment.Location == res.address
                        && appointment.Details.Length == desc.Length)
                    {
                        res.isInCalendar = true;
                    }
                }
            }
            if (!res.isInCalendar)
            {
                data.CalendarData.result.Remove(res);
                EmsApi.SaveToPhone(JsonConvert.SerializeObject(data.CalendarData), EventsData.calendarDataKey);
            }

        }
예제 #36
0
        void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
        {
            var searchTerm = e.State as string;
            if (searchTerm == null) { return; }

            var wasLastSearch = false;
            if (WasLastSearch())
            {
                wasLastSearch = true;
            }
            else
            {
                var next = Pop();
                var from = next.Key;
                var to = next.Value;
                LaunchSearchForPeriod(searchTerm, from, to);
            }

            var searchTermUpper = searchTerm.ToUpperInvariant();
            foreach (var ap in e.Results)
            {
                if (!ap.Matches(searchTermUpper)) continue;

                var firstNewerItem = Appointments.FirstOrDefault(x => x.StartTime > ap.StartTime);
                if (firstNewerItem == null)
                {
                    Appointments.Add(ap);
                }
                else
                {
                    var index = Appointments.IndexOf(firstNewerItem);
                    Appointments.Insert(index, ap);
                }

            }

            if (wasLastSearch)
            {
                IsBusy = false;
                if (!Appointments.Any())
                {
                    StatusText = string.Format(AppRes.NothingFoundMessage_searchTerm_from_to,
                        searchTerm,
                        _now.ToSwedishTime(),
                        e.EndTimeInclusive.ToSwedishTime());
                }
                else
                {
                    StatusText = null;
                }
            }
        }