/// <summary> /// Count how many references this item has. Virtual so a subclass can use a different /// algorithm (c.f. SemanticDomainsChooser's DomainNode). /// </summary> /// <returns></returns> protected virtual int CountUsages() { // Don't count the reference from an overlay, since we have no way to tell // how many times that overlay has been used. See FWR-1050. ObjectLabel label = Label; int count = 0; // I think only label.Object is likely to be null, but let's prevent crashes thoroughly. if (label != null && label.Object != null && label.Object.ReferringObjects != null) { count = label.Object.ReferringObjects.Count; foreach (ICmObject x in label.Object.ReferringObjects) { if (x is ICmOverlay) { --count; } } } return(count); }
/// <summary> /// Initializes a new instance of the <see cref="LabelNode"/> class. /// </summary> /// <param name="label">The label.</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="displayUsage"><c>true</c> if usage statistics will be displayed; otherwise, <c>false</c>.</param> public LabelNode(ObjectLabel label, IVwStylesheet stylesheet, bool displayUsage) { Tag = label; m_stylesheet = stylesheet; m_displayUsage = displayUsage; m_fEnabled = true; m_enabledColor = ForeColor; ITsString tssDisplay = label.AsTss; int wsVern; if (HasVernacularText(tssDisplay, label.Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Select(ws => ws.Handle), out wsVern)) { NodeFont = GetVernacularFont(label.Cache.WritingSystemFactory, wsVern, stylesheet); } SetNodeText(); if (label.HaveSubItems) { // this is a hack to make the node expandable before we have filled in any // actual children Nodes.Add(new TreeNode("should not see this")); } }
/// <summary> /// Creates the specified LabelNode from the ObjectLabel. /// </summary> /// <param name="nol"></param> /// <param name="stylesheet"></param> /// <param name="displayUsage"><c>true</c> if usage statistics will be displayed; otherwise, <c>false</c>.</param> /// <returns></returns> protected virtual LabelNode Create(ObjectLabel nol, IVwStylesheet stylesheet, bool displayUsage) { return(new LabelNode(nol, stylesheet, displayUsage)); }
/// -------------------------------------------------------------------------------- /// <summary> /// Wants the node for label. /// </summary> /// <param name="label">The label.</param> /// <returns></returns> /// -------------------------------------------------------------------------------- public virtual bool WantNodeForLabel(ObjectLabel label) { return(true); // by default want all nodes. }