/// <summary> /// (re)initialize the current list to correspond to the items in m_choices. /// This will destroy the selection, and then try to select the indicated line. /// </summary> void InitCurrentList(int index) { currentList.SuspendLayout(); currentList.Items.Clear(); foreach (InterlinLineSpec ls in m_choices) { string[] cols = new string[2]; cols[0] = TsStringUtils.NormalizeToNFC(m_choices.LabelFor(ls.Flid)); string wsName = ""; // This tries to find a matching ws from the combo box that would be displayed for this item // The reason we use the combo box is because that will give us names like "Default Analysis" instead of // the actual analysis ws name. foreach (WsComboItem item in WsComboItems(ls.ComboContent)) { var ws = ls.IsMagicWritingSystem ? m_cache.LangProject.DefaultWsForMagicWs(ls.WritingSystem) : ls.WritingSystem; if (getWsFromId(item.Id) == ws) { wsName = item.ToString(); break; } else { Debug.WriteLine(item.Id); } } // Last ditch effort if (wsName == "") { CoreWritingSystemDefinition wsObj = m_cache.ServiceLocator.WritingSystemManager.Get(ls.WritingSystem); if (wsObj != null) { wsName = wsObj.DisplayLabel; } } cols[1] = TsStringUtils.NormalizeToNFC(wsName); cols[1] = cols[1].Substring(0, Math.Min(cols[1].Length, 42)); var item1WithToolTip = new ListViewItem(cols); item1WithToolTip.ToolTipText = TsStringUtils.NormalizeToNFC(wsName); currentList.Items.Add(item1WithToolTip); } if (index > currentList.Items.Count && index > 0) { index--; // for when we delete the last item. } if (index >= 0 && index < currentList.Items.Count) // range check mainly for passing 0 on empty { currentList.Items[index].Selected = true; } currentList.ResumeLayout(); }
private string GetAppropriateLineLabel(InterlinLineChoices curLineChoices, int ilineChoice) { var curSpec = curLineChoices[ilineChoice]; var result = curLineChoices.LabelFor(curSpec.Flid); if (curLineChoices.RepetitionsOfFlid(curSpec.Flid) > 1) { result += "(" + curSpec.WsLabel(Cache).Text + ")"; } return(result); }
/// <summary> /// (re)initialize the current list to correspond to the items in m_choices. /// This will destroy the selection, and then try to select the indicated line. /// </summary> void InitCurrentList(int index) { currentList.SuspendLayout(); currentList.Items.Clear(); StringUtils.InitIcuDataDir(); // used for normalizing strings to NFC foreach (InterlinLineSpec ls in m_choices) { string[] cols = new string[2]; cols[0] = StringUtils.NormalizeToNFC(m_choices.LabelFor(ls.Flid)); string wsName = ""; // This tries to find a matching ws from the combo box that would be displayed for this item // The reason we use the combo box is because that will give us names like "Default Analysis" instead of // the actual analysis ws name. foreach (WsComboItem item in WsComboItems(ls.ComboContent)) { if (getWsFromIcuCode(item.IcuCode) == ls.WritingSystem) { wsName = item.ToString(); break; } } // Last ditch effort if (wsName == "") { ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor; int wsui = m_cache.DefaultUserWs; IWritingSystem engine = wsf.get_EngineOrNull(ls.WritingSystem); if (engine != null) { wsName = engine.get_UiName(wsui); } } cols[1] = StringUtils.NormalizeToNFC(wsName); currentList.Items.Add(new ListViewItem(cols)); } if (index > currentList.Items.Count && index > 0) { index--; // for when we delete the last item. } if (index >= 0 && index < currentList.Items.Count) // range check mainly for passing 0 on empty { currentList.Items[index].Selected = true; } currentList.ResumeLayout(); }
private string GetAppropriateLineLabel(InterlinLineChoices curLineChoices, int ilineChoice) { var curSpec = curLineChoices[ilineChoice]; var result = curLineChoices.LabelFor(curSpec.Flid); if (curLineChoices.RepetitionsOfFlid(curSpec.Flid) > 1) result += "(" + curSpec.WsLabel(Cache).Text + ")"; return result; }
internal InterlinClipboardHelper(IVwSelection vwsel, InterlinDocChild site, FdoCache cache) { // Get the string and split it into its individual lines. vwsel.GetSelectionString(out m_tss, "\t"); m_rgtssPieces = StringUtils.Split(m_tss, new string[] { Environment.NewLine }, StringSplitOptions.None); m_choices = site.LineChoices; m_fHaveMorphemeLevel = m_choices.HaveMorphemeLevel; if (m_fHaveMorphemeLevel) m_cMorphLines = m_idxChoiceLastMorpheme - m_idxChoiceFirstMorpheme + 1; m_idxChoiceFirstMorpheme = m_choices.FirstMorphemeIndex; m_idxChoiceLastMorpheme = m_choices.LastMorphemeIndex; m_idxChoiceFirstFreeform = m_choices.FirstFreeformIndex; m_cChoices = m_choices.Count; m_cInterlinearLines = m_choices.FirstFreeformIndex; // Get the labels for the lines in m_choices. m_rgsLabel = new string[m_cInterlinearLines]; for (int i = 0; i < m_rgsLabel.Length; ++i) m_rgsLabel[i] = m_choices.LabelFor(m_choices[i].Flid); bool fTaggingView = site is InterlinTaggingChild; if (site is InterlinTaggingChild) { m_fHaveTagging = true; m_idxChoiceTaggingLine = m_idxChoiceFirstFreeform; ++m_idxChoiceFirstFreeform; ++m_cChoices; } else { m_fHaveTagging = false; m_idxChoiceTaggingLine = -1; } m_cache = cache; }