public ChalWpfItem() { Grid_chal = new Grid(); Row_1 = new StackPanel(); Row_2 = new StackPanel(); Row_3 = new Grid(); Row_4 = new Grid(); PtBr = new Label(); Definition = new Label(); Quest_words = new List <Label>(); Cb_Answer = new ComboChallenge(); Answer = new Label(); Avg_w = new Label(); Avg_m = new Label(); Avg_all = new Label(); Tries = new Label(); Importante = new Label(); Chance = new Label(); Id_Voc = new Label(); Disable_quest = new Button(); Remove_att = new Button(); }
private static Control CreateSentence(ChalLine line, StackPanel parent, Microsoft.Office.Interop.Word.Application wordApp) { var ctrl = new Control(); string sentence = Sentences.GetSentenceToQuestion(line.Quest); var invalid_synonyms = GetInvalidSynonyms(line.Quest); //Console.WriteLine(sentence); var found = false; foreach (var word in sentence.SplitSentence()) { if (found) { CreateDefaultLabel(line, parent, word); continue; } if (line.Quest.Type == Model.Voc) { string answer = (line.Quest as VocVM).Answer; var answers_compatibility = Sentences.GetCompatibleWord(answer, word); if (answers_compatibility.Length > 0) { ctrl = new ComboChallenge(); MyCbBxs.BuildSynonyms(answers_compatibility, invalid_synonyms, ctrl as ComboChallenge, parent, char.IsUpper(word[1]), wordApp); found = true; } else { CreateDefaultLabel(line, parent, word); } } else if (line.Quest.Type == Model.Spell) { string text = (line.Quest as SpellVM).Text; if (word.ContainsInsensitive(text)) { ctrl = new TextBox(); ctrl.VerticalContentAlignment = VerticalAlignment.Center; ctrl.Margin = new Thickness(1, 0, 1, 0); ctrl.Width = text.Length * 5 + 26; ctrl.GotFocus += (source, e) => FileHtmlControls.PlayPronunciation(text, ctrl); ctrl.KeyDown += (source, e) => { if (e.Key == System.Windows.Input.Key.Enter && line.Quest.Type == Model.Spell) { FileHtmlControls.PlayPronunciation(text, ctrl); } }; if (!text.EqualsNoCase(word)) { //Console.WriteLine("answer was " + text); var dif = word.ReplaceIgnoreCase(text, ""); (ctrl as TextBox).Text = dif; } parent.Children.Add(ctrl); found = true; } else { CreateDefaultLabel(line, parent, word); } } } return(ctrl); }