/// <summary> /// Create label /// </summary> /// <param name="name"></param> /// <param name="text"></param> /// <param name="fontSize"></param> /// <param name="fontStyle"></param> /// <param name="borders"></param> /// <param name="textAlign"></param> /// <param name="posX"></param> /// <param name="posY"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static XRLabel CreateLabel(string name, string text, int fontSize, FontStyle fontStyle, BorderSide borders, ReportTextAlign textAlign, int?posX, int?posY, int width, int height) { // init cell var label = new XRLabel { Multiline = true, Borders = borders, TextAlignment = GetTextAlignment(textAlign), Padding = new PaddingInfo(2, 2, 0, 0, 100F) }; // name if (!string.IsNullOrEmpty(name)) { label.Name = name; } // text if (!string.IsNullOrEmpty(text)) { label.Text = text; } // font if (fontSize > 0) { label.Font = new Font("Times New Roman", fontSize, fontStyle); } // location if (posX != null & posY != null) { label.Location = new Point(posX.Value, posY.Value); } // width if (width > 0) { label.Width = width; } // height if (height > 0) { label.Height = height; } // return return(label); }
/// <summary> /// Convert report text align to extra text align /// </summary> /// <param name="align"></param> /// <returns></returns> public static TextAlignment GetTextAlignment(ReportTextAlign align) { switch (align) { case ReportTextAlign.TopCenter: return(TextAlignment.TopCenter); case ReportTextAlign.TopJustify: return(TextAlignment.TopJustify); case ReportTextAlign.TopLeft: return(TextAlignment.TopLeft); case ReportTextAlign.TopRight: return(TextAlignment.TopRight); case ReportTextAlign.BottomCenter: return(TextAlignment.BottomCenter); case ReportTextAlign.BottomJustify: return(TextAlignment.BottomJustify); case ReportTextAlign.BottomLeft: return(TextAlignment.BottomLeft); case ReportTextAlign.BottomRight: return(TextAlignment.BottomRight); case ReportTextAlign.MiddleCenter: return(TextAlignment.MiddleCenter); case ReportTextAlign.MiddleJustify: return(TextAlignment.MiddleJustify); case ReportTextAlign.MiddleLeft: return(TextAlignment.MiddleLeft); case ReportTextAlign.MiddleRight: return(TextAlignment.MiddleRight); default: return(TextAlignment.MiddleCenter); } }