private void searchListBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var list = (ListBox)sender; if (list.SelectedItem == _selected) { list.SelectedIndex = -1; _selected = null; ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar3"]; } else { _selected = list.SelectedItem; ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar)Resources["appbar2"]; selectedSearchResult = (LibraryEntry)searchListBox.SelectedItem; } }
private void searchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 1) { selectedSearchResult = (LibraryEntry)searchListBox.SelectedItem; minClientReqIDMap[selectedSearchResult.id] = minClientReqID; string statusCode = ""; string url = "https://udjevents.com:4897/udj/events/" + connectedEvent.id + "/active_playlist"; var client = new RestClient(url); var request = new RestRequest("songs", Method.PUT); request.AddHeader("X-Udj-Ticket-Hash", currentUser.hashID.ToString()); request.AddHeader("X-Udj-Api-Version", "0.2"); request.AddHeader("Content-Type", "text/json"); string jsonObject = @"[{ ""lib_id"":" + selectedSearchResult.id + @", ""client_request_id"":" + minClientReqID + "}]"; //create JSON object request.RequestFormat = DataFormat.Json; request.AddParameter("text/json", jsonObject, ParameterType.RequestBody); //add JSON object as string client.ExecuteAsync(request, response => { statusCode = response.StatusCode.ToString(); if (statusCode != "Created") { MessageBox.Show("There seems to be an error: " + statusCode); } else if (statusCode == "NotFound") { MessageBox.Show("You don't seemed to be connected to the internet, please check your settings and try again"); } PhoneApplicationService.Current.State["minClientReqID"] = minClientReqID++; var answer = MessageBox.Show("Your song was successfully added and upvoted! Would you like to refresh the active playlist?", "Song added", MessageBoxButton.OKCancel); if (answer == MessageBoxResult.OK) { updateNowPlaying(); } }); } }