private async void deleteButton_Click(object sender, EventArgs e)
        {
            if (curChar == null)
            {
                return;
            }
            MessageBoxResult res = MessageBox.Show("Are you sure you want to remove " + curChar.name + " from this application?", "Remove Character?", MessageBoxButton.OKCancel);
            if (res == MessageBoxResult.OK)
            {

                app.db.characterItems.DeleteOnSubmit(curChar);
                curChar = null;
                app.db.SubmitChanges();

                await loadLastCharacter();

            }
        }
 private async Task<bool> selectCharacter(Character character)
 {
     pivot.Visibility = Visibility.Collapsed;
     if (character == null)
     {
         noCharacterMessage.Visibility = Visibility.Visible;
     }
     else
     {
         noCharacterMessage.Visibility = Visibility.Collapsed;
     }
     if (this.curChar != character)
     {
         this.curChar = character;
         foreach (Character c in app.db.characterItems)
         {
             c.isSelected = false;
         }
         if (curChar != null)
         {
             curChar.isSelected = true;
         }
     }
     await loadData();
     return true;
 }
        private async void goButton_Click(object sender, EventArgs e)
        {
            goButton.IsEnabled = false;
            characterList.ItemsSource = null;
            progressIndicator.IsVisible = true;
            ErrorMessage.Text = null;
            ErrorMessage.Visibility = Visibility.Collapsed;

            try
            {
                chars = new List<Character>();
                string urlparams = "?keyID=" + apiKey.Text + "&vCode=" + vCode.Text;
                var httpClient = new HttpClient();
                httpClient.Timeout = TimeSpan.FromSeconds(10);
                string char_sheet_url = "https://api.eveonline.com/account/APIKeyInfo.xml.aspx" + urlparams;
                Uri char_sheet_uri = new Uri(char_sheet_url);

                var response = await httpClient.GetAsync(char_sheet_uri);
                if (response.StatusCode == HttpStatusCode.BadRequest)
                {
                    throw new BadRequestException("API Key or vCode is invalid");
                }
                string content = await response.Content.ReadAsStringAsync();
                var doc = XDocument.Parse(content);
                var char_sheet_response = doc.Element("eveapi");
                var skills_rowset =
                    char_sheet_response.Element("result")
                        .Element("key")
                        .Elements("rowset")
                        .FirstOrDefault(x => x.Attribute("name").Value == "characters");
                var characters_list = skills_rowset.Elements("row");

                foreach (var character in characters_list)
                {
                    string characterID = character.Attribute("characterID").Value;
                    string name = character.Attribute("characterName").Value;

                    Character b = new Character();
                    b.characterID = characterID;
                    b.vCode = vCode.Text;
                    b.keyID = apiKey.Text;
                    b.name = name;
                    b.updateInterval = 60;
                    b.canAdd = !db.characterItems.Any(x => x.characterID == characterID);
                    b.isChecked = db.characterItems.Any(x => x.characterID == characterID);
                    b.failureCount = 0;
                    b.notificationsOn = true;
                    chars.Add(b);
                }
                if (chars.Count == 0)
                {
                    ErrorMessage.Text = "No characters";
                    ErrorMessage.Visibility = Visibility.Visible;
                }
            }
            catch (BadRequestException ex)
            {
                ErrorMessage.Text = ex.Message;
                ErrorMessage.Visibility = Visibility.Visible;
            }
            catch (ForbiddenException )
            {
                Debug.WriteLine("Forbidden");
                ErrorMessage.Text = "API key is not authorized";
                ErrorMessage.Visibility = Visibility.Visible;

            }
            catch (WebException )
            {
                Debug.WriteLine("WebException");
                ErrorMessage.Text = "There was an issue with the request.";
                ErrorMessage.Visibility = Visibility.Visible;
            }
            catch (TaskCanceledException )
            {
                Debug.WriteLine("Task cancelled exception");
                ErrorMessage.Text = "The request timed out, please try again.";
                ErrorMessage.Visibility = Visibility.Visible;
            }
            progressIndicator.IsVisible = false;
            characterList.ItemsSource = chars;
            goButton.IsEnabled = true;
        }