/// <summary> /// Called when the user taps on a level frame. /// </summary> /// <param name="sender">The object sending the event.</param> /// <param name="e">The event parameters.</param> private async void LevelFrame_Tapped(object sender, EventArgs e) { ExerciseAnalysisDataModel binding = (ExerciseAnalysisDataModel)this.BindingContext; await binding.LevelClassification.Task; if (sender == this.A1Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.A1]); } else if (sender == this.A2Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.A2]); } else if (sender == this.B1Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.B1]); } else if (sender == this.B2Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.B2]); } else if (sender == this.C1Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.C1]); } else if (sender == this.C2Frame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.C2]); } else if (sender == this.UNKNOWNFrame) { this.FillLevelList(binding.LevelClassification.Result[LanguageLevelClassification.Unknown]); } }
/// <summary> /// Initializes a new instance of the <see cref="ExerciseAnalysis"/> class. /// </summary> /// <param name="ex">The <see cref="EssayExercise"/> containing the exercise to be analyzed.</param> public ExerciseAnalysis(EssayExercise ex) { ex.ExcludeFunctionalWords = false; this.currentLanguage = ex.Language; ExerciseAnalysisDataModel binding = new ExerciseAnalysisDataModel(ex); this.BindingContext = binding; this.InitializeComponent(); // TODO: move these settings to XAML. Use a syntax similar to this one (which, however, does not work): // BackgroundColor = "{Binding Converter={enums:LanguageLevelClassificationToColorConverter}, ConverterParameter={x:Static enums:LanguageLevelClassification.A1}}" // This is tracked in <https://github.com/TellOP/APP/issues/1> LanguageLevelClassificationToColorConverter langToColorConverter = new LanguageLevelClassificationToColorConverter(); this.A1Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.A1, typeof(Color), null, CultureInfo.CurrentUICulture); this.A2Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.A2, typeof(Color), null, CultureInfo.CurrentUICulture); this.B1Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.B1, typeof(Color), null, CultureInfo.CurrentUICulture); this.B2Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.B2, typeof(Color), null, CultureInfo.CurrentUICulture); this.C1Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.C1, typeof(Color), null, CultureInfo.CurrentUICulture); this.C2Frame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.C2, typeof(Color), null, CultureInfo.CurrentUICulture); this.UNKNOWNFrame.BackgroundColor = (Color)langToColorConverter.Convert(LanguageLevelClassification.Unknown, typeof(Color), null, CultureInfo.CurrentUICulture); }
/// <summary> /// Called when the user taps on a level frame. /// </summary> /// <param name="sender">The object sending the event.</param> /// <param name="e">The event parameters.</param> private async void PoSFrame_Tapped(object sender, EventArgs e) { ExerciseAnalysisDataModel binding = (ExerciseAnalysisDataModel)this.BindingContext; await binding.WordsInTextByPartOfSpeech.Task; // TODO: improve localization here! if (sender == this.PoS_Adjective_Frame) { if (!this.PoS_Adjective_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Adjective); this.RestoreOriginalPoSLabels(); this.PoS_Adjective_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Adjective; } else { this.PoS_Adjective_Caption.Text = Properties.Resources.PartOfSpeech_Adjective; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Adverb_Frame) { if (!this.PoS_Adverb_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Adverb); this.RestoreOriginalPoSLabels(); this.PoS_Adverb_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Adverb; } else { this.PoS_Adverb_Caption.Text = Properties.Resources.PartOfSpeech_Adverb; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_ClauseOpener_Frame) { if (!this.PoS_ClauseOpener_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.ClauseOpener); this.RestoreOriginalPoSLabels(); this.PoS_ClauseOpener_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_ClauseOpener; } else { this.PoS_ClauseOpener_Caption.Text = Properties.Resources.PartOfSpeech_ClauseOpener; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Conjunction_Frame) { if (!this.PoS_Conjunction_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Conjunction); this.RestoreOriginalPoSLabels(); this.PoS_Conjunction_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Conjunction; } else { this.PoS_Conjunction_Caption.Text = Properties.Resources.PartOfSpeech_Conjunction; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Determiner_Frame) { if (!this.PoS_Determiner_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Determiner); this.RestoreOriginalPoSLabels(); this.PoS_Determiner_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Determiner; } else { this.PoS_Determiner_Caption.Text = Properties.Resources.PartOfSpeech_Determiner; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_DeterminerPronoun_Frame) { if (!this.PoS_DeterminerPronoun_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.DeterminerPronoun); this.RestoreOriginalPoSLabels(); this.PoS_DeterminerPronoun_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Determiner_Pronoun; } else { this.PoS_DeterminerPronoun_Caption.Text = Properties.Resources.PartOfSpeech_Determiner_Pronoun; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_ExistentialParticle_Frame) { if (!this.PoS_ExistentialParticle_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.ExistentialParticle); this.RestoreOriginalPoSLabels(); this.PoS_ExistentialParticle_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_ExistentialParticle; } else { this.PoS_ExistentialParticle_Caption.Text = Properties.Resources.PartOfSpeech_ExistentialParticle; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_ForeignWord_Frame) { if (!this.PoS_ForeignWord_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.ForeignWord); this.RestoreOriginalPoSLabels(); this.PoS_ForeignWord_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_ForeignWord; } else { this.PoS_ForeignWord_Caption.Text = Properties.Resources.PartOfSpeech_ForeignWord; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Genitive_Frame) { if (!this.PoS_Genitive_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Genitive); this.RestoreOriginalPoSLabels(); this.PoS_Genitive_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Genitive; } else { this.PoS_Genitive_Caption.Text = Properties.Resources.PartOfSpeech_Genitive; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_InfinitiveMarker_Frame) { if (!this.PoS_InfinitiveMarker_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.InfinitiveMarker); this.RestoreOriginalPoSLabels(); this.PoS_InfinitiveMarker_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_InfinitiveMarker; } else { this.PoS_InfinitiveMarker_Caption.Text = Properties.Resources.PartOfSpeech_InfinitiveMarker; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_InterjectionOrDiscourseMarker_Frame) { if (!this.PoS_InterjectionOrDiscourseMarker_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.InterjectionOrDiscourseMarker); this.RestoreOriginalPoSLabels(); this.PoS_InterjectionOrDiscourseMarker_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Interjection; } else { this.PoS_InterjectionOrDiscourseMarker_Caption.Text = Properties.Resources.PartOfSpeech_Interjection; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_LetterAsWord_Frame) { if (!this.PoS_LetterAsWord_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.LetterAsWord); this.RestoreOriginalPoSLabels(); this.PoS_LetterAsWord_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_LetterAsWord; } else { this.PoS_LetterAsWord_Caption.Text = Properties.Resources.PartOfSpeech_LetterAsWord; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_NegativeMarker_Frame) { if (!this.PoS_NegativeMarker_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.NegativeMarker); this.RestoreOriginalPoSLabels(); this.PoS_NegativeMarker_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_NegativeMarker; } else { this.PoS_NegativeMarker_Caption.Text = Properties.Resources.PartOfSpeech_NegativeMarker; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_CommonNoun_Frame) { if (!this.PoS_CommonNoun_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.CommonNoun); this.RestoreOriginalPoSLabels(); this.PoS_CommonNoun_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_CommonNoun; } else { this.PoS_CommonNoun_Caption.Text = Properties.Resources.PartOfSpeech_CommonNoun; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_ProperNoun_Frame) { if (!this.PoS_ProperNoun_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.ProperNoun); this.RestoreOriginalPoSLabels(); this.PoS_ProperNoun_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_ProperNoun; } else { this.PoS_ProperNoun_Caption.Text = Properties.Resources.PartOfSpeech_ProperNoun; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_PartOfProperNoun_Frame) { if (!this.PoS_PartOfProperNoun_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.PartOfProperNoun); this.RestoreOriginalPoSLabels(); this.PoS_PartOfProperNoun_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_PartProperNoun; } else { this.PoS_PartOfProperNoun_Caption.Text = Properties.Resources.PartOfSpeech_PartProperNoun; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_CardinalNumber_Frame) { if (!this.PoS_CardinalNumber_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.CardinalNumber); this.RestoreOriginalPoSLabels(); this.PoS_CardinalNumber_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_CardinalNumber; } else { this.PoS_CardinalNumber_Caption.Text = Properties.Resources.PartOfSpeech_CardinalNumber; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Ordinal_Frame) { if (!this.PoS_Ordinal_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Ordinal); this.RestoreOriginalPoSLabels(); this.PoS_Ordinal_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Ordinal; } else { this.PoS_Ordinal_Caption.Text = Properties.Resources.PartOfSpeech_Ordinal; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Preposition_Frame) { if (!this.PoS_Preposition_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Preposition); this.RestoreOriginalPoSLabels(); this.PoS_Preposition_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Preposition; } else { this.PoS_Preposition_Caption.Text = Properties.Resources.PartOfSpeech_Preposition; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Pronoun_Frame) { if (!this.PoS_Pronoun_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Pronoun); this.RestoreOriginalPoSLabels(); this.PoS_Pronoun_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Pronoun; } else { this.PoS_Pronoun_Caption.Text = Properties.Resources.PartOfSpeech_Pronoun; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Unclassified_Frame) { if (!this.PoS_Unclassified_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Unclassified); this.RestoreOriginalPoSLabels(); this.PoS_Unclassified_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Unclassified; } else { this.PoS_Unclassified_Caption.Text = Properties.Resources.PartOfSpeech_Unclassified; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_Verb_Frame) { if (!this.PoS_Verb_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.Verb); this.RestoreOriginalPoSLabels(); this.PoS_Verb_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_Verb; } else { this.PoS_Verb_Caption.Text = Properties.Resources.PartOfSpeech_Verb; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_ModalVerb_Frame) { if (!this.PoS_ModalVerb_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.ModalVerb); this.RestoreOriginalPoSLabels(); this.PoS_ModalVerb_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_ModalVerb; } else { this.PoS_ModalVerb_Caption.Text = Properties.Resources.PartOfSpeech_ModalVerb; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else if (sender == this.PoS_AuxiliaryVerb_Frame) { if (!this.PoS_AuxiliaryVerb_Caption.Text.Contains(Properties.Resources.GenericOpenSymbol)) { this.FillPoSList(binding.WordsInTextByPartOfSpeech.Result, PartOfSpeech.AuxiliaryVerb); this.RestoreOriginalPoSLabels(); this.PoS_AuxiliaryVerb_Caption.Text = Properties.Resources.GenericOpenSymbol + Properties.Resources.PartOfSpeech_AuxiliaryVerb; } else { this.PoS_AuxiliaryVerb_Caption.Text = Properties.Resources.PartOfSpeech_AuxiliaryVerb; this.WordsByPoSTableSection.Clear(); this.WordsByPoSTable.HeightRequest = 0; } } else { Tools.Logger.Log("ExerciseAnalysis", "Missing frame? " + sender.ToString(), new KeyNotFoundException("Missing Frame")); } }