Esempio n. 1
0
 //user tap logout
 private void logoutTextBlock_Tap(object sender, GestureEventArgs e)
 {
     var answer = MessageBox.Show("Are you sure you want to log out?", "Log out", MessageBoxButton.OKCancel);
     if (answer == MessageBoxResult.OK)
     {
         if (settings.Contains("connectedEvent") && settings.Contains("currentUser") && settings.Contains("minClientReqID"))
         {
             selectedEvent = (Event)settings["connectedEvent"];
             selectedEvent.logout(currentUser.id, currentUser.hashID, true);
             settings.Remove("currentUser");
             settings.Remove("connectedEvent");
             settings.Remove("minClientReqID");
         }
         this.Dispatcher.BeginInvoke(() => this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)));
     }
     else findNearestEvent();
 }
Esempio n. 2
0
        //when a user taps an event
        /*       private void eventListBox_Loaded(object sender, RoutedEventArgs e)  //once the page loads,
        {
            currentUser = (User)settings["currentUser"];
            string statusCode = "";
            string url = "http://udjevents.com:4897/udj/events/40.113523/";

            var client = new RestClient(url);
            var request = new RestRequest("-88.224006", Method.GET);
            request.AddHeader("X-Udj-Api-Version", "0.2");
            request.AddHeader("X-Udj-Ticket-Hash", currentUser.hashID);

            client.ExecuteAsync(request, response =>
            {
                // string hashIDString = currentUser.hashID;

                statusCode = response.StatusCode.ToString();
                if (statusCode != "OK")
                {
                    //MessageBox.Show("It appears you're already logged in. I'll redirect you to the events listings");
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                }

            });
        }

        */
        private void eventListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 1) //checks to make sure only 1 event is selected
            {
                currentUser = (User)settings["currentUser"]; //load currentUser
                selectedEvent = (Event)eventListBox.SelectedItem; //get the selected event
                var answer = MessageBox.Show("Do you want to join this event?", "Selected Event", MessageBoxButton.OKCancel);
                if (answer == MessageBoxResult.OK)
                {
                    settings["connectedEvent"] = selectedEvent; //locally store the selectedEvent
                    settings["currentUser"] = currentUser;
                    settings["minClientReqID"] = 0;
                    EventDatePair eventDate = new EventDatePair(selectedEvent, DateTime.Now);
                    List<EventDatePair> recentEvents = new List<EventDatePair>();
                    if (settings.Contains("recentEvents"))
                        recentEvents = (List<EventDatePair>)settings["recentEvents"];
                    recentEvents.Add(eventDate); //add the selected event to recent events
                    settings["recentEvents"] = recentEvents;
                    currentUser.loginToEvent(selectedEvent.name, selectedEvent.id);

                }
                else
                {
                    findNearestEvent();
                }
            }
        }