本文整理汇总了C#中ICmObject.OwnerOfClass方法的典型用法代码示例。如果您正苦于以下问题:C# ICmObject.OwnerOfClass方法的具体用法?C# ICmObject.OwnerOfClass怎么用?C# ICmObject.OwnerOfClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICmObject
的用法示例。
在下文中一共展示了ICmObject.OwnerOfClass方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunMacro
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);
}
示例2: FindCorrespondingParagraph
/// ------------------------------------------------------------------------------------
/// <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;
}
示例3: GetTypeNameForUi
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");
}
示例4: GetTarget
static ICmObject GetTarget(ICmObject obj, int clsid)
{
if (obj.ClassID == clsid)
return obj;
if (obj.OwnerOfClass(clsid) != null)
return obj.OwnerOfClass(clsid);
return null;
}
示例5: SetRoot
/// <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;
}
示例6: GetTargetRef
/// <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;
}
示例7: Init
/// <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);
//.........这里部分代码省略.........
示例8: Enabled
public bool Enabled(ICmObject target, int targetField, int wsId, int start, int length)
{
return target is ILexExampleSentence || target.OwnerOfClass<ILexExampleSentence>() != null;
}
示例9: GetLocationInfoForObj
/// ------------------------------------------------------------------------------------
/// <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);
}
}