Beispiel #1
0
        /// <summary>
        /// Adds the label alignment to the specified axis. Not supported in <b>EPPlus</b> library.
        /// </summary>
        /// <param name="axis"><b>Xml</b> node than represent an axis definition.</param>
        /// <param name="model">A <see cref="KnownHorizontalAlignment"/> value from model.</param>
        /// <param name="documentHelper">Target xml document helper.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="axis"/> is <b>null</b>.</exception>
        /// <exception cref="InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception>
        /// <exception cref="InvalidOperationException">If <paramref name="axis"/> is not an axis.</exception>
        public static void AddAxisLabelAlignment(this XmlNode axis, KnownHorizontalAlignment model, IXmlHelper documentHelper)
        {
            SentinelHelper.ArgumentNull(axis, nameof(axis));
            SentinelHelper.IsEnumValid(model);
            SentinelHelper.IsFalse(axis.Name.Contains("catAx") || axis.Name.Contains("valAx") || axis.Name.Contains("dateAx"), "Imposible extraer tipo. el nodo no es de tipo eje");

            var axisType = axis.ExtractAxisType(documentHelper);

            switch (axisType)
            {
            case KnownAxisType.PrimaryCategoryAxis:
            case KnownAxisType.SecondaryCategoryAxis:

                var valAttr = documentHelper.CreateAttribute("val");
                valAttr.Value = model.ToEppLabelAlignmentString();

                var lblAlignXmlNode = documentHelper.CreateOrDefaultAndAppendElementToNode(axis, "c:lblAlgn");
                lblAlignXmlNode.Attributes.Append(valAttr);
                break;

            case KnownAxisType.PrimaryValueAxis:
            case KnownAxisType.SecondaryValueAxis:
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Converter for <see cref="KnownHorizontalAlignment"/> enumeration type to <see cref="ExcelHorizontalAlignment"/>.
        /// </summary>
        /// <param name="alignment">The alignment.</param>
        /// <returns>
        /// A <see cref="ExcelHorizontalAlignment"/> value.
        /// </returns>
        private static ExcelHorizontalAlignment ToEppHorizontalAlignment(this KnownHorizontalAlignment alignment)
        {
            switch (alignment)
            {
            case KnownHorizontalAlignment.Center:
                return(ExcelHorizontalAlignment.Center);

            case KnownHorizontalAlignment.Right:
                return(ExcelHorizontalAlignment.Right);

            default:
                return(ExcelHorizontalAlignment.Left);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Converts one of the enumeration values <see cref="KnownHorizontalAlignment"/> to the proper alignment value for <b>iTextSharp</b>.
        /// </summary>
        /// <param name="horizontalAlignment">Horizontal alignment.</param>
        /// <returns>
        /// A <see cref="int"/> value that represents the alignment.
        /// </returns>
        public static int ToHorizontalTableAlignment(this KnownHorizontalAlignment horizontalAlignment)
        {
            switch (horizontalAlignment)
            {
            case KnownHorizontalAlignment.Center:
                return(Element.ALIGN_CENTER);

            case KnownHorizontalAlignment.Right:
                return(Element.ALIGN_RIGHT);

            default:
            case KnownHorizontalAlignment.Left:
                return(Element.ALIGN_LEFT);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Converter for <see cref="KnownHorizontalAlignment"/> enumeration type to string representation.
        /// </summary>
        /// <param name="alignment">Alignment from model.</param>
        /// <returns>
        /// Alignment as string.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception>
        public static string ToEppLabelAlignmentString(this KnownHorizontalAlignment alignment)
        {
            SentinelHelper.IsEnumValid(alignment);

            switch (alignment)
            {
            case KnownHorizontalAlignment.Left:
                return("l");

            case KnownHorizontalAlignment.Right:
                return("r");

            default:
                return("ctr");
            }
        }
        /// <summary>
        /// Converter for <see cref="T:iTin.Export.Model.KnownHorizontalAlignment"/> enumeration type to <see cref="T:Novacode.Alignment"/>.
        /// </summary>
        /// <param name="alignment">The alignment.</param>
        /// <returns>
        /// A <see cref="T:Novacode.Alignment" /> value.
        /// </returns>
        private static Alignment ToDocxHorizontalAlignment(this KnownHorizontalAlignment alignment)
        {
            var align = Alignment.left;

            switch (alignment)
            {
            case KnownHorizontalAlignment.Center:
                align = Alignment.center;
                break;

            case KnownHorizontalAlignment.Right:
                align = Alignment.right;
                break;
            }

            return(align);
        }
        /// <summary>
        /// Returns appropiate <c>Markdown</c> syntax for specfied alignment.
        /// </summary>
        /// <param name="alignment">Model alignment.</param>
        /// <returns>
        /// Returns a <see cref="T:System.String"/> that contains <c>Markdown</c> syntax for specfied alignment.
        /// </returns>
        public static string ToMarkdownTextAlignment(this KnownHorizontalAlignment alignment)
        {
            string result = " :---- ";

            switch (alignment)
            {
            case KnownHorizontalAlignment.Center:
                result = " :----: ";
                break;

            case KnownHorizontalAlignment.Right:
                result = " ----: ";
                break;
            }

            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// Converts the enumerated type <see cref="KnownHorizontalAlignment"/> to the appropriate value for the specified alignment.
        /// </summary>
        /// <param name="alignment">Alignment to convert.</param>
        /// <returns>
        /// A <see cref="int"/> value that represents appropriate the value for the specified alignment.
        /// </returns>
        private static int ToElementHorizontalAlignment(this KnownHorizontalAlignment alignment)
        {
            int pdfAlignment = Element.ALIGN_LEFT;

            switch (alignment)
            {
            case KnownHorizontalAlignment.Center:
                pdfAlignment = Element.ALIGN_CENTER;
                break;

            case KnownHorizontalAlignment.Right:
                pdfAlignment = Element.ALIGN_RIGHT;
                break;
            }

            return(pdfAlignment);
        }
        public static ContentAlignment ToContentAlignemnt(this KnownHorizontalAlignment horizontalAlignment)
        {
            ContentAlignment result = ContentAlignment.MiddleCenter;

            switch (horizontalAlignment)
            {
            case KnownHorizontalAlignment.Right:
                result = ContentAlignment.MiddleRight;
                break;

            case KnownHorizontalAlignment.Left:
                result = ContentAlignment.MiddleLeft;
                break;
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Converter for <see cref="KnownHorizontalAlignment"/> enumeration type to <see cref="eTextAlignment"/>.
        /// </summary>
        /// <param name="alignment">Horizontal alignment.</param>
        /// <returns>
        /// A <see cref="eTextAlignment"/> value.
        /// </returns>
        /// <exception cref="InvalidEnumArgumentException">The value specified is outside the range of valid values.</exception>
        public static eTextAlignment ToEppTextHorizontalAlignment(this KnownHorizontalAlignment alignment)
        {
            SentinelHelper.IsEnumValid(alignment);

            switch (alignment)
            {
            case KnownHorizontalAlignment.Left:
                return(eTextAlignment.Left);

            case KnownHorizontalAlignment.Center:
                return(eTextAlignment.Center);

            case KnownHorizontalAlignment.Right:
                return(eTextAlignment.Right);

            default:
                return(eTextAlignment.Left);
            }
        }
Beispiel #10
0
        private static float CalculatesHorizontalDelta(KnownHorizontalAlignment imageAlignment, RectangleF bounds, TextSharpPdfImage image, float horizontalOffset)
        {
            var deltaX = horizontalOffset;

            switch (imageAlignment)
            {
            case KnownHorizontalAlignment.Center:
                deltaX += (bounds.Right - bounds.Left - image.ScaledWidth) / 2.0f;
                break;

            case KnownHorizontalAlignment.Right:
                deltaX += bounds.Left + (bounds.Right - image.ScaledWidth);
                break;

            case KnownHorizontalAlignment.Left:
                break;
            }

            return(deltaX);
        }