public void Load(WordDefinition[] words)
        {
            _picsbox = new PictureBox[words.Length];

            _gridview.Rows.Clear();
            for (int i = 0; i < words.Length; i++)
            {
                //picsbox[i] = new PictureBox();

                DataGridViewRow dgvr = new DataGridViewRow();
                dgvr.Height = 100;
                DataGridViewTextBoxCell text = new DataGridViewTextBoxCell()
                {
                    Value = words[i].Definition
                };
                DataGridViewImageCell img = new DataGridViewImageCell()
                {
                    Value = null
                };
                DataGridViewTextBoxCell tag = new DataGridViewTextBoxCell()
                {
                    Value = words[i].Tag
                };

                if (words[i].Image.Length > 1)
                {
                    _picsbox[i] = new PictureBox();
                    _picsbox[i].ImageLocation = words[i].Image;
                    _picsbox[i].LoadCompleted += Loaded;
                    _picsbox[i].LoadAsync();
                }

                dgvr.Cells.Add(text);
                dgvr.Cells.Add(img);
                dgvr.Cells.Add(tag);
                _gridview.Rows.Add(dgvr);
            }
        }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the WordDefinitions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWordDefinitions(WordDefinition wordDefinition)
 {
     base.AddObject("WordDefinitions", wordDefinition);
 }
예제 #3
0
 /// <summary>
 /// Create a new WordDefinition object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="word">Initial value of the Word property.</param>
 /// <param name="definition">Initial value of the Definition property.</param>
 /// <param name="image">Initial value of the Image property.</param>
 /// <param name="tag">Initial value of the Tag property.</param>
 public static WordDefinition CreateWordDefinition(global::System.Int64 id, global::System.String word, global::System.String definition, global::System.String image, global::System.String tag)
 {
     WordDefinition wordDefinition = new WordDefinition();
     wordDefinition.Id = id;
     wordDefinition.Word = word;
     wordDefinition.Definition = definition;
     wordDefinition.Image = image;
     wordDefinition.Tag = tag;
     return wordDefinition;
 }
예제 #4
0
        private void ParseMnemonicDictionary(string word)
        {
            FireLogMessage("Parsing Mnemonics for: " + word);

            GreWord greWord = GetGreWord(word);
            MnemonicsDictionaryHtml gd = (_entities.MnemonicsDictionaryHtmls.Where(w => w.Word == word)).FirstOrDefault();
            if (gd == null)
                return;

            string text = gd.Html;
            Regex regexWordUl = new Regex("<ul class='wordnet'>(.+?)</ul>", RegexOptions.Singleline);
            Regex regexWordLi = new Regex("<li>(.+?)</li>", RegexOptions.Singleline);

            Regex regexImage = new Regex("<div class=\"floatright\">.+?<img src=\"(.+?)\".+?</div>", RegexOptions.Singleline);
            Regex regexTag = new Regex("<div class=\"floatleft\">(.+?)</div>", RegexOptions.Singleline);

            Match meaningMatch = regexWordUl.Match(text);
            if (meaningMatch.Success)
            {
                MatchCollection meanings = regexWordLi.Matches(meaningMatch.Value);

                foreach (Match m in meanings)
                {
                    string tag = "";
                    string img = "";

                    string def = CleanText(m.Groups[1].Value);
                    MatchCollection mci = regexImage.Matches(def);
                    foreach (Match mi in mci)
                    {
                        Match mt = regexTag.Match(def);

                        img = mi.Groups[1].Value;
                        tag = mt.Groups[1].Value.Replace("\r\n", "");

                        def = regexImage.Replace(def, "");
                        def = regexTag.Replace(def, "");
                        def = def.Replace("<div class='clear'></div>", "");
                    }

                    WordDefinition wordDefinition = new WordDefinition { Definition = def, Image = img, Tag = tag, GreWord = greWord, };
                    _entities.AddToWordDefinitions(wordDefinition);
                    _entities.SaveChanges();
                }
            }

            Regex regexSelectedMnemonicDiv = new Regex("<div class='mnemonics'>(.+?)</div>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Regex regexSelectedMnemonicLi = new Regex(@"<li><p>(.+?)</p><p>\s+added by.+?</li>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Match selectedMnemonic = regexSelectedMnemonicDiv.Match(text);
            if (selectedMnemonic.Success)
            {
                MatchCollection selectedMnemonics = regexSelectedMnemonicLi.Matches(selectedMnemonic.Groups[1].Value);

                foreach (Match m in selectedMnemonics)
                {
                    //listSelectedMnemonics.Items.Add(clarify(m.Groups[1].Value));
                    string def = CleanText(m.Groups[1].Value);
                    FeaturedMnemonic mnemonics = new FeaturedMnemonic
                                                     {
                                                         Mnemonic = def,
                                                         GreWord = greWord
                                                     };
                    _entities.AddToFeaturedMnemonics(mnemonics);
                    _entities.SaveChanges();
                }
            }

            Regex regexAllMnemonicDiv = new Regex("<div class='mnemonic'>(.+?)</div>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Regex regexAllMnemonicLi = new Regex(@"<li><p>(.+?)</p><p>\s+added by.+?<p>Was this mnemonic useful \?&nbsp; &nbsp;\s+<strong id='hallo\d+'>(.+?)</strong>.+?<strong id='hallo\d+'>&nbsp;(.+?)</strong>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Match allMnemonic = regexAllMnemonicDiv.Match(text);
            if (allMnemonic.Success)
            {
                MatchCollection meanings = regexAllMnemonicLi.Matches(allMnemonic.Groups[1].Value);

                foreach (Match m in meanings)
                {
                    string def = CleanText(m.Groups[1].Value);
                    BasicMnemonic mnemonics = new BasicMnemonic()
                    {
                        Mnemonic = def,
                        Helpful = m.Groups[2].Value,
                        NotHelpful = m.Groups[3].Value
                    };
                    mnemonics.GreWord = greWord;
                    _entities.AddToBasicMnemonics(mnemonics);
                    _entities.SaveChanges();
                }
            }
        }