/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the section index and paragraph index for the specified object, either an /// StTxtPara or a ICmTranslation/ISegment of an IScrTxtPara. /// </summary> /// <param name="obj">An ICmObject associated with an annotation (i.e. the annotation's /// BeginObjectRA) If this is not a IScrTxtPara or ICmTranslation/ISegment of a IScrTxtPara, this /// method can't do anything very useful.</param> /// <param name="iNewNoteSection">The index of the section, or -1 if the index cannot /// be determined.</param> /// <param name="iNewNotePara">The index of paragraph, or int.MaxValue if the index /// cannot be determined.</param> /// ------------------------------------------------------------------------------------ private void GetLocationInfoForObj(ICmObject obj, out int iNewNoteSection, out int iNewNotePara) { iNewNoteSection = -1; iNewNotePara = int.MaxValue; // Don't rely on secion/paragraph information if reference object is in a saved version if (obj == null || obj.OwnerOfClass <IScrDraft>() != null) { return; } if (obj is IScrTxtPara) { IScrTxtPara para = (IScrTxtPara)obj; iNewNotePara = para.IndexInOwner; IScrSection section = para.OwningSection; if (section != null) { iNewNoteSection = section.IndexInOwner; } } else if (obj is ICmTranslation) { ICmTranslation trans = (ICmTranslation)obj; Debug.Assert(trans.Owner is IScrTxtPara); GetLocationInfoForObj(trans.Owner, out iNewNoteSection, out iNewNotePara); } else if (obj is ISegment) { ISegment segment = (ISegment)obj; Debug.Assert(segment.Owner is IScrTxtPara); GetLocationInfoForObj(segment.Owner, out iNewNoteSection, out iNewNotePara); } }
public void RunMacro(ICmObject target, int targetField, int wsId, int startOffset, int length) { var example = target as ILexExampleSentence ?? target.OwnerOfClass<ILexExampleSentence>(); var sense = example.OwnerOfClass<ILexSense>(); var entry = sense.Entry; if (!(entry.LexemeFormOA is IMoStemAllomorph)) { MessageBox.Show("This macro only works on stems"); return; } var newEntry = entry.Services.GetInstance<ILexEntryFactory>().Create(); var newSense = entry.Services.GetInstance<ILexSenseFactory>().Create(); newEntry.SensesOS.Add(newSense); newSense.ExamplesOS.Add(example); // moves the chosen example // Would be nice to use CopyObject, but currently not public newEntry.LexemeFormOA = entry.Services.GetInstance<IMoStemAllomorphFactory>().Create(); foreach (var ws in entry.LexemeFormOA.Form.AvailableWritingSystemIds) newEntry.LexemeFormOA.Form.set_String(ws, entry.LexemeFormOA.Form.get_String(ws)); foreach (var ws in sense.Gloss.AvailableWritingSystemIds) newSense.Gloss.set_String(ws, sense.Gloss.get_String(ws)); foreach (var ws in sense.Definition.AvailableWritingSystemIds) newSense.Definition.set_String(ws, sense.Gloss.get_String(ws)); // Enhance JohnT: maybe there is more stuff we want to copy? //Now make it a subentry var ler = entry.Services.GetInstance<ILexEntryRefFactory>().Create(); newEntry.EntryRefsOS.Add(ler); ler.RefType = LexEntryRefTags.krtComplexForm; // must be a complex form to be a subentry ler.ComponentLexemesRS.Add(entry); ler.PrimaryLexemesRS.Add(entry); }
private string GetLexReferenceName(ILexEntry lexEntry, ILexReference lexRef, out ILexEntry parentEntry) { parentEntry = null; ILexRefType lexRefType = lexRef.OwnerOfClass <ILexRefType>(); string name = lexRefType.ShortName; if (string.IsNullOrEmpty(name)) { name = lexRefType.Abbreviation.BestAnalysisAlternative.Text; } var mappingType = (LexRefTypeTags.MappingTypes)lexRefType.MappingType; switch (mappingType) { case LexRefTypeTags.MappingTypes.kmtSenseTree: case LexRefTypeTags.MappingTypes.kmtEntryTree: case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree: case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair: // Sense Pair with different Forward/Reverse names case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair: // Entry Pair with different Forward/Reverse names case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair: // Entry or sense Pair with different Forward/Reverse names if (lexRef.TargetsRS.Count > 0) { ICmObject firstObj = lexRef.TargetsRS[0]; ILexEntry firstEntry = null; switch (firstObj.ClassID) { case LexEntryTags.kClassId: firstEntry = (ILexEntry)firstObj; break; case LexSenseTags.kClassId: firstEntry = firstObj.OwnerOfClass <ILexEntry>(); break; } if (firstEntry != lexEntry) { name = lexRefType.ReverseName.BestAnalysisAlternative.Text; if (string.IsNullOrEmpty(name)) { name = lexRefType.ReverseAbbreviation.BestAnalysisAlternative.Text; } } if (mappingType == LexRefTypeTags.MappingTypes.kmtSenseTree || mappingType == LexRefTypeTags.MappingTypes.kmtEntryTree || mappingType == LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree) { parentEntry = firstEntry; } } break; } return(name.Normalize()); }
/// <summary> /// Get a reference we should jump to in order to show the specified object. /// </summary> /// <param name="target"></param> /// <returns></returns> internal ScrReference GetTargetRef(ICmObject target) { BCVRef targetRef; var para = target as IScrTxtPara; if (para == null) { para = target.OwnerOfClass <IStTxtPara>() as IScrTxtPara; } if (para != null) { BCVRef end; para.GetRefsAtPosition(0, out targetRef, out end); return(new ScrReference(targetRef, Cache.LangProject.TranslatedScriptureOA.Versification)); } // Not a paragraph or owned by one. Try for a section. var section = target as IScrSection; if (section == null) { section = target.OwnerOfClass <IScrSection>(); } if (section == null) { // Failing that the first section of some book... var book = target as IScrBook; if (book == null) { book = target.OwnerOfClass <IScrBook>(); } if (book != null && book.SectionsOS.Count > 0) { section = book.SectionsOS[0]; } } if (section != null) { return(new ScrReference(section.VerseRefMin, Cache.LangProject.TranslatedScriptureOA.Versification)); } // Enhance JohnT: possibly we can do better for footnotes, notes, other Scripture-related objects? return(null); }
private bool RunMergeEntryDialog(object argument, bool fLoseNoTextData) { ICmObject obj = m_mediator.PropertyTable.GetValue("ActiveClerkSelectedObject") as ICmObject; Debug.Assert(obj != null); if (obj == null) { return(false); // should never happen, but nothing we can do if it does! } FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); Debug.Assert(cache != null); Debug.Assert(cache == obj.Cache); ILexEntry currentEntry = obj as ILexEntry; if (currentEntry == null) { currentEntry = obj.OwnerOfClass(LexEntryTags.kClassId) as ILexEntry; } Debug.Assert(currentEntry != null); if (currentEntry == null) { return(false); } using (MergeEntryDlg dlg = new MergeEntryDlg()) { Debug.Assert(argument != null && argument is Command); dlg.SetDlgInfo(cache, m_mediator, currentEntry); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var survivor = dlg.SelectedObject as ILexEntry; Debug.Assert(survivor != currentEntry); UndoableUnitOfWorkHelper.Do(LexTextControls.ksUndoMergeEntry, LexTextControls.ksRedoMergeEntry, cache.ActionHandlerAccessor, () => { survivor.MergeObject(currentEntry, fLoseNoTextData); survivor.DateModified = DateTime.Now; }); MessageBox.Show(null, LexTextControls.ksEntriesHaveBeenMerged, LexTextControls.ksMergeReport, MessageBoxButtons.OK, MessageBoxIcon.Information); m_mediator.SendMessage("JumpToRecord", survivor.Hvo); } } return(true); }
public void RunMacro(ICmObject target, int targetField, int wsId, int startOffset, int length) { var example = target as ILexExampleSentence ?? target.OwnerOfClass <ILexExampleSentence>(); var sense = example.OwnerOfClass <ILexSense>(); var entry = sense.Entry; if (!(entry.LexemeFormOA is IMoStemAllomorph)) { MessageBox.Show("This macro only works on stems"); return; } var newEntry = entry.Services.GetInstance <ILexEntryFactory>().Create(); var newSense = entry.Services.GetInstance <ILexSenseFactory>().Create(); newEntry.SensesOS.Add(newSense); newSense.ExamplesOS.Add(example); // moves the chosen example // Would be nice to use CopyObject, but currently not public newEntry.LexemeFormOA = entry.Services.GetInstance <IMoStemAllomorphFactory>().Create(); foreach (var ws in entry.LexemeFormOA.Form.AvailableWritingSystemIds) { newEntry.LexemeFormOA.Form.set_String(ws, entry.LexemeFormOA.Form.get_String(ws)); } foreach (var ws in sense.Gloss.AvailableWritingSystemIds) { newSense.Gloss.set_String(ws, sense.Gloss.get_String(ws)); } foreach (var ws in sense.Definition.AvailableWritingSystemIds) { newSense.Definition.set_String(ws, sense.Gloss.get_String(ws)); } // Enhance JohnT: maybe there is more stuff we want to copy? //Now make it a subentry var ler = entry.Services.GetInstance <ILexEntryRefFactory>().Create(); newEntry.EntryRefsOS.Add(ler); ler.RefType = LexEntryRefTags.krtComplexForm; // must be a complex form to be a subentry ler.ComponentLexemesRS.Add(entry); ler.PrimaryLexemesRS.Add(entry); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Finds paragraph in the passed book that is at a similar structural location to the /// given paragraph's location in its book. /// </summary> /// <param name="book">Current version of book</param> /// <param name="savedPara">Paragraph in saved archive of the book</param> /// <returns> /// Paragraph that is in a similar location to the passed paragraph if it exists; /// otherwise <c>null</c> will be returned. /// </returns> /// ------------------------------------------------------------------------------------ private ICmObject FindCorrespondingParagraph(IScrBook book, ICmObject savedPara) { // make sure we really did find a paragraph if (!(savedPara is IStTxtPara)) return null; IScrBook savedBook = savedPara.OwnerOfClass<IScrBook>(); if (savedBook != null) { IStText owningText = (IStText)savedPara.Owner; int paraIndex = savedPara.IndexInOwner; IStText curText = null; int owningFlid = owningText.OwningFlid; if (owningFlid == (int)ScrBookTags.kflidTitle) curText = book.TitleOA; else if (owningFlid == (int)ScrSectionTags.kflidHeading || owningFlid == (int)ScrSectionTags.kflidContent) { IScrSection owningSection = (IScrSection)owningText.Owner; int sectionIndex = owningSection.IndexInOwner; sectionIndex = Math.Min(sectionIndex, book.SectionsOS.Count - 1); IScrSection curSection = book.SectionsOS[sectionIndex]; while (!curSection.IsIntro) { sectionIndex--; if (sectionIndex < 0) return null; curSection = book.SectionsOS[sectionIndex]; } curText = (owningFlid == (int)ScrSectionTags.kflidHeading) ? curSection.HeadingOA : curSection.ContentOA; } else return null; paraIndex = Math.Min(paraIndex, curText.ParagraphsOS.Count - 1); return curText.ParagraphsOS[paraIndex]; } return null; }
private string GetTypeNameForUi(ICmObject obj) { if (obj is ICmPossibility) return (obj as ICmPossibility).ItemTypeName(m_mediator.StringTbl); IFsFeatureSystem featsys = obj.OwnerOfClass(FsFeatureSystemTags.kClassId) as IFsFeatureSystem; if (featsys != null) { if (featsys.OwningFlid == LangProjectTags.kflidPhFeatureSystem) { string sClass = m_mediator.StringTbl.GetString(obj.ClassName, "ClassNames"); return m_mediator.StringTbl.GetString(sClass + "-Phonological", "AlternativeTypeNames"); } } return m_mediator.StringTbl.GetString(obj.ClassName, "ClassNames"); }
static ICmObject GetTarget(ICmObject obj, int clsid) { if (obj.ClassID == clsid) return obj; if (obj.OwnerOfClass(clsid) != null) return obj.OwnerOfClass(clsid); return null; }
/// <summary> /// Allows process to find an appropriate root hvo and change the current root. /// Subclasses (e.g. NotebookExportDialog) can override. /// </summary> /// <param name="cmo"></param> /// <param name="clidRoot"></param> /// <returns>Returns -1 if root hvo doesn't need changing.</returns> protected virtual int SetRoot(ICmObject cmo, out int clidRoot) { clidRoot = -1; var hvoRoot = -1; // Handle LexEntries that no longer have owners. if (cmo is ILexEntry) { hvoRoot = m_cache.LanguageProject.LexDbOA.Hvo; clidRoot = m_cache.ServiceLocator.GetInstance<Virtuals>().LexDbEntries; } else if (cmo is ICmSemanticDomain) { hvoRoot = cmo.OwnerOfClass<ICmPossibilityList>().Hvo; clidRoot = CmPossibilityListTags.kClassId; } else if (cmo.Owner != null) { hvoRoot = cmo.Owner.Hvo; clidRoot = cmo.Owner.ClassID; } return hvoRoot; }
/// <summary> /// Get a reference we should jump to in order to show the specified object. /// </summary> /// <param name="target"></param> /// <returns></returns> internal ScrReference GetTargetRef(ICmObject target) { BCVRef targetRef; var para = target as IScrTxtPara; if (para == null) para = target.OwnerOfClass<IStTxtPara>() as IScrTxtPara; if (para != null) { BCVRef end; para.GetRefsAtPosition(0, out targetRef, out end); return new ScrReference(targetRef, Cache.LangProject.TranslatedScriptureOA.Versification); } // Not a paragraph or owned by one. Try for a section. var section = target as IScrSection; if (section == null) section = target.OwnerOfClass<IScrSection>(); if (section == null) { // Failing that the first section of some book... var book = target as IScrBook; if (book == null) book = target.OwnerOfClass<IScrBook>(); if (book != null && book.SectionsOS.Count > 0) section = book.SectionsOS[0]; } if (section != null) return new ScrReference(section.VerseRefMin, Cache.LangProject.TranslatedScriptureOA.Versification); // Enhance JohnT: possibly we can do better for footnotes, notes, other Scripture-related objects? return null; }
/// <summary> /// Initilize the gui control. /// </summary> /// <param name="mediator"></param> /// <param name="configurationNode">NB: In this case it is the main 'window' element node, /// se we have to drill down to find the control definition node(s).</param> /// <param name="sourceObject"></param> public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject) { CheckDisposed(); Debug.Assert(mediator != null); Debug.Assert(configurationNode != null); Debug.Assert(sourceObject != null && (sourceObject is IWfiWordform || sourceObject is IWfiAnalysis || sourceObject is IWfiGloss)); m_cache = sourceObject.Cache; m_mediator = mediator; m_configurationNode = configurationNode; if (sourceObject is IWfiWordform) { m_wordform = (IWfiWordform)sourceObject; } else { var anal = sourceObject is IWfiAnalysis ? (IWfiAnalysis)sourceObject : sourceObject.OwnerOfClass<IWfiAnalysis>(); m_wordform = anal.OwnerOfClass<IWfiWordform>(); } helpProvider.HelpNamespace = m_mediator.HelpTopicProvider.HelpFile; helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); helpProvider.SetHelpKeyword(this, m_mediator.HelpTopicProvider.GetHelpString(s_helpTopic)); helpProvider.SetShowHelp(this, true); m_mediator.PropertyTable.SetProperty("IgnoreStatusPanel", true); m_mediator.PropertyTable.SetPropertyPersistence("IgnoreStatusPanel", false); m_progAdvInd = new ProgressReporting(m_toolStripProgressBar); // Gather up the nodes. const string xpathBase = "/window/controls/parameters[@id='guicontrols']/guicontrol[@id='{0}']/parameters[@id='{1}']"; var xpath = String.Format(xpathBase, "WordformConcordanceBrowseView", "WordformInSegmentsOccurrenceList"); var configNode = m_configurationNode.SelectSingleNode(xpath); // And create the RecordClerks. var clerk = RecordClerkFactory.CreateClerk(m_mediator, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiWordformTags.kClassId] = clerk; m_configurationNodes[WfiWordformTags.kClassId] = configNode; xpath = String.Format(xpathBase, "AnalysisConcordanceBrowseView", "AnalysisInSegmentsOccurrenceList"); configNode = m_configurationNode.SelectSingleNode(xpath); clerk = RecordClerkFactory.CreateClerk(m_mediator, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiAnalysisTags.kClassId] = clerk; m_configurationNodes[WfiAnalysisTags.kClassId] = configNode; xpath = String.Format(xpathBase, "GlossConcordanceBrowseView", "GlossInSegmentsOccurrenceList"); configNode = m_configurationNode.SelectSingleNode(xpath); clerk = RecordClerkFactory.CreateClerk(m_mediator, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiGlossTags.kClassId] = clerk; m_configurationNodes[WfiGlossTags.kClassId] = configNode; Debug.Assert(m_wordform != null); Debug.Assert(sourceObject != null); tvSource.Font = new Font(MiscUtils.StandardSansSerif, 9); tvTarget.Font = new Font(MiscUtils.StandardSansSerif, 9); var srcTnWf = new TreeNode(); var tarTnWf = new TreeNode(); tarTnWf.Text = srcTnWf.Text = TsStringUtils.NormalizeToNFC(MEStrings.ksNoAnalysis); tarTnWf.Tag = srcTnWf.Tag = m_wordform; tvSource.Nodes.Add(srcTnWf); tvTarget.Nodes.Add(tarTnWf); if (srcTnWf.Tag == sourceObject) tvSource.SelectedNode = srcTnWf; var cnt = 0; // Note: the left side source tree only has human approved analyses, // since only those can have instances from text-land pointing at them. foreach (var anal in m_wordform.HumanApprovedAnalyses) { var srcTnAnal = new TreeNode(); var tarTnAnal = new TreeNode { Text = srcTnAnal.Text = TsStringUtils.NormalizeToNFC( String.Format(MEStrings.ksAnalysisX, (++cnt))), Tag = srcTnAnal.Tag = anal }; srcTnWf.Nodes.Add(srcTnAnal); tarTnWf.Nodes.Add(tarTnAnal); if (srcTnAnal.Tag == sourceObject) tvSource.SelectedNode = srcTnAnal; foreach (var gloss in anal.MeaningsOC) { var srcTnGloss = new TreeNode(); var tarTnGloss = new TreeNode(); var tss = gloss.Form.BestAnalysisAlternative; var props = tss.get_PropertiesAt(0); int nVar; var ws = props.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar); var fontname = m_wordform.Cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName; tarTnGloss.NodeFont = new Font(fontname, 9); srcTnGloss.NodeFont = new Font(fontname, 9); tarTnGloss.Text = srcTnGloss.Text = TsStringUtils.NormalizeToNFC(tss.Text); tarTnGloss.Tag = srcTnGloss.Tag = gloss; srcTnAnal.Nodes.Add(srcTnGloss); tarTnAnal.Nodes.Add(tarTnGloss); if (srcTnGloss.Tag == sourceObject) tvSource.SelectedNode = srcTnGloss; } } tvSource.ExpandAll(); tvSource.SelectedNode.EnsureVisible(); tvTarget.ExpandAll(); }
/// <summary> /// Initilize the gui control. /// </summary> /// <param name="mediator"></param> /// <param name="propertyTable"></param> /// <param name="configurationNode">NB: In this case it is the main 'window' element node, /// se we have to drill down to find the control definition node(s).</param> /// <param name="sourceObject"></param> public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationNode, ICmObject sourceObject) { CheckDisposed(); Debug.Assert(mediator != null); Debug.Assert(configurationNode != null); Debug.Assert(sourceObject != null && (sourceObject is IWfiWordform || sourceObject is IWfiAnalysis || sourceObject is IWfiGloss)); m_cache = sourceObject.Cache; m_mediator = mediator; m_propertyTable = propertyTable; m_configurationNode = configurationNode; if (sourceObject is IWfiWordform) { m_wordform = (IWfiWordform)sourceObject; } else { var anal = sourceObject is IWfiAnalysis ? (IWfiAnalysis)sourceObject : sourceObject.OwnerOfClass <IWfiAnalysis>(); m_wordform = anal.OwnerOfClass <IWfiWordform>(); } helpProvider.HelpNamespace = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider").HelpFile; helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); helpProvider.SetHelpKeyword(this, m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider").GetHelpString(s_helpTopic)); helpProvider.SetShowHelp(this, true); m_propertyTable.SetProperty("IgnoreStatusPanel", true, true); m_propertyTable.SetPropertyPersistence("IgnoreStatusPanel", false); m_progAdvInd = new ProgressReporting(m_toolStripProgressBar); // Gather up the nodes. const string xpathBase = "/window/controls/parameters[@id='guicontrols']/guicontrol[@id='{0}']/parameters[@id='{1}']"; var xpath = String.Format(xpathBase, "WordformConcordanceBrowseView", "WordformInSegmentsOccurrenceList"); var configNode = m_configurationNode.SelectSingleNode(xpath); // And create the RecordClerks. var clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiWordformTags.kClassId] = clerk; m_configurationNodes[WfiWordformTags.kClassId] = configNode; xpath = String.Format(xpathBase, "AnalysisConcordanceBrowseView", "AnalysisInSegmentsOccurrenceList"); configNode = m_configurationNode.SelectSingleNode(xpath); clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiAnalysisTags.kClassId] = clerk; m_configurationNodes[WfiAnalysisTags.kClassId] = configNode; xpath = String.Format(xpathBase, "GlossConcordanceBrowseView", "GlossInSegmentsOccurrenceList"); configNode = m_configurationNode.SelectSingleNode(xpath); clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true); clerk.ProgressReporter = m_progAdvInd; m_recordClerks[WfiGlossTags.kClassId] = clerk; m_configurationNodes[WfiGlossTags.kClassId] = configNode; Debug.Assert(m_wordform != null); Debug.Assert(sourceObject != null); tvSource.Font = new Font(MiscUtils.StandardSansSerif, 9); tvTarget.Font = new Font(MiscUtils.StandardSansSerif, 9); var srcTnWf = new TreeNode(); var tarTnWf = new TreeNode(); tarTnWf.Text = srcTnWf.Text = TsStringUtils.NormalizeToNFC(MEStrings.ksNoAnalysis); tarTnWf.Tag = srcTnWf.Tag = m_wordform; tvSource.Nodes.Add(srcTnWf); tvTarget.Nodes.Add(tarTnWf); if (srcTnWf.Tag == sourceObject) { tvSource.SelectedNode = srcTnWf; } var cnt = 0; // Note: the left side source tree only has human approved analyses, // since only those can have instances from text-land pointing at them. foreach (var anal in m_wordform.HumanApprovedAnalyses) { var srcTnAnal = new TreeNode(); var tarTnAnal = new TreeNode { Text = srcTnAnal.Text = TsStringUtils.NormalizeToNFC( String.Format(MEStrings.ksAnalysisX, (++cnt))), Tag = srcTnAnal.Tag = anal }; srcTnWf.Nodes.Add(srcTnAnal); tarTnWf.Nodes.Add(tarTnAnal); if (srcTnAnal.Tag == sourceObject) { tvSource.SelectedNode = srcTnAnal; } foreach (var gloss in anal.MeaningsOC) { var srcTnGloss = new TreeNode(); var tarTnGloss = new TreeNode(); var tss = gloss.Form.BestAnalysisAlternative; var props = tss.get_PropertiesAt(0); int nVar; var ws = props.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar); var fontname = m_wordform.Cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName; tarTnGloss.NodeFont = new Font(fontname, 9); srcTnGloss.NodeFont = new Font(fontname, 9); tarTnGloss.Text = srcTnGloss.Text = TsStringUtils.NormalizeToNFC(tss.Text); tarTnGloss.Tag = srcTnGloss.Tag = gloss; srcTnAnal.Nodes.Add(srcTnGloss); tarTnAnal.Nodes.Add(tarTnGloss); if (srcTnGloss.Tag == sourceObject) { tvSource.SelectedNode = srcTnGloss; } } } tvSource.ExpandAll(); tvSource.SelectedNode.EnsureVisible(); tvTarget.ExpandAll(); }
public bool Enabled(ICmObject target, int targetField, int wsId, int start, int length) { return(target is ILexExampleSentence || target.OwnerOfClass <ILexExampleSentence>() != null); }
public bool Enabled(ICmObject target, int targetField, int wsId, int start, int length) { return target is ILexExampleSentence || target.OwnerOfClass<ILexExampleSentence>() != null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the section index and paragraph index for the specified object, either an /// StTxtPara or a ICmTranslation/ISegment of an IScrTxtPara. /// </summary> /// <param name="obj">An ICmObject associated with an annotation (i.e. the annotation's /// BeginObjectRA) If this is not a IScrTxtPara or ICmTranslation/ISegment of a IScrTxtPara, this /// method can't do anything very useful.</param> /// <param name="iNewNoteSection">The index of the section, or -1 if the index cannot /// be determined.</param> /// <param name="iNewNotePara">The index of paragraph, or int.MaxValue if the index /// cannot be determined.</param> /// ------------------------------------------------------------------------------------ private void GetLocationInfoForObj(ICmObject obj, out int iNewNoteSection, out int iNewNotePara) { iNewNoteSection = -1; iNewNotePara = int.MaxValue; // Don't rely on secion/paragraph information if reference object is in a saved version if (obj == null || obj.OwnerOfClass<IScrDraft>() != null) return; if (obj is IScrTxtPara) { IScrTxtPara para = (IScrTxtPara)obj; iNewNotePara = para.IndexInOwner; IScrSection section = para.OwningSection; if (section != null) iNewNoteSection = section.IndexInOwner; } else if (obj is ICmTranslation) { ICmTranslation trans = (ICmTranslation)obj; Debug.Assert(trans.Owner is IScrTxtPara); GetLocationInfoForObj(trans.Owner, out iNewNoteSection, out iNewNotePara); } else if (obj is ISegment) { ISegment segment = (ISegment)obj; Debug.Assert(segment.Owner is IScrTxtPara); GetLocationInfoForObj(segment.Owner, out iNewNoteSection, out iNewNotePara); } }