internal static bool TranslateTextAlign(string styleString, out TextAlignments textAlignment) { textAlignment = TextAlignments.General; if (!string.IsNullOrEmpty(styleString)) { if (CompareWithInvariantCulture("General", styleString)) { textAlignment = TextAlignments.General; } else if (CompareWithInvariantCulture("Left", styleString)) { textAlignment = TextAlignments.Left; } else if (CompareWithInvariantCulture("Center", styleString)) { textAlignment = TextAlignments.Center; } else if (CompareWithInvariantCulture("Right", styleString)) { textAlignment = TextAlignments.Right; } else { if (!CompareWithInvariantCulture("Default", styleString)) { return(false); } textAlignment = TextAlignments.General; } return(true); } return(false); }
public void SetTextStringAlignment(TextAlignments alignment, bool newFormatStrings) { StringAlignment alignment2 = this.CreateTextStringAlignment(alignment); this.NewFormatStrings(newFormatStrings); this.m_stringFormat.Alignment = alignment2; }
internal void SetTextStringAlignment(TextAlignments alignment, bool newFormatStrings) { StringAlignment alignment2 = CreateTextStringAlignment(alignment); NewFormatStrings(newFormatStrings); m_stringFormat.Alignment = alignment2; }
internal static ContentAlignment GetStyleContentAlignment(Style style, StyleInstance styleInstance) { TextAlignments styleTextAlign = GetStyleTextAlign(style, styleInstance); VerticalAlignments styleVerticalAlignment = GetStyleVerticalAlignment(style, styleInstance); ContentAlignment result = ContentAlignment.TopLeft; switch (styleTextAlign) { case TextAlignments.Center: switch (styleVerticalAlignment) { case VerticalAlignments.Bottom: result = ContentAlignment.BottomCenter; break; case VerticalAlignments.Middle: result = ContentAlignment.MiddleCenter; break; default: result = ContentAlignment.TopCenter; break; } break; case TextAlignments.Right: switch (styleVerticalAlignment) { case VerticalAlignments.Bottom: result = ContentAlignment.BottomRight; break; case VerticalAlignments.Middle: result = ContentAlignment.MiddleRight; break; default: result = ContentAlignment.TopRight; break; } break; default: switch (styleVerticalAlignment) { case VerticalAlignments.Bottom: result = ContentAlignment.BottomLeft; break; case VerticalAlignments.Middle: result = ContentAlignment.MiddleLeft; break; } break; } return(result); }
internal void PopulateStyleInstance(ICompiledStyleInstance styleInstance, bool isParagraphStyle) { if (isParagraphStyle) { TextAlignments textAlign = TextAlign; if (textAlign != 0) { styleInstance.TextAlign = textAlign; } return; } ReportColor color = Color; if (color != null) { styleInstance.Color = color; } string fontFamily = FontFamily; if (!string.IsNullOrEmpty(fontFamily)) { styleInstance.FontFamily = fontFamily; } ReportSize fontSize = FontSize; if (fontSize != null) { styleInstance.FontSize = fontSize; } FontStyles fontStyle = FontStyle; if (fontStyle != 0) { styleInstance.FontStyle = fontStyle; } FontWeights fontWeight = FontWeight; if (fontWeight != 0) { styleInstance.FontWeight = fontWeight; } TextDecorations textDecoration = TextDecoration; if (textDecoration != 0) { styleInstance.TextDecoration = textDecoration; } }
private StringAlignment CreateTextStringAlignment(TextAlignments alignment) { StringAlignment stringAlignment = StringAlignment.Near; switch (alignment) { case TextAlignments.Center: return(StringAlignment.Center); case TextAlignments.Right: return(StringAlignment.Far); default: return(StringAlignment.Near); } }
internal static byte Translate(TextAlignments aValue) { switch (aValue) { case TextAlignments.Center: return(2); case TextAlignments.Left: return(1); case TextAlignments.Right: return(3); default: return(0); } }
public static Vector2 GetPositionAligned(TextAlignments alignment, Rectangle rect, SpriteFont font, string text) { if (string.IsNullOrEmpty(text)) return Vector2.Zero; Vector2 textDimens = font.MeasureString(text); int midRectPosX = rect.X + (rect.Width / 2); int midRectPosY = rect.Y + (rect.Height / 2); int midTextWidth = (int)textDimens.X / 2; int midTextHeight = (int)textDimens.Y / 2; switch (alignment) { case TextAlignments.Center: return new Vector2(midRectPosX - midTextWidth, midRectPosY - midTextHeight); case TextAlignments.Left: return new Vector2(rect.X, midRectPosY - midTextHeight); case TextAlignments.Right: return new Vector2((rect.X + rect.Width) - textDimens.X, midRectPosY - midTextHeight); default : return Vector2.Zero; } }
public static bool TranslateTextAlign(string styleString, out TextAlignments textAlignment) { textAlignment = TextAlignments.General; if (!string.IsNullOrEmpty(styleString)) { if (RichTextStyleTranslator.CompareWithInvariantCulture("General", styleString)) { textAlignment = TextAlignments.General; goto IL_0067; } if (RichTextStyleTranslator.CompareWithInvariantCulture("Left", styleString)) { textAlignment = TextAlignments.Left; goto IL_0067; } if (RichTextStyleTranslator.CompareWithInvariantCulture("Center", styleString)) { textAlignment = TextAlignments.Center; goto IL_0067; } if (RichTextStyleTranslator.CompareWithInvariantCulture("Right", styleString)) { textAlignment = TextAlignments.Right; goto IL_0067; } if (RichTextStyleTranslator.CompareWithInvariantCulture("Default", styleString)) { textAlignment = TextAlignments.General; goto IL_0067; } return(false); } return(false); IL_0067: return(true); }
private void SetStyleValues(bool isParagraph) { if (this.m_currentHtmlElement.CssStyle != null) { string text = default(string); ReportSize reportSize = default(ReportSize); if (isParagraph && base.m_allowMultipleParagraphs) { if (this.m_currentHtmlElement.CssStyle.TryGetValue("text-align", out text)) { TextAlignments textAlign = default(TextAlignments); if (RichTextStyleTranslator.TranslateTextAlign(text, out textAlign)) { base.m_currentStyle.TextAlign = textAlign; } else { base.m_richTextLogger.RegisterInvalidValueWarning("text-align", text, this.m_currentHtmlElement.CharacterPosition); } } if (this.m_currentHtmlElement.CssStyle.TryGetValue("text-indent", out text)) { if (ReportSize.TryParse(text, true, out reportSize)) { base.m_currentParagraph.HangingIndent = reportSize; } else { base.m_richTextLogger.RegisterInvalidSizeWarning("text-indent", text, this.m_currentHtmlElement.CharacterPosition); } } ReportSize generalPadding = null; if (this.m_currentHtmlElement.CssStyle.TryGetValue("padding", out text)) { if (ReportSize.TryParse(text, out reportSize)) { generalPadding = reportSize; } else { base.m_richTextLogger.RegisterInvalidSizeWarning("padding", text, this.m_currentHtmlElement.CharacterPosition); } } ReportSize size = default(ReportSize); if (this.HasPaddingValue("padding-top", generalPadding, out size)) { base.m_currentParagraph.AddSpaceBefore(size); } if (this.HasPaddingValue("padding-bottom", generalPadding, out size)) { base.m_currentParagraph.AddSpaceAfter(size); } if (this.HasPaddingValue("padding-left", generalPadding, out size)) { base.m_currentParagraph.AddLeftIndent(size); } if (this.HasPaddingValue("padding-right", generalPadding, out size)) { base.m_currentParagraph.AddRightIndent(size); } } if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-family", out text)) { base.m_currentStyle.FontFamily = text; } if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-size", out text)) { if (ReportSize.TryParse(text, out reportSize)) { base.m_currentStyle.FontSize = reportSize; } else { base.m_richTextLogger.RegisterInvalidSizeWarning("font-size", text, this.m_currentHtmlElement.CharacterPosition); } } if (this.m_currentHtmlElement.CssStyle.TryGetValue("font-weight", out text)) { FontWeights fontWeight = default(FontWeights); if (RichTextStyleTranslator.TranslateFontWeight(text, out fontWeight)) { base.m_currentStyle.FontWeight = fontWeight; } else { base.m_richTextLogger.RegisterInvalidValueWarning("font-weight", text, this.m_currentHtmlElement.CharacterPosition); } } if (this.m_currentHtmlElement.CssStyle.TryGetValue("color", out text)) { ReportColor color = default(ReportColor); if (ReportColor.TryParse(RichTextStyleTranslator.TranslateHtmlColor(text), out color)) { base.m_currentStyle.Color = color; } else { base.m_richTextLogger.RegisterInvalidColorWarning("color", text, this.m_currentHtmlElement.CharacterPosition); } } } }
private void ParseParagraphElement(HtmlElement.HtmlElementType elementType, FunctionalList <ListStyle> listStyles) { this.CloseParagraph(); if (base.m_currentParagraph.ElementType == HtmlElement.HtmlElementType.P) { base.m_currentParagraph = base.m_currentParagraph.RemoveParagraph(HtmlElement.HtmlElementType.P); base.m_currentStyle = base.m_currentStyle.RemoveStyle(HtmlElement.HtmlElementType.P); } if (elementType == HtmlElement.HtmlElementType.LI) { this.FlushPendingLI(); if (listStyles.Count > 0) { base.m_currentParagraph.ListStyle = listStyles.First; } else { base.m_currentParagraph.ListStyle = ListStyle.Bulleted; } } else { base.m_currentStyle = base.m_currentStyle.CreateChildStyle(elementType); base.m_currentParagraph = base.m_currentParagraph.CreateChildParagraph(elementType); switch (elementType) { case HtmlElement.HtmlElementType.H1: base.m_currentStyle.FontSize = StyleDefaults.H1FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H1Margin); break; case HtmlElement.HtmlElementType.H2: base.m_currentStyle.FontSize = StyleDefaults.H2FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H2Margin); break; case HtmlElement.HtmlElementType.H3: base.m_currentStyle.FontSize = StyleDefaults.H3FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H3Margin); break; case HtmlElement.HtmlElementType.H4: base.m_currentStyle.FontSize = StyleDefaults.H4FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H4Margin); break; case HtmlElement.HtmlElementType.H5: base.m_currentStyle.FontSize = StyleDefaults.H5FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H5Margin); break; case HtmlElement.HtmlElementType.H6: base.m_currentStyle.FontSize = StyleDefaults.H6FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H6Margin); break; case HtmlElement.HtmlElementType.P: this.SetMarginTopAndBottom(StyleDefaults.PMargin); break; } string text = default(string); if (!this.m_currentHtmlElement.IsEmptyElement && this.m_currentHtmlElement.HasAttributes && base.m_allowMultipleParagraphs && this.m_currentHtmlElement.Attributes.TryGetValue("align", out text)) { TextAlignments textAlign = default(TextAlignments); if (RichTextStyleTranslator.TranslateTextAlign(text, out textAlign)) { base.m_currentStyle.TextAlign = textAlign; } else { base.m_richTextLogger.RegisterInvalidValueWarning("align", text, this.m_currentHtmlElement.CharacterPosition); } } } this.SetStyleValues(true); }
private void CreateFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration, TextAlignments alignment, VerticalAlignments verticalAlignment, Directions direction, WritingModes writingMode) { this.CreateGDIFont(family, size, style, weight, decoration); StringAlignment textStringAlignment = this.CreateTextStringAlignment(alignment); bool directionRightToLeft = false; if (direction == Directions.RTL) { directionRightToLeft = true; } this.SetWritingMode(writingMode); StringAlignment lineStringAlignment = this.CreateLineStringAlignment(verticalAlignment); this.CreateFormatString(textStringAlignment, lineStringAlignment, directionRightToLeft); }
public CanvasFont(string family, ReportSize size, FontStyles style, FontWeights weight, TextDecorations decoration, TextAlignments alignment, VerticalAlignments verticalAlignment, Directions direction, WritingModes writingMode) { this.CreateFont(family, size, style, weight, decoration, alignment, verticalAlignment, direction, writingMode); }