private void dataGridView1_DoubleClick(object sender, EventArgs e) { DataGridView gv = (DataGridView)sender; if (gv.SelectedCells.Count > 0) { DataGridViewColumn col = gv.Columns[gv.SelectedCells[0].ColumnIndex]; if (col.DataGridView.SelectedCells.Count > 0 && gv.SelectedCells[0].Selected) { DataGridViewRow dr = gv.SelectedCells[0].OwningRow; int id = -1; id = int.Parse(dr.Cells[LetterEntity.FIELD_ID].Value.ToString()); if (!_selectMode) { LetterForm form = new LetterForm((int)gv.Tag); form.LetterId = id; form.initLetter(); form.ShowDialog(); if (form.DataChanged) { fillGrid(); } } else { _returnLetterId = id; this.Close(); } } } }
private void letterGrid_DoubleClick(object sender, EventArgs e) { DataGridView gv = (DataGridView)sender; if (gv.SelectedCells.Count <= 0) { return; } DataGridViewColumn col = gv.Columns[gv.SelectedCells[0].ColumnIndex]; bool isAnySelected = col.DataGridView.SelectedCells.Count > 0 && gv.SelectedCells[0].Selected; if (!isAnySelected) { return; } DataGridViewRow dr = gv.SelectedCells[0].OwningRow; int letterId = int.Parse(dr.Cells[0].Value.ToString()); int type = _letterBL.getLetterType(letterId); LetterForm form = new LetterForm(type); form.LetterId = letterId; form.initLetter(); form.ShowDialog(); }
public StringPart(LetterData letter, int fromCharacterIndex, int toCharacterIndex, LetterForm letterForm) { this.letter = letter; this.fromCharacterIndex = fromCharacterIndex; this.toCharacterIndex = toCharacterIndex; this.letterForm = letterForm; }
public LetterData ConvertToLetterWithForcedForm(LetterData baseForVariation, LetterForm form) { var l = baseForVariation.Clone(); l.ForcedLetterForm = form; return(l); }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { DataGridView gv = (DataGridView)sender; if (gv.SelectedCells.Count > 0) { DataGridViewColumn col = gv.Columns[gv.SelectedCells[0].ColumnIndex]; if (col.DataGridView.SelectedCells.Count > 0 && gv.SelectedCells[0].Selected) { DataGridViewRow dr = gv.SelectedCells[0].OwningRow; int id = -1; if (dr.Cells[LetterEntity.FIELD_ID] == null || dr.Cells[LetterEntity.FIELD_ID].Value == null) { return; } id = int.Parse(dr.Cells[LetterEntity.FIELD_ID].Value.ToString()); LetterForm form = new LetterForm(); form.LetterId = id; form.initLetter(); form.ShowDialog(); } } }
private void grid_DoubleClick(object sender, EventArgs e) { DataGridView gv = (DataGridView)sender; if (gv.SelectedCells.Count > 0) { DataGridViewColumn col = gv.Columns[gv.SelectedCells[0].ColumnIndex]; if (col.DataGridView.SelectedCells.Count > 0 && gv.SelectedCells[0].Selected) { DataGridViewRow dr = gv.SelectedCells[0].OwningRow; int id = -1; if (gv.Tag.Equals(LetterBL.LETTER_TYPE_SEND)) { id = int.Parse(dr.Cells[LetterEntity.FIELD_ID + "_1"].Value.ToString()); } else { id = int.Parse(dr.Cells[LetterEntity.FIELD_ID].Value.ToString()); } LetterForm form = new LetterForm((int)gv.Tag); form.LetterId = id; form.initLetter(); form.ShowDialog(); if (form.DataChanged) { FillGrids(); } } } }
public void ThenISeeTheEnterToTheMailButton() { LetterForm letterForm = dataProvider.Form; var actualMessagee = new LoginPage().GetButtonMessage(); Assert.True(actualMessagee.Contains(letterForm.Username)); }
// @note: this should be the only constructor for LL_LetterData public LL_LetterData(LetterData _data) { Data = _data; if (_data.ForcedLetterForm != LetterForm.None) { Form = _data.ForcedLetterForm; } }
public void ThenISendTheLetter() { LetterForm letterForm = dataProvider.Form; var emptyDraftFolder = new MailProfilePage().SendTheMessage() .VerifyTheMessageWasDisapeared(); Assert.That(emptyDraftFolder, Is.EqualTo(letterForm.NoMessagesFolder)); }
public static char GetArabicCharacterByLetterForm(char ch, LetterForm form) { int key = ((int)ch) | ((int)form) << 16; if (charForms.ContainsKey(key)) { return((char)charForms[key]); } return(ch); }
public void ThenILogInAsAUser() { User user = dataProvider.User; LetterForm letterForm = dataProvider.Form; var nickname = new LoginPage().EnterLogin(user.Login).EnterPassword(user.Password) .ClickSubmit().GetUserNickname(); Assert.That(nickname, Is.EqualTo(letterForm.Username)); }
private void btnNew_Click(object sender, EventArgs e) { LetterForm form = new LetterForm(); form.LetterType = LetterType; form.initLetter(); form.LetterId = -1; form.ShowDialog(); if (form.DataChanged) { fillGrid(); } }
private void btnLetter_Click(object sender, EventArgs e) { LetterBL letterBl = new LetterBL(); LetterEntity letterEntity = letterBl.getByLetterNumber(txtLetterNumber.Text); LetterForm form = new LetterForm(); form.LetterType = int.Parse(letterEntity.get(LetterEntity.FIELD_LETTER_TYPE).ToString()); form.LetterId = (int)letterEntity.get(LetterEntity.FIELD_ID); form.readOnly = true; form.initLetter(); form.ShowDialog(); }
public static char GetLetterForm(char chr, LetterForm form) { for (int n = 0; n < ARABIC_GLPHIES.Length; n++) { for (int glyphIndex = 0; glyphIndex < ARABIC_GLPHIES[n].Length; glyphIndex++) { if (chr == (char)ARABIC_GLPHIES[n][glyphIndex]) { return((char)ARABIC_GLPHIES[n][(int)form]); } } } return(chr); }
public string GetStringForDisplay(LetterForm form = LetterForm.Isolated, bool forceShowAccent = false) { // Accented letters are always shown as non-accented if (!forceShowAccent && !AppManager.I.ParentEdition.ShowAccents && HasAccent) { return(Base.GetStringForDisplay(form)); } // Get the string for the specific form, without fallback var hexunicode = GetUnicode(form, fallback: false); if (hexunicode == "") { return(""); } var output = ""; // add the "-" to diacritic symbols to indentify better if it's over or below hte mid line if (Type == LetterDataType.DiacriticSymbol) { output = "\u0640"; } var unicode = int.Parse(hexunicode, NumberStyles.HexNumber); output += ((char)unicode).ToString(); if (Symbol_Unicode != "") { var unicode_added = int.Parse(Symbol_Unicode, NumberStyles.HexNumber); output += ((char)unicode_added).ToString(); } // add a "-" before medial and final single letters where needed if (form == LetterForm.Final && FinalFix != "" || form == LetterForm.Medial && MedialFix != "") { output = "\u0640" + output; } if (form == LetterForm.Initial && InitialFix != "" || form == LetterForm.Medial && InitialFix != "") { output = output + "\u0640"; } return(output); }
private QuestionPackData CreateSingleQuestionPackData(LetterData letter, LetterForm correctForm) { var teacher = AppManager.I.Teacher; // Find a word with the letter in that form var usableWords = teacher.VocabularyAi.SelectData( () => FindEligibleWords(maximumWordLength, letter, correctForm), new SelectionParameters(parameters.correctSeverity, 1, useJourney: parameters.useJourneyForCorrect, packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs_words) ); var question = usableWords[0]; // Place the correct letter and form var correctAnswers = new List <LetterData>(); var letterWithForm = AppManager.I.VocabularyHelper.ConvertToLetterWithForcedForm(letter, correctForm); correctAnswers.Add(letterWithForm); // Place the other forms as wrong forms var wrongAnswers = new List <LetterData>(); foreach (var wrongForm in letter.GetAvailableForms()) { if (wrongForm == correctForm) { continue; } letterWithForm = AppManager.I.VocabularyHelper.ConvertToLetterWithForcedForm(letter, wrongForm); wrongAnswers.Add(letterWithForm); } if (ConfigAI.VerboseQuestionPacks) { string debugString = "--------- TEACHER: question pack result ---------"; debugString += "\nQuestion: " + question; debugString += "\nCorrect Answers: " + correctAnswers.Count; foreach (var l in correctAnswers) { debugString += " " + l; } ConfigAI.AppendToTeacherReport(debugString); } return(QuestionPackData.Create(question, correctAnswers, wrongAnswers)); }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { return; } int letterid = (int)(dataGridView1.SelectedRows[0].Cells[4].Value); LetterEntity entity = _letterBL.getByLetterId(letterid); int letterType = int.Parse(entity.get(LetterEntity.FIELD_LETTER_TYPE).ToString()); LetterForm form = new LetterForm(letterType); form.LetterId = letterid; form.LetterEntity = entity; form.initLetter(); form.ShowDialog(); //if (form.DataChanged) // FillGrids(); }
private void btnDisplay_Click(object sender, EventArgs e) { DataGridViewColumn col = dataGridView1.Columns[dataGridView1.SelectedCells[0].ColumnIndex]; if (col.DataGridView.SelectedCells.Count > 0 && dataGridView1.SelectedCells[0].Selected) //if (dataGridView1.SelectedRows.Count > 0) { DataGridViewRow dr = dataGridView1.SelectedCells[0].OwningRow; int id = int.Parse(dr.Cells[LetterEntity.FIELD_ID].Value.ToString()); LetterForm form = new LetterForm(); form.LetterType = LetterType; form.LetterId = id; form.initLetter(); form.ShowDialog(); if (form.DataChanged) { fillGrid(); } } }
private void showLetter(object sender, string index) { DataGridView gv = (DataGridView)sender; if (gv.SelectedCells.Count > 0) { DataGridViewColumn col = gv.Columns[gv.SelectedCells[0].ColumnIndex]; if (col.DataGridView.SelectedCells.Count > 0 && gv.SelectedCells[0].Selected) { DataGridViewRow dr = gv.SelectedCells[0].OwningRow; int id = -1; id = int.Parse(dr.Cells[LetterEntity.FIELD_ID + index].Value.ToString()); int letterType = int.Parse(dr.Cells[LetterEntity.FIELD_LETTER_TYPE + index].Value.ToString()); LetterForm form = new LetterForm(letterType); form.LetterId = id; //form.readOnly = true; form.initLetter(); form.ShowDialog(); } } }
public string GetUnicode(LetterForm form = LetterForm.Isolated, bool fallback = true) { switch (Kind) { case LetterDataKind.Symbol: return(Isolated_Unicode); default: switch (form) { case LetterForm.Initial: return(Initial_Unicode != "" ? Initial_Unicode : (fallback ? Isolated_Unicode : "")); case LetterForm.Medial: return(Medial_Unicode != "" ? Medial_Unicode : (fallback ? Isolated_Unicode : "")); case LetterForm.Final: return(Final_Unicode != "" ? Final_Unicode : (fallback ? Isolated_Unicode : "")); default: return(Isolated_Unicode); } } }
private bool WordIsEligible(WordData word, LetterData containedLetter, LetterForm form, int maxWordLength) { // Check max length if (word.Letters.Length > maxWordLength) { return(false); } // Check that it contains the letter only once if (AppManager.I.VocabularyHelper.WordContainsLetterTimes(word, containedLetter) > 1) { return(false); } // Check that it contains a letter in the correct form var letterWithForm = AppManager.I.VocabularyHelper.ConvertToLetterWithForcedForm(containedLetter, form); if (!AppManager.I.VocabularyHelper.WordContainsLetter(word, letterWithForm, LetterEqualityStrictness.WithActualForm)) { return(false); } return(true); }
/// <summary> /// 3.5 Shaping /// Implements rules R1-R7 and rules L1-L3 of section 8.2 (Arabic) of the Unicode standard. /// </summary> // TODO - this code is very special-cased. private string PerformArabicShaping(string text) { ArabicShapeJoiningType last_jt = ArabicShapeJoiningType.U; LetterForm last_form = LetterForm.Isolated; int last_pos = 0; char last_char = BidiChars.NotAChar; LetterForm[] letterForms = new LetterForm[text.Length]; for (int curr_pos = 0; curr_pos < text.Length; ++curr_pos) { char ch = text[curr_pos]; //string chStr = ((int)ch).ToString("X4"); ArabicShapeJoiningType jt = UnicodeArabicShapingResolver.GetArabicShapeJoiningType(ch); if ((jt == ArabicShapeJoiningType.R || jt == ArabicShapeJoiningType.D || jt == ArabicShapeJoiningType.C) && (last_jt == ArabicShapeJoiningType.L || last_jt == ArabicShapeJoiningType.D || last_jt == ArabicShapeJoiningType.C)) { if (last_form == LetterForm.Isolated && (last_jt == ArabicShapeJoiningType.D || last_jt == ArabicShapeJoiningType.L)) { letterForms[last_pos] = LetterForm.Initial; } else if (last_form == LetterForm.Final && last_jt == ArabicShapeJoiningType.D) { letterForms[last_pos] = LetterForm.Medial; } letterForms[curr_pos] = LetterForm.Final; last_form = LetterForm.Final; last_jt = jt; last_pos = curr_pos; last_char = ch; } else if (jt != ArabicShapeJoiningType.T) { letterForms[curr_pos] = LetterForm.Isolated; last_form = LetterForm.Isolated; last_jt = jt; last_pos = curr_pos; last_char = ch; } else { letterForms[curr_pos] = LetterForm.Isolated; } } last_char = BidiChars.NotAChar; last_pos = 0; int insert_pos = 0; StringBuilder sb = new StringBuilder(); ArrayList lenArr = new ArrayList(_char_lengths); for (int curr_pos = 0; curr_pos < text.Length; ++curr_pos) { char ch = text[curr_pos]; //string chStr = ((int)ch).ToString("X4"); ArabicShapeJoiningType jt = UnicodeArabicShapingResolver.GetArabicShapeJoiningType(ch); if (last_char == BidiChars.ARABIC_LAM && ch != BidiChars.ARABIC_ALEF && ch != BidiChars.ARABIC_ALEF_MADDA_ABOVE && ch != BidiChars.ARABIC_ALEF_HAMZA_ABOVE && ch != BidiChars.ARABIC_ALEF_HAMZA_BELOW && jt != ArabicShapeJoiningType.T) { last_char = BidiChars.NotAChar; } else if (ch == BidiChars.ARABIC_LAM) { last_char = ch; last_pos = curr_pos; insert_pos = sb.Length; } if (last_char == BidiChars.ARABIC_LAM) { if (letterForms[last_pos] == LetterForm.Medial) { switch (ch) { case BidiChars.ARABIC_ALEF: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_FINAL; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_MADDA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_MADDA_ABOVE_FINAL; lenArr.RemoveAt(insert_pos); lenArr[insert_pos] = (int)(lenArr[insert_pos]) + 1; continue; case BidiChars.ARABIC_ALEF_HAMZA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_ABOVE_FINAL; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_HAMZA_BELOW: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_BELOW_FINAL; lenArr.RemoveAt(insert_pos); continue; } } else if (letterForms[last_pos] == LetterForm.Initial) { switch (ch) { case BidiChars.ARABIC_ALEF: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_ISOLATED; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_MADDA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_MADDA_ABOVE_ISOLATED; lenArr.RemoveAt(insert_pos); lenArr[insert_pos] = (int)(lenArr[insert_pos]) + 1; continue; case BidiChars.ARABIC_ALEF_HAMZA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_ABOVE_ISOLATED; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_HAMZA_BELOW: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_BELOW_ISOLATED; lenArr.RemoveAt(insert_pos); continue; } } } sb.Append(UnicodeArabicShapingResolver.GetArabicCharacterByLetterForm(ch, letterForms[curr_pos])); } _char_lengths = (int[])lenArr.ToArray(typeof(int)); return(sb.ToString()); }
public List <WordData> FindEligibleWords(int maxWordLength, LetterData containedLetter, LetterForm form) { var vocabularyHelper = AppManager.I.VocabularyHelper; var eligibleWords = new List <WordData>(); var pair = new KeyValuePair <LetterData, LetterForm>(containedLetter, form); if (!eligibleWordsForLetters.ContainsKey(pair)) { foreach (var word in vocabularyHelper.GetWordsByCategory(category, parameters.wordFilters)) { if (!WordIsEligible(word, containedLetter, form, maxWordLength)) { continue; } eligibleWords.Add(word); //Debug.Log("Letter: " + containedLetter + " form: " + form + " Word: " + word); } eligibleWordsForLetters[pair] = eligibleWords; } eligibleWords = eligibleWordsForLetters[pair]; //Debug.LogWarning("Eligible words: " + eligibleWords.Count + " out of " + vocabularyHelper.GetWordsByCategory(category, parameters.wordFilters).Count); return(eligibleWords); }
/// <summary> /// 3.5 Shaping /// Implements rules R1-R7 and rules L1-L3 of section 8.2 (Arabic) of the Unicode standard. /// </summary> // TODO - this code is very special-cased. private string PerformArabicShaping(string text) { ArabicShapeJoiningType last_jt = ArabicShapeJoiningType.U; LetterForm last_form = LetterForm.Isolated; int last_pos = 0; char last_char = BidiChars.NotAChar; LetterForm[] letterForms = new LetterForm[text.Length]; for (int curr_pos = 0; curr_pos < text.Length; ++curr_pos) { char ch = text[curr_pos]; ArabicShapeJoiningType jt = UnicodeArabicShapingResolver.GetArabicShapeJoiningType(ch); if ((jt == ArabicShapeJoiningType.R || jt == ArabicShapeJoiningType.D || jt == ArabicShapeJoiningType.C) && (last_jt == ArabicShapeJoiningType.L || last_jt == ArabicShapeJoiningType.D || last_jt == ArabicShapeJoiningType.C)) { if (last_form == LetterForm.Isolated && (last_jt == ArabicShapeJoiningType.D || last_jt == ArabicShapeJoiningType.L)) { letterForms[last_pos] = LetterForm.Initial; } else if (last_form == LetterForm.Final && last_jt == ArabicShapeJoiningType.D) { letterForms[last_pos] = LetterForm.Medial; } letterForms[curr_pos] = LetterForm.Final; last_form = LetterForm.Final; last_jt = jt; last_pos = curr_pos; last_char = ch; } else if (jt != ArabicShapeJoiningType.T) { letterForms[curr_pos] = LetterForm.Isolated; last_form = LetterForm.Isolated; last_jt = jt; last_pos = curr_pos; last_char = ch; } else letterForms[curr_pos] = LetterForm.Isolated; } last_char = BidiChars.NotAChar; last_pos = 0; int insert_pos = 0; StringBuilder sb = new StringBuilder(); List<int> lenArr = new List<int>(_char_lengths); for (int curr_pos = 0; curr_pos < text.Length; ++curr_pos) { char ch = text[curr_pos]; //string chStr = ((int)ch).ToString("X4"); ArabicShapeJoiningType jt = UnicodeArabicShapingResolver.GetArabicShapeJoiningType(ch); if (last_char == BidiChars.ARABIC_LAM && ch != BidiChars.ARABIC_ALEF && ch != BidiChars.ARABIC_ALEF_MADDA_ABOVE && ch != BidiChars.ARABIC_ALEF_HAMZA_ABOVE && ch != BidiChars.ARABIC_ALEF_HAMZA_BELOW && jt != ArabicShapeJoiningType.T) { last_char = BidiChars.NotAChar; } else if (ch == BidiChars.ARABIC_LAM) { last_char = ch; last_pos = curr_pos; insert_pos = sb.Length; } if (last_char == BidiChars.ARABIC_LAM) { if (letterForms[last_pos] == LetterForm.Medial) { switch (ch) { case BidiChars.ARABIC_ALEF: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_FINAL; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_MADDA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_MADDA_ABOVE_FINAL; lenArr.RemoveAt(insert_pos); lenArr[insert_pos] = (int)(lenArr[insert_pos]) + 1; continue; case BidiChars.ARABIC_ALEF_HAMZA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_ABOVE_FINAL; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_HAMZA_BELOW: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_BELOW_FINAL; lenArr.RemoveAt(insert_pos); continue; } } else if (letterForms[last_pos] == LetterForm.Initial) { switch (ch) { case BidiChars.ARABIC_ALEF: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_ISOLATED; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_MADDA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_MADDA_ABOVE_ISOLATED; lenArr.RemoveAt(insert_pos); lenArr[insert_pos] = (int)(lenArr[insert_pos]) + 1; continue; case BidiChars.ARABIC_ALEF_HAMZA_ABOVE: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_ABOVE_ISOLATED; lenArr.RemoveAt(insert_pos); continue; case BidiChars.ARABIC_ALEF_HAMZA_BELOW: sb[insert_pos] = BidiChars.ARABIC_LAM_ALEF_HAMZA_BELOW_ISOLATED; lenArr.RemoveAt(insert_pos); continue; } } } sb.Append(UnicodeArabicShapingResolver.GetArabicCharacterByLetterForm(ch, letterForms[curr_pos])); } _char_lengths = lenArr.ToArray(); return sb.ToString(); }
public static char GetArabicCharacterByLetterForm(char ch, LetterForm form) { int key = ((int)ch) | ((int)form) << 16; if (charForms.ContainsKey(key)) return (char)charForms[key]; return ch; }
private bool FormsLookTheSame(LetterForm form1, LetterForm form2) { //Debug.Log("form1: " + GetStringForDisplay(form1)); //Debug.Log("form2: " + GetStringForDisplay(form2)); return(GetStringForDisplay(form1) == GetStringForDisplay(form2)); }