private SimpleListChooser MakeChooserWithExtantMsas(IMoInflAffixSlot slot, XCore.Command cmd)
{
// Want the list of all lex entries which have an infl affix Msa
// Do not want to list the infl affix Msas that are already assigned to the slot.
var candidates = new HashSet<ICmObject>();
bool fIsPrefixSlot = m_template.PrefixSlotsRS.Contains(slot);
foreach (var lex in slot.OtherInflectionalAffixLexEntries)
{
bool fInclude = EntryHasAffixThatMightBeInSlot(lex, fIsPrefixSlot);
if (fInclude)
{
foreach (var msa in lex.MorphoSyntaxAnalysesOC)
{
if (msa is IMoInflAffMsa)
{
candidates.Add(msa);
break;
}
}
}
}
var labels = ObjectLabel.CreateObjectLabels(Cache, candidates.OrderBy(iafmsa => iafmsa.Owner.ShortName), null);
XCore.PersistenceProvider persistProvider = new PersistenceProvider(m_mediator.PropertyTable);
var aiForceMultipleChoices = new ICmObject[0];
var chooser = new SimpleListChooser(persistProvider, labels,
m_ChooseInflectionalAffixHelpTopic, Cache, aiForceMultipleChoices,
m_mediator.HelpTopicProvider);
chooser.SetHelpTopic("khtpChoose-Grammar-InflAffixTemplateControl");
chooser.SetFontForDialog(new int[] { Cache.DefaultVernWs, Cache.DefaultAnalWs }, StyleSheet, WritingSystemFactory);
chooser.Cache = Cache;
// We don't want the ()'s indicating optionality since the text spells it out.
chooser.TextParam = slot.Name.AnalysisDefaultWritingSystem.Text;
chooser.Title = m_sInflAffixChooserTitle;
if (slot.Optional)
chooser.InstructionalText = m_sInflAffixChooserInstructionalTextOpt;
else
chooser.InstructionalText = m_sInflAffixChooserInstructionalTextReq;
chooser.AddLink(m_sInflAffix, SimpleListChooser.LinkType.kDialogLink,
new MakeInflAffixEntryChooserCommand(Cache, true, m_sInflAffix, fIsPrefixSlot, slot, m_mediator));
chooser.SetObjectAndFlid(slot.Hvo, slot.OwningFlid);
string sGuiControl = XmlUtils.GetOptionalAttributeValue(cmd.ConfigurationNode, "guicontrol");
if (!String.IsNullOrEmpty(sGuiControl))
{
chooser.ReplaceTreeView(m_mediator, sGuiControl);
}
return chooser;
}