private void SearchSemanticDomains(string searchString) { // The FindDomainsThatMatch method returns IEnumerable<ICmSemanticDomain> // based on the search string we give it. m_textSearch.Update(); if (!string.IsNullOrEmpty(searchString)) { try { m_listView.ItemChecked -= OnDomainListChecked; var semDomainsToShow = m_semDomRepo.FindDomainsThatMatch(searchString); SemanticDomainSelectionUtility.UpdateDomainListLabels( ObjectLabel.CreateObjectLabels(m_cache, semDomainsToShow, string.Empty, m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(m_cache.DefaultAnalWs)), m_stylesheet, m_listView, true); m_treeView.Visible = false; m_listView.Visible = true; m_btnCancelSearch.SearchIsActive = true; } finally { m_listView.ItemChecked += OnDomainListChecked; } } else { m_treeView.Visible = true; m_listView.Visible = false; m_btnCancelSearch.SearchIsActive = false; } }
/// <summary> /// A trivial override to use a special method to get the names of items. /// For semantic domain in this tool we want to display a sense count (if non-zero). /// </summary> /// <param name="obj"></param> /// <param name="font"></param> /// <returns></returns> protected override string GetTreeNodeLabel(ICmObject obj, out Font font) { var baseName = base.GetTreeNodeLabel(obj, out font); var sd = obj as ICmSemanticDomain; if (sd == null) { return(baseName); // pathological defensive programming } int senseCount = SemanticDomainSelectionUtility.SenseReferenceCount(sd); if (senseCount == 0) { return(baseName); } return(baseName + " (" + senseCount + ")"); }
private void OnDomainListChecked(object sender, ItemCheckedEventArgs e) { var domain = m_semDomRepo.GetObject((int)e.Item.Tag); SemanticDomainSelectionUtility.AdjustSelectedDomainList(domain, m_stylesheet, e.Item.Checked, m_listView); }