public bool Matches(QuestionKey other) { return StartRef == other.StartRef && EndRef == other.EndRef && Text == other.Text; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the index of the (first) phrase in the (filtered) collection that matches the /// given key. /// </summary> /// ------------------------------------------------------------------------------------ public int FindPhrase(QuestionKey phraseKey) { for (int i = 0; i < FilteredSortedPhrases.Count; i++) { TranslatablePhrase phrase = FilteredSortedPhrases[i]; if (phrase.PhraseKey.Matches(phraseKey)) return i; } return -1; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reloads the specified f force save. /// </summary> /// <param name="fForceSave">if set to <c>true</c> [f force save].</param> /// <param name="key">The key of the question to try to select after reloading.</param> /// <param name="fallBackRow">the index of the row to select if a question witht the /// given key cannot be found.</param> /// ------------------------------------------------------------------------------------ private void Reload(bool fForceSave, QuestionKey key, int fallBackRow) { using (new WaitCursor(this)) { int iCol = dataGridUns.CurrentCell.ColumnIndex; Save(fForceSave); int iSortedCol = -1; bool sortAscending = true; for (int i = 0; i < dataGridUns.Columns.Count; i++) { switch (dataGridUns.Columns[i].HeaderCell.SortGlyphDirection) { case SortOrder.Ascending: iSortedCol = i; break; case SortOrder.Descending: iSortedCol = i; sortAscending = false; break; default: continue; } break; } m_helper.TranslationsChanged -= m_helper_TranslationsChanged; dataGridUns.RowCount = 0; LoadTranslations(null); ApplyFilter(); if (iSortedCol >= 0) SortByColumn(iSortedCol, sortAscending); if (key != null) { int iRow = m_helper.FindPhrase(key); if (iRow < 0) iRow = fallBackRow; if (iRow < dataGridUns.Rows.Count) dataGridUns.CurrentCell = dataGridUns.Rows[iRow].Cells[iCol]; } } }