本文整理汇总了C#中IVwEnv.AddString方法的典型用法代码示例。如果您正苦于以下问题:C# IVwEnv.AddString方法的具体用法?C# IVwEnv.AddString怎么用?C# IVwEnv.AddString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwEnv
的用法示例。
在下文中一共展示了IVwEnv.AddString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSegmentReference
/// <summary>
/// Add a segment number appropriate to the current segment being displayed.
/// (See LT-1236.)
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo"></param>
private void AddSegmentReference(IVwEnv vwenv, int hvo)
{
ITsString tssSegNum;
StringBuilder sbSegNum = new StringBuilder();
int flid = 0;
var seg = m_segRepository.GetObject(hvo);
var para = seg.Paragraph;
if (para != null)
{
ISilDataAccess sda = vwenv.DataAccess;
int cseg = para.SegmentsOS.Count;
int idxSeg = para.SegmentsOS.IndexOf(seg); // sda.GetObjIndex(hvoStPara, ktagParaSegments, hvo);
IStText stText = para.Owner as IStText;
if (stText != null)
flid = stText.OwningFlid;
if (flid == ScrSectionTags.kflidContent)
{
var scrPara = para as IScrTxtPara;
// With null book name and trimmed it should have just chapter:v{a,b}.
// The {a,b} above would not be the segment identifiers we add for multiple segments in
// a verse, but the letters indicating that the verse label is for only part of the verse.
// There is therefore a pathological case where, say, verse 4a as labeled in the main text
// gets another letter because 4a has multiple segments 4aa, 4ab, etc.
string chapRef = ScriptureServices.FullScrRef(scrPara, seg.BeginOffset, "").Trim();
sbSegNum.Append(chapRef + ScriptureServices.VerseSegLabel(scrPara, idxSeg));
}
else
{
int idxPara = para.OwnOrd;
if (idxPara >= 0)
{
sbSegNum.AppendFormat("{0}", idxPara + 1);
if (idxSeg >= 0 && cseg > 1)
sbSegNum.AppendFormat(".{0}", idxSeg + 1);
}
}
}
ITsStrBldr tsbSegNum = m_tsf.GetBldr();
tsbSegNum.ReplaceTsString(0, tsbSegNum.Length, TsStringUtils.MakeTss(sbSegNum.ToString(), m_cache.DefaultUserWs));
tsbSegNum.SetIntPropValues(0, tsbSegNum.Length, (int)FwTextPropType.ktptBold,
(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
tssSegNum = tsbSegNum.GetString();
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
(int)FwTextPropVar.ktpvMilliPoint, 10000);
vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor,
(int)FwTextPropVar.ktpvDefault, (int)CmObjectUi.RGB(SystemColors.ControlText));
try
{
m_fIsAddingSegmentReference = true;
vwenv.OpenInnerPile();
vwenv.AddString(tssSegNum);
vwenv.CloseInnerPile();
}
finally
{
m_fIsAddingSegmentReference = false;
}
}
示例2: Display
//.........这里部分代码省略.........
}
Debug.Assert(wsHvo > 0, "Could not find writing system.");
int wsOldDefault = this.DefaultWs;
this.DefaultWs = wsHvo;
// Cell 1 shows the ws abbreviation.
vwenv.OpenTableCell(1,1);
vwenv.Props = m_ttpLabel;
vwenv.AddObj(wsHvo, this, ReversalIndexEntrySliceView.kFragWsAbbr);
vwenv.CloseTableCell();
// Second cell has the contents for the reversal entries.
vwenv.OpenTableCell(1,1);
// This displays the field flush right for RTL data, but gets arrow keys to
// behave reasonably. See comments on LT-5287.
IWritingSystem lgws = m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(this.DefaultWs);
if (lgws != null && lgws.RightToLeft)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
}
vwenv.OpenParagraph();
// Do vector of entries in the second column.
vwenv.AddObjVec(ReversalIndexEntrySliceView.kFlidEntries, this, ReversalIndexEntrySliceView.kFragEntries);
vwenv.CloseParagraph();
vwenv.CloseTableCell();
this.DefaultWs = wsOldDefault;
break;
}
case ReversalIndexEntrySliceView.kFragEntryForm:
{
vwenv.AddStringAltMember((int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm,
this.DefaultWs, this);
int hvoCurrent = vwenv.CurrentObject();
if (hvoCurrent > 0)
{
IReversalIndexEntry rie = ReversalIndexEntry.CreateFromDBObject(m_cache, hvoCurrent);
Debug.Assert(rie != null);
int[] rgWs = m_cache.LangProject.GetReversalIndexWritingSystems(rie.Hvo, false);
int wsAnal = m_cache.DefaultAnalWs;
ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
tisb.SetIntPropValues((int)FwTextPropType.ktptWs,
(int)FwTextPropVar.ktpvDefault, wsAnal);
tisb.SetIntPropValues((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
tisb.Append(" [");
int cstr = 0;
ITsTextProps ttpBase = null;
for (int i = 0; i < rgWs.Length; ++i)
{
int ws = rgWs[i];
if (ws == this.DefaultWs)
continue;
string sForm = rie.ReversalForm.GetAlternative(ws);
if (sForm != null && sForm.Length != 0)
{
if (cstr > 0)
tisb.Append(", ");
++cstr;
string sWs = m_cache.GetMultiUnicodeAlt(ws,
(int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, wsAnal,
"LgWritingSystem_Abbr");
if (sWs != null && sWs.Length != 0)
示例3: Display
/// -----------------------------------------------------------------------------------
/// <summary>
/// This is the main interesting method of displaying objects and fragments of them.
/// </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 kfragRoot:
ITsString tssWord = vwenv.DataAccess.get_StringProp(hvo, ktagCf);
ITsStrBldr tsbSdRelation = m_tssSdRelation.GetBldr();
ITsStrBldr tsbLexRel = m_tssLexRelation.GetBldr();
if (tssWord != null && tssWord.Length > 0)
{
int ich = tsbSdRelation.Text.IndexOf("{0}");
if (ich >= 0)
tsbSdRelation.ReplaceTsString(ich, ich + 3, tssWord);
ich = tsbLexRel.Text.IndexOf("{0}");
if (ich >= 0)
tsbLexRel.ReplaceTsString(ich, ich + 3, tssWord);
}
int cDomains = vwenv.DataAccess.get_VecSize(hvo, ktagDomains);
int cLexRels = vwenv.DataAccess.get_VecSize(hvo, ktagLexRels);
Debug.Assert(cDomains > 0 || cLexRels > 0);
if (cDomains > 0)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint,
6000);
vwenv.OpenParagraph();
vwenv.AddString(tsbSdRelation.GetString());
vwenv.CloseParagraph();
vwenv.AddLazyVecItems(ktagDomains, this, kfragEntryList);
}
if (cLexRels > 0)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
(int)FwTextPropVar.ktpvMilliPoint, 6000);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint, 6000);
vwenv.OpenParagraph();
vwenv.AddString(tsbLexRel.GetString());
vwenv.CloseParagraph();
vwenv.AddLazyVecItems(ktagLexRels, this, kfragEntryList);
}
break;
case kfragEntryList:
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.OpenParagraph();
vwenv.set_IntProperty((int)FwTextPropType.ktptBold,
(int)FwTextPropVar.ktpvEnum,
(int)FwTextToggleVal.kttvForceOn);
vwenv.AddStringProp(ktagName, this);
vwenv.AddString (m_tssColon);
vwenv.AddObjVec(ktagWords, this, kfragWords);
vwenv.CloseParagraph();
break;
case kfragName:
vwenv.AddStringProp(ktagName, this);
break;
default:
throw new Exception("bad case in RelatedWordsVc.Display");
}
}
示例4: DisplayFootnoteReference
/// ------------------------------------------------------------------------------------
/// <summary>
/// Displays the footnote reference.
/// </summary>
/// <param name="vwenv">The view environment.</param>
/// <param name="hvoFootnote">The HVO of the footnote.</param>
/// ------------------------------------------------------------------------------------
internal void DisplayFootnoteReference(IVwEnv vwenv, int hvoFootnote)
{
IScrFootnote footnote = m_cache.ServiceLocator.GetInstance<IScrFootnoteRepository>().GetObject(hvoFootnote);
ITsString tssRef = TsStringUtils.MakeTss(footnote.GetReference(m_wsDefault),
m_wsDefault, ScrStyleNames.FootnoteTargetRef);
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
vwenv.AddString(tssRef);
}
示例5: Display
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
// Ignore 0 hvo's. RootObject may have not been set. FWNX-613.
if (hvo == 0)
return;
switch(frag)
{
case kfragRoot:
if (m_dxLabWidth == 0)
{
int dmpx1, dmpy; //, dmpx2;
vwenv.get_StringWidth(m_tssTitle, m_ttpBold, out dmpx1, out dmpy);
//vwenv.get_StringWidth(m_tssComments, m_ttpBold, out dmpx2, out dmpy);
//m_dxLabWidth = Math.Max(dmpx1, dmpx2) + 13000; // add 3 pt spacing to box, 10 to margin.
m_dxLabWidth = dmpx1 + 13000; // add 3 pt spacing to box, 10 to margin.
m_dxWsLabWidth = 0;
foreach (ITsString tssLabel in m_WsLabels)
{
vwenv.get_StringWidth(tssLabel, m_ttpWsLabel, out dmpx1, out dmpy);
m_dxWsLabWidth = Math.Max(m_dxWsLabWidth, dmpx1);
}
m_dxWsLabWidth += 18000; // 3 pts white space each side, 11 margin, 1 border, plus 1 for safety.
}
VwLength vlTable;
vlTable.nVal = 10000;
vlTable.unit = VwUnit.kunPercent100;
VwLength vlColLabels; // 5-pt space plus max label width.
vlColLabels.nVal = m_dxLabWidth;
vlColLabels.unit = VwUnit.kunPoint1000;
VwLength vlColWsLabels; // 5-pt space plus max ws label width.
vlColWsLabels.nVal = m_dxWsLabWidth;
vlColWsLabels.unit = VwUnit.kunPoint1000;
// The Main column is relative and uses the rest of the space.
VwLength vlColMain;
vlColMain.nVal = 1;
vlColMain.unit = VwUnit.kunRelative;
// The Padding column allows for the the trailing margin and border.
VwLength vlColPadding;
vlColPadding.nVal = 10000;
vlColPadding.unit = VwUnit.kunPoint1000;
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTop,
(int) FwTextPropVar.ktpvMilliPoint, 5000);
vwenv.OpenTable(4, // Four columns.
vlTable, // Table uses 100% of available width.
0, // Border thickness.
VwAlignment.kvaLeft, // Default alignment.
VwFramePosition.kvfpVoid, // No border.
VwRule.kvrlNone, // No rules between cells.
0, // No forced space between cells.
0, // no padding inside cells.
false);
vwenv.MakeColumns(1, vlColLabels);
vwenv.MakeColumns(1, vlColWsLabels);
vwenv.MakeColumns(1, vlColMain);
vwenv.MakeColumns(1, vlColPadding);
vwenv.OpenTableBody();
for (int i = 0; i < m_writingSystems.Length; i++)
{
vwenv.OpenTableRow();
// First cell has 'Title' label in bold.
vwenv.Props = m_ttpBold;
vwenv.OpenTableCell(1,1);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading,
(int) FwTextPropVar.ktpvMilliPoint, 10000);
if (i == 0) // only on the first row
{
// We want this fixed at 10 point, since it's considered a UI component, not data.
// See LT-4816
vwenv.set_IntProperty((int)FwTextPropType.ktptFontSize,
(int)FwTextPropVar.ktpvMilliPoint, 10000);
vwenv.AddString(m_tssTitle);
}
vwenv.CloseTableCell();
// Second cell has ws labels.
vwenv.set_IntProperty((int)FwTextPropType.ktptBackColor,
(int) FwTextPropVar.ktpvDefault, m_editBackColor);
vwenv.set_IntProperty((int)FwTextPropType.ktptBorderLeading,
(int)FwTextPropVar.ktpvMilliPoint, 1000);
if (i == 0)
vwenv.set_IntProperty((int)FwTextPropType.ktptBorderTop,
(int)FwTextPropVar.ktpvMilliPoint, 1000);
if (i == m_writingSystems.Length - 1)
vwenv.set_IntProperty((int)FwTextPropType.ktptBorderBottom,
(int)FwTextPropVar.ktpvMilliPoint, 1000);
vwenv.OpenTableCell(1,1);
vwenv.Props = m_ttpDataCellProps;
vwenv.Props = m_ttpWsLabel;
vwenv.AddString(m_WsLabels[i]);
//.........这里部分代码省略.........
示例6: DisplayWithWritingSystemLabel
private void DisplayWithWritingSystemLabel(IVwEnv vwenv, int ws)
{
ITsString tssLabel = NameOfWs(ws);
// We use a table to display
// encodings in column one and the strings in column two.
// The table uses 100% of the available width.
VwLength vlTable;
vlTable.nVal = 10000;
vlTable.unit = VwUnit.kunPercent100;
int dxs; // Width of displayed string.
int dys; // Height of displayed string (not used here).
vwenv.get_StringWidth(tssLabel, null, out dxs, out dys);
VwLength vlColWs; // 5-pt space plus max label width.
vlColWs.nVal = dxs + 5000;
vlColWs.unit = VwUnit.kunPoint1000;
// The Main column is relative and uses the rest of the space.
VwLength vlColMain;
vlColMain.nVal = 1;
vlColMain.unit = VwUnit.kunRelative;
// Enhance JohnT: possibly allow for right-to-left UI by reversing columns?
vwenv.OpenTable(2, // Two columns.
vlTable, // Table uses 100% of available width.
0, // Border thickness.
VwAlignment.kvaLeft, // Default alignment.
VwFramePosition.kvfpVoid, // No border.
VwRule.kvrlNone, // No rules between cells.
0, // No forced space between cells.
0, // No padding inside cells.
false);
// Specify column widths. The first argument is the number of columns,
// not a column index. The writing system column only occurs at all if its
// width is non-zero.
vwenv.MakeColumns(1, vlColWs);
vwenv.MakeColumns(1, vlColMain);
vwenv.OpenTableBody();
vwenv.OpenTableRow();
// First cell has writing system abbreviation displayed using m_ttpLabel.
//vwenv.Props = m_ttpLabel;
vwenv.OpenTableCell(1, 1);
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
vwenv.AddString(tssLabel);
vwenv.CloseTableCell();
// Second cell has the string contents for the alternative.
// DN version has some property setting, including trailing margin and RTL.
if (m_fRtlScript)
{
vwenv.set_IntProperty((int) FwTextPropType.ktptRightToLeft,
(int) FwTextPropVar.ktpvEnum,
(int) FwTextToggleVal.kttvForceOn);
vwenv.set_IntProperty((int) FwTextPropType.ktptAlign,
(int) FwTextPropVar.ktpvEnum,
(int) FwTextAlign.ktalTrailing);
}
//if (!m_editable)
//{
// vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
// (int)TptEditable.ktptNotEditable);
//}
vwenv.set_IntProperty((int) FwTextPropType.ktptPadTop, (int) FwTextPropVar.ktpvMilliPoint, 2000);
vwenv.OpenTableCell(1, 1);
vwenv.AddStringProp(m_flid, this);
vwenv.CloseTableCell();
vwenv.CloseTableRow();
vwenv.CloseTableBody();
vwenv.CloseTable();
}
示例7: Display
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo"></param>
/// <param name="frag"></param>
/// ------------------------------------------------------------------------------------
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
if (m_displayOptions.LiteralStringLabels)
{
ITsStrFactory factory = TsStrFactoryClass.Create();
vwenv.AddString(factory.MakeString("Label" + m_counter++, m_wsDefault));
}
switch (frag)
{
case kfragRoot: // the root; Display the paragraph
AddParagraphBoxContents(vwenv, () =>
{
if (m_displayOptions.ReadOnlyView)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum,
(int)TptEditable.ktptNotEditable);
}
});
break;
default:
throw new ApplicationException("Unexpected frag in SimpleRootSiteDataProviderVc");
}
}
示例8: AddColoredString
/// <summary>
/// Add the specified string in the specified color to the display, using the UI Writing system.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="color"></param>
/// <param name="str"></param>
protected void AddColoredString(IVwEnv vwenv, int color, string str)
{
SetColor(vwenv, color);
vwenv.AddString(m_tsf.MakeString(str, m_wsUi));
}
示例9: Display
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
#if __MonoCS__
// TODO-Linux: Randomly m_tsf seem to have been Release.
// eg Marshal.ReleaseComObject(m_tsf);
// However the Dispose method isn't called (which calls the Release)
// Currently unsure what is doing this need to find out - very concerning
// Hack - just recreate a new TsStrFactory each time... for now
// seems to stop the problem.
m_tsf = TsStrFactoryClass.Create();
#endif
CheckDisposed();
if (hvo == 0)
return; // Can't do anything without an hvo (except crash -- see LT-9348).
#if DEBUG
//TimeRecorder.Begin("Display");
#endif
switch (frag)
{
case kfragStText: // new root object for InterlinDocChild.
SetupRealVernWsForDisplay(WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph,
hvo, StTextTags.kflidParagraphs));
vwenv.AddLazyVecItems(StTextTags.kflidParagraphs, this, kfragInterlinPara);
break;
case kfragInterlinPara: // Whole StTxtPara. This can be the root fragment in DE view.
if (vwenv.DataAccess.get_VecSize(hvo, StTxtParaTags.kflidSegments) == 0)
{
vwenv.NoteDependency(new int[] { hvo }, new int[] { StTxtParaTags.kflidSegments }, 1);
vwenv.AddString(m_tssEmptyPara);
}
else
{
PreferredVernWs = WritingSystemServices.ActualWs(m_cache, WritingSystemServices.kwsVernInParagraph, hvo, StTxtParaTags.kflidSegments);
// Include the plain text version of the paragraph?
vwenv.AddLazyVecItems(StTxtParaTags.kflidSegments, this, kfragParaSegment);
}
break;
case kfragParaSegment:
// Don't put anything in this segment if it is a 'label' segment (typically containing a verse
// number for TE).
var seg = m_segRepository.GetObject(hvo);
if (seg.IsLabel)
break;
// This puts ten points between segments. There's always 5 points below each line of interlinear;
// if there are no freeform annotations another 5 points makes 10 between segments.
// If there are freeforms, we need the full 10 points after the last of them.
var haveFreeform = seg.FreeTranslation != null || seg.LiteralTranslation != null || seg.NotesOS.Count > 0;
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint, !haveFreeform ? 5000 : 10000);
vwenv.OpenDiv();
// Enhance JohnT: determine what the overall direction of the paragraph should
// be and set it.
if (m_mpBundleHeight == 0)
{
// First time...figure it out.
int dmpx, dmpyAnal, dmpyVern;
vwenv.get_StringWidth(m_tssEmptyAnalysis, null, out dmpx, out dmpyAnal);
vwenv.get_StringWidth(m_tssEmptyVern, null, out dmpx, out dmpyVern);
m_mpBundleHeight = dmpyAnal * 4 + dmpyVern * 3;
}
// The interlinear bundles are not editable.
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
(int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
if (m_fRtl)
{
vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft,
(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
vwenv.set_IntProperty((int)FwTextPropType.ktptAlign,
(int)FwTextPropVar.ktpvEnum, (int) FwTextAlign.ktalRight);
}
vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum,
(int)SpellingModes.ksmDoNotCheck);
vwenv.OpenParagraph();
AddSegmentReference(vwenv, hvo); // Calculate and display the segment reference.
AddLabelPile(vwenv, m_tsf, m_cache, true, m_fShowMorphBundles);
vwenv.AddObjVecItems(SegmentTags.kflidAnalyses, this, kfragBundle);
// JohnT, 1 Feb 2008. Took this out as I can see no reason for it; AddObjVecItems handles
// the dependency already. Adding it just means that any change to the forms list
// regenerates a higher level than needed, which contributes to a great deal of scrolling
// and flashing (LT-7470).
// Originally added by Eric in revision 72 on the trunk as part of handling phrases.
// Eric can't see any reason we need it now, either. If you find a need to re-insert it,
// please document carefully the reasons it is needed and what bad consequences follow
// from removing it.
//vwenv.NoteDependency(new int[] { hvo }, new int[] { ktagSegmentForms }, 1);
vwenv.CloseParagraph();
// We'd get the same visual effect from just calling AddFreeformAnnotations here. But then a regenerate
// such as happens when hiding or showing a prompt has to redisplay the whole segment. This initially
// makes it lazy, then the lazy stuff gets expanded. In the process we may get undesired scrolling (LT-12248).
// So we insert another layer of object, allowing just the freeforms to be regenerated.
var flidSelf = Cache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false);
vwenv.AddObjProp(flidSelf, this, kfragFreeformBundle);
vwenv.CloseDiv();
break;
case kfragFreeformBundle:
AddFreeformAnnotations(vwenv, hvo);
break;
case kfragBundle: // One annotated word bundle; hvo is the IAnalysis object.
// checking AllowLayout (especially in context of Undo/Redo make/break phrase)
//.........这里部分代码省略.........
示例10: DisplayVec
public override void DisplayVec(IVwEnv vwenv, int hvo, int tag, int frag)
{
CheckDisposed();
switch (frag)
{
case kfragSegFf: // freeform annotations. (Cf override in InterlinPrintVc)
{
// Note that changes here may need to be refleced in FreeformAdder's code
// for selecting a newly created annotation.
AddFreeformAnnotations(vwenv, hvo);
break;
}
default:
if (frag >= kfragWordGlossWs && frag < kfragWordGlossWs + m_WsList.AnalysisWsIds.Length)
{
// Displaying one ws of all the glosses of an analysis, separated by commas.
vwenv.OpenParagraph();
IWfiAnalysis wa = m_coRepository.GetObject(hvo) as IWfiAnalysis;
int i = 0;
foreach (IWfiGloss gloss in wa.MeaningsOC)
{
if (i != 0)
vwenv.AddString(CommaSpaceString);
vwenv.AddObj(gloss.Hvo, this, frag);
i++;
}
vwenv.CloseParagraph();
}
else
{
base.DisplayVec (vwenv, hvo, tag, frag);
}
break;
}
}
示例11: AddAnalysisPos
/// <summary>
/// Add a display of the category of hvoAnalysis.
/// If choiceOffset is -1, display the current analysis writing systems, otherwise,
/// display the one indicated (choiceIndex is an index into line choices).
/// When choice index is not -1, hvoAnalysis may not be the current object.
/// In that case, we invoke AddObj with a special flid which results in a recursive
/// call to this, but with the correct current object.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvoAnalysis"></param>
protected void AddAnalysisPos(IVwEnv vwenv, int hvoAnalysis, int hvoCurrent, int choiceIndex)
{
IWfiAnalysis wa = m_coRepository.GetObject(hvoAnalysis) as IWfiAnalysis;
int hvoPos = wa.CategoryRA != null ? wa.CategoryRA.Hvo : 0;
SetColor(vwenv, LabelRGBFor(choiceIndex));
if (hvoPos == 0)
{
vwenv.OpenParagraph();
vwenv.NoteDependency(new int[] {hvoAnalysis},
new int[] {WfiAnalysisTags.kflidCategory}, 1);
vwenv.AddString(m_tssMissingAnalysisPos);
vwenv.CloseParagraph();
}
else if (choiceIndex < 0)
{
vwenv.AddObjProp(WfiAnalysisTags.kflidCategory, this, kfragCategory);
}
else
{
if (hvoCurrent == hvoAnalysis)
vwenv.AddObjProp(WfiAnalysisTags.kflidCategory, this, kfragLineChoices + choiceIndex);
else
vwenv.AddObj(hvoAnalysis, this, kfragAnalysisCategoryChoices + choiceIndex); // causes recursive call with right hvoCurrent
}
}
示例12: AddLabelPile
/// <summary>
/// Add the pile of labels used to identify the lines in interlinear text.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="tsf"></param>
/// <param name="cache"></param>
/// <param name="wsList">Null if don't want multiple writing systems.</param>
/// <param name="fShowMutlilingGlosses"></param>
public void AddLabelPile(IVwEnv vwenv, ITsStrFactory tsf, FdoCache cache,
bool fWantMultipleSenseGloss, bool fShowMorphemes)
{
CheckDisposed();
int wsUI = cache.DefaultUserWs;
var spaceStr = TsStringUtils.MakeTss(" ", wsUI);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
(int)FwTextPropVar.ktpvMilliPoint, 10000);
vwenv.set_IntProperty((int)FwTextPropType.ktptBold,
(int)FwTextPropVar.ktpvEnum,
(int)FwTextToggleVal.kttvForceOn);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginBottom,
(int)FwTextPropVar.ktpvMilliPoint,
5000); // default spacing is fine for all embedded paragraphs.
vwenv.OpenInnerPile();
for (var i = 0; i < m_lineChoices.Count; i++)
{
InterlinLineSpec spec = m_lineChoices[i];
if (!spec.WordLevel)
break;
SetColor(vwenv, LabelRGBFor(spec));
ITsString tss = MakeUiElementString(m_lineChoices.LabelFor(spec.Flid), wsUI, null);
var bldr = tss.GetBldr();
if (m_lineChoices.RepetitionsOfFlid(spec.Flid) > 1)
{
bldr.Append(spaceStr);
bldr.Append(spec.WsLabel(cache));
AddLineIndexProperty(bldr, i);
// Enhance GJM: Might be able to do without paragraph now?
vwenv.OpenParagraph();
vwenv.AddString(bldr.GetString());
vwenv.CloseParagraph();
}
else
{
AddLineIndexProperty(bldr, i);
vwenv.AddString(bldr.GetString());
}
}
vwenv.CloseInnerPile();
}
示例13: DisplayLexGlossWithInflType
/// <summary>
/// NOTE: this routine is ignorant of calling context, so caller must provide NoteDependency to the possibleVariant and the sense
/// (e.g. vwenv.NoteDependency(new[] { wfiMorphBundle.Hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1);
/// vwenv.NoteDependency(new[] { wfiMorphBundle.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1);
/// </summary>
/// <param name="vwenv"></param>
/// <param name="possibleVariant"></param>
/// <param name="sense"></param>
/// <param name="spec"></param>
/// <param name="inflType"></param>
/// <returns>true if there was anything to display </returns>
internal bool DisplayLexGlossWithInflType(IVwEnv vwenv, ILexEntry possibleVariant, ILexSense sense, InterlinLineSpec spec,
ILexEntryInflType inflType)
{
int iLineChoice = m_lineChoices.IndexOf(spec);
ILexEntryRef ler;
if (possibleVariant.IsVariantOfSenseOrOwnerEntry(sense, out ler))
{
var wsPreferred = GetRealWsOrBestWsForContext(sense.Hvo, spec);
var wsGloss = Cache.ServiceLocator.WritingSystemManager.Get(wsPreferred);
var wsUser = Cache.ServiceLocator.WritingSystemManager.UserWritingSystem;
var testGloss = sense.Gloss.get_String(wsPreferred);
// don't bother adding anything for an empty gloss.
if (testGloss.Text != null && testGloss.Text.Length >= 0)
{
vwenv.OpenParagraph();
// see if we have an irregularly inflected form type reference
var leitFirst =
ler.VariantEntryTypesRS.Where(
let => let.ClassID == LexEntryInflTypeTags.kClassId).FirstOrDefault();
// add any GlossPrepend info
if (leitFirst != null)
{
vwenv.OpenInnerPile();
// TODO: add dependency to VariantType GlossPrepend/Append names
vwenv.NoteDependency(new[] { ler.Hvo },
new[] { LexEntryRefTags.kflidVariantEntryTypes }, 1);
vwenv.OpenParagraph();
ITsString tssPrepend = null;
if (inflType != null)
{
tssPrepend = MorphServices.AddTssGlossAffix(null, inflType.GlossPrepend, wsGloss, wsUser);
}
else
{
ITsIncStrBldr sbPrepend;
ITsIncStrBldr sbAppend;
JoinGlossAffixesOfInflVariantTypes(ler, wsPreferred, out sbPrepend,
out sbAppend);
if (sbPrepend.Text != null)
tssPrepend = sbPrepend.GetString();
}
if (tssPrepend != null)
vwenv.AddString(tssPrepend);
vwenv.CloseParagraph();
vwenv.CloseInnerPile();
}
// add gloss of main entry or sense
{
vwenv.OpenInnerPile();
// NOTE: remember to NoteDependency from OuterObject
vwenv.AddObj(sense.Hvo, this, kfragLineChoices + iLineChoice);
vwenv.CloseInnerPile();
}
// now add variant type info
if (leitFirst != null)
{
vwenv.OpenInnerPile();
// TODO: add dependency to VariantType GlossPrepend/Append names
vwenv.NoteDependency(new[] { ler.Hvo },
new[] { LexEntryRefTags.kflidVariantEntryTypes }, 1);
vwenv.OpenParagraph();
ITsString tssAppend = null;
if (inflType != null)
{
tssAppend = MorphServices.AddTssGlossAffix(null, inflType.GlossAppend, wsGloss, wsUser);
}
else
{
ITsIncStrBldr sbPrepend;
ITsIncStrBldr sbAppend;
JoinGlossAffixesOfInflVariantTypes(ler, wsPreferred, out sbPrepend,
out sbAppend);
if (sbAppend.Text != null)
tssAppend = sbAppend.GetString();
}
{
// Use AddProp/DisplayVariant to store GlossAppend with m_tssPendingGlossAffix
// this allows InterlinearExporter to know to export a glsAppend item
try
{
if (tssAppend != null)
m_tssPendingGlossAffix = tssAppend;
else
m_tssPendingGlossAffix = m_tssMissingGlossAppend;
vwenv.AddProp(ktagGlossAppend, this, 0);
}
finally
//.........这里部分代码省略.........
示例14: DisplayMorphBundle
/// <summary>
/// Displays a MorphBundle, setting the colors of its parts.
/// </summary>
/// <param name="vwenv"></param>
/// <param name="hvo">WfiMorphBundle</param>
private void DisplayMorphBundle(IVwEnv vwenv, int hvo)
{
IWfiMorphBundle wmb = null;
if (hvo != 0)
wmb = m_wmbRepository.GetObject(hvo);
vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing,
(int)FwTextPropVar.ktpvMilliPoint, 10000);
vwenv.OpenInnerPile();
int first = m_lineChoices.FirstMorphemeIndex;
int last = m_lineChoices.LastMorphemeIndex;
IMoForm mf = null;
if (wmb != null)
mf = wmb.MorphRA;
if (vwenv is CollectorEnv && mf != null)
{
// Collectors are given an extra initial chance to 'collect' the morph type, if any.
vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph,
this, kfragMorphType);
}
for (int i = first; i <= last; i++)
{
InterlinLineSpec spec = m_lineChoices[i];
SetColor(vwenv, LabelRGBFor(spec));
switch (spec.Flid)
{
case InterlinLineChoices.kflidMorphemes:
if (wmb == null)
{
vwenv.AddString(m_tssMissingMorph);
}
else if (mf == null)
{
// displaying morphemes should be
int ws = 0;
if (wmb.MorphRA != null)
{
Debug.Assert(spec.StringFlid == MoFormTags.kflidForm);
ws = GetRealWsOrBestWsForContext(wmb.MorphRA.Hvo, spec);
}
// If no morph, use the form of the morph bundle (and the entry is of
// course missing)
if (ws == 0)
{
ws = WritingSystemServices.ActualWs(m_cache, spec.WritingSystem, wmb.Hvo,
WfiMorphBundleTags.kflidForm);
}
vwenv.AddStringAltMember(
WfiMorphBundleTags.kflidForm, ws, this);
}
else
{
// Got a morph, show it.
vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph,
this, kfragMorphFormChoices + i);
// And the LexEntry line.
}
break;
case InterlinLineChoices.kflidLexEntries:
if (mf == null)
{
if (hvo != 0)
vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMorph }, 1);
vwenv.AddString(m_tssMissingEntry);
}
else
{
int ws = GetRealWsOrBestWsForContext(mf.Hvo, spec);
if (ws == 0)
ws = spec.WritingSystem;
LexEntryVc vcEntry = new LexEntryVc(m_cache);
vcEntry.WritingSystemCode = ws;
vwenv.AddObj(hvo, vcEntry, LexEntryVc.kfragEntryAndVariant);
}
break;
case InterlinLineChoices.kflidLexGloss:
int flid = 0;
if (wmb != null)
{
vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidMorph }, 1);
vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1);
vwenv.NoteDependency(new[] { hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1);
if (wmb.SenseRA == null)
{
if (ShowDefaultSense && wmb.DefaultSense != null && UsingGuess)
{
flid = wmb.Cache.MetaDataCacheAccessor.GetFieldId2(WfiMorphBundleTags.kClassId,
"DefaultSense", false);
}
}
else
{
flid = WfiMorphBundleTags.kflidSense;
if (wmb.MorphRA != null &&
DisplayLexGlossWithInflType(vwenv, wmb.MorphRA.Owner as ILexEntry, wmb.SenseRA, spec, wmb.InflTypeRA))
//.........这里部分代码省略.........
示例15: Display
public override void Display(IVwEnv vwenv, int hvo, int frag)
{
CheckDisposed();
// Enhance JohnT: make the alignment position a function of window width.
// Enhance JohnT: change background if this is the selected context line.
vwenv.OpenConcPara(m_info.ContextStringStartOffset,
m_info.ContextStringStartOffset + m_info.ContextStringLength,
VwConcParaOpts.kcpoDefault,
72 * 2 * 1000); // 72 pts per inch * 2 inches * 1000 -> 2" in millipoints.
if (m_info.Hvo == 0 || m_info.ContentStringFlid == 0)
{
vwenv.AddString(m_info.ContentString);
}
else
{
Debug.Assert(hvo == m_info.Hvo);
vwenv.AddStringProp(m_info.ContentStringFlid, this);
}
vwenv.CloseParagraph();
}