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); } }
private async void searchResultList_PositionChanged(object sender, EventArgs e) { ViewportControl viewport = sender as ViewportControl; if (viewport.Viewport.Bottom >= viewport.Bounds.Bottom && MainPage._isEventsLoaded && viewport.ManipulationState == System.Windows.Controls.Primitives.ManipulationState.Animating) { searchResultList.ListFooterTemplate = (DataTemplate)Application.Current.Resources["EventsFooterTemplate"]; ObservableCollection <EventsResult> res = MainPage.data.EventsData.result; string baseUrl = EmsApi.getBaseUrl("events", "v1", "search", EmsApi.GetClubIds(), SearchQuery, "", SearchData.result.Count); EventsData oldEvents = await EmsApi.getRawResponseAs <EventsData>(baseUrl); EmsApi.prettyDisplayDates(oldEvents.result); //Appending... foreach (EventsResult oldResult in oldEvents.result) { SearchData.result.Add(oldResult); } if (oldEvents == null || oldEvents.result.Count < 10) { searchResultList.ListFooterTemplate = (DataTemplate)Application.Current.Resources["ReachedLastSearchEventFooterTemplate"]; } else { searchResultList.ListHeaderTemplate = null; } } }
public void LoadingEnd() { EmsApi.SetProggressIndicatorVisibility(false); EventList.IsEnabled = true; _isEventsLoaded = true; ClubSelection.isInitialized = true; }
public static void changeLanguageTo(EmsApi.Languages lang) { MainPage.EmsLanguage = lang; switch (lang) { case EmsApi.Languages.tr: Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("tr"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("tr"); break; case EmsApi.Languages.en: Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); break; default: break; } EmsApi.SaveToPhone(JsonConvert.SerializeObject(lang), languageKey); LocalizedStrings.LocalizedStringsResource.UpdateLanguage(); updateContentWithLanguage(); }
public async void MainPage_Loaded(object sender, RoutedEventArgs e) { try { if (!isLoaded) { initLanguage(); LoadingStarted(); await initApplication(); isLoaded = true; } else { ApplicationBar.IsVisible = false; LoadingStarted(); await updateEventsWithLanguage(); await updateClubsWithLanguage(); updateButtonTexts(); ApplicationBar.IsVisible = MainPagePivotView.SelectedIndex != 0; } LoadingEnd(); } catch (Exception ex) { EmsApi.Log(ex.Message); LoadingEnd(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { searchResultList.ListFooterTemplate = null; string clubIds = EmsApi.GetClubIds(); SearchQuery = textToBeSearched.Text.ToString(); AddInfoTemplate("EventsFooterTemplate"); string url = EmsApi.getBaseUrl("events", "v1", "search", "", SearchQuery, "", 0, "", "", MainPage.EmsLanguage); EventsData res = await EmsApi.getRawResponseAs <EventsData>(url); if (res == null || res.result == null || res.result.Count == 0) { AddInfoTemplate("NoSearchEventFooterTemplate"); return; } EmsApi.prettyDisplayDates(res.result); AddInfoTemplate("ListTemplate", true, res.result); //To reach it from details page. SearchData = res; }
private async Task updateEventsWithLanguage() { EventList.ItemsSource = null; data.EventsData = await EmsApi.GetEventsInfo("", EmsLanguage); EventList.ItemsSource = data.EventsData.result; EmsApi.prettyDisplayDates(data.EventsData.result); }
public void LoadingStarted() { EmsApi.StartTrayLoadingAnimation(); _isEventsLoaded = false; EventList.IsEnabled = false; //Reset the header and the footer of the events list EventList.ListHeaderTemplate = null; EventList.ListFooterTemplate = null; }
private void reorginizeDates(EventsResult res) { CultureInfo culture = new CultureInfo("en-US"); double hours = double.Parse(res.duration, culture); Duration.Content = EmsApi.GetTimeSpan(DateTime.Now.AddHours(-hours), true); CreatedAt.Content = DateTime.Parse(res.created_at).ToLongDateString(); Date.Content = DateTime.Parse(res.event_date).ToLongDateString(); }
private async Task updateClubsWithLanguage() { ClubsList.ItemsSource = null; ClubsList.IsHitTestVisible = false; EmsApi.StartTrayLoadingAnimation(); if (data.ClubsData != null) { data.ClubsData = await EmsApi.GetClubsData("", EmsLanguage); } EmsApi.SetProggressIndicatorVisibility(false); ClubsList.ItemsSource = data.ClubsData.result; ClubsList.IsHitTestVisible = true; }
private void FillRectangle_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (IsTickButtonChecked()) { ChangeCheckedStatus(false, "GrayButtonBrush"); } else { ChangeCheckedStatus(true, "BackButtonBrush"); } EmsApi.SaveToPhone(JsonConvert.SerializeObject(MainPage.data.ClubsData), ClubsData.clubsDataKey); EmsApi.SaveToPhone(JsonConvert.SerializeObject(MainPage.data.ClubIdIsCheked), ClubsData.IsCheckedKey); }
private async Task initApplication() { data.ClubIdIsCheked = EmsApi.GetClubsIdIsChecked(); data.CalendarData = EmsApi.GetCalendarData(); resetCalendar(); data.ClubsData = await EmsApi.GetClubsData("", EmsLanguage); data.EventsData = await EmsApi.GetEventsInfo("", EmsLanguage); data.HomeLinks = await EmsApi.GetHomeLinks(); DataContext = data; EmsApi.prettyDisplayDates(data.EventsData.result); }
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); }
private void HomeLinksList_SelectionChanged(object sender, SelectionChangedEventArgs e) { LongListSelector lls = sender as LongListSelector; if (lls == null || lls.SelectedItem == null) { return; } ClubResult res = lls.SelectedItem as ClubResult; MainPage.data.ClubIdIsCheked[res.id] = res.IsChecked; EmsApi.SaveToPhone(JsonConvert.SerializeObject(MainPage.data.ClubsData), ClubsData.clubsDataKey); EmsApi.SaveToPhone(JsonConvert.SerializeObject(MainPage.data.ClubIdIsCheked), ClubsData.IsCheckedKey); lls.SelectedItem = null; }
private async void ClubSelection_Loaded(object sender, RoutedEventArgs e) { if (!isInitialized) { SelectionStackPanel.IsHitTestVisible = false; SettinsCheckBoxList.IsHitTestVisible = false; EmsApi.StartTrayLoadingAnimation(); if (MainPage.data.ClubsData != null) { MainPage.data.ClubsData = await EmsApi.GetClubsData("", MainPage.EmsLanguage); } EmsApi.SetProggressIndicatorVisibility(false); SelectionStackPanel.IsHitTestVisible = true; SettinsCheckBoxList.IsHitTestVisible = true; isInitialized = true; } DataContext = MainPage.data; }
private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { Clipboard.SetText((sender as HyperlinkButton).Content.ToString()); EmsApi.showToast(AppResources.CopyMessage); }
private async void EventList_PositionChanged(object sender, EventArgs e) { ViewportControl viewport = sender as ViewportControl; if (MainPage._isEventsLoaded && viewport.ManipulationState == System.Windows.Controls.Primitives.ManipulationState.Animating) { ObservableCollection <EventsResult> res = MainPage.data.EventsData.result; if (viewport.Viewport.Bottom >= viewport.Bounds.Bottom) { //Loading... EventList.ListFooterTemplate = (DataTemplate)Application.Current.Resources["EventsFooterTemplate"]; string baseUrl = EmsApi.getBaseUrl("events", "v1", "after", EmsApi.GetClubIds(), "", (res[res.Count - 1] as EventsResult).id, 0, "", "", EmsLanguage); EventsData freshEventsList = await EmsApi.getRawResponseAs <EventsData>(baseUrl); EmsApi.prettyDisplayDates(freshEventsList.result); //Appending... foreach (EventsResult item in freshEventsList.result) { MainPage.data.EventsData.result.Add(item); } //Displaying the footer acording to data obtained. if (freshEventsList == null || freshEventsList.result.Count < 10) { EventList.ListFooterTemplate = (DataTemplate)Application.Current.Resources["ReachedLastEventFooterTemplate"]; } else { EventList.ListHeaderTemplate = null; } } if (viewport.Viewport.Top <= viewport.Bounds.Top) { //Loading... EventList.ListHeaderTemplate = (DataTemplate)Application.Current.Resources["EventsHeaderTemplate"]; string baseUrl = EmsApi.getBaseUrl("events", "v1", "before", EmsApi.GetClubIds(), "", (res[0] as EventsResult).id, 0, "", "", EmsLanguage); EventsData oldEvents = await EmsApi.getRawResponseAs <EventsData>(baseUrl); EmsApi.prettyDisplayDates(oldEvents.result); //Appending to the top of the list... foreach (EventsResult oldResult in oldEvents.result) { MainPage.data.EventsData.result.Insert(0, oldResult); } //Displaying the header acording to data obtained. if (oldEvents == null || oldEvents.result.Count < 10) { EventList.ListHeaderTemplate = (DataTemplate)Application.Current.Resources["ReachedFirstEventHeaderTemplate"]; } else { EventList.ListHeaderTemplate = null; } } } }