protected virtual void SetCharacterProperties(CharacterPropertiesBase style) { if (!string.IsNullOrWhiteSpace(Font)) { Utils.StringToCharacterPropertiesFont(Font, style); } if (AllCaps) { style.AllCaps = true; } if (ResetAllCaps) { style.AllCaps = false; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { style.BackColor = backColor; } if (Bold) { style.Bold = true; } if (ResetBold) { style.Bold = false; } if (!string.IsNullOrWhiteSpace(FontName)) { style.FontName = FontName; } if (FontSize.HasValue) { style.FontSize = FontSize; } var foreColor = Utils.ColorFromString(ForeColor); if (foreColor != Color.Empty) { style.ForeColor = foreColor; } if (Hidden) { style.Hidden = true; } if (ResetHidden) { style.Hidden = false; } var highlightColor = Utils.ColorFromString(HighlightColor); if (highlightColor != Color.Empty) { style.HighlightColor = highlightColor; } if (Italic) { style.Italic = true; } if (ResetItalic) { style.Italic = false; } if (!string.IsNullOrWhiteSpace(Language)) { var langParts = 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 (NoProof) { style.NoProof = true; } if (ResetNoProof) { style.NoProof = false; } if (Strikeout.HasValue) { style.Strikeout = Strikeout; } if (Subscript) { style.Subscript = true; } if (ResetSubscript) { style.Subscript = false; } if (Superscript) { style.Superscript = true; } if (ResetSubscript) { style.Superscript = false; } if (Underline.HasValue) { style.Underline = Underline; } var underlineColor = Utils.ColorFromString(UnderlineColor); if (underlineColor != Color.Empty) { style.UnderlineColor = underlineColor; } if (Scale.HasValue) { style.Scale = Scale; } if (Spacing.HasValue) { style.Spacing = Spacing; } if (Position.HasValue) { style.Position = Position; } if (SnapToGrid) { style.SnapToGrid = true; } if (ResetSnapToGrid) { style.SnapToGrid = false; } if (KerningThreshold.HasValue) { style.KerningThreshold = KerningThreshold; } if (SmallCaps) { style.SmallCaps = true; } if (ResetSmallCaps) { style.SmallCaps = false; } if (ThemeFontEastAsia.HasValue) { style.ThemeFontEastAsia = ThemeFontEastAsia; } if (ThemeFontComplexScript.HasValue) { style.ThemeFontComplexScript = ThemeFontComplexScript; } if (ThemeFontHighAnsi.HasValue) { style.ThemeFontHighAnsi = ThemeFontHighAnsi; } if (ThemeFontAscii.HasValue) { style.ThemeFontAscii = ThemeFontAscii; } if (!string.IsNullOrWhiteSpace(FontNameEastAsia)) { style.FontNameEastAsia = FontNameEastAsia; } if (!string.IsNullOrWhiteSpace(FontNameComplexScript)) { style.FontNameComplexScript = FontNameComplexScript; } if (!string.IsNullOrWhiteSpace(FontNameHighAnsi)) { style.FontNameHighAnsi = FontNameHighAnsi; } if (!string.IsNullOrWhiteSpace(FontNameAscii)) { style.FontNameAscii = FontNameAscii; } }
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; } }