internal int DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, Set<int> candidates) { int hvo = 0; ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates); using (SimpleListChooser chooser = new SimpleListChooser(m_persistenceProvider, labels, fieldName)) { chooser.Cache = m_cache; chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOAHvo; chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink, FwLink.Create(toolName, m_cache.GetGuidFromId(chooser.TextParamHvo), m_cache.ServerName, m_cache.DatabaseName)); chooser.ReplaceTreeView(m_mediator, guiControl); if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl) chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl"); else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl"); else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl"); DialogResult res = chooser.ShowDialog(); if (res != DialogResult.Cancel) { chooser.HandleAnyJump(); if (chooser.ChosenOne != null) hvo = chooser.ChosenOne.Hvo; } } return hvo; }
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; }
protected ICmObject DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, IEnumerable<ICmObject> candidates) { ICmObject obj = null; IEnumerable<ObjectLabel> labels = ObjectLabel.CreateObjectLabels(m_cache, candidates); using (var chooser = new SimpleListChooser(m_persistProvider, labels, fieldName, m_mediator.HelpTopicProvider)) { chooser.Cache = m_cache; chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOA.Hvo; Guid guidTextParam = m_cache.LangProject.PhonologicalDataOA.Guid; chooser.AddLink(linkText, ReallySimpleListChooser.LinkType.kGotoLink, new FwLinkArgs(toolName, guidTextParam)); chooser.ReplaceTreeView(m_mediator, guiControl); chooser.SetHelpTopic(FeatureChooserHelpTopic); DialogResult res = chooser.ShowDialog(); if (res != DialogResult.Cancel) { chooser.HandleAnyJump(); if (chooser.ChosenOne != null) obj = chooser.ChosenOne.Object; } } return obj; }