Esempio n. 1
0
        public GridHeaderHelper AddColumnDate(
            double weight,
            string text,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.AddColumn(weight, text);

            cell.SetFormatDate(null, border, alignment);

            return(this);
        }
Esempio n. 2
0
        public GridColumnHelper AddColumnDateTime(
            double weight,
            string dataMember,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.AddColumn(weight, dataMember);

            cell.SetFormatDateTime(null, border, alignment);

            return(this);
        }
Esempio n. 3
0
        public GridHelper AddColumnDateTime(
            double weight,
            string text,
            string dataMember,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            this.headerHelper.AddColumnDateTime(weight, text, border, alignment);

            this.columnHelper.AddColumnDateTime(weight, dataMember, border, alignment);

            return(this);
        }
Esempio n. 4
0
        public GridColumnHelper AddColumnPercent(
            double weight,
            string dataMember,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.AddColumn(weight, dataMember);

            cell.SetFormatPercent(null, border, alignment);

            cell.AddZeroNullFormattingRule(dataMember);

            return(this);
        }
Esempio n. 5
0
        internal void OnUpdateStyle(Style style)
        {
            BackgroundColor         = null;
            TextColor               = null;
            FontAttribute           = null;
            FontFamily              = null;
            FontSize                = 0;
            LineBreakMode           = null;
            HorizontalTextAlignment = null;
            VerticalTextAlignment   = null;

            if (style == null)
            {
                return;
            }

            foreach (var item in style.Setters)
            {
                if (item.Property == Label.BackgroundColorProperty)
                {
                    BackgroundColor = ValueSelector.GetValueFromStyle <Color>(item);
                    BackgroundColor.Value.MultiplyAlpha(0.5);
                }
                else if (item.Property == Label.TextColorProperty)
                {
                    TextColor = ValueSelector.GetValueFromStyle <Color>(item);
                }
                else if (item.Property == Label.FontAttributesProperty)
                {
                    FontAttribute = ValueSelector.GetValueFromStyle <FontAttributes>(item);
                }
                else if (item.Property == Label.FontFamilyProperty)
                {
                    FontFamily = ValueSelector.GetValueFromStyle <string>(item);
                }
                else if (item.Property == Label.FontSizeProperty)
                {
                    FontSize = ValueSelector.GetValueFromStyle <double>(item);
                }
                else if (item.Property == Label.VerticalTextAlignmentProperty)
                {
                    VerticalTextAlignment = ValueSelector.GetValueFromStyle <TextAlignment>(item);
                }
                else if (item.Property == Label.HorizontalTextAlignmentProperty)
                {
                    HorizontalTextAlignment = ValueSelector.GetValueFromStyle <TextAlignment>(item);
                }
            }
        }
Esempio n. 6
0
 public ParaStyle(TextWrapping?wrapping = null, TextAlignment?alignment = null, double?tab_size = null)
 {
     if (wrapping != null)
     {
         Wrapping = wrapping.Value;
     }
     if (alignment != null)
     {
         Alignment = alignment.Value;
     }
     if (tab_size != null)
     {
         TabSize = tab_size.Value;
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Display a MessageBox
        /// </summary>
        /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
        /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
        /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
        /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
        /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
        /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
        /// <returns>The result chosen by the user</returns>
        public MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "",
                                               MessageBoxButton buttons       = MessageBoxButton.OK,
                                               MessageBoxImage icon           = MessageBoxImage.None,
                                               MessageBoxResult defaultResult = MessageBoxResult.None,
                                               MessageBoxResult cancelResult  = MessageBoxResult.None,
                                               IDictionary <MessageBoxResult, string> buttonLabels = null,
                                               FlowDirection?flowDirection = null,
                                               TextAlignment?textAlignment = null)
        {
            var vm = this.messageBoxViewModelFactory();

            vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, buttonLabels, flowDirection, textAlignment);
            this.ShowDialog(vm);
            return(vm.ClickedButton);
        }
Esempio n. 8
0
        /// <summary>
        /// Setup the MessageBoxViewModel with the information it needs
        /// </summary>
        /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
        /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
        /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
        /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
        /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
        /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
        public void Setup(string messageBoxText, string caption = null, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None,
                          MessageBoxResult defaultResult        = MessageBoxResult.None, MessageBoxResult cancelResult = MessageBoxResult.None, IDictionary <MessageBoxResult, string> buttonLabels = null,
                          FlowDirection?flowDirection           = null, TextAlignment?textAlignment = null)
        {
            _messageBoxText = messageBoxText;
            _caption        = caption;
            _buttons        = buttons;
            _icon           = icon;
            _defaultResult  = defaultResult;
            _cancelResult   = cancelResult;
            _buttonLabels   = buttonLabels;
            _flowDirection  = flowDirection;
            _textAlignment  = textAlignment;

            Configure();
        }
Esempio n. 9
0
        public GroupFooterHelper AddColumnPercent(
            double weight,
            string dataMember,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.ContainerControl.AddCell(weight);

            var binding = this.Report is DetailReportBand?
                          cell.AddTextBinding(this.Report.Report.JoinWithDataMember(dataMember)) :
                              cell.AddTextBinding(this.Report.JoinWithDataMember(dataMember));

            cell.SetFormatPercent(null, border, alignment);

            return(this);
        }
Esempio n. 10
0
        public GroupFooterHelper AddColumnMoney(
            double weight,
            string dataMember,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.ContainerControl.AddCell(weight);

            var binding = cell.AddTextBinding(this.Report.JoinWithDataMember(dataMember));

            cell.SetFormatMoney(null, border, alignment);

            cell.Summary = this.CreateSummary(SummaryFunc.Sum, binding.FormatString);

            return(this);
        }
Esempio n. 11
0
        //public static Label Foo(this Label view)
        //{
        //    return view;
        //}

        public static T TextAlign <T>(this T view, TextAlignment?hAlign = null, TextAlignment?vAlign = null)
            where T : Label
        {
            //Set horizontal alignment
            if (hAlign.HasValue)
            {
                view.HorizontalTextAlignment = hAlign.Value;
            }

            //Set vertical alignment
            if (vAlign.HasValue)
            {
                view.VerticalTextAlignment = vAlign.Value;
            }

            return(view);
        }
        private static PdfName TransformTextAlignmentValueToName(TextAlignment?textAlignment)
        {
            //TODO set rightToLeft value according with actual text content if it is possible.
            bool isLeftToRight = true;

            switch (textAlignment)
            {
            case TextAlignment.LEFT: {
                if (isLeftToRight)
                {
                    return(PdfName.Start);
                }
                else
                {
                    return(PdfName.End);
                }
                goto case TextAlignment.CENTER;
            }

            case TextAlignment.CENTER: {
                return(PdfName.Center);
            }

            case TextAlignment.RIGHT: {
                if (isLeftToRight)
                {
                    return(PdfName.End);
                }
                else
                {
                    return(PdfName.Start);
                }
                goto case TextAlignment.JUSTIFIED;
            }

            case TextAlignment.JUSTIFIED:
            case TextAlignment.JUSTIFIED_ALL: {
                return(PdfName.Justify);
            }

            default: {
                return(PdfName.Start);
            }
            }
        }
        private void ApplyTextAlignment(TextAlignment?textAlignment, LineLayoutResult result, LineRenderer processedRenderer
                                        , Rectangle layoutBox, IList <Rectangle> floatRendererAreas, bool onlyOverflowedFloatsLeft, float lineIndent
                                        )
        {
            if (textAlignment == TextAlignment.JUSTIFIED && result.GetStatus() == LayoutResult.PARTIAL && !result.IsSplitForcedByNewline
                    () && !onlyOverflowedFloatsLeft || textAlignment == TextAlignment.JUSTIFIED_ALL)
            {
                if (processedRenderer != null)
                {
                    Rectangle actualLineLayoutBox = layoutBox.Clone();
                    FloatingHelper.AdjustLineAreaAccordingToFloats(floatRendererAreas, actualLineLayoutBox);
                    processedRenderer.Justify(actualLineLayoutBox.GetWidth() - lineIndent);
                }
            }
            else
            {
                if (textAlignment != TextAlignment.LEFT && processedRenderer != null)
                {
                    Rectangle actualLineLayoutBox = layoutBox.Clone();
                    FloatingHelper.AdjustLineAreaAccordingToFloats(floatRendererAreas, actualLineLayoutBox);
                    float deltaX = Math.Max(0, actualLineLayoutBox.GetWidth() - lineIndent - processedRenderer.GetOccupiedArea
                                                ().GetBBox().GetWidth());
                    switch (textAlignment)
                    {
                    case TextAlignment.RIGHT: {
                        AlignStaticKids(processedRenderer, deltaX);
                        break;
                    }

                    case TextAlignment.CENTER: {
                        AlignStaticKids(processedRenderer, deltaX / 2);
                        break;
                    }

                    case TextAlignment.JUSTIFIED: {
                        if (BaseDirection.RIGHT_TO_LEFT.Equals(this.GetProperty <BaseDirection?>(Property.BASE_DIRECTION)))
                        {
                            AlignStaticKids(processedRenderer, deltaX);
                        }
                        break;
                    }
                    }
                }
            }
        }
Esempio n. 14
0
 public static T UsePlainTextPresenter <T>([NotNull] this T contextBuilder,
                                           double?fontSize               = null, Brush foreground = null, double?textBoxHeight = null,
                                           int?maxLength                 = null, bool?multiLines  = null, int?maxLines         = null,
                                           TextAlignment?textAlignment   = null, TextWrapping?textWrapping    = null,
                                           Action <TextBox> configurator = null, ITypeConverter textConverter = null) where T : IContextBuilder
 {
     contextBuilder.SetPresenter(PlainTextPresenter.Instance);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.FontSizeProperty, fontSize);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.ForegroundProperty, foreground);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.TextBoxHeightProperty, textBoxHeight);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.MaxLengthProperty, maxLength);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.MultiLineProperty, multiLines);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.MaxLinesProperty, maxLines);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.TextAlignmentProperty, textAlignment);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.TextWrappingProperty, textWrapping);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.TextBoxConfiguratorProperty, configurator);
     contextBuilder.SetPropertyNotNull(PlainTextPresenter.TextConverterProperty, textConverter);
     return(contextBuilder);
 }
Esempio n. 15
0
        protected MessageBoxResult ShowMessageBox(string messageBoxText,
                                                  MessageBoxButton buttons       = MessageBoxButton.OK,
                                                  MessageBoxImage icon           = MessageBoxImage.None,
                                                  MessageBoxResult defaultResult = MessageBoxResult.None,
                                                  MessageBoxResult cancelResult  = MessageBoxResult.None,
                                                  FlowDirection?flowDirection    = null,
                                                  TextAlignment?textAlignment    = null)
        {
            var buttonsLabels = new Dictionary <MessageBoxResult, string>
            {
                { MessageBoxResult.Cancel, L("Cancel") },
                { MessageBoxResult.No, L("No") },
                { MessageBoxResult.None, L("None") },
                { MessageBoxResult.OK, L("OK") },
                { MessageBoxResult.Yes, L("Yes") }
            };

            return(WindowManager.ShowMessageBox(messageBoxText, L("HotsBpHelper"), buttons, icon, defaultResult, cancelResult, buttonsLabels, flowDirection, textAlignment));
        }
        /// <summary>
        /// Return a ParagraphOptions with parameters to set specific properties
        /// </summary>
        /// <param name="FontFamily"></param>
        /// <param name="FontStyle"></param>
        /// <param name="FontWeight"></param>
        /// <param name="FontSize"></param>
        /// <param name="FontColor"></param>
        /// <param name="TextAlignment"></param>
        /// <returns></returns>
        public static ParagraphOptions Set(
            TextFontFamily FontFamily   = null,
            TextFontStyle?FontStyle     = null,
            TextFontWeight?FontWeight   = null,
            double?FontSize             = null,
            Color?FontColor             = null,
            TextAlignment?TextAlignment = null
            )
        {
            var value = new ParagraphOptions();

            if (FontFamily != null)
            {
                value.FontOptions.FontFamily = FontFamily;
            }

            if (FontStyle.HasValue)
            {
                value.FontOptions.FontStyle = FontStyle.Value;
            }

            if (FontWeight.HasValue)
            {
                value.FontOptions.FontWeight = FontWeight.Value;
            }

            if (FontSize.HasValue)
            {
                value.FontOptions.FontSize = FontSize.Value;
            }

            if (FontColor.HasValue)
            {
                value.FontOptions.FontColor = FontColor.Value;
            }

            if (TextAlignment.HasValue)
            {
                value.TextAlignment = TextAlignment.Value;
            }

            return(value);
        }
Esempio n. 17
0
        /// <summary>
        /// Display a MessageBox
        /// </summary>
        /// <param name="messageBoxText">A <see cref="System.String"/> that specifies the text to display.</param>
        /// <param name="caption">A <see cref="System.String"/> that specifies the title bar caption to display.</param>
        /// <param name="buttons">A <see cref="System.Windows.MessageBoxButton"/> value that specifies which button or buttons to display.</param>
        /// <param name="icon">A <see cref="System.Windows.MessageBoxImage"/> value that specifies the icon to display.</param>
        /// <param name="defaultResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the default result of the message box.</param>
        /// <param name="cancelResult">A <see cref="System.Windows.MessageBoxResult"/> value that specifies the cancel result of the message box</param>
        /// <param name="buttonLabels">A dictionary specifying the button labels, if desirable</param>
        /// <param name="flowDirection">The <see cref="System.Windows.FlowDirection"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultFlowDirection"/></param>
        /// <param name="textAlignment">The <see cref="System.Windows.TextAlignment"/> to use, overrides the <see cref="MessageBoxViewModel.DefaultTextAlignment"/></param>
        /// <returns>The result chosen by the user</returns>
        public MessageBoxResult ShowMessageBox(string messageBoxText, string caption = "",
                                               MessageBoxButton buttons       = MessageBoxButton.OK,
                                               MessageBoxImage icon           = MessageBoxImage.None,
                                               MessageBoxResult defaultResult = MessageBoxResult.None,
                                               MessageBoxResult cancelResult  = MessageBoxResult.None,
                                               IDictionary <MessageBoxResult, string> buttonLabels = null,
                                               FlowDirection?flowDirection = null,
                                               TextAlignment?textAlignment = null)
        {
            var vm = this.messageBoxViewModelFactory();

            vm.Setup(messageBoxText, caption, buttons, icon, defaultResult, cancelResult, buttonLabels, flowDirection, textAlignment);
            // Don't go through the IoC container to get the View. This means we can simplify it...
            var messageBoxView = new MessageBoxView();

            messageBoxView.InitializeComponent();
            this.viewManager.BindViewToModel(messageBoxView, vm);
            this.ShowDialog(vm);
            return(vm.ClickedButton);
        }
Esempio n. 18
0
        public GroupFooterHelper AddColumnPercent(
            double weight,
            string dataMember,
            string numeratorColumnName,
            string denominatorColumnName,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var cell = this.ContainerControl.AddCell(weight);

            var binding = cell.AddTextBinding(this.Report.JoinWithDataMember(dataMember));

            cell.SetFormatPercent(null, border, alignment);

            cell.Summary = this.CreateSummary(SummaryFunc.Custom, binding.FormatString);

            new PercentGroupCalculationHelper(cell, numeratorColumnName, denominatorColumnName);

            return(this);
        }
Esempio n. 19
0
        public GridHeaderHelper AddColumn(
            double weight,
            string text,
            BorderSide?border       = null,
            TextAlignment?alignment = null)
        {
            var result = this.AddColumn(weight, text);

            if (border.HasValue)
            {
                result.SetBorder(border.Value);
            }

            if (alignment.HasValue)
            {
                result.SetAlignment(alignment.Value);
            }

            return(this);
        }
Esempio n. 20
0
        public static void SetFormat(this XRControl control,
                                     string formatString,
                                     BorderSide?border,
                                     TextAlignment?alignment)
        {
            if (!string.IsNullOrWhiteSpace(formatString))
            {
                control.SetFormat(formatString);
            }

            if (border.HasValue)
            {
                control.SetBorder(border.Value);
            }

            if (alignment.HasValue)
            {
                control.SetAlignment(alignment.Value);
            }
        }
        protected override void ReadParagraphProperties(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.NamespaceURI == WordprocessingMLNamespace)
                {
                    Paragraph paragraph = (Paragraph)_current;

                    switch (reader.LocalName)
                    {
                    case AlignmentElement:
                        TextAlignment?textAlignment = ConvertTextAlignment(GetValueAttribute(reader));
                        if (textAlignment.HasValue)
                        {
                            paragraph.TextAlignment = textAlignment.Value;
                        }
                        break;

                    case PageBreakBeforeElement:
                        paragraph.BreakPageBefore = GetOnOffValueAttribute(reader);
                        break;

                    case SpacingElement:
                        paragraph.Margin = GetSpacing(reader, paragraph.Margin);
                        break;

                    case IndentationElement:
                        SetParagraphIndent(reader, paragraph);
                        break;

                    case ShadingElement:
                        Brush background = GetShading(reader);
                        if (background != null)
                        {
                            paragraph.Background = background;
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 22
0
 public SVGXTextStyle(SVGXTextStyle toClone)
 {
     this.fontSize         = toClone.fontSize;
     this.fontStyle        = toClone.fontStyle;
     this.alignment        = toClone.alignment;
     this.textTransform    = toClone.textTransform;
     this.whitespaceMode   = toClone.whitespaceMode;
     this.textColor        = toClone.textColor;
     this.outlineColor     = toClone.outlineColor;
     this.outlineWidth     = toClone.outlineWidth;
     this.outlineSoftness  = toClone.outlineSoftness;
     this.glowOuter        = toClone.glowOuter;
     this.glowOffset       = toClone.glowOffset;
     this.glowColor        = toClone.glowColor;
     this.underlayColor    = toClone.underlayColor;
     this.underlayX        = toClone.underlayX;
     this.underlayY        = toClone.underlayY;
     this.underlayDilate   = toClone.underlayDilate;
     this.underlaySoftness = toClone.underlaySoftness;
     this.fontAsset        = toClone.fontAsset;
     this.faceDilate       = toClone.faceDilate;
 }
Esempio n. 23
0
        /// <summary>Convenience method to write a text aligned about the specified point</summary>
        /// <param name="p">
        /// paragraph of text to be placed to the page. By default it has no leading and is written in single line.
        /// Set width to write multiline text.
        /// </param>
        /// <param name="x">the point about which the text will be aligned and rotated</param>
        /// <param name="y">the point about which the text will be aligned and rotated</param>
        /// <param name="pageNumber">the page number to write the text</param>
        /// <param name="textAlign">horizontal alignment about the specified point</param>
        /// <param name="vertAlign">vertical alignment about the specified point</param>
        /// <param name="angle">the angle of rotation applied to the text, in radians</param>
        /// <returns>this object</returns>
        public virtual T ShowTextAligned(Paragraph p, float x, float y, int pageNumber, TextAlignment?textAlign,
                                         VerticalAlignment?vertAlign, float angle)
        {
            Div div = new Div();

            div.SetTextAlignment(textAlign).SetVerticalAlignment(vertAlign);
            if (angle != 0)
            {
                div.SetRotationAngle(angle);
            }
            div.SetProperty(Property.ROTATION_POINT_X, x);
            div.SetProperty(Property.ROTATION_POINT_Y, y);
            float divSize = 5e3f;
            float divX    = x;
            float divY    = y;

            if (textAlign == TextAlignment.CENTER)
            {
                divX = x - divSize / 2;
                p.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            }
            else
            {
                if (textAlign == TextAlignment.RIGHT)
                {
                    divX = x - divSize;
                    p.SetHorizontalAlignment(HorizontalAlignment.RIGHT);
                }
            }
            if (vertAlign == VerticalAlignment.MIDDLE)
            {
                divY = y - divSize / 2;
            }
            else
            {
                if (vertAlign == VerticalAlignment.TOP)
                {
                    divY = y - divSize;
                }
            }
            if (pageNumber == 0)
            {
                pageNumber = 1;
            }
            div.SetFixedPosition(pageNumber, divX, divY, divSize).SetHeight(divSize);
            if (p.GetProperty <Leading>(Property.LEADING) == null)
            {
                p.SetMultipliedLeading(1);
            }
            div.Add(p.SetMargins(0, 0, 0, 0));
            div.SetRole(PdfName.Artifact);
            this.Add(div);
            return((T)(Object)this);
        }
Esempio n. 24
0
 /// <summary>Convenience method to write a text aligned about the specified point</summary>
 /// <param name="p">
 /// paragraph of text to be placed to the page. By default it has no leading and is written in single line.
 /// Set width to write multiline text.
 /// </param>
 /// <param name="x">the point about which the text will be aligned and rotated</param>
 /// <param name="y">the point about which the text will be aligned and rotated</param>
 /// <param name="textAlign">horizontal alignment about the specified point</param>
 /// <param name="vertAlign">vertical alignment about the specified point</param>
 /// <returns>this object</returns>
 public virtual T ShowTextAligned(Paragraph p, float x, float y, TextAlignment?textAlign, VerticalAlignment?
                                  vertAlign)
 {
     return(ShowTextAligned(p, x, y, pdfDocument.GetNumberOfPages(), textAlign, vertAlign, 0));
 }
Esempio n. 25
0
 /// <summary>Convenience method to write a text aligned about the specified point</summary>
 /// <param name="text">text to be placed to the page</param>
 /// <param name="x">the point about which the text will be aligned and rotated</param>
 /// <param name="y">the point about which the text will be aligned and rotated</param>
 /// <param name="textAlign">horizontal alignment about the specified point</param>
 /// <param name="angle">the angle of rotation applied to the text, in radians</param>
 /// <returns>this object</returns>
 public virtual T ShowTextAligned(String text, float x, float y, TextAlignment?textAlign, float angle)
 {
     return(ShowTextAligned(text, x, y, textAlign, VerticalAlignment.BOTTOM, angle));
 }
Esempio n. 26
0
 /// <summary>Convenience method to write a text aligned about the specified point</summary>
 /// <param name="text">text to be placed to the page</param>
 /// <param name="x">the point about which the text will be aligned and rotated</param>
 /// <param name="y">the point about which the text will be aligned and rotated</param>
 /// <param name="textAlign">horizontal alignment about the specified point</param>
 /// <returns>this object</returns>
 public virtual T ShowTextAligned(String text, float x, float y, TextAlignment?textAlign)
 {
     return(ShowTextAligned(text, x, y, textAlign, 0));
 }
Esempio n. 27
0
        public static Element Create(Element parent, string text, Color?color = null, TextAlignment?alignment = null)
        {
            var label = Element.Create(parent);

            if (text != null)
            {
                label.Set(new LabelText {
                    Value = text
                });
            }
            if (color != null)
            {
                label.Set(new LabelColor {
                    Value = color.Value
                });
            }
            if (alignment != null)
            {
                label.Set(alignment.Value);
            }
            label.SizeToFit = true;
            label.Measure   = e => Measure(e);
            label.Draw      = dc => Draw(dc);
            return(label);
        }
Esempio n. 28
0
        public static TextAlignment?GetVerticalTextAlignment(this View view, TextAlignment?defaultValue = null)
        {
            var value = view.GetEnvironment <TextAlignment?>(view, EnvironmentKeys.Text.VerticalAlignment);

            return(value ?? defaultValue);
        }
 /// <summary>Sets the text alignment of this Element.</summary>
 /// <param name="alignment">
 /// an enum value of type
 /// <see cref="iText.Layout.Properties.TextAlignment?"/>
 /// </param>
 /// <returns>this Element.</returns>
 public virtual T SetTextAlignment(TextAlignment?alignment)
 {
     SetProperty(Property.TEXT_ALIGNMENT, alignment);
     return((T)(Object)this);
 }
Esempio n. 30
0
        private void DrawOverlayText(PdfCanvas canvas, String overlayText, Rectangle annotRect, PdfBoolean repeat,
                                     PdfString defaultAppearance, int justification)
        {
            IDictionary <String, IList> parsedDA;

            try {
                parsedDA = ParseDAParam(defaultAppearance);
            }
            catch (NullReferenceException) {
                throw new PdfException(PdfException.DefaultAppearanceNotFound);
            }
            PdfFont       font;
            float         fontSize       = 12;
            IList         fontArgs       = parsedDA.Get("Tf");
            PdfDictionary formDictionary = pdfDocument.GetCatalog().GetPdfObject().GetAsDictionary(PdfName.AcroForm);

            if (fontArgs != null && formDictionary != null)
            {
                font     = GetFontFromAcroForm((PdfName)fontArgs[0]);
                fontSize = ((PdfNumber)fontArgs[1]).FloatValue();
            }
            else
            {
                font = PdfFontFactory.CreateFont();
            }
            if (pdfDocument.IsTagged())
            {
                canvas.OpenTag(new CanvasArtifact());
            }
            iText.Layout.Canvas modelCanvas   = new iText.Layout.Canvas(canvas, pdfDocument, annotRect, false);
            Paragraph           p             = new Paragraph(overlayText).SetFont(font).SetFontSize(fontSize).SetMargin(0);
            TextAlignment?      textAlignment = TextAlignment.LEFT;

            switch (justification)
            {
            case 1: {
                textAlignment = TextAlignment.CENTER;
                break;
            }

            case 2: {
                textAlignment = TextAlignment.RIGHT;
                break;
            }

            default: {
                break;
            }
            }
            p.SetTextAlignment(textAlignment);
            IList strokeColorArgs;

            parsedDA.TryGetValue("StrokeColor", out strokeColorArgs);
            if (strokeColorArgs != null)
            {
                p.SetStrokeColor(GetColor(strokeColorArgs));
            }
            IList fillColorArgs;

            parsedDA.TryGetValue("FillColor", out fillColorArgs);
            if (fillColorArgs != null)
            {
                p.SetFontColor(GetColor(fillColorArgs));
            }
            modelCanvas.Add(p);
            if (repeat != null && repeat.GetValue())
            {
                bool?isFull = modelCanvas.GetRenderer().GetPropertyAsBoolean(Property.FULL);
                while (isFull == null || (bool)!isFull)
                {
                    p.Add(overlayText);
                    LayoutArea previousArea = modelCanvas.GetRenderer().GetCurrentArea().Clone();
                    modelCanvas.Relayout();
                    if (modelCanvas.GetRenderer().GetCurrentArea().Equals(previousArea))
                    {
                        // Avoid infinite loop. This might be caused by the fact that the font does not support the text we want to show
                        break;
                    }
                    isFull = modelCanvas.GetRenderer().GetPropertyAsBoolean(Property.FULL);
                }
            }
            modelCanvas.GetRenderer().Flush();
            if (pdfDocument.IsTagged())
            {
                canvas.CloseTag();
            }
        }