protected virtual void DoSetDefaultCharacter(CharacterStyleOptions options) { var book = options?.Book?.Document ?? Document; using (new UsingProcessor(() => book.BeginUpdate(), () => book.EndUpdate())) SetCharacterOptions(book.DefaultCharacterProperties, options); }
public SCBook SetDefaultCharacter(CharacterStyleOptions options) { ExecuteSynchronized(options, () => DoSetDefaultCharacter(options)); return(this); }
protected virtual void SetCharacterOptions(CharacterPropertiesBase style, CharacterStyleOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options), "Options are not provided."); } if (!string.IsNullOrWhiteSpace(options.Font)) { Utils.StringToCharacterPropertiesFont(options.Font, style); } if (options.AllCaps.HasValue) { style.AllCaps = options.AllCaps.Value; } var backColor = Utils.ColorFromString(options.BackColor); if (backColor != Color.Empty) { style.BackColor = backColor; } if (options.Bold.HasValue) { style.Bold = options.Bold.Value; } if (!string.IsNullOrWhiteSpace(options.FontName)) { style.FontName = options.FontName; } if (options.FontSize.HasValue) { style.FontSize = options.FontSize; } var foreColor = Utils.ColorFromString(options.ForeColor); if (foreColor != Color.Empty) { style.ForeColor = foreColor; } if (options.Hidden.HasValue) { style.Hidden = options.Hidden.Value; } var highlightColor = Utils.ColorFromString(options.HighlightColor); if (highlightColor != Color.Empty) { style.HighlightColor = highlightColor; } if (options.Italic.HasValue) { style.Italic = options.Italic; } if (!string.IsNullOrWhiteSpace(options.Language)) { var langParts = options.Language.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var latinCulture = langParts.Length > 0 ? new CultureInfo(langParts[0]) : CultureInfo.InvariantCulture; var bidiCulture = langParts.Length > 1 ? new CultureInfo(langParts[1]) : CultureInfo.InvariantCulture; var eastAsiaCulture = langParts.Length > 2 ? new CultureInfo(langParts[2]) : CultureInfo.InvariantCulture; var langInfo = new DevExpress.XtraRichEdit.Model.LangInfo(latinCulture, bidiCulture, eastAsiaCulture); style.Language = langInfo; } if (options.NoProof.HasValue) { style.NoProof = options.NoProof.Value; } if (options.Strikeout.HasValue) { style.Strikeout = (DevExpress.XtraRichEdit.API.Native.StrikeoutType)options.Strikeout.Value; } if (options.Subscript.HasValue) { style.Subscript = options.Subscript; } if (options.Superscript.HasValue) { style.Superscript = options.Superscript; } if (options.Underline.HasValue) { style.Underline = (DevExpress.XtraRichEdit.API.Native.UnderlineType)options.Underline.Value; } var underlineColor = Utils.ColorFromString(options.UnderlineColor); if (underlineColor != Color.Empty) { style.UnderlineColor = underlineColor; } if (options.Scale.HasValue) { style.Scale = options.Scale.Value; } if (options.Spacing.HasValue) { style.Spacing = options.Spacing.Value; } if (options.Position.HasValue) { style.Position = options.Position.Value; } if (options.SnapToGrid.HasValue) { style.SnapToGrid = options.SnapToGrid.Value; } if (options.KerningThreshold.HasValue) { style.KerningThreshold = options.KerningThreshold.Value; } if (options.SmallCaps.HasValue) { style.SmallCaps = options.SmallCaps.Value; } if (options.ThemeFontEastAsia.HasValue) { style.ThemeFontEastAsia = (DevExpress.XtraRichEdit.API.Native.ThemeFont)options.ThemeFontEastAsia.Value; } if (options.ThemeFontComplexScript.HasValue) { style.ThemeFontComplexScript = (DevExpress.XtraRichEdit.API.Native.ThemeFont)options.ThemeFontComplexScript.Value; } if (options.ThemeFontHighAnsi.HasValue) { style.ThemeFontHighAnsi = (DevExpress.XtraRichEdit.API.Native.ThemeFont)options.ThemeFontHighAnsi.Value; } if (options.ThemeFontAscii.HasValue) { style.ThemeFontAscii = (DevExpress.XtraRichEdit.API.Native.ThemeFont)options.ThemeFontAscii.Value; } if (!string.IsNullOrWhiteSpace(options.FontNameEastAsia)) { style.FontNameEastAsia = options.FontNameEastAsia; } if (!string.IsNullOrWhiteSpace(options.FontNameComplexScript)) { style.FontNameComplexScript = options.FontNameComplexScript; } if (!string.IsNullOrWhiteSpace(options.FontNameHighAnsi)) { style.FontNameHighAnsi = options.FontNameHighAnsi; } if (!string.IsNullOrWhiteSpace(options.FontNameAscii)) { style.FontNameAscii = options.FontNameAscii; } }