private static void WriteInflMsaForLexEntryInflType(XmlWriter writer, string wordType, ILexEntryInflType lexEntryInflType) { IMoInflAffixSlot slot; if (wordType != null) { slot = lexEntryInflType.Services.GetInstance <IMoInflAffixSlotRepository>().GetObject(Convert.ToInt32(wordType)); } else { var slots = lexEntryInflType.SlotsRC; IMoInflAffixSlot firstSlot = slots.FirstOrDefault(); slot = firstSlot; } if (slot != null) { writer.WriteStartElement("inflMsa"); WritePosXmlAttribute(writer, slot.Owner as IPartOfSpeech, "cat"); writer.WriteAttributeString("slot", slot.Hvo.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("slotAbbr", slot.Name.BestAnalysisAlternative.Text); writer.WriteAttributeString("slotOptional", "false"); WriteFeatureStructureNodes(writer, lexEntryInflType.InflFeatsOA, lexEntryInflType.Hvo); writer.WriteEndElement(); //inflMsa } }
public MakeInflAffixEntryChooserCommand(FdoCache cache, bool fCloseBeforeExecuting, string sLabel, bool fPrefix, IMoInflAffixSlot slot, Mediator mediator) : base(cache, fCloseBeforeExecuting, sLabel, mediator) { m_fPrefix = fPrefix; m_slot = slot; }
public MakeInflAffixEntryChooserCommand(FdoCache cache, bool fCloseBeforeExecuting, string sLabel, bool fPrefix, IMoInflAffixSlot slot, XCore.Mediator mediator) : base(cache, fCloseBeforeExecuting, sLabel, mediator) { m_fPrefix = fPrefix; m_slot = slot; }
// Handles a change in the item selected in the affix slot combo box. void HandleComboSlotChange(object sender, EventArgs ea) { if (m_skipEvents) { return; } FwComboBox combo = sender as FwComboBox; HvoTssComboItem selItem = combo.SelectedItem as HvoTssComboItem; m_selectedSlot = (selItem == null) ? null : m_cache.ServiceLocator.GetInstance <IMoInflAffixSlotRepository>().GetObject(selItem.Hvo); }
/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOS != null) { // Cache items to add, which prevents prop changed being called for each add. (Fixes FWR-3083) List <HvoTssComboItem> itemsToAdd = new List <HvoTssComboItem>(); foreach (var slot in GetSlots()) { string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slot.Hvo, m_tsf.MakeString(name, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle)); itemsToAdd.Add(newItem); if (m_selectedSlot != null && m_selectedSlot.Hvo == newItem.Hvo) { matchIdx = itemsToAdd.Count - 1; } } } m_fwcbSlots.Items.AddRange(itemsToAdd.ToArray()); } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlot = null; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }
/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOSHvo > 0) { Set <int> hvoSlots = GetHvoSlots(); foreach (int slotID in hvoSlots) { IMoInflAffixSlot slot = MoInflAffixSlot.CreateFromDBObject(m_cache, slotID); string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slotID, m_tsf.MakeString(name, m_cache.LangProject.DefaultAnalysisWritingSystem)); int idx = m_fwcbSlots.Items.Add(newItem); if (newItem.Hvo == m_selectedSlotHvo) { matchIdx = idx; } } } } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlotHvo = 0; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }
protected void CreateInflMsaForLexEntryInflType(XmlDocument doc, XmlNode node, ILexEntryInflType lexEntryInflType) { /*var slots = lexEntryInflType.SlotsRC; * IMoInflAffixSlot firstSlot = null; * foreach (var slot in slots) * { * if (firstSlot == null) * firstSlot = slot; * }*/ IMoInflAffixSlot slot; var slotId = node.SelectSingleNode("MoForm/@wordType"); if (slotId != null) { slot = m_cache.ServiceLocator.GetInstance <IMoInflAffixSlotRepository>().GetObject(Convert.ToInt32(slotId.InnerText)); } else { var slots = lexEntryInflType.SlotsRC; IMoInflAffixSlot firstSlot = null; foreach (var slot1 in slots) // there's got to be a better way to do this... { firstSlot = slot1; break; } slot = firstSlot; } XmlNode nullInflMsaNode; nullInflMsaNode = CreateXmlElement(doc, "inflMsa", node); CreatePOSXmlAttribute(doc, nullInflMsaNode, slot.Owner as IPartOfSpeech, "cat"); CreateXmlAttribute(doc, "slot", slot.Hvo.ToString(), nullInflMsaNode); CreateXmlAttribute(doc, "slotAbbr", slot.Name.BestAnalysisAlternative.Text, nullInflMsaNode); CreateXmlAttribute(doc, "slotOptional", "false", nullInflMsaNode); CreateFeatureStructureNodes(doc, nullInflMsaNode, lexEntryInflType.InflFeatsOA, lexEntryInflType.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; }
private void AddInflAffixMsaToSlot(ICmObject obj, IMoInflAffixSlot slot) { var inflMsa = obj as IMoInflAffMsa; if (inflMsa == null) return; var lex = inflMsa.OwnerOfClass<ILexEntry>(); if (lex == null) return; // play it safe bool fMiamSet = false; // assume we won't find an existing infl affix msa foreach (var msa in lex.MorphoSyntaxAnalysesOC) { if (msa.ClassID == MoInflAffMsaTags.kClassId) { // is an inflectional affix msa var miam = (IMoInflAffMsa)msa; var pos = miam.PartOfSpeechRA; if (pos == null) { // use the first unspecified one miam.PartOfSpeechRA = slot.OwnerOfClass<IPartOfSpeech>(); miam.SlotsRC.Clear(); // just in case... miam.SlotsRC.Add(slot); fMiamSet = true; break; } else if (pos.AllAffixSlots.Contains(slot)) { // if the slot is in this POS if (miam.SlotsRC.Count == 0) { // use the first available miam.SlotsRC.Add(slot); fMiamSet = true; break; } else if (miam.SlotsRC.Contains(slot)) { // it is already set (probably done by the CreateEntry dialog process) fMiamSet = true; break; } else if (lex.IsCircumfix()) { // only circumfixes can more than one slot miam.SlotsRC.Add(slot); fMiamSet = true; break; } } } } if (!fMiamSet) { // need to create a new infl affix msa var newMsa = Cache.ServiceLocator.GetInstance<IMoInflAffMsaFactory>().Create(); lex.MorphoSyntaxAnalysesOC.Add(newMsa); EnsureNewMsaHasSense(lex, newMsa); newMsa.SlotsRC.Add(slot); newMsa.PartOfSpeechRA = slot.OwnerOfClass<IPartOfSpeech>(); } }
private ITsString TsSlotName(IMoInflAffixSlot slot) { if (slot != null) { if (slot.Name.AnalysisDefaultWritingSystem.Text == m_sNewSlotName) { NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(Cache.ActionHandlerAccessor, () => slot.Name.SetAnalysisDefaultWritingSystem(GetNextUnnamedSlotName())); } return slot.Name.AnalysisDefaultWritingSystem; } else { return Cache.TsStrFactory.MakeString(MEStrings.ksQuestions, Cache.DefaultUserWs); } }
private ITsString TsSlotNameOfMsa(IMoInflAffMsa msa) { ITsString tssResult = null; IMoInflAffixSlot slot = null; #if !MaybeSomeDayToTryAndGetRemoveMsaCorrectForCircumfixes if (msa.SlotsRC.Count > 0) { slot = msa.SlotsRC.First(); } tssResult = TsSlotName(slot); m_slot = slot; #else slot = (FDO.Ling.MoInflAffixSlot)CmObject.CreateFromDBObject(this.Cache, m_hvoSlot); sResult = TsSlotName(slot); #endif return tssResult; }
/// <summary> /// Reset the slot combo box. /// </summary> private void ResetSlotCombo() { m_fwcbSlots.SuspendLayout(); m_fwcbSlots.Items.Clear(); int matchIdx = -1; if (m_selectedMainPOS != null) { // Cache items to add, which prevents prop changed being called for each add. (Fixes FWR-3083) List<HvoTssComboItem> itemsToAdd = new List<HvoTssComboItem>(); foreach (var slot in GetSlots()) { string name = slot.Name.BestAnalysisAlternative.Text; if (name != null && name.Length > 0) // Don't add empty strings. { HvoTssComboItem newItem = new HvoTssComboItem(slot.Hvo, m_tsf.MakeString(name, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle)); itemsToAdd.Add(newItem); if (m_selectedSlot != null && m_selectedSlot.Hvo == newItem.Hvo) matchIdx = itemsToAdd.Count - 1; } } m_fwcbSlots.Items.AddRange(itemsToAdd.ToArray()); } if (matchIdx == -1) { m_fwcbSlots.SelectedIndex = -1; m_selectedSlot = null; // if the current proposed slot isn't possible for the POS, forget it. } else { try { m_skipEvents = true; m_fwcbSlots.SelectedIndex = matchIdx; } finally { m_skipEvents = false; } } m_fwcbSlots.Enabled = m_fwcbSlots.Items.Count > 0; m_lSLots.Enabled = m_fwcbSlots.Enabled; m_fwcbSlots.ResumeLayout(); }
private int GetAffixSequenceContainingSlot(IMoInflAffixSlot slot, out IFdoReferenceSequence<IMoInflAffixSlot> seq, out int index) { index = m_template.PrefixSlotsRS.IndexOf(slot); if (index >= 0) { seq = m_template.PrefixSlotsRS; return MoInflAffixTemplateTags.kflidPrefixSlots; } else { index = m_template.SuffixSlotsRS.IndexOf(slot); if (index >= 0) { seq = m_template.SuffixSlotsRS; return MoInflAffixTemplateTags.kflidSuffixSlots; } } seq = null; return 0; }
/// <summary> /// Initialize the dialog. /// </summary> /// <param name="cache">The FDO cache to use.</param> /// <param name="morphType">The morpheme type</param> /// <param name="msaType">The type of msa</param> /// <param name="slot">The default slot of the inflectional affix msa to</param> /// <param name="mediator">The mediator.</param> /// <param name="filter">The filter.</param> public void SetDlgInfo(FdoCache cache, IMoMorphType morphType, MsaType msaType, IMoInflAffixSlot slot, Mediator mediator, MorphTypeFilterType filter) { CheckDisposed(); Mediator = mediator; SetDlgInfo(cache, morphType, 0, filter); m_msaGroupBox.MSAType = msaType; Slot = slot; }
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InsertEntryDlg)); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_formLabel = new System.Windows.Forms.Label(); this.m_tbLexicalForm = new SIL.FieldWorks.Common.Widgets.FwTextBox(); this.m_tbGloss = new SIL.FieldWorks.Common.Widgets.FwTextBox(); this.m_btnHelp = new System.Windows.Forms.Button(); this.m_morphTypeLabel = new System.Windows.Forms.Label(); this.m_cbMorphType = new SIL.FieldWorks.Common.Controls.FwOverrideComboBox(); this.m_cbComplexFormType = new SIL.FieldWorks.Common.Controls.FwOverrideComboBox(); this.m_matchingEntriesGroupBox = new System.Windows.Forms.GroupBox(); this.m_labelArrow = new System.Windows.Forms.Label(); this.m_imageList = new System.Windows.Forms.ImageList(this.components); this.m_linkSimilarEntry = new System.Windows.Forms.LinkLabel(); this.m_matchingObjectsBrowser = new SIL.FieldWorks.Common.Controls.MatchingObjectsBrowser(); this.m_toolTipSlotCombo = new System.Windows.Forms.ToolTip(this.components); this.m_msaGroupBox = new SIL.FieldWorks.LexText.Controls.MSAGroupBox(); this.m_propsGroupBox = new System.Windows.Forms.GroupBox(); this.m_complexTypeLabel = new System.Windows.Forms.Label(); this.m_glossGroupBox = new System.Windows.Forms.GroupBox(); this.m_lnkAssistant = new System.Windows.Forms.LinkLabel(); ((System.ComponentModel.ISupportInitialize)(this.m_tbLexicalForm)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_tbGloss)).BeginInit(); this.m_matchingEntriesGroupBox.SuspendLayout(); this.m_propsGroupBox.SuspendLayout(); this.m_glossGroupBox.SuspendLayout(); this.SuspendLayout(); // // m_btnOK // resources.ApplyResources(this.m_btnOK, "m_btnOK"); this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Name = "m_btnOK"; // // m_btnCancel // resources.ApplyResources(this.m_btnCancel, "m_btnCancel"); this.m_btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.m_btnCancel.Name = "m_btnCancel"; // // m_formLabel // resources.ApplyResources(this.m_formLabel, "m_formLabel"); this.m_formLabel.Name = "m_formLabel"; // // m_tbLexicalForm // this.m_tbLexicalForm.AdjustStringHeight = true; this.m_tbLexicalForm.BackColor = System.Drawing.SystemColors.Window; this.m_tbLexicalForm.controlID = null; resources.ApplyResources(this.m_tbLexicalForm, "m_tbLexicalForm"); this.m_tbLexicalForm.HasBorder = true; this.m_tbLexicalForm.Name = "m_tbLexicalForm"; this.m_tbLexicalForm.SelectionLength = 0; this.m_tbLexicalForm.SelectionStart = 0; this.m_tbLexicalForm.TextChanged += new System.EventHandler(this.tbLexicalForm_TextChanged); // // m_tbGloss // this.m_tbGloss.AdjustStringHeight = true; this.m_tbGloss.BackColor = System.Drawing.SystemColors.Window; this.m_tbGloss.controlID = null; resources.ApplyResources(this.m_tbGloss, "m_tbGloss"); this.m_tbGloss.HasBorder = true; this.m_tbGloss.Name = "m_tbGloss"; this.m_tbGloss.SelectionLength = 0; this.m_tbGloss.SelectionStart = 0; this.m_tbGloss.TextChanged += new System.EventHandler(this.tbGloss_TextChanged); // // m_btnHelp // resources.ApplyResources(this.m_btnHelp, "m_btnHelp"); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Click += new System.EventHandler(this.btnHelp_Click); // // m_morphTypeLabel // resources.ApplyResources(this.m_morphTypeLabel, "m_morphTypeLabel"); this.m_morphTypeLabel.Name = "m_morphTypeLabel"; // // m_cbMorphType // this.m_cbMorphType.AllowSpaceInEditBox = false; this.m_cbMorphType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; resources.ApplyResources(this.m_cbMorphType, "m_cbMorphType"); this.m_cbMorphType.Name = "m_cbMorphType"; this.m_cbMorphType.SelectedIndexChanged += new System.EventHandler(this.cbMorphType_SelectedIndexChanged); // // m_cbComplexFormType // this.m_cbComplexFormType.AllowSpaceInEditBox = false; this.m_cbComplexFormType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; resources.ApplyResources(this.m_cbComplexFormType, "m_cbComplexFormType"); this.m_cbComplexFormType.Name = "m_cbComplexFormType"; this.m_cbComplexFormType.SelectedIndexChanged += new System.EventHandler(this.cbComplexFormType_SelectedIndexChanged); // // m_matchingEntriesGroupBox // resources.ApplyResources(this.m_matchingEntriesGroupBox, "m_matchingEntriesGroupBox"); this.m_matchingEntriesGroupBox.Controls.Add(this.m_labelArrow); this.m_matchingEntriesGroupBox.Controls.Add(this.m_linkSimilarEntry); this.m_matchingEntriesGroupBox.Controls.Add(this.m_matchingObjectsBrowser); this.m_matchingEntriesGroupBox.Name = "m_matchingEntriesGroupBox"; this.m_matchingEntriesGroupBox.TabStop = false; // // m_labelArrow // resources.ApplyResources(this.m_labelArrow, "m_labelArrow"); this.m_labelArrow.ImageList = this.m_imageList; this.m_labelArrow.Name = "m_labelArrow"; this.m_labelArrow.Click += new System.EventHandler(this.btnSimilarEntry_Click); // // m_imageList // this.m_imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageList.ImageStream"))); this.m_imageList.TransparentColor = System.Drawing.Color.Fuchsia; this.m_imageList.Images.SetKeyName(0, "GoToArrow.bmp"); // // m_linkSimilarEntry // resources.ApplyResources(this.m_linkSimilarEntry, "m_linkSimilarEntry"); this.m_linkSimilarEntry.Name = "m_linkSimilarEntry"; this.m_linkSimilarEntry.TabStop = true; this.m_linkSimilarEntry.Click += new System.EventHandler(this.btnSimilarEntry_Click); // // m_matchingObjectsBrowser // resources.ApplyResources(this.m_matchingObjectsBrowser, "m_matchingObjectsBrowser"); this.m_matchingObjectsBrowser.Name = "m_matchingObjectsBrowser"; this.m_matchingObjectsBrowser.TabStop = false; this.m_matchingObjectsBrowser.SelectionChanged += new FwSelectionChangedEventHandler(this.m_matchingObjectsBrowser_SelectionChanged); this.m_matchingObjectsBrowser.SelectionMade += new FwSelectionChangedEventHandler(this.m_matchingObjectsBrowser_SelectionMade); this.m_matchingObjectsBrowser.SearchCompleted += new EventHandler(this.m_matchingObjectsBrowser_SearchCompleted); this.m_matchingObjectsBrowser.ColumnsChanged += new EventHandler(this.m_matchingObjectsBrowser_ColumnsChanged); // // m_toolTipSlotCombo // this.m_toolTipSlotCombo.AutoPopDelay = 5000; this.m_toolTipSlotCombo.InitialDelay = 250; this.m_toolTipSlotCombo.ReshowDelay = 100; this.m_toolTipSlotCombo.ShowAlways = true; // // m_msaGroupBox // resources.ApplyResources(this.m_msaGroupBox, "m_msaGroupBox"); this.m_msaGroupBox.MSAType = SIL.FieldWorks.FDO.MsaType.kNotSet; this.m_msaGroupBox.Name = "m_msaGroupBox"; this.m_msaGroupBox.Slot = null; // // m_propsGroupBox // this.m_propsGroupBox.Controls.Add(this.m_complexTypeLabel); this.m_propsGroupBox.Controls.Add(this.m_morphTypeLabel); this.m_propsGroupBox.Controls.Add(this.m_cbMorphType); this.m_propsGroupBox.Controls.Add(this.m_cbComplexFormType); this.m_propsGroupBox.Controls.Add(this.m_tbLexicalForm); this.m_propsGroupBox.Controls.Add(this.m_formLabel); resources.ApplyResources(this.m_propsGroupBox, "m_propsGroupBox"); this.m_propsGroupBox.Name = "m_propsGroupBox"; this.m_propsGroupBox.TabStop = false; // // m_complexTypeLabel // resources.ApplyResources(this.m_complexTypeLabel, "m_complexTypeLabel"); this.m_complexTypeLabel.Name = "m_complexTypeLabel"; // // m_glossGroupBox // this.m_glossGroupBox.Controls.Add(this.m_lnkAssistant); this.m_glossGroupBox.Controls.Add(this.m_tbGloss); resources.ApplyResources(this.m_glossGroupBox, "m_glossGroupBox"); this.m_glossGroupBox.Name = "m_glossGroupBox"; this.m_glossGroupBox.TabStop = false; // // m_lnkAssistant // resources.ApplyResources(this.m_lnkAssistant, "m_lnkAssistant"); this.m_lnkAssistant.Name = "m_lnkAssistant"; this.m_lnkAssistant.TabStop = true; this.m_lnkAssistant.VisitedLinkColor = System.Drawing.Color.Blue; this.m_lnkAssistant.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkAssistant_LinkClicked); // // InsertEntryDlg // this.AcceptButton = this.m_btnOK; resources.ApplyResources(this, "$this"); this.CancelButton = this.m_btnCancel; this.Controls.Add(this.m_glossGroupBox); this.Controls.Add(this.m_propsGroupBox); this.Controls.Add(this.m_msaGroupBox); this.Controls.Add(this.m_matchingEntriesGroupBox); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "InsertEntryDlg"; this.ShowInTaskbar = false; this.Load += new System.EventHandler(this.InsertEntryDlg_Load); this.Closed += new System.EventHandler(this.InsertEntryDlg_Closed); this.Closing += new System.ComponentModel.CancelEventHandler(this.InsertEntryDlg_Closing); ((System.ComponentModel.ISupportInitialize)(this.m_tbLexicalForm)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_tbGloss)).EndInit(); this.m_matchingEntriesGroupBox.ResumeLayout(false); this.m_matchingEntriesGroupBox.PerformLayout(); this.m_propsGroupBox.ResumeLayout(false); this.m_glossGroupBox.ResumeLayout(false); this.m_glossGroupBox.PerformLayout(); this.ResumeLayout(false); }
internal static XElement CreateMorphemeElement(IMoMorphSynAnalysis msa, ILexEntryInflType inflType) { var msaElem = new XElement("Morpheme", new XAttribute("id", msa.Hvo)); switch (msa.ClassID) { case MoStemMsaTags.kClassId: var stemMsa = (IMoStemMsa)msa; msaElem.Add(new XAttribute("type", "stem")); if (stemMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", stemMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (stemMsa.FromPartsOfSpeechRC.Count > 0) { msaElem.Add(new XElement("FromCategories", stemMsa.FromPartsOfSpeechRC.Select(pos => new XElement("Category", pos.Abbreviation.BestAnalysisAlternative.Text)))); } if (stemMsa.InflectionClassRA != null) { msaElem.Add(new XElement("InflClass", stemMsa.InflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoDerivAffMsaTags.kClassId: var derivMsa = (IMoDerivAffMsa)msa; msaElem.Add(new XAttribute("type", "deriv")); if (derivMsa.FromPartOfSpeechRA != null) { msaElem.Add(new XElement("FromCategory", derivMsa.FromPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (derivMsa.ToPartOfSpeechRA != null) { msaElem.Add(new XElement("ToCategory", derivMsa.ToPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (derivMsa.ToInflectionClassRA != null) { msaElem.Add(new XElement("ToInflClass", derivMsa.ToInflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoUnclassifiedAffixMsaTags.kClassId: var unclassMsa = (IMoUnclassifiedAffixMsa)msa; msaElem.Add(new XAttribute("type", "unclass")); if (unclassMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", unclassMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoInflAffMsaTags.kClassId: var inflMsa = (IMoInflAffMsa)msa; msaElem.Add(new XAttribute("type", "infl")); if (inflMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", inflMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (inflMsa.SlotsRC.Count > 0) { IMoInflAffixSlot slot = inflMsa.SlotsRC.First(); msaElem.Add(new XElement("Slot", new XAttribute("optional", slot.Optional), slot.Name.BestAnalysisAlternative.Text)); } break; } msaElem.Add(new XElement("HeadWord", msa.OwnerOfClass <ILexEntry>().HeadWord.Text)); var glossSB = new StringBuilder(); if (inflType != null) { string prepend = inflType.GlossPrepend.BestAnalysisAlternative.Text; if (prepend != "***") { glossSB.Append(prepend); } } ILexSense sense = msa.OwnerOfClass <ILexEntry>().SenseWithMsa(msa); glossSB.Append(sense == null ? ParserCoreStrings.ksQuestions : sense.Gloss.BestAnalysisAlternative.Text); if (inflType != null) { string append = inflType.GlossAppend.BestAnalysisAlternative.Text; if (append != "***") { glossSB.Append(append); } } msaElem.Add(new XElement("Gloss", glossSB.ToString())); return(msaElem); }
internal static XElement CreateMorphemeElement(IMoMorphSynAnalysis msa) { var msaElem = new XElement("Morpheme", new XAttribute("id", msa.Hvo)); switch (msa.ClassID) { case MoStemMsaTags.kClassId: var stemMsa = (IMoStemMsa)msa; msaElem.Add(new XAttribute("type", "stem")); if (stemMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", stemMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (stemMsa.FromPartsOfSpeechRC.Count > 0) { msaElem.Add(new XElement("FromCategories", stemMsa.FromPartsOfSpeechRC.Select(pos => new XElement("Category", pos.Abbreviation.BestAnalysisAlternative.Text)))); } if (stemMsa.InflectionClassRA != null) { msaElem.Add(new XElement("InflClass", stemMsa.InflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoDerivAffMsaTags.kClassId: var derivMsa = (IMoDerivAffMsa)msa; msaElem.Add(new XAttribute("type", "deriv")); if (derivMsa.FromPartOfSpeechRA != null) { msaElem.Add(new XElement("FromCategory", derivMsa.FromPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (derivMsa.ToPartOfSpeechRA != null) { msaElem.Add(new XElement("ToCategory", derivMsa.ToPartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (derivMsa.ToInflectionClassRA != null) { msaElem.Add(new XElement("ToInflClass", derivMsa.ToInflectionClassRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoUnclassifiedAffixMsaTags.kClassId: var unclassMsa = (IMoUnclassifiedAffixMsa)msa; msaElem.Add(new XAttribute("type", "unclass")); if (unclassMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", unclassMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } break; case MoInflAffMsaTags.kClassId: var inflMsa = (IMoInflAffMsa)msa; msaElem.Add(new XAttribute("type", "infl")); if (inflMsa.PartOfSpeechRA != null) { msaElem.Add(new XElement("Category", inflMsa.PartOfSpeechRA.Abbreviation.BestAnalysisAlternative.Text)); } if (inflMsa.SlotsRC.Count > 0) { IMoInflAffixSlot slot = inflMsa.SlotsRC.First(); msaElem.Add(new XElement("Slot", new XAttribute("optional", slot.Optional), slot.Name.BestAnalysisAlternative.Text)); } break; } msaElem.Add(new XElement("HeadWord", msa.OwnerOfClass <ILexEntry>().HeadWord.Text)); msaElem.Add(new XElement("Gloss", msa.GetGlossOfFirstSense())); return(msaElem); }
private void HandleInsertAroundSlot(bool fBefore, IMoInflAffixSlot chosenSlot, out int flid, out int ihvo) { IFdoReferenceSequence<IMoInflAffixSlot> seq; int index; flid = GetAffixSequenceContainingSlot(m_obj as IMoInflAffixSlot, out seq, out index); int iOffset = (fBefore) ? 0 : 1; UndoableUnitOfWorkHelper.Do(MEStrings.ksUndoAddSlot, MEStrings.ksRedoAddSlot, Cache.ActionHandlerAccessor, () => seq.Insert(index + iOffset, chosenSlot)); // The views system numbers visually, so adjust index for RTL vernacular writing system. ihvo = index + iOffset; if (IsRTL()) ihvo = (seq.Count - 1) - ihvo; }
private void HandleInsertAroundStem(bool fBefore, IMoInflAffixSlot chosenSlot, out int flid, out int ihvo) { if (fBefore) { flid = MoInflAffixTemplateTags.kflidPrefixSlots; // The views system numbers visually, so adjust index for RTL vernacular writing system. if (IsRTL()) ihvo = 0; else ihvo = m_template.PrefixSlotsRS.Count; UndoableUnitOfWorkHelper.Do(MEStrings.ksUndoAddSlot, MEStrings.ksRedoAddSlot, Cache.ActionHandlerAccessor, () => m_template.PrefixSlotsRS.Add(chosenSlot)); } else { flid = MoInflAffixTemplateTags.kflidSuffixSlots; // The views system numbers visually, so adjust index for RTL vernacular writing system. if (IsRTL()) ihvo = m_template.SuffixSlotsRS.Count; else ihvo = 0; UndoableUnitOfWorkHelper.Do(MEStrings.ksUndoAddSlot, MEStrings.ksRedoAddSlot, Cache.ActionHandlerAccessor, () => m_template.SuffixSlotsRS.Insert(0, chosenSlot)); } }
/// <summary> /// Handle interaction between POS and Slot ptoeprties for a inflectional affix MSA. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// If the new value is zero, then set the Slot prop to zero. /// If the new value is not zero, then make sure the Slot prop is valid. /// If the current slot is not legal for the new POS value, then set it to zero. /// Otherwise leave the slot value alone. /// </remarks> protected void OnReferenceChanged(object sender, FwObjectSelectionEventArgs e) { Debug.Assert(sender is AtomicReferenceLauncher); var source = (AtomicReferenceLauncher)sender; Debug.Assert(Control == source); Debug.Assert(Object is IMoInflAffMsa); int idxSender = ContainingDataTree.Slices.IndexOf(this); int otherFlid = MoInflAffMsaTags.kflidSlots; Slice otherSlice = null; int idxOther; // Try to get the Slots slice. // Check for slices before this one. if (idxSender > 0) { idxOther = idxSender - 1; while (idxOther >= 0 && (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object))) { otherSlice = ContainingDataTree.Slices[idxOther--]; if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid) { break; } otherSlice = null; } } // Check for following slices, if we didn't get one earlier. if (otherSlice == null && idxSender < ContainingDataTree.Slices.Count) { idxOther = idxSender + 1; while (idxOther < ContainingDataTree.Slices.Count && (otherSlice == null || (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object))) { otherSlice = ContainingDataTree.Slices[idxOther++]; if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid) { break; } otherSlice = null; } } VectorReferenceLauncher otherControl = null; if (otherSlice != null) { Debug.Assert(otherSlice.Flid == otherFlid); Debug.Assert(otherSlice.Object == Object); otherControl = otherSlice.Control as VectorReferenceLauncher; Debug.Assert(otherControl != null); } var msa = Object as IMoInflAffMsa; IMoInflAffixSlot slot = null; if (msa.SlotsRC.Count > 0) { slot = msa.SlotsRC.First(); } if (e.Hvo == 0 || slot != null) { var pos = msa.PartOfSpeechRA; var slots = pos != null ? pos.AllAffixSlots : Enumerable.Empty <IMoInflAffixSlot>(); bool clearSlot = e.Hvo == 0 || !slots.Contains(slot); if (clearSlot) { if (otherControl == null) { msa.SlotsRC.Clear(); // The slot slice is not showing, so directly set the object's Slot property. } else { otherControl.AddItem(null); // Reset it using the other slice, so it gets refreshed. } } } }
//private void DetermineSlotContextMenuItemContent(UIItemDisplayProperties display) //{ // if (m_class == 0) // return; // should not happen // if (m_class == MoInflAffixSlot.kclsidMoInflAffixSlot) // { // IMoInflAffixSlot slot = new MoInflAffixSlot(Cache, m_hvo); // display.Text = DoXXXReplace(display.Text, CheckSlotName(slot)); // } // else if (m_class == MoInflAffixTemplate.kclsidMoInflAffixTemplate) // { // display.Text = DoXXXReplace(display.Text, m_sStem); // } // else if (m_class == MoInflAffMsa.kclsidMoInflAffMsa) // { // display.Visible = false; // display.Enabled = false; // } //} // //private string DoXXXReplace(string sSource, string sReplace) //{ // return sSource.Replace("XXX", sReplace); //} //private string DoYYYReplace(string sSource, string sReplace) //{ // return sSource.Replace("YYY", sReplace); //} /// <summary> /// Fix the name of any slot that is still "Type slot name here". /// </summary> /// <param name="slot"></param> private void FixSlotName(IMoInflAffixSlot slot) { if (slot.Name.AnalysisDefaultWritingSystem.Text == m_sNewSlotName) slot.Name.SetAnalysisDefaultWritingSystem(GetNextUnnamedSlotName()); }
private static bool IsValidSlot(IMoInflAffixSlot affixSlot) { return affixSlot.Affixes.Take(1).Any(); }
// Handles a change in the item selected in the affix slot combo box. void HandleComboSlotChange(object sender, EventArgs ea) { if (m_skipEvents) return; FwComboBox combo = sender as FwComboBox; HvoTssComboItem selItem = combo.SelectedItem as HvoTssComboItem; m_selectedSlot = (selItem == null) ? null : m_cache.ServiceLocator.GetInstance<IMoInflAffixSlotRepository>().GetObject(selItem.Hvo); }
//private void DetermineSlotContextMenuItemContent(UIItemDisplayProperties display) //{ // if (m_class == 0) // return; // should not happen // if (m_class == MoInflAffixSlot.kclsidMoInflAffixSlot) // { // IMoInflAffixSlot slot = new MoInflAffixSlot(Cache, m_hvo); // display.Text = DoXXXReplace(display.Text, CheckSlotName(slot)); // } // else if (m_class == MoInflAffixTemplate.kclsidMoInflAffixTemplate) // { // display.Text = DoXXXReplace(display.Text, m_sStem); // } // else if (m_class == MoInflAffMsa.kclsidMoInflAffMsa) // { // display.Visible = false; // display.Enabled = false; // } //} // //private string DoXXXReplace(string sSource, string sReplace) //{ // return sSource.Replace("XXX", sReplace); //} //private string DoYYYReplace(string sSource, string sReplace) //{ // return sSource.Replace("YYY", sReplace); //} private string CheckSlotName(IMoInflAffixSlot slot) { string sResult; if (slot != null) { if (slot.Name.AnalysisDefaultWritingSystem == m_sNewSlotName) slot.Name.AnalysisDefaultWritingSystem = GetNextUnnamedSlotName(); sResult = slot.Name.AnalysisDefaultWritingSystem; ; } else sResult = MEStrings.ksQuestions; return sResult; }
/// <summary> /// /// </summary> /// <param name="sLabel"></param> /// <returns></returns> internal ITsString MenuLabelForInflTemplateAddInflAffixMsa(string sLabel) { CheckDisposed(); if (m_obj.ClassID == MoInflAffMsaTags.kClassId) { return DetermineMsaContextMenuItemLabel(sLabel); } else if (m_obj.ClassID == MoInflAffixSlotTags.kClassId) { m_slot = m_obj as IMoInflAffixSlot; return DoXXXReplace(sLabel, TsSlotName(m_slot)); } else { return null; } }
private ITsString TsSlotName(IMoInflAffixSlot slot) { ITsStrFactory tsf = TsStrFactoryClass.Create(); if (slot != null) { if (slot.Name.AnalysisDefaultWritingSystem == m_sNewSlotName) slot.Name.AnalysisDefaultWritingSystem = GetNextUnnamedSlotName(); return tsf.MakeString(slot.Name.AnalysisDefaultWritingSystem, Cache.DefaultAnalWs); } else { return tsf.MakeString(MEStrings.ksQuestions, Cache.DefaultUserWs); } }