Ejemplo n.º 1
0
 private void BValidate_Click(object sender, RoutedEventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(tbMercenaryCode.Text))
     {
         testMerc = new MercenaryItem(tbMercenaryCode.Text);
         if (testMerc.ValidateMercenaryCode())
         {
             if (testMerc.isHordeMercenary)
             {
                 MessageBox.Show("Horde Mercenary code successfully validated, you may now import this mercenary!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                 bSave.IsEnabled = true;
             }
             else
             {
                 MessageBox.Show("Mercenary code successfully validated, you may now import this mercenary!", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                 bSave.IsEnabled = true;
             }
         }
         else
         {
             MessageBox.Show("The code does not appear to be valid! Make sure you copied the code correctly and try again.\n\nI'm a bit stupid at the moment, in the future I might be able to help you!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
     else
     {
         MessageBox.Show("I can't validate something that doesn't exist you dum-dum. Try actually pasting something, huh? What do you take me for?!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 2
0
        private void BValidate_Click(object sender, RoutedEventArgs e)
        {
            List <string>        parsedMercenaries = new List <string>();
            List <MercenaryItem> _invalidMercs     = new List <MercenaryItem>();

            if (!String.IsNullOrWhiteSpace(tbMercenaryCode.Text))
            {
                _mercenaryList.Clear(); // Clear List For Next Validation

                Regex profile = new Regex(@"^CharacterProfiles=\(.+\)", RegexOptions.Multiline);
                Regex ws      = new Regex(@"^\s+CharacterProfiles=\(.+\)", RegexOptions.Multiline); // We'll also look for any leading whitespace
                Regex horde   = new Regex(@"(DefaultCharacterFace=\(.+)");
                foreach (Match match in profile.Matches(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(match.Value);
                }
                foreach (Match match in ws.Matches(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(match.Value.TrimStart());
                }
                if (horde.IsMatch(tbMercenaryCode.Text))
                {
                    parsedMercenaries.Add(horde.Match(tbMercenaryCode.Text).Value);
                }

                foreach (string parsedMercenary in parsedMercenaries)
                {
                    MercenaryItem mercenary = new MercenaryItem(parsedMercenary);
                    if (mercenary.ValidateMercenaryCode())
                    {
                        _mercenaryList.Add(mercenary);
                        bSave.IsEnabled = true;
                    }
                    else
                    {
                        _invalidMercs.Add(mercenary);
                    }
                }
                _mercenaryList.Reverse(); // Reverse the list so it appears in the order it was pasted in
                if (_mercenaryList.Count == 0 && _invalidMercs.Count == 0)
                {
                    MessageBox.Show("Invalid mercenary code! Make sure you copied the code correctly and try again.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    MessageBox.Show(String.Format("{0} mercenaries successfully validated!\n\n{1} mercenaries failed to validate!", _mercenaryList.Count, _invalidMercs.Count), "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Cannot validate empty code, you dummy!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }