本文整理汇总了C#中ITsTextProps.GetIntPropValues方法的典型用法代码示例。如果您正苦于以下问题:C# ITsTextProps.GetIntPropValues方法的具体用法?C# ITsTextProps.GetIntPropValues怎么用?C# ITsTextProps.GetIntPropValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITsTextProps
的用法示例。
在下文中一共展示了ITsTextProps.GetIntPropValues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScaleProperty
/// ------------------------------------------------------------------------------------
/// <summary>
/// Scales the given property based on the scaling factor and sets it in the in-memory
/// stylesheet.
/// </summary>
/// <param name="stylesheet">The in-memory stylesheet used for overriding properties.
/// </param>
/// <param name="scalingFactor">The scaling factor.</param>
/// <param name="styleName">Name of the style.</param>
/// <param name="styleProps">The style props.</param>
/// <param name="prop">The type of property to be scaled.</param>
/// ------------------------------------------------------------------------------------
private static void ScaleProperty(InMemoryStyleSheet stylesheet,
decimal scalingFactor, string styleName, ITsTextProps styleProps,
FwTextPropType prop)
{
int var;
int propValue = styleProps.GetIntPropValues((int)prop, out var);
if (propValue != -1 && var == (int)FwTextPropVar.ktpvMilliPoint)
{
if (prop == FwTextPropType.ktptFontSize)
{
Debug.Assert(propValue >= 4);
// Calculate new value for this style, rounding to reasonable value.
propValue = ScaleAndRoundProp(scalingFactor, propValue, 1000);
// Adjusted font size must be at least 4 pts
propValue = Math.Max(propValue, 4000);
}
else
propValue = ScaleAndRoundProp(scalingFactor, propValue, 1);
stylesheet.AddIntPropOverride(styleName, prop,
FwTextPropVar.ktpvMilliPoint, propValue);
}
}
示例2: AppendRun
/// ------------------------------------------------------------------------------------
/// <summary>
/// Appends a run of text with the given TsTextProps.
/// </summary>
/// <param name="sRun">The text to append</param>
/// <param name="props">The properties to use</param>
/// ------------------------------------------------------------------------------------
public void AppendRun(string sRun, ITsTextProps props)
{
CheckDisposed();
//note: For efficiency, we usually skip the Replace() if the string is empty.
// However, if the builder is has Length == 0, then we want to replace the
// properties on the empty run of the TsString.
// A TsString always has at least one run, even if it is empty, and this controls
// the props when the user begins to enter text in an empty para.
if (sRun != string.Empty || Length == 0)
{
System.Diagnostics.Debug.Assert(props != null);
int var;
int ws = props.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
// Make sure we handle the magic writing systems
if (ws == (int)CellarModuleDefns.kwsAnal)
{
// default analysis writing system
ITsPropsBldr bldr = props.GetBldr();
bldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
m_cache.DefaultAnalWs);
props = bldr.GetTextProps();
}
else if (ws == (int)CellarModuleDefns.kwsVern)
{
// default vernacular writing system
ITsPropsBldr bldr = props.GetBldr();
bldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
m_cache.DefaultVernWs);
props = bldr.GetTextProps();
}
else
{
System.Diagnostics.Debug.Assert(ws > 0); // not quite right if >2G objects.
}
m_ParaStrBldr.Replace(Length, Length, sRun, props);
}
}
示例3: AddTextToPara
/// ------------------------------------------------------------------------------------
/// <summary>
/// Add the given text and props as a new run to the end of the specified paragraph
/// under construction.
/// </summary>
/// <param name="sText">Text to be appended to the paragraph being built</param>
/// <param name="pttpProps">Properties (should contain only a named style) for the run
/// of text to be added.</param>
/// <param name="strbldr">String builder of paragraph being built</param>
/// ------------------------------------------------------------------------------------
protected void AddTextToPara(string sText, ITsTextProps pttpProps, ITsStrBldr strbldr)
{
// Don't bother trying to add empty runs. Also don't add runs consisting of a single
// space if processing a marker that maps to a paragraph style.
if (sText.Length > 0 &&
(sText != " " || m_styleProxy.StyleType == StyleType.kstCharacter))
{
// send the text and props directly to the Builder, after first ensuring that
// a ws is specified.
int var;
int ws = pttpProps.GetIntPropValues((int)FwTextPropType.ktptWs,
out var);
if (ws == -1)
{
ws = GetWsForContext(strbldr);
ITsPropsBldr tpb = pttpProps.GetBldr();
tpb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, ws);
pttpProps = tpb.GetTextProps();
}
int cchLength = strbldr.Length;
// Remove extra space.
if (cchLength > 0 && UnicodeCharProps.get_IsSeparator(sText[0]))
{
string s = strbldr.GetChars(cchLength - 1, cchLength);
if (UnicodeCharProps.get_IsSeparator(s[0]))
sText = sText.Substring(1);
}
if (sText != string.Empty || cchLength == 0)
strbldr.Replace(cchLength, cchLength, sText, pttpProps);
}
}
示例4: spyOnTextProps
private void spyOnTextProps(ITsTextProps ttp)
{
int tpt; // ??
// look at integer props
int cintProps = ttp.IntPropCount;
for (int i = 0; i < cintProps; i++)
{
int nVar;
int intProp = ttp.GetIntProp(i, out tpt, out nVar);
int Value = ttp.GetIntPropValues(tpt, out nVar);
Value = 34; // need something so Value can be looked at
}
// look at string props
int cstrProps = ttp.StrPropCount;
for (int i = 0; i < cstrProps; i++)
{
string strProp = ttp.GetStrProp(i, out tpt);
string Value = ttp.GetStrPropValue(tpt);
Value = "why?"; // need something so Value can be looked at
}
}
示例5: VerifyHyperlinkPropsAreCorrect
/// ------------------------------------------------------------------------------------
/// <summary>
/// Asserts the properties of a run are set correctly to be a hyperlink for the given
/// URL.
/// </summary>
/// <param name="props">The properties.</param>
/// <param name="expectedWs">The expected writing system.</param>
/// <param name="sUrl">The URL.</param>
/// ------------------------------------------------------------------------------------
public static void VerifyHyperlinkPropsAreCorrect(ITsTextProps props, int expectedWs,
string sUrl)
{
Assert.AreEqual(1, props.IntPropCount);
int nDummy;
Assert.AreEqual(expectedWs,
props.GetIntPropValues((int)FwTextPropType.ktptWs, out nDummy));
Assert.AreEqual(2, props.StrPropCount);
Assert.AreEqual(StyleServices.Hyperlink,
props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
string sObjData = props.GetStrPropValue((int)FwTextPropType.ktptObjData);
Assert.AreEqual(Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName), sObjData[0]);
Assert.AreEqual(sUrl, sObjData.Substring(1));
}
示例6: IsEditable
/// ------------------------------------------------------------------------------------
/// <summary>
/// Determine if text that belongs to ttp and vps is editable.
/// </summary>
/// <param name="ttp"></param>
/// <param name="vps"></param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public static bool IsEditable(ITsTextProps ttp, IVwPropertyStore vps)
{
int nVar;
int nVal = -1;
if (ttp != null)
nVal = ttp.GetIntPropValues((int)FwTextPropType.ktptEditable,
out nVar);
if (nVal == -1 && vps != null)
nVal = vps.get_IntProperty((int)FwTextPropType.ktptEditable);
if (nVal == (int)TptEditable.ktptNotEditable ||
nVal == (int)TptEditable.ktptSemiEditable)
return false;
return true;
}
示例7: PropsAreEqual
/// ------------------------------------------------------------------------------------
/// <summary>
/// Compares two TsTextProps
/// </summary>
/// <param name="ttp1">expected</param>
/// <param name="ttp2">actual</param>
/// <param name="sHowDifferent">Human(geek)-readable string telling how the props are
/// different, or indicating no difference</param>
/// <returns>True if they contain the same props, false otherwise</returns>
/// ------------------------------------------------------------------------------------
public static bool PropsAreEqual(ITsTextProps ttp1, ITsTextProps ttp2,
out string sHowDifferent)
{
// check how intProps compare
int cProps1 = ttp1.IntPropCount;
int cProps2 = ttp2.IntPropCount;
int tpv1, tpv2; // prop values
int nVar1, nVar2; // variation info
int tpt; // prop type
for (int iprop = 0; iprop < cProps1; iprop++)
{
tpv1 = ttp1.GetIntProp(iprop, out tpt, out nVar1);
tpv2 = ttp2.GetIntPropValues(tpt, out nVar2);
if (tpv1 != tpv2 || nVar1 != nVar2)
{
if (tpt == (int)FwTextPropType.ktptWs)
sHowDifferent = string.Format("Props differ in ktptWs property. "
+ "Expected <{0}>, but was <{1}>.", tpv1, tpv2);
else
sHowDifferent = string.Format("Props differ in intProp type {0}. "
+ "Expected <{1},{2}>, but was <{3},{4}>.", tpt, tpv1, nVar1, tpv2, nVar2);
return false;
}
}
// if count of intProps differs, it will be difficult to report exact difference
// so just issue a simple response for now
if (cProps1 != cProps2)
{
sHowDifferent = string.Format("Props differ in count of intProps. "
+ "Expected <{0}>, but was <{1}>.", cProps1, cProps2);
return false;
}
// check for string properties differences
int s1count = ttp1.StrPropCount;
int s2count = ttp2.StrPropCount;
int strtype;
string strval1, strval2; // prop values
for (int iprop = 0; iprop < s1count; iprop++)
{
strval1 = ttp1.GetStrProp(iprop, out strtype);
strval2 = ttp2.GetStrPropValue(strtype);
if (strval1 != strval2)
{
if (strtype == (int)FwTextPropType.ktptNamedStyle)
sHowDifferent = string.Format("Props differ in ktptNamedStyle property. "
+ "Expected <{0}>, but was <{1}>.", strval1, strval2);
else if (strtype == (int)FwTextPropType.ktptObjData)
sHowDifferent = string.Format("Props differ in ktptObjData property. "
+ "Expected <{0}>, but was <{1}>.", strval1, strval2);
// we could detail the objectDataType and Guid if needed
else
sHowDifferent = string.Format("Props differ in strProp type {0}. "
+ "Expected <{1}>, but was <{2}>.", strtype, strval1, strval2);
return false;
}
}
// if count of strProps differs, it will be difficult to report exact difference
// so just issue a simple response for now
if (s1count != s2count)
{
sHowDifferent = string.Format("Props differ in count of strProps. "
+ "Expected <{0}>, but was <{1}>.", s1count, s2count);
return false;
}
// if we reach this point, no differences were found
sHowDifferent = "TextProps objects appear to contain the same properties.";
return true;
}
示例8: ApplyTextProps
/// <summary>
/// Compute the assembled styles that results from applying the properties specified in the text props to this.
/// We might start with a root assembled styles that says to use a 10-point font,
/// then apply a paragraph style which says to use a 12-point font, except for French use 14-point.
/// Then in another text props we may tell it the writing system is French, and must get 14-point as the
/// result. Or, in a single TsTextProps, we may tell it the WS is French and to apply a character
/// style which says to use 16-point, except for French 18-point; the result needs to be 18-point.
/// It's also theoretically possible that the same text props again says directly to use 20-point; that
/// should win over all the others.
/// We achieve most of this by simply looking for the ws, then the named style, then everything else
/// (and when we process a style, if we already know a ws we include the overrides for that ws).
/// However, when we process the paragraph style, we don't know what ws a run in that paragraph will have.
/// </summary>
/// <param name="props"></param>
/// <returns></returns>
public AssembledStyles ApplyTextProps(ITsTextProps props)
{
AssembledStyles result = this;
// Apply writing system, if present, first, so that it can be used to select
// a named style effect.
int ttv;
int ws = props.GetIntPropValues((int) FwTextPropType.ktptWs, out ttv);
if (ttv != -1)
result = result.WithWs(ws);
// Apply named style next, if present, so that style effects can be overridden by explicit ones.
var namedStyle = props.GetStrPropValue((int) FwTextPropType.ktptNamedStyle);
if (namedStyle != null)
result = result.WithNamedStyle(namedStyle);
int count = props.IntPropCount;
for (int i = 0; i < count; i++)
{
int tpt;
int val = props.GetIntProp(i, out tpt, out ttv);
switch (tpt)
{
case (int) FwTextPropType.ktptWs: // handled first
break;
case (int) FwTextPropType.ktptBold:
int weight;
Debug.Assert(ttv == (int) FwTextPropVar.ktpvEnum);
switch (val)
{
case (int) FwTextToggleVal.kttvForceOn:
weight = (int) VwFontWeight.kvfwBold;
break;
// todo JohnT: several others.
default:
weight = (int)VwFontWeight.kvfwNormal;
break;
}
result = result.WithFontWeight(weight);
break;
}
}
return result;
}
示例9: XmlTextRun
/// ------------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="XmlTextRun"/> class, based on the given
/// run information
/// </summary>
/// <param name="wsDefault">The default writing system of the paragraph.</param>
/// <param name="lgwsf">The writing system factory.</param>
/// <param name="text">The text of the run.</param>
/// <param name="props">The properties of the run.</param>
/// ------------------------------------------------------------------------------------
public XmlTextRun(int wsDefault, ILgWritingSystemFactory lgwsf, string text,
ITsTextProps props)
{
int dummy;
int wsRun = props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy);
if (wsRun != wsDefault)
IcuLocale = lgwsf.GetStrFromWs(wsRun);
StyleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
m_text = text;
}
示例10: WritingSystem
/// ------------------------------------------------------------------------------------
/// <summary>
/// Returns the writing system of the specified ITsTextProps of a character style
/// </summary>
/// <param name="charStyleTextProps">The ITsTextProps</param>
/// <returns>The writing system value</returns>
/// ------------------------------------------------------------------------------------
public static int WritingSystem(ITsTextProps charStyleTextProps)
{
int nVar = 0;
return charStyleTextProps.GetIntPropValues((int)FwTextPropType.ktptWs,
out nVar);
}