Beispiel #1
0
        private void ButtonCardId_Click(object sender, RoutedEventArgs e)
        {
            TextBoxCardInfo.Clear();
            ListViewCardList.Items.Clear();

            string id = TextBoxCardId.Text.Trim();

            if (string.IsNullOrWhiteSpace(id))
            {
                MessageBox.Show("Card Id should not be empty.");
                return;
            }

            var prefix = "Sim_";

            if (id.StartsWith(prefix))
            {
                id = id.Replace(prefix, string.Empty);
            }

            var cards = Cards.All.Values;

            id = id.ToLowerInvariant();
            var cardList = cards.Where(x => x.Id.ToLowerInvariant().Contains(id)).ToList();

            if (cardList.Count == 0)
            {
                MessageBox.Show($"Can not find the card with id {id}");
                return;
            }

            AddCardToListView(cardList);
        }
Beispiel #2
0
        private void ButtonCardName_Click(object sender, RoutedEventArgs e)
        {
            TextBoxCardInfo.Clear();
            ListViewCardList.Items.Clear();

            string name = TextBoxCardName.Text.Trim();

            if (string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show("Card Name should not be empty.");
                return;
            }

            var dictionary = new Dictionary <string, Card>();
            var cardList   = Cards.GetFromFuzzyName(name, Locale.zhCN, false);

            foreach (var item in cardList)
            {
                AddItemToDictionary(dictionary, item);
            }
            cardList = Cards.GetFromFuzzyName(name, Locale.enUS, false);
            foreach (var item in cardList)
            {
                AddItemToDictionary(dictionary, item);
            }

            if (dictionary.Count == 0)
            {
                MessageBox.Show($"Can not find the card with name {name} in English(en-US) or Chinese(zh-CN)");
                return;
            }

            cardList = dictionary.Values.ToList();
            AddCardToListView(cardList);
        }
Beispiel #3
0
        private void TextBoxCardText_OnKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }

            TextBoxCardInfo.Clear();
            ListViewCardList.Items.Clear();

            string text = TextBoxCardText.Text.Trim();

            if (string.IsNullOrWhiteSpace(text))
            {
                MessageBox.Show("Card text should not be empty.");
                return;
            }

            var dictionary = new Dictionary <string, Card>();
            var cardList   = Cards.GetFromFuzzyText(text, Locale.zhCN, false);

            foreach (var item in cardList)
            {
                AddItemToDictionary(dictionary, item);
            }
            cardList = Cards.GetFromFuzzyText(text, Locale.enUS, false);
            foreach (var item in cardList)
            {
                AddItemToDictionary(dictionary, item);
            }

            if (dictionary.Count == 0)
            {
                MessageBox.Show($"Can not find the card with text {text} in English(en-US) or Chinese(zh-CN)");
                return;
            }

            cardList = dictionary.Values.ToList();
            AddCardToListView(cardList);
        }