public void ClearWebColliders(WebDictionary webDictionary) { foreach (KeyValuePair <string, IndexColorMap> web in webDictionary) { childObjects.Find(x => x.name == web.Key).GetComponent <ColorSwapper>().EraseWebColliders(web.Value.IntArray); } }
private void CambridgeButton_Click(object sender, EventArgs e) { ActiveControl = null; _dictionary = WebDictionary.Cambridge; dictionarySelectorPanel.Visible = true; dictionarySelectorPanel.Location = cambridgeButton.Location; if (!string.IsNullOrWhiteSpace(searchBox.Text)) { Task.Factory.StartNew(FetchData); } }
private void TurengButton_Click(object sender, EventArgs e) { ActiveControl = null; _dictionary = WebDictionary.Tureng; dictionarySelectorPanel.Visible = true; dictionarySelectorPanel.Location = turengButton.Location; chromWebBrowser.BringToFront(); if (!string.IsNullOrWhiteSpace(searchBox.Text)) { Task.Factory.StartNew(FetchData); } }
public static Task <WebDictionary <string> > ProcessAsync(IOwinContext context, string id) { if (id == null) { throw new BadRequestException("GetExternalMediaInfo: id is null"); } WebDictionary <string> webDictionary = new WebDictionary <string> { { "Id", id } }; return(Task.FromResult(webDictionary)); }
public WebDictionary <string> GetExternalMediaInfo(WebMediaType type, string id) { var dict = new WebDictionary <string>(); dict.Add("Id", id); if (type == WebMediaType.MusicAlbum) { dict.Add("Type", "mvcentral album"); } if (type == WebMediaType.MusicArtist) { dict.Add("Type", "mvcentral artist"); } if (type == WebMediaType.MusicTrack) { dict.Add("Type", "mvcentral track"); } return(dict); }
public WebSearchResult() { Details = new WebDictionary <string>(); }
public WordDataGrid(WebDictionary word, double partOfSpeechAndWordPlayerFontSize, double sentenceFontSize, Grid mainGrid, int index, SentencePlayer sentencePlayer) { mainGrid.RowDefinitions.Add(new RowDefinition()); mainGrid.RowDefinitions[index].Height = new GridLength(1, GridUnitType.Star); ScrollViewer scrollViewer = new ScrollViewer(); Grid dataGrid = new Grid(); dataGrid.VerticalAlignment = VerticalAlignment.Top; scrollViewer.Content = dataGrid; Grid.SetRow(scrollViewer, index); mainGrid.Children.Add(scrollViewer); int gridRowIndex = 0; int sentenceCount = 0; foreach (var partOfSpeechAndMeaningPair in word.Sentences) { #region 詞性設定 var partOfSpeechLabel = new GridLabel( partOfSpeechAndMeaningPair.Key, partOfSpeechAndWordPlayerFontSize, Brushes.Lavender, dataGrid, GridDefinitions.Row, null, gridRowIndex); gridRowIndex++; #endregion foreach (var meaningAndSentencePair in partOfSpeechAndMeaningPair.Value) { #region 中文意思設定 var chineseMeaningLabel = new GridLabel( $" {meaningAndSentencePair.Key}", partOfSpeechAndWordPlayerFontSize, Brushes.PapayaWhip, dataGrid, GridDefinitions.Row, null, gridRowIndex); gridRowIndex++; #endregion for (int i = 0; i < meaningAndSentencePair.Value.Count; i++) { #region 英文例句設定 dataGrid.RowDefinitions.Add(new RowDefinition()); var sentenceGrid = new Grid(); string[] sentanceWords = meaningAndSentencePair.Value[i].GetEnglishSentence().Split(new char[] { ' ' }); sentenceGrid.HorizontalAlignment = HorizontalAlignment.Left; #region 加上前面的空白間隔 var emptyLabel = new GridLabel($" ", sentenceFontSize, null, sentenceGrid, GridDefinitions.Column, GridLength.Auto, 0); #endregion for (int j = 0; j < sentanceWords.Length; j++) { var wordButton = new WordButton(sentanceWords[j] + " ", sentenceFontSize, sentenceGrid, j + 1); } #region 句子發音 sentencePlayer.SetSentenceVoiceButton(sentenceCount, sentenceFontSize, sentenceGrid, sentanceWords.Length + 1); #endregion Grid.SetRow(sentenceGrid, gridRowIndex); dataGrid.Children.Add(sentenceGrid); gridRowIndex++; #endregion #region 中文例句設定 var chineseSentenceLabel = new GridLabel( $" {meaningAndSentencePair.Value[i].GetChineseSentence()}", sentenceFontSize, Brushes.Gainsboro, dataGrid, GridDefinitions.Row, null, gridRowIndex); gridRowIndex++; #endregion sentenceCount++; } } } }
public override WebDictionary GetDictionaryByHtml(string wordStr) { WebDictionary word = null; try { var htmlStr = GetHtml(GetDictionaryURL(wordStr)); Document htmlDoc = NSoupClient.Parse(htmlStr); var allBlock = htmlDoc.GetElementsByTag("ol").First(x => x.Attr("class") == "mb-15 reg searchCenterMiddle"); var meaningBlock = allBlock.GetElementsByTag("div").First(x => x.Attr("class") == "grp grp-tab-content-explanation tabsContent tab-content-explanation tabActived"); var phonetic = htmlDoc.GetElementsByTag("div").First(x => x.Attr("class") == "compList ml-25 d-ib").Text(); phonetic = phonetic.Replace('ˋ', '`'); var rows = meaningBlock.GetElementsByTag("li").ToArray(); var sentencesByPos = new Dictionary <string, Dictionary <string, List <Sentence> > >(); string partOfSpeech = ""; for (int i = 0; i < rows.Length; i++)//詞性 { var rowStr = rows[i].Text(); Regex regex = new Regex(@"\d+"); Match match = regex.Match(rowStr); if (match.Success) { //中文意思 var meaning = rows[i].GetElementsByTag("span").First().Text(); if (!sentencesByPos[partOfSpeech].ContainsKey(meaning)) { sentencesByPos[partOfSpeech].Add(meaning, new List <Sentence>()); } var sentenceElements = rows[i].GetElementsByTag("p"); foreach (var sentenceElement in sentenceElements) { var sentence = sentenceElement.Text(); int firstChineseIndex = -1; for (int j = 0; j < sentence.Length; j++) { UnicodeCategory cat = char.GetUnicodeCategory(sentence[j]); if (cat == UnicodeCategory.OtherLetter) { firstChineseIndex = j; break; } } var engSentence = sentence.Substring(0, firstChineseIndex - 1); var chiSentence = sentence.Substring(firstChineseIndex); sentencesByPos[partOfSpeech][meaning].Add(new Sentence(chiSentence, engSentence)); } } else { //詞性 partOfSpeech = rowStr; sentencesByPos[partOfSpeech] = new Dictionary <string, List <Sentence> >(); } } word = new YahooDictionary(wordStr, sentencesByPos, phonetic); } catch (Exception e) { //MessageBox.Show($"Error : {e.Message}"); } return(word); }
public override WebDictionary GetDictionaryByHtml(string wordStr) { WebDictionary word = null; try { var htmlStr = GetHtml(GetDictionaryURL(wordStr)); Document htmlDoc = NSoupClient.Parse(htmlStr); var meaningsByPos = new Dictionary <string, List <string> >(); var sentencesByPos = new Dictionary <string, Dictionary <string, List <Sentence> > >(); var POS_Blocks = htmlDoc.GetElementsByTag("div").Where(x => x.Attr("class") == "entry-body__el clrd js-share-holder").ToArray(); if (POS_Blocks.Length == 0) { return(word); } HashSet <string> phonetics = new HashSet <string>(); foreach (var POS_Block in POS_Blocks) { var pos = POS_Block.GetElementsByTag("div").FirstOrDefault(x => x.Attr("class") == "pos-header").GetElementsByTag("span").FirstOrDefault(x => x.Attr("class") == "pos").Text(); if (!meaningsByPos.ContainsKey(pos)) { meaningsByPos.Add(pos, new List <string>()); } if (!sentencesByPos.ContainsKey(pos)) { sentencesByPos.Add(pos, new Dictionary <string, List <Sentence> >()); } var header = POS_Block.GetElementsByTag("span").Where(x => x.Attr("class") == "pron-info"); var phoneticList = new List <string>(); foreach (var item in header) { var element = item as NSoup.Nodes.Element; var kind = element.GetElementsByTag("span").FirstOrDefault(x => x.Attr("class") == "region"); var phonetic = element.GetElementsByTag("span").FirstOrDefault(x => x.Attr("class") == "pron"); phoneticList.Add($"{kind?.Text()}:{phonetic?.Text()}"); } var phoneticStr = String.Join(" ", phoneticList); phonetics.Add(phoneticStr); var senseBlocks = POS_Block.GetElementsByTag("div").Where(x => x.Attr("class") == "sense-block").ToArray(); foreach (var senseBlock in senseBlocks) { var defBlocks = senseBlock.GetElementsByTag("div").Where(x => x.Attr("class") == "def-block pad-indent"); foreach (var defBlock in defBlocks) { var engSense = defBlock.GetElementsByTag("b").FirstOrDefault(x => x.Attr("class") == "def").Text(); var chiSense = defBlock.GetElementsByTag("span").FirstOrDefault(x => x.Attr("class") == "trans").Text(); var mean = $"{chiSense}\n{engSense}"; meaningsByPos[pos].Add(mean); if (!sentencesByPos[pos].ContainsKey(mean)) { sentencesByPos[pos].Add(mean, new List <Sentence>()); } var examples = defBlock.GetElementsByTag("div").Where(x => x.Attr("class") == "examp emphasized"); foreach (var example in examples) { var meanStr = example.Text(); var chiSentence = example.GetElementsByTag("span").FirstOrDefault(x => x.Attr("class") == "trans").Text(); var engSentence = meanStr.Substring(0, meanStr.Length - chiSentence.Length - 1); var sentence = new Sentence(chiSentence, engSentence); sentencesByPos[pos][mean].Add(sentence); } } } } word = new CambridgeDictionary(wordStr, sentencesByPos, phonetics); } catch (Exception e) { //MessageBox.Show($"Error : {e.Message}"); } return(word); }
public WebSearchResult() { Details = new WebDictionary<string>(); }