コード例 #1
0
		private SimpleListChooser MakeChooserWithExtantSlots(bool fIsPrefixSlot)
		{
			int slotFlid;
			if (fIsPrefixSlot)
				slotFlid = MoInflAffixTemplateTags.kflidPrefixSlots;
			else
				slotFlid = MoInflAffixTemplateTags.kflidSuffixSlots;
			var labels = ObjectLabel.CreateObjectLabels(Cache, m_template.ReferenceTargetCandidates(slotFlid), null);
			PersistenceProvider persistProvider =
				new PersistenceProvider(m_mediator.PropertyTable);
			SimpleListChooser chooser = new SimpleListChooser(persistProvider, labels,
				m_ChooseSlotHelpTopic, m_mediator.HelpTopicProvider);
			chooser.SetHelpTopic("khtpChoose-Grammar-InflAffixTemplateControl");
			chooser.Cache = Cache;
			chooser.TextParamHvo = m_template.Owner.Hvo;
			chooser.Title = m_sSlotChooserTitle;
			chooser.InstructionalText = m_sSlotChooserInstructionalText;
			string sTopPOS;
			var pos = GetHighestPOS(m_template.OwnerOfClass<IPartOfSpeech>(), out sTopPOS);
			string sLabel = String.Format(m_sObligatorySlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, pos.Hvo,
				false, m_mediator));
			sLabel = String.Format(m_sOptionalSlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, pos.Hvo, true,
				m_mediator));
			chooser.SetObjectAndFlid(pos.Hvo, MoInflAffixTemplateTags.kflidSlots);
			return chooser;
		}
コード例 #2
0
		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;
		}
コード例 #3
0
		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;
		}
コード例 #4
0
		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;
		}
コード例 #5
0
		private SimpleListChooser MakeChooserWithExtantSlots(bool fIsPrefixSlot)
		{
			int slotFlid;
			if (fIsPrefixSlot)
				slotFlid = (int)MoInflAffixTemplate.MoInflAffixTemplateTags.kflidPrefixSlots;
			else
				slotFlid = (int) MoInflAffixTemplate.MoInflAffixTemplateTags.kflidSuffixSlots;
			ObjectLabelCollection labels = new ObjectLabelCollection(
				Cache,
				m_template.ReferenceTargetCandidates(slotFlid),
				null);
			PersistenceProvider persistProvider =
				new PersistenceProvider(m_mediator.PropertyTable);
			SimpleListChooser chooser =
				new SimpleListChooser(persistProvider, labels, m_ChooseSlotHelpTopic);
			chooser.Cache = Cache;
			chooser.TextParamHvo = m_template.OwnerHVO;
			chooser.Title = m_sSlotChooserTitle;
			chooser.InstructionalText = m_sSlotChooserInstructionalText;
			string sTopPOS;
			int posHvo = GetHvoOfHighestPOS(m_template.OwnerHVO, out sTopPOS);
			string sLabel = String.Format(m_sObligatorySlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, posHvo,
				false, m_mediator));
			sLabel = String.Format(m_sOptionalSlot, sTopPOS);
			chooser.AddLink(sLabel, SimpleListChooser.LinkType.kSimpleLink,
				new MakeInflAffixSlotChooserCommand(Cache, true, sLabel, posHvo, true,
				m_mediator));
			chooser.SetObjectAndFlid(posHvo, (int)FDO.Ling.MoInflAffixTemplate.MoInflAffixTemplateTags.kflidSlots);
			return chooser;
		}