本文整理汇总了C#中IVwEnv.AddSimpleRect方法的典型用法代码示例。如果您正苦于以下问题:C# IVwEnv.AddSimpleRect方法的具体用法?C# IVwEnv.AddSimpleRect怎么用?C# IVwEnv.AddSimpleRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwEnv
的用法示例。
在下文中一共展示了IVwEnv.AddSimpleRect方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Display
/// ------------------------------------------------------------------------------------
/// <summary>
/// This is the main interesting method of displaying objects and fragments of them.
/// A Scripture is displayed by displaying its Books;
/// and a Book is displayed by displaying its Title and Sections;
/// and a Section is diplayed by displaying its Heading and Content;
/// which are displayed by using the standard view constructor for StText.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo"></param>
/// <param name="frag"></param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
CheckDisposed();
if (hvo == 0)
return; // not much we can display without a valid object
switch (frag)
{
case (int)ScrFrags.kfrBook:
vwenv.OpenDiv();
vwenv.AddObjProp(ScrBookTags.kflidTitle, this,
(int)StTextFrags.kfrText);
vwenv.NoteDependency(new int[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo },
new int[] { ScriptureTags.kflidScriptureBooks }, 1);
vwenv.NoteDependency(new int[] { hvo },
new int[] { ScrBookTags.kflidSections }, 1);
vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection);
// TODO (EberhardB): The gap between the intro division and the text
// division probably needs to be configurable somewhere...
// Add a 24 point gap at the bottom of the intro section
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 24000, 0);
vwenv.CloseDiv();
break;
default:
base.Display(vwenv, hvo, frag);
break;
}
}
示例2: Display
/// ------------------------------------------------------------------------------------
/// <summary>
/// Display some simple rectangles to represent a header and a footer.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo"></param>
/// <param name="frag"></param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
// Display each dummy header or footer as a rectangle, which allows us
// to accurately predict the height.
switch(hvo)
{
case DummyHeaderFooterConfigurer.khvoHeader:
vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch / 4, 0);
break;
case DummyHeaderFooterConfigurer.khvoFooter:
vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0);
break;
default:
Assert.Fail();
break;
}
}
示例3: Display
/// ------------------------------------------------------------------------------------
/// <summary>
/// Displays the specified vwenv.
/// </summary>
/// <param name="vwenv">The vwenv.</param>
/// <param name="hvo">The hvo.</param>
/// <param name="frag">The frag.</param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
CheckDisposed();
switch(frag)
{
case kfragLazyScripture:
{
// The configure method insists on trying to make an initial selection.
// If there isn't something selectable there, it expands everything.
vwenv.AddStringProp((int)Scripture.ScriptureTags.kflidChapterVerseSepr, this);
vwenv.AddLazyVecItems((int)Scripture.ScriptureTags.kflidScriptureBooks, this,
kfragLazyBook);
break;
}
case kfragLazyBook:
{
vwenv.AddLazyVecItems((int)ScrBook.ScrBookTags.kflidSections, this,
kfragDummySection);
break;
}
case kfragDummySection:
{
vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidHeading, this,
kfragDummyStText);
vwenv.AddObjProp((int)ScrSection.ScrSectionTags.kflidContent, this,
kfragDummyStText);
break;
}
case kfragDummyStText:
{
vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
m_fParaWithContent ? kfragDummyParaWithContent : kfragDummyPara);
break;
}
case kfragDummyPara:
{
// Display each dummy paragraph as a rectangle an inch high, which allows us
// to accurately predict the height of a known number of them.
vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch, MiscUtils.kdzmpInch, 0);
break;
}
case kfragDummyParaWithContent:
{
vwenv.OpenMappedTaggedPara();
vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
vwenv.CloseParagraph();
break;
}
}
}
示例4: AddWordBundleInternal
protected override void AddWordBundleInternal(int hvo, IVwEnv vwenv)
{
// Determine whether it is the focus box occurrence.
if (FocusBoxOccurrence != null)
{
int hvoSeg, tag, ihvo;
vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out hvoSeg, out tag, out ihvo);
if (hvoSeg == FocusBoxOccurrence.Segment.Hvo && ihvo == FocusBoxOccurrence.Index)
{
// Leave room for the Sandbox instead of displaying the internlinear data.
// The first argument makes it invisible in case a little bit of it shows around
// the sandbox.
// The last argument puts the 'Baseline' of the sandbox (which aligns with the base of the
// first line of text) an appropriate distance from the top of the Sandbox. This aligns it's
// top line of text properly.
// Enhance JohnT: 90% of font height is not always exactly right, but it's the closest
// I can get wihtout a new API to get the exact ascent of the font.
int dympBaseline = Common.Widgets.FontHeightAdjuster.
GetFontHeightForStyle("Normal", m_stylesheet, m_wsVernForDisplay,
m_cache.LanguageWritingSystemFactoryAccessor) * 9 / 10;
uint transparent = 0xC0000000; // FwTextColor.kclrTransparent won't convert to uint
vwenv.AddSimpleRect((int)transparent,
FocusBoxSize.Width, FocusBoxSize.Height, -(FocusBoxSize.Height - dympBaseline));
return;
}
}
base.AddWordBundleInternal(hvo, vwenv);
}
示例5: InsertBookSeparator
/// ------------------------------------------------------------------------------------
/// <summary>
/// Insert a bar to separate this book from the following book (unless this is the last
/// book being displayed).
/// </summary>
/// ------------------------------------------------------------------------------------
protected virtual void InsertBookSeparator(int hvoScrBook, IVwEnv vwenv)
{
FilteredScrBooks filter = m_cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);
int hvoLastScrBook = filter.GetBook(filter.BookCount - 1).Hvo;
if (hvoLastScrBook != hvoScrBook)
{
vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 20000, 0);
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(ColorUtil.LightInverse(m_BackColor)), -1, 10000, 0);
vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 5000, 0);
}
}
示例6: Display
/// ------------------------------------------------------------------------------------
/// <summary>
/// This is the main interesting method of displaying objects and fragments of them.
/// A Scripture is displayed by displaying its Books;
/// and a Book is displayed by displaying its Title and Sections;
/// and a Section is diplayed by displaying its Heading and Content;
/// which are displayed by using the standard view constructor for StText.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo"></param>
/// <param name="frag"></param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
CheckDisposed();
switch(frag)
{
case (int)FootnoteFrags.kfrScripture:
case (int)ScrFrags.kfrScripture:
{
vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1);
// This fragment should only be used on full refresh - clear the user prompt
// flags so they will be shown again.
ClearUserPromptUpdates();
// We add this lazy - we will expand some of it immediately, but the non-
// visible parts will remain lazy!
vwenv.NoteDependency(new[]{m_cache.LanguageProject.TranslatedScriptureOA.Hvo},
new[]{ScriptureTags.kflidScriptureBooks}, 1);
vwenv.AddLazyVecItems(BooksTag, this,
frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook);
// Add a 48 point gap at the bottom of the view
if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture))
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0);
break;
}
case (int)ScrFrags.kfrBook:
{
vwenv.OpenDiv();
vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText);
vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection);
// Add a 48 point gap at the bottom of the view
if (!PrintLayout && m_fShowTailingSpace)
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0);
if (!PrintLayout)
InsertBookSeparator(hvo, vwenv);
vwenv.CloseDiv();
break;
}
case (int)ScrFrags.kfrSection:
{
vwenv.OpenDiv();
vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText);
vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText);
vwenv.CloseDiv();
break;
}
case (int)StTextFrags.kfrPara:
if (PrintLayout || !m_fDisplayInTable)
{
// We are displaying Scripture or a print layout view
base.Display(vwenv, hvo, frag);
}
else
{
// We are displaying a back translation or Scripture in draftview in a table
// Open a table to display the BT para in column 1, and the icon in column 2.
VwLength vlTable; // we use this to specify that the table takes 100% of the width.
vlTable.nVal = 10000;
vlTable.unit = VwUnit.kunPercent100;
VwLength vlColumn; // and this one to specify 90% for the text
vlColumn.nVal = DisplayTranslation ? 9000 : 10000;
vlColumn.unit = VwUnit.kunPercent100;
int nColumns = DisplayTranslation ? 2 : 1;
vwenv.OpenTable(nColumns, // One or two columns.
vlTable, // Table uses 100% of available width.
0, // Border thickness.
VwAlignment.kvaLeft, // Default alignment.
VwFramePosition.kvfpVoid, // No border.
//VwFramePosition.kvfpBox,
//VwRule.kvrlAll, // rule lines between cells
VwRule.kvrlNone,
0, //No space between cells.
0, //No padding inside cells.
false);
// Specify column widths. The first argument is the number of columns,
// not a column index.
vwenv.MakeColumns(nColumns, vlColumn);
vwenv.OpenTableBody();
vwenv.OpenTableRow();
//.........这里部分代码省略.........
示例7: AddPreviewPara
/// ------------------------------------------------------------------------------------
/// <summary>
/// Adds a paragraph (gray line) to the preview.
/// </summary>
/// <param name="vwenv">The vwenv.</param>
/// <param name="props">Text props, or <c>null</c>.</param>
/// <param name="fAddSpaceBefore"><c>true</c> to add 6pt space before the paragraph</param>
/// ------------------------------------------------------------------------------------
private void AddPreviewPara(IVwEnv vwenv, ITsTextProps props, bool fAddSpaceBefore)
{
// (width is -1, meaning "use the rest of the line")
if (props != null)
vwenv.Props = props;
else if (fAddSpaceBefore)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptSpaceBefore,
(int)FwTextPropVar.ktpvMilliPoint, 6000);
}
vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
(int)FwTextPropVar.ktpvEnum, m_fRtl ? -1 : 0);
vwenv.OpenParagraph();
vwenv.AddSimpleRect(Color.LightGray.ToArgb(), -1, kdmpFakeHeight, 0);
vwenv.CloseParagraph();
}
示例8: InsertNoteSeparator
/// ------------------------------------------------------------------------------------
/// <summary>
/// Insert a bar to separate this note from the following note (unless this is the first
/// note being displayed).
/// </summary>
/// <param name="vwenv">View environment</param>
/// ------------------------------------------------------------------------------------
protected virtual void InsertNoteSeparator(IVwEnv vwenv)
{
vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 7000, 0);
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(ColorUtil.LightInverse(m_BackColor)), -1, 1000, 0);
vwenv.AddSimpleRect((int)FwTextColor.kclrTransparent, -1, 4000, 0);
}
示例9: Display
/// ------------------------------------------------------------------------------------
/// <summary>
/// Displays the specified vwenv.
/// </summary>
/// <param name="vwenv">The vwenv.</param>
/// <param name="hvo">The hvo.</param>
/// <param name="frag">The frag.</param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
switch (frag)
{
case kfragScrFootnotes:
{
vwenv.AddObjVecItems(ScriptureTags.kflidScriptureBooks, this,
kfragBookFootnotes);
break;
}
case kfragBookFootnotes:
{
vwenv.AddObjVecItems(ScrBookTags.kflidFootnotes, this,
kfragFootnote);
break;
}
case kfragFootnote:
{
// Display each dummy footnote as a rectangle a half inch high, which allows us
// to accurately predict the height of a known number of them. Also put in a very
// short editable string, which we use for some other tests, but should not
// affect the paragraph height.
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
(int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 10);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint, MiscUtils.kdzmpInch / 5);
vwenv.OpenParagraph();
if (m_fWantStrings)
vwenv.AddStringProp(StFootnoteTags.kflidFootnoteMarker, this);
vwenv.AddSimpleRect(0, MiscUtils.kdzmpInch / 2, MiscUtils.kdzmpInch / 2, 0);
vwenv.CloseParagraph();
break;
}
}
}
示例10: InsertBookSeparator
/// ------------------------------------------------------------------------------------
/// <summary>
/// Insert a bar to separate this book from the following book (unless this is the last
/// book being displayed).
/// </summary>
/// ------------------------------------------------------------------------------------
protected virtual void InsertBookSeparator(int hvoScrBook, IVwEnv vwenv)
{
int hvoScr = m_cache.GetOwnerOfObject(hvoScrBook);
int hvoLastScrBook = m_cache.GetVectorItem(hvoScr, BooksTag,
m_cache.GetVectorSize(hvoScr, BooksTag) - 1);
if (hvoLastScrBook != hvoScrBook)
{
uint transparent = 0xC0000000; // FwTextColor.kclrTransparent won't convert to uint
vwenv.AddSimpleRect(transparent, -1, 20000, 0);
vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(ColorUtil.LightInverse(m_BackColor)), -1, 10000, 0);
vwenv.AddSimpleRect(transparent, -1, 5000, 0);
}
}
示例11: Display
/// -----------------------------------------------------------------------------------
/// <summary>
/// This is the main interesting method of displaying objects and fragments of them.
/// Here a text is displayed by displaying its paragraphs;
/// and a paragraph is displayed by invoking its style rule, making a paragraph,
/// and displaying its contents.
/// </summary>
/// <param name="vwenv">view environment</param>
/// <param name="hvo">id of object to be displayed</param>
/// <param name="frag">fragment of data</param>
/// -----------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
CheckDisposed();
switch(frag)
{
case (int)StTextFrags.kfrFootnote:
{
if (HandleEmptyText(vwenv, hvo))
break;
vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrFootnotePara);
break;
}
case (int)StTextFrags.kfrText:
{
if (HandleEmptyText(vwenv, hvo))
break;
if (m_fLazy)
{
vwenv.AddLazyVecItems((int)StText.StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrPara);
}
else
{
vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrPara);
}
break;
}
case (int)StTextFrags.kfrFootnoteMarker:
{
StFootnote footnote = new StFootnote(Cache, hvo);
if (footnote.DisplayFootnoteMarker)
DisplayFootnoteMarker(vwenv);
break;
}
case (int)StTextFrags.kfrLabel:
{
// The label is not editable.
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.AddString(m_tssLabel);
break;
}
case (int)StTextFrags.kfrPara:
case (int)StTextFrags.kfrFootnotePara:
{
InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
break;
}
case (int)StTextFrags.kfrTranslation:
{
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
Editable ? (int)TptEditable.ktptIsEditable
: (int)TptEditable.ktptNotEditable);
// Display the translation, or its user prompt
if (!InsertTranslationUserPrompt(vwenv, hvo))
{
vwenv.AddStringAltMember((int)CmTranslation.CmTranslationTags.kflidTranslation,
m_wsDefault, this);
}
break;
}
case (int)StTextFrags.kfrSegmentFreeTranslations:
// Hvo is a CmBaseAnnotation of one segment of an StTxtPara.
if (IsLabelSegment(hvo))
{
CmBaseAnnotation segment = (CmBaseAnnotation)CmBaseAnnotation.CreateFromDBObject(Cache, hvo, false);
vwenv.AddString(GetBackTransLabelText(segment));
vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(this.BackColor), 1200, 0, 0); // a narrow space, font-neutral
}
else
{
vwenv.AddObjProp(StTxtPara.SegmentFreeTranslationFlid(Cache), this, (int)StTextFrags.kfrFreeTrans);
vwenv.AddString(OneSpaceString);
}
break;
case (int)StTextFrags.kfrFreeTrans:
// Hvo is a CmIndirectAnnotation whose Contents are the free/back translation.
vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault,
(int)ColorUtil.ConvertColorToBGR(SystemColors.Window));
ITsString tssVal = vwenv.DataAccess.get_MultiStringAlt(hvo,
(int) CmAnnotation.CmAnnotationTags.kflidComment, BackTranslationWS);
//.........这里部分代码省略.........
示例12: Display
//.........这里部分代码省略.........
// This puts 3 points of margin on the first FF annotation, if any.
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
(int)FwTextPropVar.ktpvMilliPoint, 0); // 3000
vwenv.AddObjVec(ktagSegFF, this, kfragSegFf);
vwenv.CloseDiv();
break;
case kfragBundle: // One annotated word bundle; hvo is CmBaseAnnotation.
// checking AllowLayout (especially in context of Undo/Redo make/break phrase)
// helps prevent us from rebuilding the display until we've finished
// reconstructing the data and cache. Otherwise we can crash.
if (m_rootsite != null && !m_rootsite.AllowLayout)
return;
// set the display WS here even though it is set in the paragraph frag, since this frag might
// get called on its own during a prop update
int paraHvo = m_cache.GetObjProperty(hvo, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject);
if (paraHvo != 0)
PreferredVernWs = m_cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, paraHvo, ktagParaSegments);
SetupForTwfic(hvo);
// Give whatever box we make 10 points of separation from whatever follows.
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
(int)FwTextPropVar.ktpvMilliPoint, 10000);
if (hvo == m_hvoSandboxAnnotation)
{
// Leave room for the Sandbox instead of displaying the internlinear data.
// The first argument makes it invisible in case a little bit of it shows around
// the sandbox.
// The last argument puts the 'Baseline' of the sandbox (which aligns with the base of the
// first line of text) an appropriate distance from the top of the Sandbox. This aligns it's
// top line of text properly.
// Enhance JohnT: 90% of font height is not always exactly right, but it's the closest
// I can get wihtout a new API to get the exact ascent of the font.
int dympBaseline = SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.GetFontHeightForStyle("Normal", m_stylesheet,
m_wsCurrentTwfic, m_cache.LanguageWritingSystemFactoryAccessor) * 9 / 10;
vwenv.AddSimpleRect(0xC0000000, // FwTextColor.kclrTransparent won't convert to uint
SandboxSize.Width, SandboxSize.Height, -(SandboxSize.Height - dympBaseline));
SetupForTwfic(0);
break;
}
// Make an 'inner pile' to contain the wordform and annotations.
// 10 points below also helps space out the paragraph.
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint, 5000);
vwenv.OpenInnerPile();
// Get the instanceOf property of the annotation and see whether it exists. If not it is
// just a punctuation annotation, and we just insert the form.
vwenv.NoteDependency(new int[] { hvo }, new int[] { InterlinDocChild.TagAnalysis }, 1);
int hvoInstanceOf = vwenv.DataAccess.get_ObjectProp(hvo, InterlinDocChild.TagAnalysis);
// Treat a non-vernacular word as unconnected to any kind of analysis.
if (m_wsCurrentTwfic != m_wsVernForDisplay || !m_vernWss.Contains(m_wsCurrentTwfic))
{
// Cf CanBeAnalyzed method.
hvoInstanceOf = 0;
}
if (hvoInstanceOf == 0)
{
vwenv.AddStringProp(m_flidStringValue, this);
}
else
{
// It's a full Twfic annotation, display the full bundle.
vwenv.AddObjProp(InterlinDocChild.TagAnalysis, this, kfragTwficAnalysis);
}
AddExtraTwficRows(vwenv, hvo);
//vwenv.AddObjProp(ktagTwficDefault, this, kfragTwficAnalysis);
vwenv.CloseInnerPile();
// revert back to the paragraph vernWs.
示例13: InsertNoteSeparator
/// ------------------------------------------------------------------------------------
/// <summary>
/// Insert a bar to separate this note from the following note (unless this is the first
/// note being displayed).
/// </summary>
/// <param name="vwenv">View environment</param>
/// ------------------------------------------------------------------------------------
protected virtual void InsertNoteSeparator(IVwEnv vwenv)
{
uint transparent = 0xC0000000; // FwTextColor.kclrTransparent won't convert to uint
vwenv.AddSimpleRect(transparent, -1, 7000, 0);
vwenv.AddSimpleRect(ColorUtil.ConvertColorToBGR(ColorUtil.LightInverse(m_BackColor)), -1, 1000, 0);
vwenv.AddSimpleRect(transparent, -1, 4000, 0);
}
示例14: Display
/// -----------------------------------------------------------------------------------
/// <summary>
/// This is the main interesting method of displaying objects and fragments of them.
/// Here a text is displayed by displaying its paragraphs;
/// and a paragraph is displayed by invoking its style rule, making a paragraph,
/// and displaying its contents.
/// </summary>
/// <param name="vwenv">view environment</param>
/// <param name="hvo">id of object to be displayed</param>
/// <param name="frag">fragment of data</param>
/// -----------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
switch(frag)
{
case (int)StTextFrags.kfrFootnote:
{
if (HandleEmptyText(vwenv, hvo))
break;
IStFootnote footnote = Cache.ServiceLocator.GetInstance<IStFootnoteRepository>().GetObject(hvo);
if (footnote.DisplayFootnoteMarker)
{
// We need to note this dependency here (for the update of the footnote
// marker) instead of in the frag for the marker because noting the
// dependency at the frag for the marker caused some weird problems
// with the VwNotifiers which caused the view to sometimes update
// incorrectly. (FWR-1299) It also makes more sense for it to be here
// since the dependency would be on the whole footnote in either case
// anyways.
vwenv.NoteDependency(new int[] { footnote.Owner.Hvo }, new int[] { footnote.OwningFlid }, 1);
}
vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrFootnotePara);
break;
}
case (int)StTextFrags.kfrText:
{
if (HandleEmptyText(vwenv, hvo))
break;
if (hvo == 0)
return; // leave view empty, better than crashing.
if (m_fLazy)
{
vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrPara);
}
else
{
vwenv.AddObjVecItems(StTextTags.kflidParagraphs, this,
(int)StTextFrags.kfrPara);
}
break;
}
case (int)StTextFrags.kfrFootnoteMarker:
{
IStFootnote footnote = Cache.ServiceLocator.GetInstance<IStFootnoteRepository>().GetObject(hvo);
if (footnote.DisplayFootnoteMarker)
DisplayFootnoteMarker(vwenv, footnote);
break;
}
case (int)StTextFrags.kfrLabel:
{
// The label is not editable.
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.AddString(m_tssLabel);
break;
}
case (int)StTextFrags.kfrPara:
case (int)StTextFrags.kfrFootnotePara:
{
InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
break;
}
case (int)StTextFrags.kfrTranslation:
{
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
// Display the translation, or its user prompt
ICmTranslation trans = Cache.ServiceLocator.GetInstance<ICmTranslationRepository>().GetObject(hvo);
if (!InsertTranslationUserPrompt(vwenv, trans))
vwenv.AddStringAltMember(CmTranslationTags.kflidTranslation, m_wsDefault, this);
break;
}
case (int)StTextFrags.kfrSegmentFreeTranslations:
// Hvo is one segment of an StTxtPara.
ISegment seg = Cache.ServiceLocator.GetInstance<ISegmentRepository>().GetObject(hvo);
if (seg.IsLabel)
{
// Added dependencies to get labels to update automatically (FWR-1341, FWR-1342, FWR-1417)
vwenv.NoteStringValDependency(seg.Paragraph.Hvo, StTxtParaTags.kflidContents, 0, seg.Paragraph.Contents);
vwenv.NoteDependency(new [] {seg.Paragraph.Hvo}, new [] {StTxtParaTags.kflidSegments}, 1);
vwenv.AddString(GetBackTransLabelText(seg));
vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), 1200, 0, 0); // a narrow space, font-neutral
}
else
//.........这里部分代码省略.........