本文整理汇总了C#中FwStyleSheet.FindStyle方法的典型用法代码示例。如果您正苦于以下问题:C# FwStyleSheet.FindStyle方法的具体用法?C# FwStyleSheet.FindStyle怎么用?C# FwStyleSheet.FindStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FwStyleSheet
的用法示例。
在下文中一共展示了FwStyleSheet.FindStyle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportStyleProxy
/// ------------------------------------------------------------------------------------
/// <summary>
/// Constructor with ContextValues and MarkerDomain as a parameters.
/// </summary>
/// <param name="sStyleName">Name of the style.</param>
/// <param name="styleType">kstCharacter or kstParagraph</param>
/// <param name="ws">character or paragraph writing system</param>
/// <param name="context">Context that will be used if this is a new style (otherwise existing
/// context in DB will be used), see ContextValues for possible types</param>
/// <param name="domain">The marker domain to use</param>
/// <param name="styleSheet">The style sheet</param>
/// ------------------------------------------------------------------------------------
public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
ContextValues context, MarkerDomain domain, FwStyleSheet styleSheet)
{
m_FwStyleSheet = styleSheet;
m_domain = domain;
Debug.Assert(m_FwStyleSheet != null);
m_ttpFormattingProps = null;
m_fIsScriptureStyle = true; //default
m_sEndMarker = null; //default
if (context == ContextValues.EndMarker)
{ // this proxy represents an end marker - not a style; set bogus info
sStyleName = "End"; //name does not matter
styleType = StyleType.kstCharacter;
}
else if (sStyleName != null)
{
// Determine whether style exists in the StyleSheet
Debug.Assert(ws != 0);
m_style = m_FwStyleSheet.FindStyle(sStyleName);
if (m_style != null)
{
// If this is an existing style, the actual type, context, structure, and
// function always override the requested values.
styleType = m_style.Type;
context = (ContextValues)m_style.Context;
m_structure = (StructureValues)m_style.Structure;
m_function = (FunctionValues)m_style.Function;
}
}
m_sStyleName = sStyleName;
m_StyleType = styleType;
m_ws = ws;
m_Context = context;
// //force StartOfFootnote marker to be processed as a para style proxy having para props
// if (context == StyleRole.StartOfFootnote)
// m_StyleType = StyleType.kstParagraph;
//set the text property vars for this proxy
SetTextProps();
}
示例2: SetFontSizeLineHeightAndSpaceBeforeAfter
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the font size line height and space before after.
/// </summary>
/// <param name="stylesheet">The real stylesheet.</param>
/// <param name="styleName">Name of the style to modify.</param>
/// <param name="basedOnStyle">The name of the based-on style.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="lineHeight">Height of the line.</param>
/// <param name="spaceBefore">The space before.</param>
/// <param name="spaceAfter">The space after.</param>
/// ------------------------------------------------------------------------------------
private static void SetFontSizeLineHeightAndSpaceBeforeAfter(FwStyleSheet stylesheet,
string styleName, string basedOnStyle, int fontSize, int lineHeight, int spaceBefore,
int spaceAfter)
{
IStStyle style = stylesheet.FindStyle(styleName);
TsPropsBldr tpb = (TsPropsBldr)style.Rules.GetBldr();
if (fontSize != -1)
{
tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize,
(int)FwTextPropVar.ktpvMilliPoint, fontSize);
}
if (lineHeight != -1)
{
tpb.SetIntPropValues((int)FwTextPropType.ktptLineHeight,
(int)FwTextPropVar.ktpvMilliPoint, lineHeight);
}
if (spaceBefore != -1)
{
tpb.SetIntPropValues((int)FwTextPropType.ktptSpaceBefore,
(int)FwTextPropVar.ktpvMilliPoint, spaceBefore);
}
if (spaceAfter != -1)
{
tpb.SetIntPropValues((int)FwTextPropType.ktptSpaceAfter,
(int)FwTextPropVar.ktpvMilliPoint, spaceAfter);
}
int hvoBasedOn = 0;
if (!string.IsNullOrEmpty(basedOnStyle))
{
IStStyle basedOn = stylesheet.FindStyle(basedOnStyle);
if (basedOn != null)
hvoBasedOn = basedOn.Hvo;
}
stylesheet.PutStyle(styleName, string.Empty, style.Hvo, hvoBasedOn, 0,
(int)StyleType.kstParagraph, true, false, tpb.GetTextProps());
}
示例3: AddHyperlink
/// ------------------------------------------------------------------------------------
/// <summary>
/// Appends the given text as a hyperlink to the given URL.
/// </summary>
/// <param name="strBldr">The string builder.</param>
/// <param name="ws">The HVO of the writing system to use for the added text.</param>
/// <param name="sLinkText">The text which should appear as the hyperlink text</param>
/// <param name="sUrl">The URL that is the target of the hyperlink.</param>
/// <param name="stylesheet">The stylesheet.</param>
/// <returns><c>true</c> if the hyperlink was successfully inserted; <c>false</c>
/// otherwise (indicating that the hyperlink style could not be found in the given
/// stylesheet). In either case, the link text will be appended to the string builder.
/// </returns>
/// ------------------------------------------------------------------------------------
public static bool AddHyperlink(ITsStrBldr strBldr, int ws, string sLinkText, string sUrl,
FwStyleSheet stylesheet)
{
var hyperlinkStyle = stylesheet.FindStyle(StyleServices.Hyperlink);
if (hyperlinkStyle == null)
return false;
if (stylesheet != null && stylesheet.Cache != null && stylesheet.Cache.ProjectId != null)
sUrl = FwLinkArgs.FixSilfwUrlForCurrentProject(sUrl, stylesheet.Cache.ProjectId.Name,
stylesheet.Cache.ProjectId.ServerName);
int ichStart = strBldr.Length;
strBldr.Replace(ichStart, ichStart, sLinkText, StyleUtils.CharStyleTextProps(null, ws));
StringServices.MarkTextInBldrAsHyperlink(strBldr, ichStart, strBldr.Length,
sUrl, hyperlinkStyle);
return true;
}
示例4: ConvertSelToLink
/// ------------------------------------------------------------------------------------
/// <summary>
/// Applies the given URL as a hotlink to the currently selected text, if any, or
/// inserts a link to the URL.
/// </summary>
/// <param name="clip">The URL.</param>
/// <param name="stylesheet">The stylesheet.</param>
/// ------------------------------------------------------------------------------------
public void ConvertSelToLink(string clip, FwStyleSheet stylesheet)
{
CheckDisposed();
var hyperlinkStyle = stylesheet.FindStyle(StyleServices.Hyperlink);
if (m_callbacks == null || m_callbacks.EditedRootBox == null || hyperlinkStyle == null)
return;
IVwSelection sel = m_callbacks.EditedRootBox.Selection;
ISilDataAccess sda = m_callbacks.EditedRootBox.DataAccess;
var actionHandler = sda.GetActionHandler();
if(actionHandler == null)
return; // no way we can do it.
ITsString tssLink;
bool fGotItAll;
sel.GetFirstParaString(out tssLink, " ", out fGotItAll);
ITsStrBldr tsb = tssLink.GetBldr();
if (sel.IsRange)
{
// Use the text of the selection as the text of the link
int ich = tssLink.Text.IndexOf(Environment.NewLine);
if (!fGotItAll || ich >= 0)
{
tsb.ReplaceTsString(ich, tsb.Length, null);
int ichTop;
if (sel.EndBeforeAnchor)
ichTop = sel.get_ParagraphOffset(true);
else
ichTop = sel.get_ParagraphOffset(false);
SelectionHelper helper =
SelectionHelper.Create(sel, EditedRootBox.Site);
helper.IchAnchor = ichTop;
helper.IchEnd = ich;
sel = helper.Selection;
}
//sel.GetSelectionString(out tssLink, " ");
}
if (!sel.IsRange)
{
ITsStrFactory tsf = TsStrFactoryClass.Create();
tssLink = tsf.MakeString(clip, sda.WritingSystemFactory.UserWs);
tsb = tssLink.GetBldr();
}
using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(actionHandler, EditedRootBox.Site,
RootSiteStrings.ksUndoInsertLink, RootSiteStrings.ksRedoInsertLink))
{
if (m_cache != null && m_cache.ProjectId != null)
clip = FwLinkArgs.FixSilfwUrlForCurrentProject(clip, m_cache.ProjectId.Name,
m_cache.ProjectId.ServerName);
var filename = StringServices.MarkTextInBldrAsHyperlink(tsb, 0, tsb.Length, clip, hyperlinkStyle, m_cache.LanguageProject.LinkedFilesRootDir);
if (FileUtils.IsFilePathValid(filename))
{
Debug.Assert(m_cache.LangProject.FilePathsInTsStringsOA != null, "Somehow migration #30 did not add the FilePathsInTsStrings CmFolder. Fix by modifying FindOrCreateFolder()");
DomainObjectServices.FindOrCreateFile(m_cache.LangProject.FilePathsInTsStringsOA, filename);
}
tssLink = tsb.GetString();
sel.ReplaceWithTsString(tssLink);
undoTaskHelper.RollBack = false;
// Arrange that immediate further typing won't extend link.
sel = Callbacks.EditedRootBox.Selection; // may have been changed.
if (sel == null)
return;
ITsPropsBldr pb = tssLink.get_PropertiesAt(0).GetBldr();
pb.SetStrPropValue((int)FwTextPropType.ktptObjData, null);
pb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
sel.SetTypingProps(pb.GetTextProps());
}
}
示例5: MarkTextInBldrAsHyperlink
/// ------------------------------------------------------------------------------------
/// <summary>
/// Marks the indicated text in the given string builder as a hyperlink.
/// </summary>
/// <param name="strBldr">The string builder.</param>
/// <param name="ichStart">The index of the first character in the string builder which
/// should be marked as hyperlink text.</param>
/// <param name="ichLim">The "limit" index in the string builder indicating the end of
/// the hyperlink text.</param>
/// <param name="url">The URL that is the target of the hyperlink.</param>
/// <param name="stylesheet">The stylesheet.</param>
/// <returns><c>true</c> if the hyperlink was successfully inserted; <c>false</c>
/// otherwise (indicating that the hyperlink style could not be found in the given
/// stylesheet)</returns>
/// ------------------------------------------------------------------------------------
public static bool MarkTextInBldrAsHyperlink(ITsStrBldr strBldr, int ichStart,
int ichLim, string url, FwStyleSheet stylesheet)
{
IStStyle hyperlinkStyle = stylesheet.FindStyle(StStyle.Hyperlink);
if (hyperlinkStyle == null)
return false;
string propVal = Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName).ToString() + url;
hyperlinkStyle.InUse = true;
strBldr.SetStrPropValue(ichStart, ichLim, (int)FwTextPropType.ktptNamedStyle, StStyle.Hyperlink);
strBldr.SetStrPropValue(ichStart, ichLim, (int)FwTextPropType.ktptObjData, propVal);
return true;
}