Example #1
0
        private static void SizeLayoutElement(ILayoutElement layoutElement,
                                              float height,
                                              VerticalAlign verticalAlign,
                                              float restrictedHeight,
                                              float? width,
                                              bool variableColumnWidth,
                                              float columnWidth)
        {
            float? newHeight = null;

            // if verticalAlign is "justify" or "contentJustify", 
            // restrict the height to restrictedHeight.  Otherwise, 
            // size it normally
            if (verticalAlign == VerticalAlign.Justify ||
                verticalAlign == VerticalAlign.ContentJustify)
            {
                newHeight = restrictedHeight;
            }
            else
            {
                if (null != layoutElement.PercentHeight)
                    newHeight = CalculatePercentHeight(layoutElement, height);
            }

            if (variableColumnWidth)
                layoutElement.SetLayoutBoundsSize(width, newHeight);
            else
                layoutElement.SetLayoutBoundsSize(columnWidth, newHeight);
        }
Example #2
0
 public Label(string text, HorizontalAlign halign, VerticalAlign valign) {
     m_text = text;
     
     m_font = new Font("Arial", 8, FontStyle.Regular);
     m_stringFormat = new StringFormat();
     m_color = Color.Black;
     this.HorizontalAlign = halign;
     this.VerticalAlign = valign;
 }
Example #3
0
 public PccRow(string Css)
 {
     m_Row = new TableRow();
     m_Css = Css;
     m_HAlign = 0;
     m_VAlign = 0;
     m_CellSpan = 0;
     m_RowSpan = 0;
     m_Height = 0;
 }
Example #4
0
 public PccRow(string Css, HorizontalAlign HAlign, VerticalAlign VAlign, int CellSpan, int RowSpan, int Height)
 {
     m_Row = new TableRow();
     m_Css = Css;
     m_HAlign = HAlign;
     m_VAlign = VAlign;
     m_CellSpan = CellSpan;
     m_RowSpan = RowSpan;
     m_Height = Height;
 }
Example #5
0
 public Text(SpriteFont font, string text, Vector2 position, Color color, HorizontalAlign horizontalAlign = HorizontalAlign.Center, VerticalAlign verticalAlign = VerticalAlign.Center)
     : base(false)
 {
     this.font = font;
     this.text = text;
     Position = position;
     Color = color;
     this.horizontalOrigin = horizontalAlign;
     this.verticalOrigin = verticalAlign;
     UpdateSize();
 }
Example #6
0
File: Text.cs Project: prime31/Nez
		public Text( IFont font, string text, Vector2 localOffset, Color color )
		{
			_font = font;
			_text = text;
			_localOffset = localOffset;
			this.color = color;
			_horizontalAlign = HorizontalAlign.Left;
			_verticalAlign = VerticalAlign.Top;

			updateSize();
		}
Example #7
0
        public Label(string text, SpriteFont spriteFont)
        {
            this.Text = text;
            this.SpriteFont = spriteFont;
            this.HorizontalAlign = HorizontalAlign.LEFT;
            this.VerticalAlign = VerticalAlign.TOP;

            this.TextSize = this.SpriteFont.MeasureString(text);
            this.Width = (int)this.TextSize.X;
            this.Height = (int)this.TextSize.Y;
        }
Example #8
0
 public PccRow()
 {
     //
     // TODO: 在這裡加入建構函式的程式碼
     //
     m_Row = new TableRow();
     m_Css = "";
     m_HAlign = 0;
     m_VAlign = 0;
     m_CellSpan = 0;
     m_RowSpan = 0;
     m_Height = 0;
 }
	public Renderer(float size,
		float width,
		float height,
		Style style,
		Align align = Align.LEFT,
		VerticalAlign verticalAlign = VerticalAlign.TOP,
		float lineSpacing = 1.0f,
		float letterSpacing = 0.0f,
		float leftMargin = 0.0f,
		float rightMargin = 0.0f)
	{
		Init(size, width, height, style, align, verticalAlign,
			lineSpacing, letterSpacing, leftMargin, rightMargin);
	}
                public Parameter(float size, float width, float height, Style style,
			Align align, VerticalAlign verticalAlign, float lineSpacing,
			float letterSpacing, float leftMargin, float rightMargin)
                {
                    mSize = size;
                    mWidth = width;
                    mHeight = height;
                    mStyle = style;
                    mAlign = align;
                    mVerticalAlign = verticalAlign;
                    mLineSpacing = lineSpacing;
                    mLetterSpacing = letterSpacing;
                    mLeftMargin = leftMargin;
                    mRightMargin = rightMargin;
                }
        /// <summary>Constructor.</summary>
        /// <param name="container">The containing block element whose children are being stacked.</param>
        /// <param name="horizontal">The alignment to apply to the X axis.</param>
        /// <param name="vertical">The alignment to apply to the Y axis.</param>
        public StackPanel(jQueryObject container, HorizontalAlign horizontal, VerticalAlign vertical)
        {
            // Setup initial conditions.
            this.container = container;

            // Set default values.
            Horizontal = Script.IsNullOrUndefined(horizontal) ? DefaultHorizontal : horizontal;
            Vertical = Script.IsNullOrUndefined(vertical) ? DefaultVertical: vertical;

            // Wire up events.
            childMargin.PropertyChanged += delegate { UpdateLayout(); };

            // Finish up.
            isInitialized = true;
            UpdateLayout();
        }
Example #12
0
        public Background(Rectangle screenBounds, TextureFrame frame, VerticalAlign vertical = VerticalAlign.Middle, HorizontalAlign horizontal = 
            HorizontalAlign.Center)
        {
            if (screenBounds == null || screenBounds.Size == Point.Zero)
                throw new ArgumentNullException(nameof(screenBounds));

            if (frame == null)
                throw new ArgumentNullException(nameof(frame));

            _frame = frame;
            Color = Color.White;
            Alpha = 1f;

            var scaleFactor = Math.Max(screenBounds.Width/frame.Size.X,
                screenBounds.Height/frame.Size.Y);
            _scale = new Vector2(scaleFactor);

            var pos = new Vector2();
            var frameSize = frame.Size*scaleFactor;
            switch (vertical)
            {
                case VerticalAlign.Top:
                    pos.Y = 0;
                    break;
                case VerticalAlign.Bottom:
                    pos.Y = SkidiGame.ScreenBounds.Height - frameSize.Y;
                    break;
                case VerticalAlign.Middle:
                    pos.Y = (SkidiGame.ScreenBounds.Height - frameSize.Y)*.5f;
                    break;
            }

            switch (horizontal)
            {
                case HorizontalAlign.Left:
                    pos.X = 0;
                    break;
                case HorizontalAlign.Right:
                    pos.X = (SkidiGame.ScreenBounds.Width - frameSize.X);
                    break;
                case HorizontalAlign.Center:
                    pos.X = (SkidiGame.ScreenBounds.Width - frameSize.X)*.5f;
                    break;
            }

            Position = pos;
        }
Example #13
0
        public static string GetName(VerticalAlign type)
        {
            string result = String.Empty;

            switch (type)
            {
                case VerticalAlign.Middle:
                    result = "middle";
                    break;
                case VerticalAlign.Top:
                    result = "top";
                    break;
                case VerticalAlign.Bottom:
                    result = "bottom";
                    break;
            }

            return result;
        }
        public static void DrawInRect(
			SpriteBatch spriteBatch, 
			GameSprite sprite, 
			Rectangle bounds, 
			HorizontalAlign alignHorizontal = HorizontalAlign.Center,
			VerticalAlign alignVertical = VerticalAlign.Middle
		)
        {
            Vector2 location = Vector2.Zero;
            Vector2 origin = Vector2.Zero;

            switch (alignHorizontal) {
            case HorizontalAlign.Left:
                location.X = bounds.X;
                origin.X = 0;
                break;
            case HorizontalAlign.Center:
                location.X = bounds.X + bounds.Width / 2;
                origin.X = sprite.TextureRect.Width / 2;
                break;
            case HorizontalAlign.Right:
                location.X = bounds.X + bounds.Width;
                origin.X = sprite.TextureRect.Width;
                break;
            }

            switch (alignVertical) {
            case VerticalAlign.Top:
                location.Y = bounds.Y;
                origin.Y = 0;
                break;
            case VerticalAlign.Middle:
                location.Y = bounds.Y + bounds.Height / 2;
                origin.Y = sprite.TextureRect.Height / 2;
                break;
            case VerticalAlign.Bottom:
                location.Y = bounds.Y + bounds.Height;
                origin.Y = sprite.TextureRect.Height;
                break;
            }

            sprite.Draw (spriteBatch, location, origin: origin);
        }
Example #15
0
        public static string GetName(VerticalAlign type)
        {
            string result = String.Empty;

            switch (type)
            {
            case VerticalAlign.Middle:
                result = "middle";
                break;

            case VerticalAlign.Top:
                result = "top";
                break;

            case VerticalAlign.Bottom:
                result = "bottom";
                break;
            }

            return(result);
        }
Example #16
0
        /// <summary>
        /// Выравнивание контрола, внутри родительского окна или контрола,
        /// по заданным параметрам
        /// </summary>
        /// <param name="control"></param>
        /// <param name="h">Горизонтальное выравнивание</param>
        /// <param name="v">Вертикальное выравнивание</param>
        /// <returns></returns>
        public static Point Align(this Control control, HorizontalAlign h, VerticalAlign v)
        {
            int     x;                          // Координата верхнего угла по оси (x)
            int     y;                          // Координата верхнего угла по оси (y)
            Control parent = control.Parent;    // Владелец дочернего контрола

            switch (h)                          // Выбор значения для координаты (x)
            {
            case HorizontalAlign.Left:          // выравнивание по левому краю
                x = 0;
                break;

            case HorizontalAlign.Right:         // выравнивание по правому краю
                x = parent.ClientSize.Width - control.Size.Width;
                break;

            default:                               // выравнивание по центру
                x = parent.ClientSize.Width / 2 - control.Size.Width / 2;
                break;
            }


            switch (v)                          // Выбор значения для координаты (y)
            {
            case VerticalAlign.Top:             // выравнивание по верхнему краю
                y = 0;
                break;

            case VerticalAlign.Bottom:          // выравнивание по нижнему краю
                y = parent.ClientSize.Height - control.Size.Height;
                break;

            default:                            // выравнивание по центру
                y = parent.ClientSize.Height / 2 - control.Size.Height / 2;
                break;
            }

            return(new Point(x, y));
        }
Example #17
0
        /// <summary>
        /// Renders a string from a specified SpriteFont
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch to render to</param>
        /// <param name="font">SpriteFont to render with</param>
        /// <param name="text">String to render</param>
        /// <param name="color">Text Color</param>
        /// <param name="position">Position to render to</param>
        /// <param name="hAlign">Horizontal Align</param>
        /// <param name="vAlign">Vertical Align</param>
        public static void DrawText(SpriteBatch spriteBatch, SpriteFont font, string text, Color color, Vector2 position, HorizontalAlign hAlign, VerticalAlign vAlign)
        {
            //Get the size of the text for offsetting
            Vector2 fullSize = font.MeasureString(text);

            //Offset Horizontal and Vertical aligns based on the specified enum value
            Vector2 alignOffset = new Vector2();

            switch (hAlign)
            {
                case HorizontalAlign.AlignCenter:
                    alignOffset.X = fullSize.X / 2;
                    break;
                case HorizontalAlign.AlignRight:
                    alignOffset.X = fullSize.X;
                    break;
                default:
                    break;
            }

            switch (vAlign)
            {
                case VerticalAlign.AlignCenter:
                    alignOffset.Y = fullSize.Y / 2;
                    break;
                case VerticalAlign.AlignBottom:
                    alignOffset.Y = fullSize.Y;
                    break;
                default:
                    break;
            }

            Vector2 drawPos = position - alignOffset;
            drawPos.X = (int)Math.Round(drawPos.X);
            drawPos.Y = (int)Math.Round(drawPos.Y);

            spriteBatch.DrawString(font, text, drawPos, color);
        }
Example #18
0
        public TableCell AddCell(VerticalAlign withVerticalAlignment, string withAlignment, Unit forWidth, params Control[] withControls)
        {
            if (null == _currentRow)
            {
                throw new InvalidOperationException("No Current Row!!!");
            }

            TableCell cell = new TableCell();

            cell.VerticalAlign = withVerticalAlignment;
            cell.Attributes.Add(ALIGN_ATTRIBUTE, withAlignment);
            if (Unit.Empty != forWidth)
            {
                cell.Width = forWidth;
            }
            foreach (Control inputControl in withControls)
            {
                cell.Controls.Add(inputControl);
            }
            _currentRow.Cells.Add(cell);

            return(cell);
        }
 public OutlineText(SpriteFont font, string text, Vector2 position, HorizontalAlign horizontalAlign = HorizontalAlign.Center, VerticalAlign verticalAlign = VerticalAlign.Center)
     : this(font, text, position, Color.White, horizontalAlign, verticalAlign)
 {
 }
Example #20
0
 /// <summary>
 /// Computes the location of a rectangle of the specified size, align to the given anchor.
 /// </summary>
 /// <param name="size">The rectangle size.</param>
 /// <param name="anchor">The anchor rectangle.</param>
 /// <param name="horizontalAlignment">The horizontal alignment.</param>
 /// <param name="verticalAlignment">The vertical alignment.</param>
 /// <returns>The aligned rectangle.</returns>
 public static Rectangle Align(this Size size, Rectangle anchor, HorizontalAlign horizontalAlignment, VerticalAlign verticalAlignment)
 {
     // Declare the location.
     Point location = default(Point);
     // Compute the X coordinate.
     switch (horizontalAlignment)
     {
         case HorizontalAlign.LeftOutside:
             location.X = anchor.Left - size.Width;
             break;
         case HorizontalAlign.LeftInside:
             location.X = anchor.Left;
             break;
         case HorizontalAlign.Center:
             location.X = anchor.Left + (anchor.Width >> 1) - (size.Width >> 1);
             break;
         case HorizontalAlign.RightInside:
             location.X = anchor.Right - size.Width;
             break;
         case HorizontalAlign.RightOutside:
             location.X = anchor.Right;
             break;
     }
     // Compute the Y coordinate.
     switch (verticalAlignment)
     {
         case VerticalAlign.TopOutside:
             location.Y = anchor.Top - size.Height;
             break;
         case VerticalAlign.TopInside:
             location.Y = anchor.Top;
             break;
         case VerticalAlign.Center:
             location.Y = anchor.Top + (anchor.Height >> 1) - (size.Height >> 1);
             break;
         case VerticalAlign.BottomInside:
             location.Y = anchor.Bottom - size.Height;
             break;
         case VerticalAlign.BottomOutside:
             location.Y = anchor.Bottom;
             break;
     }
     // Return the aligned rectangle.
     return new Rectangle(location, size);
 }
Example #21
0
 public Text(SpriteFont font, string text, Vector2 position, Color color, HorizontalAlign horizontalAlign = HorizontalAlign.Center, VerticalAlign verticalAlign = VerticalAlign.Center)
     : base(false)
 {
     this.font             = font;
     this.text             = text;
     Position              = position;
     Color                 = color;
     this.horizontalOrigin = horizontalAlign;
     this.verticalOrigin   = verticalAlign;
     UpdateSize();
 }
Example #22
0
 public static bool DrawText(string text, Vector2 position, Vector2 bottomRight, Color color, Vector2 scale, Font font, HorizontalAlign horizontalAlign = HorizontalAlign.Left, VerticalAlign verticalAlign = VerticalAlign.Top, float fRotation = 0.0f)
 {
     return(DrawText(text, position, bottomRight, color, scale, font, horizontalAlign, verticalAlign, fRotation, Vector2.Zero));
 }
Example #23
0
 public OutlineText(SpriteFont font, string text, Vector2 position, HorizontalAlign horizontalAlign = HorizontalAlign.Center, VerticalAlign verticalAlign = VerticalAlign.Center)
     : this(font, text, position, Color.White, horizontalAlign, verticalAlign)
 {
 }
Example #24
0
 public WatermarkTransformation(HorizontalAlign alignX, VerticalAlign alignY, int padding)
 {
     HorizontalAlign = alignX;
     VerticalAlign   = alignY;
     Padding         = padding;
 }
Example #25
0
 public static GdiVerticalAlign ToGdiVerticalAlign(VerticalAlign align)
 {
     return(VerticalAlignMap[align]);
 }
Example #26
0
 /**
  * Specifies the alignment which shall be applied to the contents of this
  * run.in relation to the default appearance of the run.s text. This allows
  * the text to be repositioned as subscript or superscript without altering
  * the font size of the run.properties.
  * <p/>
  * If this element is not present, the default value is to leave the
  * formatting applied at previous level in the style hierarchy. If this
  * element is never applied in the style hierarchy, then the text shall not
  * be subscript or superscript relative to the default baseline location for
  * the contents of this run.
  * </p>
  *
  * @param valign
  * @see VerticalAlign
  */
 public void SetSubscript(VerticalAlign valign)
 {
     CT_RPr pr = run.IsSetRPr() ? run.rPr : run.AddNewRPr();
     CT_VerticalAlignRun ctValign = pr.IsSetVertAlign() ? pr.vertAlign : pr.AddNewVertAlign();
     ctValign.val = EnumConverter.ValueOf<ST_VerticalAlignRun, VerticalAlign>(valign);
 }
Example #27
0
File: Text.cs Project: prime31/Nez
		public Text setVerticalAlign( VerticalAlign vAlign )
		{
			_verticalAlign = vAlign;
			updateCentering();

			return this;
		}
        private void AddTextWithShadow(GuiRenderer renderer, string text, Vec2 position, HorizontalAlign horizontalAlign,
            VerticalAlign verticalAlign, ColorValue color)
        {
            Vec2 shadowOffset = 2.0f / RendererWorld.Instance.DefaultViewport.DimensionsInPixels.Size.ToVec2();

            renderer.AddText(text, position + shadowOffset, horizontalAlign, verticalAlign,
                new ColorValue(0, 0, 0, color.Alpha / 2));
            renderer.AddText(text, position, horizontalAlign, verticalAlign, color);
        }
Example #29
0
 public static void Add(this ValuesInitializer @this, VerticalAlign value) =>
 @this.Element <BlockElement, VerticalAlign>().VerticalAlign = value;
Example #30
0
        public virtual void PositionInsideMenuScreen(MenuScreen menu, HorizontalAlign h, VerticalAlign v, float margin = 0)
        {
            float x = 0;
            float y = 0;

            if (h == HorizontalAlign.Left)
            {
                x = menu.MenuOffset.X + margin;
            }
            if (h == HorizontalAlign.CopyLeft)
            {
                x = menu.MenuOffset.X;
            }
            if (h == HorizontalAlign.Center)
            {
                x = menu.MenuOffset.X + (menu.MenuSize.X - this.Size.X) / 2;
            }
            if (h == HorizontalAlign.CopyRight)
            {
                x = menu.MenuSize.X - this.Size.X;
            }
            if (h == HorizontalAlign.Right)
            {
                x = menu.MenuOffset.X + menu.MenuSize.X - this.Size.X - margin;
            }

            if (v == VerticalAlign.Top)
            {
                y = menu.MenuOffset.Y + margin;
            }
            if (v == VerticalAlign.CopyTop)
            {
                y = menu.MenuOffset.Y;
            }
            if (v == VerticalAlign.Middle)
            {
                y = menu.MenuOffset.Y + (menu.MenuSize.Y - this.Size.Y) / 2;
            }
            if (v == VerticalAlign.CopyBottom)
            {
                y = menu.MenuOffset.Y + menu.MenuSize.Y - this.Size.Y;
            }
            if (v == VerticalAlign.Bottom)
            {
                y = menu.MenuOffset.Y + menu.MenuSize.Y - this.Size.Y - margin;
            }

            this.Position = new Vector2(x, y);
        }
 public VerticalLayout(VerticalAlign alignment)
 {
     align = alignment;
 }
Example #32
0
 /// <summary>
 /// Set vertical-align attribute of htm element
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public HtmlStyleBuilder Valign(VerticalAlign value)
 {
     if (value == VerticalAlign.NotSet)
         Remove("vertical-align");
     MergeAttribute("vertical-align", value.ToString().ToLower(), true);
     return this;
 }
Example #33
0
            public WatermarkTextTransformation(
                string text,
                Color fontColor,
                int fontSize,
                FontStyle fontStyle,
                FontFamily fontFamily,
                HorizontalAlign alignX,
                VerticalAlign alignY,
                int padding)
                : base(alignX, alignY, padding) {

                Text = text;
                FontColor = fontColor;
                FontSize = fontSize;
                FontStyle = fontStyle;
                FontFamily = fontFamily;
            }
Example #34
0
 public UIStyleInfo Align(HorizontalAlign halign, VerticalAlign valign)
 {
     _horizontalAlign = halign;
     _verticalAlign   = valign;
     return(this);
 }
Example #35
0
 /// <summary>
 /// Create a standard font text without explicit rotation
 /// </summary>
 public Text(string text, Vector2 position, Vector2 bottomRight, Color color, Vector2 scale, StandardFont font, HorizontalAlign horizontalAlign = HorizontalAlign.Left, VerticalAlign verticalAlign = VerticalAlign.Top, float fRotation = 0.0f) : this(text, position, bottomRight, color, scale, font, horizontalAlign, verticalAlign, fRotation, Vector2.Zero)
 {
 }
Example #36
0
 public UIStyleInfo VerticalAlign(VerticalAlign align)
 {
     _verticalAlign = align;
     return(this);
 }
Example #37
0
		void AddTextWithShadow( GuiRenderer renderer, Engine.Renderer.Font font, string text, Vec2 position,
			HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, ColorValue color )
		{
			Vec2 shadowOffset = 2.0f / renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();

			renderer.AddText( font, text, position + shadowOffset, horizontalAlign, verticalAlign,
				new ColorValue( 0, 0, 0, color.Alpha / 2 ) );
			renderer.AddText( font, text, position, horizontalAlign, verticalAlign, color );
		}
Example #38
0
        public Rect GetCharacterRect(Vector2 position, string text, int index, HorizontalAlign halign, VerticalAlign valign)
        {
            Rect r = new Rect();

            r.Position = getCharacterPosition(position, text, index, halign, valign);
            r.Size.Y   = Baseline;
            if (index == text.Length)
            {
                r.Size.X = _charWidth[0];
            }
            else
            {
                if (text[index] == ' ')
                {
                    r.Size.X = SpaceWidth;
                }
                else
                {
                    int ci = GetCharacterIndex(text[index]);
                    if (ci == -1)
                    {
                        ci = 0;
                    }
                    r.Size.X = _charWidth[ci];
                }
            }
            return(r);
        }
Example #39
0
 internal TextRun(string text, FontStyle fontStyle, FontVariant fontVariant, FontWeight fontWeight, TextDecoration textDecoration, VerticalAlign verticalAlign)
     : base(string.IsNullOrEmpty(text))
 {
     // init
     this.Text           = text;
     this.FontStyle      = fontStyle;
     this.FontVariant    = fontVariant;
     this.FontWeight     = fontWeight;
     this.TextDecoration = textDecoration;
     this.VerticalAlign  = verticalAlign;
 }
Example #40
0
        /// <summary>
        /// Get the position of the upper left corner of a glyph when drawing text at a certain position with a certain alignment
        /// </summary>
        /// <param name="position">The position to draw the text</param>
        /// <param name="text">The text to draw</param>
        /// <param name="index">The index of the character in question</param>
        /// <returns></returns>
        Vector2 getCharacterPosition(Vector2 position, string text, int index, HorizontalAlign halign, VerticalAlign valign)
        {
            int line      = 0;
            int lineStart = 0;

            for (int i = 0; i <= index && i < text.Length; i++)
            {
                if (text[i] == '\n')
                {
                    line++;
                    lineStart = i + 1;
                }
            }
            float height = getTextHeight(text);
            int   start  = lineStart;
            float width  = getLineWidth(text, ref start, index);

            start = lineStart;
            float lineWidth = getLineWidth(text, ref start);

            position.Y += line * (Baseline + LineSpacing);
            switch (valign)
            {
            case VerticalAlign.Middle:
                position.Y -= (int)height / 2;
                break;

            case VerticalAlign.Bottom:
                position.Y -= height;
                break;
            }
            position.X += width;
            switch (halign)
            {
            case HorizontalAlign.Center:
                position.X -= (int)lineWidth / 2;
                break;

            case HorizontalAlign.Right:
                position.X -= lineWidth;
                break;
            }
            return(position);
        }
Example #41
0
 public static bool DrawText(string text, Vector2 position, Vector2 bottomRight, Color color, Vector2 scale, StandardFont font, HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, float fRotation, Vector2 fRotationCenter, bool clip = false, bool wordBreak = false, bool postGUI = false, bool colorCoded = false, bool subPixelPositioning = false)
 {
     return(MtaClient.DxDrawText(text, position.X, position.Y, bottomRight.X, bottomRight.Y, color.Hex, scale.X, scale.Y, font.ToString().ToLower(), horizontalAlign.ToString().ToLower(), verticalAlign.ToString().ToLower(), clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenter.X, fRotationCenter.Y));
 }
Example #42
0
        public void DrawString(UI ui, Matrix projection, Vector2 position, string text, Color color, HorizontalAlign halign = HorizontalAlign.Left, VerticalAlign valign = VerticalAlign.Top)
        {
            position.Floor();
            Material.ProjectionMatrix = projection;
            Material.Tint             = color;
            if (valign != VerticalAlign.Top)
            {
                float height = getTextHeight(text);
                if (valign == VerticalAlign.Middle)
                {
                    height = (int)height / 2;
                }
                position.Y -= height;
            }
            int i = 0;

            while (i < text.Length)
            {
                drawLine(ui, position, text, ref i, halign);
                position.Y += Baseline + LineSpacing;
            }
        }
Example #43
0
        // Made non-virtual, since it may be confusing to override this method when it's style
        // is rendered by RenderWebPart.
        private void RenderTitleBar(HtmlTextWriter writer, WebPart webPart)
        {
            // Can't apply title style here, since the border would be inside the cell padding
            // of the parent td.
            // titleStyle.AddAttributesToRender(writer, this);
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");

            // Want table to span full width of part for drag and drop
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");

            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            int    colspan           = 1;
            bool   showTitleIcons    = Zone.ShowTitleIcons;
            string titleIconImageUrl = null;

            if (showTitleIcons)
            {
                titleIconImageUrl = webPart.TitleIconImageUrl;
                if (!String.IsNullOrEmpty(titleIconImageUrl))
                {
                    colspan++;
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    RenderTitleIcon(writer, webPart);
                    writer.RenderEndTag();  // Td
                }
            }

            // title text
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");

            TableItemStyle titleStyle = Zone.PartTitleStyle;

            // Render align and wrap from the TableItemStyle (copied from TableItemStyle.cs)
            if (titleStyle.Wrap == false)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            }
            HorizontalAlign hAlign = titleStyle.HorizontalAlign;

            if (hAlign != HorizontalAlign.NotSet)
            {
                TypeConverter hac = TypeDescriptor.GetConverter(typeof(HorizontalAlign));
                writer.AddAttribute(HtmlTextWriterAttribute.Align, hac.ConvertToString(hAlign).ToLower(CultureInfo.InvariantCulture));
            }
            VerticalAlign vAlign = titleStyle.VerticalAlign;

            if (vAlign != VerticalAlign.NotSet)
            {
                TypeConverter vac = TypeDescriptor.GetConverter(typeof(VerticalAlign));
                writer.AddAttribute(HtmlTextWriterAttribute.Valign, vac.ConvertToString(vAlign).ToLower(CultureInfo.InvariantCulture));
            }

            if (Zone.RenderClientScript)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, GetWebPartTitleClientID(webPart));
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            if (showTitleIcons)
            {
                if (!String.IsNullOrEmpty(titleIconImageUrl))
                {
                    // Render &nbsp; so there is a space between the icon and the title text
                    // Can't be rendered in RenderTitleIcon(), since we want the space to be a valid drag target
                    writer.Write("&nbsp;");
                }
            }

            RenderTitleText(writer, webPart);

            writer.RenderEndTag();  // Td

            RenderVerbsInTitleBar(writer, webPart, colspan);

            writer.RenderEndTag();  // Tr
            writer.RenderEndTag();  // Table
        }
Example #44
0
 public void SetDefaultCellData(string Css, HorizontalAlign HAlign, VerticalAlign VAlign, int CellSpan, int RowSpan, int Height)
 {
     m_Css = Css;
     m_HAlign = HAlign;
     m_VAlign = VAlign;
     m_CellSpan = CellSpan;
     m_RowSpan = RowSpan;
     m_Height = Height;
 }
    /// <summary>
    /// Prepares the layout of the web part.
    /// </summary>
    protected override void PrepareLayout()
    {
        // Prepare the main markup
        StartLayout();

        string style = null;

        // Table width
        string width         = TableWidth;
        bool   hasTableWidth = false;

        if (!String.IsNullOrEmpty(width))
        {
            style        += "width: " + width;
            hasTableWidth = true;
        }

        if (IsDesign)
        {
            Append("<table class=\"LayoutTable\" cellspacing=\"0\"");

            // Append style
            if (!String.IsNullOrEmpty(style))
            {
                Append(" style=\"");
                Append(style);
                Append("\"");
            }

            Append(">");

            if (ViewModeIsDesign())
            {
                Append("<tr><td class=\"LayoutHeader\">");

                // Add header container
                AddHeaderContainer();

                Append("</td></tr>");
            }

            Append("<tr><td>");
        }

        Append("<table cellspacing=\"0\" ");

        // Add table class
        string tableClass = TableCSSClass;

        if (!String.IsNullOrEmpty(tableClass))
        {
            Append(" class=\"");
            Append(tableClass);
            Append("\"");
        }

        // Append style
        if (!String.IsNullOrEmpty(style))
        {
            Append(" style=\"");
            Append(style);
            Append("\"");
        }

        Append(">");

        string heightPropertyName = null;
        string widthPropertyName  = null;

        // Prepare vertical alignment
        string valign = null;

        switch (VerticalAlign.ToLowerCSafe())
        {
        case "top":
        case "middle":
        case "bottom":
            valign = VerticalAlign.ToLowerCSafe();
            break;
        }

        bool hasEmptyColumn = false;

        // Add the rows
        for (int j = 1; j <= Rows; j++)
        {
            // Set the height property
            heightPropertyName = "Row" + j + "Height";

            Append("<tr");

            // Prepare the class for the row
            string thisRowClass = ValidationHelper.GetString(GetValue("Row" + j + "CSSClass"), "");
            if (!String.IsNullOrEmpty(thisRowClass))
            {
                Append(" class=\"");
                Append(thisRowClass);
                Append("\"");
            }

            Append(">");

            // Add the columns
            int cols = Columns;
            for (int i = 1; i <= cols; i++)
            {
                // Set the width property
                widthPropertyName = "Column" + i + "Width";

                Append("<td");

                // Cell class
                string thisColumnClass = ValidationHelper.GetString(GetValue("Column" + i + "CSSClass"), "");
                if (!String.IsNullOrEmpty(thisColumnClass))
                {
                    Append(" class=\"");
                    Append(thisColumnClass);
                    Append("\"");
                }

                style = null;

                // Add vertical alignment
                if (!String.IsNullOrEmpty(valign))
                {
                    style += "vertical-align: " + valign + ";";
                }

                // Column width
                if (j == 1)
                {
                    width = ValidationHelper.GetString(GetValue(widthPropertyName), "");
                    if (!String.IsNullOrEmpty(width))
                    {
                        if (!IsDesign || (i < cols) || !hasTableWidth || hasEmptyColumn)
                        {
                            style += " width: " + width + ";";
                        }
                    }
                    else
                    {
                        hasEmptyColumn = true;
                    }
                }

                // Row height
                if (i == 1)
                {
                    string height = ValidationHelper.GetString(GetValue(heightPropertyName), "");
                    if (!String.IsNullOrEmpty(height))
                    {
                        style += " height: " + height + ";";
                    }
                }

                // Append style
                if (!String.IsNullOrEmpty(style))
                {
                    Append(" style=\"");
                    Append(style);
                    Append("\"");
                }

                if (IsDesign)
                {
                    string cellId = "cell-" + j + "-" + i;
                    Append(" id=\"" + ShortClientID + "_" + cellId + "\"");
                }

                Append(">");

                // Add the zone
                AddZone(ID + "_" + j + "_" + i, "[" + j + "," + i + "]");

                Append("</td>");

                if (IsDesign && AllowDesignMode)
                {
                    Append("<td class=\"HorizontalResizer\" onmousedown=\"" + GetHorizontalResizerScript("cell-1-" + i, widthPropertyName, false, "cell-" + j + "-" + i) + " return false;\">&nbsp;</td>");
                }
            }

            Append("</tr>");

            if (IsDesign && AllowDesignMode)
            {
                Append("<tr>");

                // Add the columns
                for (int i = 1; i <= Columns; i++)
                {
                    // Set the width property
                    widthPropertyName = "Column" + i + "Width";

                    Append("<td class=\"VerticalResizer\" onmousedown=\"" + GetVerticalResizerScript("cell-" + j + "-1", heightPropertyName, "cell-" + j + "-" + i) + " return false;\">&nbsp;</td>");
                    Append("<td class=\"BothResizer\" onmousedown=\"" + GetHorizontalResizerScript("cell-1-" + i, widthPropertyName, false, "cell-" + j + "-" + i) + " " + GetVerticalResizerScript("cell-" + j + "-1", heightPropertyName, "cell-" + j + "-" + i) + " return false;\">&nbsp;</td>");
                }

                Append("</tr>");
            }
        }

        Append("</table>");

        if (IsDesign)
        {
            Append("</td></tr>");

            // Footer
            if (AllowDesignMode)
            {
                Append("<tr><td class=\"LayoutFooter cms-bootstrap\"><div class=\"LayoutFooterContent\">");

                // Row actions
                Append("<div class=\"LayoutLeftActions\">");
                AppendAddAction(ResHelper.GetString("Layout.AddRow"), "Rows");
                if (Rows > 1)
                {
                    AppendRemoveAction(ResHelper.GetString("Layout.RemoveRow"), "Rows");
                }
                Append("</div>");

                // Column actions
                Append("<div class=\"LayoutRightActions\">");
                AppendAddAction(ResHelper.GetString("Layout.AddColumn"), "Columns");
                if (Columns > 1)
                {
                    AppendRemoveAction(ResHelper.GetString("Layout.RemoveColumn"), "Columns");
                }
                Append("</div>");
                Append("<div class=\"ClearBoth\"></div>");

                Append("</div></td></tr>");
            }

            Append("</table>");
        }

        // Finalize
        FinishLayout();
    }
Example #46
0
        public static int addText(BlockArea ba, FontState fontState, float red,
                                  float green, float blue, WrapOption wrapOption,
                                  LinkSet ls, int whiteSpaceCollapse,
                                  char[] data, int start, int end,
                                  TextState textState, VerticalAlign vAlign)
        {
            if (fontState.FontVariant == FontVariant.SMALL_CAPS)
            {
                FontState smallCapsFontState;
                try
                {
                    int smallCapsFontHeight =
                        (int)(((double)fontState.FontSize) * 0.8d);
                    smallCapsFontState = new FontState(fontState.FontInfo,
                                                       fontState.FontFamily,
                                                       fontState.FontStyle,
                                                       fontState.FontWeight,
                                                       smallCapsFontHeight,
                                                       FontVariant.NORMAL);
                }
                catch (FonetException ex)
                {
                    smallCapsFontState = fontState;
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Error creating small-caps FontState: " + ex.Message);
                }

                char      c;
                bool      isLowerCase;
                int       caseStart;
                FontState fontStateToUse;
                for (int i = start; i < end;)
                {
                    caseStart   = i;
                    c           = data[i];
                    isLowerCase = (Char.IsLetter(c) && Char.IsLower(c));
                    while (isLowerCase == (Char.IsLetter(c) && Char.IsLower(c)))
                    {
                        if (isLowerCase)
                        {
                            data[i] = Char.ToUpper(c);
                        }
                        i++;
                        if (i == end)
                        {
                            break;
                        }
                        c = data[i];
                    }
                    if (isLowerCase)
                    {
                        fontStateToUse = smallCapsFontState;
                    }
                    else
                    {
                        fontStateToUse = fontState;
                    }
                    int index = addRealText(ba, fontStateToUse, red, green, blue,
                                            wrapOption, ls, whiteSpaceCollapse,
                                            data, caseStart, i, textState,
                                            vAlign);
                    if (index != -1)
                    {
                        return(index);
                    }
                }

                return(-1);
            }

            return(addRealText(ba, fontState, red, green, blue, wrapOption, ls,
                               whiteSpaceCollapse, data, start, end, textState,
                               vAlign));
        }
Example #47
0
        public override Status Layout(Area area)
        {
            if (this.marker == MarkerBreakAfter)
            {
                return(new Status(Status.OK));
            }

            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                string        id       = this.properties.GetId();
                TextAlign     align    = this.properties.GetTextAlign();
                VerticalAlign valign   = properties.GetVerticalAlign();
                Overflow      overflow = properties.GetOverflow();

                this.breakBefore = this.properties.GetProperty("break-before").GetEnum();
                this.breakAfter  = this.properties.GetProperty("break-after").GetEnum();
                this.width       = this.properties.GetProperty("width").GetLength().MValue();
                this.height      = this.properties.GetProperty("height").GetLength().MValue();
                this.contwidth   =
                    this.properties.GetProperty("content-width").GetLength().MValue();
                this.contheight =
                    this.properties.GetProperty("content-height").GetLength().MValue();
                this.wauto  = this.properties.GetProperty("width").GetLength().IsAuto();
                this.hauto  = this.properties.GetProperty("height").GetLength().IsAuto();
                this.cwauto =
                    this.properties.GetProperty("content-width").GetLength().IsAuto();
                this.chauto =
                    this.properties.GetProperty("content-height").GetLength().IsAuto();

                this.startIndent =
                    this.properties.GetProperty("start-indent").GetLength().MValue();
                this.endIndent =
                    this.properties.GetProperty("end-indent").GetLength().MValue();
                this.spaceBefore =
                    this.properties.GetProperty("space-before.optimum").GetLength().MValue();
                this.spaceAfter =
                    this.properties.GetProperty("space-after.optimum").GetLength().MValue();

                this.scaling = this.properties.GetProperty("scaling").GetEnum();

                area.getIDReferences().CreateID(id);
                if (this.areaCurrent == null)
                {
                    this.areaCurrent =
                        new ForeignObjectArea(propMgr.GetFontState(area.getFontInfo()),
                                              area.getAllocationWidth());

                    this.areaCurrent.start();
                    areaCurrent.SetWidth(this.width);
                    areaCurrent.SetHeight(this.height);
                    areaCurrent.SetContentWidth(this.contwidth);
                    areaCurrent.setContentHeight(this.contheight);
                    areaCurrent.setScaling(this.scaling);
                    areaCurrent.setAlign(align);
                    areaCurrent.setVerticalAlign(valign);
                    areaCurrent.setOverflow(overflow);
                    areaCurrent.setSizeAuto(wauto, hauto);
                    areaCurrent.setContentSizeAuto(cwauto, chauto);

                    areaCurrent.setPage(area.getPage());

                    int numChildren = this.children.Count;
                    if (numChildren > 1)
                    {
                        throw new FonetException("Only one child element is allowed in an instream-foreign-object");
                    }
                    if (this.children.Count > 0)
                    {
                        FONode fo = (FONode)children[0];
                        Status status;
                        if ((status =
                                 fo.Layout(this.areaCurrent)).isIncomplete())
                        {
                            return(status);
                        }
                        this.areaCurrent.end();
                    }
                }

                this.marker = 0;

                if (breakBefore == BreakBefore.PAGE ||
                    ((spaceBefore + areaCurrent.getEffectiveHeight())
                     > area.spaceLeft()))
                {
                    return(new Status(Status.FORCE_PAGE_BREAK));
                }

                if (breakBefore == BreakBefore.ODD_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_ODD));
                }

                if (breakBefore == BreakBefore.EVEN_PAGE)
                {
                    return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
                }
            }

            if (this.areaCurrent == null)
            {
                return(new Status(Status.OK));
            }

            if (area is BlockArea)
            {
                BlockArea ba = (BlockArea)area;
                LineArea  la = ba.getCurrentLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.addPending();
                if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth())
                {
                    la = ba.createNextLineArea();
                    if (la == null)
                    {
                        return(new Status(Status.AREA_FULL_NONE));
                    }
                }
                la.addInlineArea(areaCurrent, GetLinkSet());
            }
            else
            {
                area.addChild(areaCurrent);
                area.increaseHeight(areaCurrent.getEffectiveHeight());
            }

            if (this.isInTableCell)
            {
                startIndent += forcedStartOffset;
            }

            areaCurrent.setStartIndent(startIndent);
            areaCurrent.setPage(area.getPage());

            if (breakAfter == BreakAfter.PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK));
            }

            if (breakAfter == BreakAfter.ODD_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK_ODD));
            }

            if (breakAfter == BreakAfter.EVEN_PAGE)
            {
                this.marker = MarkerBreakAfter;
                return(new Status(Status.FORCE_PAGE_BREAK_EVEN));
            }

            areaCurrent = null;
            return(new Status(Status.OK));
        }
Example #48
0
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetError(
                    "Text outside block area" + new String(ca, start, length));
                return(new Status(Status.OK));
            }
            if (this.marker == MarkerStart)
            {
                string fontFamily =
                    this.parent.properties.GetProperty("font-family").GetString();
                string fontStyle =
                    this.parent.properties.GetProperty("font-style").GetString();
                string fontWeight =
                    this.parent.properties.GetProperty("font-weight").GetString();
                int fontSize =
                    this.parent.properties.GetProperty("font-size").GetLength().MValue();
                int fontVariant =
                    this.parent.properties.GetProperty("font-variant").GetEnum();

                int letterSpacing =
                    this.parent.properties.GetProperty("letter-spacing").GetLength().MValue();
                this.fs = new FontState(area.getFontInfo(), fontFamily,
                                        fontStyle, fontWeight, fontSize,
                                        fontVariant, letterSpacing);

                ColorType c = this.parent.properties.GetProperty("color").GetColorType();
                this.red   = c.Red;
                this.green = c.Green;
                this.blue  = c.Blue;

                this.verticalAlign =
                    this.parent.properties.GetVerticalAlign();

                this.wrapOption =
                    (WrapOption)this.parent.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.parent.properties.GetProperty("white-space-collapse").GetEnum();
                this.ts = new TextState();
                ts.setUnderlined(underlined);
                ts.setOverlined(overlined);
                ts.setLineThrough(lineThrough);

                this.marker = this.start;
            }
            int orig_start = this.marker;

            this.marker = addText((BlockArea)area, fs, red, green, blue,
                                  wrapOption, this.GetLinkSet(),
                                  whiteSpaceCollapse, ca, this.marker, length,
                                  ts, verticalAlign);
            if (this.marker == -1)
            {
                return(new Status(Status.OK));
            }
            else if (this.marker != orig_start)
            {
                return(new Status(Status.AREA_FULL_SOME));
            }
            else
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
        }
Example #49
0
 public WatermarkTransformation(HorizontalAlign alignX, VerticalAlign alignY, int padding) {
     HorizontalAlign = alignX;
     VerticalAlign = alignY;
     Padding = padding;
 }
Example #50
0
        public static System.Drawing.Image CreateWatermark(this System.Drawing.Image originalImg, System.Drawing.Image watermarkImg, HorizontalAlign align, VerticalAlign valign)
        {
            int x    = 0;
            int y    = 0;
            int num3 = originalImg.Width - watermarkImg.Width;
            int num4 = originalImg.Height - watermarkImg.Height;

            switch (align)
            {
            case HorizontalAlign.Left:
                x = 5;
                break;

            case HorizontalAlign.Center:
                x = ((num3 / 2) <= 5) ? 5 : (num3 / 2);
                break;

            case HorizontalAlign.Right:
                x = (num3 <= 10) ? 5 : (num3 - 5);
                break;

            default:
                x = 5;
                break;
            }
            switch (valign)
            {
            case VerticalAlign.Top:
                y = 5;
                break;

            case VerticalAlign.Middle:
                y = ((num4 / 2) <= 5) ? 5 : (num4 / 2);
                break;

            case VerticalAlign.Bottom:
                y = (num4 <= 10) ? 5 : (num4 - 5);
                break;

            default:
                y = 5;
                break;
            }
            return(originalImg.CreateWatermark(watermarkImg, x, y));
        }
Example #51
0
            public WatermarkImageTransformation(
                WebImage image,
                int width,
                int height,
                HorizontalAlign horizontalAlign,
                VerticalAlign verticalAlign,
                int opacity,
                int padding)
                : base(horizontalAlign, verticalAlign, padding) {

                WatermarkImage = image;
                Width = width;
                Height = height;
                Opacity = opacity;
            }
Example #52
0
        public static System.Drawing.Image CreateWatermark(this System.Drawing.Image originalImg, string text, HorizontalAlign align, VerticalAlign valign)
        {
            int  x    = 0;
            int  y    = 0;
            Font font = new Font("Arial", 10f);
            int  num3 = originalImg.Width - ((int)(font.SizeInPoints * text.Length));
            int  num4 = originalImg.Height - ((int)(font.SizeInPoints * 2f));

            switch (align)
            {
            case HorizontalAlign.Left:
                x = 5;
                break;

            case HorizontalAlign.Center:
                x = ((num3 / 2) <= 5) ? 5 : (num3 / 2);
                break;

            case HorizontalAlign.Right:
                x = (num3 <= 10) ? 5 : (num3 - 5);
                break;

            default:
                x = 5;
                break;
            }
            switch (valign)
            {
            case VerticalAlign.Top:
                y = 5;
                break;

            case VerticalAlign.Middle:
                y = ((num4 / 2) <= 5) ? 5 : (num4 / 2);
                break;

            case VerticalAlign.Bottom:
                y = (num4 <= 10) ? 5 : (num4 - 5);
                break;

            default:
                y = 5;
                break;
            }
            font.Dispose();
            return(originalImg.CreateWatermark(text, x, y));
        }
Example #53
0
 /// <summary>
 /// Create a text object with a standard font
 /// </summary>
 public Text(string text, Vector2 position, Vector2 bottomRight, Color color, Vector2 scale, StandardFont font, HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, float fRotation, Vector2 fRotationCenter, bool clip = false, bool wordBreak = false, bool postGUI = false, bool colorCoded = false, bool subPixelPositioning = false)
 {
     Content             = text;
     Position            = position;
     Color               = color;
     Scale               = scale;
     StandardFont        = font;
     HorizontalAlignment = horizontalAlign;
     VerticalAlignment   = verticalAlign;
     Rotation            = fRotation;
     RotationOrigin      = fRotationCenter;
     SubPixelPositioning = subPixelPositioning;
     PostGUI             = postGUI;
     Clip          = clip;
     WordBreak     = wordBreak;
     ColorCoded    = colorCoded;
     useCustomFont = false;
     BottomRight   = bottomRight;
 }
            public virtual void Init(float size, float width, float height,
		Style style, Align align, VerticalAlign verticalAlign,
		float lineSpacing, float letterSpacing, float leftMargin,
		float rightMargin)
            {
            }
Example #55
0
 public void SetVerticle(int v)
 {
     verticalAlign = (VerticalAlign)v;
 }
Example #56
0
            public override void LoadFormatInfo()
            {
                HorizontalAlign horizontalAlign;
                Color           backColor = this.runtimeStyle.BackColor;

                this.backColor = ColorTranslator.ToHtml(backColor);
                backColor      = this.runtimeStyle.ForeColor;
                this.foreColor = ColorTranslator.ToHtml(backColor);
                FontInfo font = this.runtimeStyle.Font;

                this.fontName        = font.Name;
                this.fontNameChanged = false;
                this.bold            = font.Bold;
                this.italic          = font.Italic;
                this.underline       = font.Underline;
                this.strikeOut       = font.Strikeout;
                this.overline        = font.Overline;
                this.fontType        = -1;
                FontUnit size = font.Size;

                if (!size.IsEmpty)
                {
                    this.fontSize = null;
                    switch (size.Type)
                    {
                    case FontSize.AsUnit:
                        this.fontType = 10;
                        this.fontSize = size.ToString(CultureInfo.CurrentCulture);
                        break;

                    case FontSize.Smaller:
                        this.fontType = 1;
                        break;

                    case FontSize.Larger:
                        this.fontType = 2;
                        break;

                    case FontSize.XXSmall:
                        this.fontType = 3;
                        break;

                    case FontSize.XSmall:
                        this.fontType = 4;
                        break;

                    case FontSize.Small:
                        this.fontType = 5;
                        break;

                    case FontSize.Medium:
                        this.fontType = 6;
                        break;

                    case FontSize.Large:
                        this.fontType = 7;
                        break;

                    case FontSize.XLarge:
                        this.fontType = 8;
                        break;

                    case FontSize.XXLarge:
                        this.fontType = 9;
                        break;
                    }
                }
                TableItemStyle runtimeStyle = null;

                if (this.runtimeStyle is TableItemStyle)
                {
                    runtimeStyle       = (TableItemStyle)this.runtimeStyle;
                    horizontalAlign    = runtimeStyle.HorizontalAlign;
                    this.allowWrapping = runtimeStyle.Wrap;
                }
                else
                {
                    horizontalAlign = ((TableStyle)this.runtimeStyle).HorizontalAlign;
                }
                this.horzAlignment = 0;
                switch (horizontalAlign)
                {
                case HorizontalAlign.Left:
                    this.horzAlignment = 1;
                    break;

                case HorizontalAlign.Center:
                    this.horzAlignment = 2;
                    break;

                case HorizontalAlign.Right:
                    this.horzAlignment = 3;
                    break;

                case HorizontalAlign.Justify:
                    this.horzAlignment = 4;
                    break;
                }
                if (runtimeStyle != null)
                {
                    VerticalAlign verticalAlign = runtimeStyle.VerticalAlign;
                    this.vertAlignment = 0;
                    switch (verticalAlign)
                    {
                    case VerticalAlign.Top:
                        this.vertAlignment = 1;
                        return;

                    case VerticalAlign.Middle:
                        this.vertAlignment = 2;
                        return;

                    case VerticalAlign.Bottom:
                        this.vertAlignment = 3;
                        break;

                    default:
                        return;
                    }
                }
            }
Example #57
0
        /// <summary>
        /// Adds text watermark to a WebImage.
        /// </summary>
        /// <param name="text">Text to use as a watermark.</param>
        /// <param name="fontColor">Watermark color. Can be specified as a string (e.g. "White") or as a hex value (e.g. "#00FF00").</param>
        /// <param name="fontSize">Font size in points.</param>
        /// <param name="fontStyle">Font style: bold, italics, etc.</param>
        /// <param name="fontFamily">Font family name: e.g. Microsoft Sans Serif</param>
        /// <param name="horizontalAlign">Horizontal alignment for watermark text. Can be "right", "left", or "center".</param>
        /// <param name="verticalAlign">Vertical alignment for watermark text. Can be "top", "bottom", or "middle".</param>
        /// <param name="opacity">Watermark text opacity. Should be between 0 and 100.</param>
        /// <param name="padding">Size of padding around watermark text in pixels.</param>
        /// <returns>Modified WebImage instance with added watermark.</returns>
        public WebImage AddTextWatermark(
            string text,
            string fontColor       = "Black",
            int fontSize           = 12,
            string fontStyle       = "Regular",
            string fontFamily      = "Microsoft Sans Serif",
            string horizontalAlign = "Right",
            string verticalAlign   = "Bottom",
            int opacity            = 100,
            int padding            = 5)
        {
            if (String.IsNullOrEmpty(text))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "text");
            }

            Color color;

            if (!ConversionUtil.TryFromStringToColor(fontColor, out color))
            {
                throw new ArgumentException(HelpersResources.WebImage_IncorrectColorName);
            }

            if ((opacity < 0) || (opacity > 100))
            {
                throw new ArgumentOutOfRangeException("opacity", String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_Between, 0, 100));
            }

            int alpha = 255 * opacity / 100;

            color = Color.FromArgb(alpha, color);

            if (fontSize <= 0)
            {
                throw new ArgumentOutOfRangeException(
                          "fontSize",
                          String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThan, 0));
            }

            FontStyle fontStyleEnum;

            if (!ConversionUtil.TryFromStringToEnum(fontStyle, out fontStyleEnum))
            {
                throw new ArgumentException(HelpersResources.WebImage_IncorrectFontStyle);
            }

            FontFamily fontFamilyClass;

            if (!ConversionUtil.TryFromStringToFontFamily(fontFamily, out fontFamilyClass))
            {
                throw new ArgumentException(HelpersResources.WebImage_IncorrectFontFamily);
            }

            HorizontalAlign horizontalAlignEnum = ParseHorizontalAlign(horizontalAlign);
            VerticalAlign   verticalAlignEnum   = ParseVerticalAlign(verticalAlign);

            if (padding < 0)
            {
                throw new ArgumentOutOfRangeException(
                          "padding",
                          String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, 0));
            }

            WatermarkTextTransformation transformation =
                new WatermarkTextTransformation(text, color, fontSize, fontStyleEnum, fontFamilyClass, horizontalAlignEnum, verticalAlignEnum, padding);

            _transformations.Add(transformation);
            return(this);
        }
Example #58
0
 /// <summary>
 /// Set the vertical alignment of text
 /// </summary>
 public bool SetVerticalAlign(VerticalAlign alignment)
 {
     return(MtaClient.GuiLabelSetVerticalAlign(element, alignment.ToString().ToLower()));
 }
	public virtual void Init(float size,
		float width,
		float height,
		Style style,
		Align align = Align.LEFT,
		VerticalAlign verticalAlign = VerticalAlign.TOP,
		float lineSpacing = 1.0f,
		float letterSpacing = 0.0f,
		float leftMargin = 0.0f,
		float rightMargin = 0.0f)
	{
		mSize = size;
		mWidth = width;
		mHeight = height;
		mStyle = style;
		mAlign = align;
		mVerticalAlign = verticalAlign;
		mLetterSpacing = letterSpacing;
		mLineSpacing = lineSpacing;
		mLeftMargin = leftMargin;
		mRightMargin = rightMargin;
		mEmpty = true;

		mTexture2D = new Texture2D(8, 8, TextureFormat.Alpha8, false);
		mTexture2D.Apply(true, true);
		mTexture2D.filterMode = FilterMode.Bilinear;
		mTexture2D.anisoLevel = 1;
		mTexture2D.wrapMode = TextureWrapMode.Clamp;

		mMaterial = new Material(Shader.Find("SystemFont"));
		mMaterial.mainTexture = mTexture2D;
		mMaterial.color = new UnityEngine.Color(1, 1, 1, 1);

		Vector3[] vertices = new Vector3[4];
		Vector2[] uv = new Vector2[4];
		int[] triangles = new int[6];

		int w = 1;
		int h = 1;
		while (w < width)
			w <<= 1;
		while (h < height)
			h <<= 1;

		vertices[0] = new Vector3(w, -h, 0);
		vertices[1] = new Vector3(w, 0, 0);
		vertices[2] = new Vector3(0, -h, 0);
		vertices[3] = new Vector3(0, 0, 0);

		float w2 = 2.0f * w;
		float u0 = 1.0f / w2;
		float u1 = u0 + (float)(w * 2 - 2) / w2;
		float h2 = 2.0f * h;
		float v0 = 1.0f / h2;
		float v1 = v0 + (float)(h * 2 - 2) / h2;

		uv[0] = new Vector2(u1, v0);
		uv[1] = new Vector2(u1, v1);
		uv[2] = new Vector2(u0, v0);
		uv[3] = new Vector2(u0, v1);

		triangles[0] = 0;
		triangles[1] = 1;
		triangles[2] = 2;
		triangles[3] = 2;
		triangles[4] = 1;
		triangles[5] = 3;

		mMesh = new Mesh();
		mMesh.vertices = vertices;
		mMesh.uv = uv;
		mMesh.triangles = triangles;
		mMesh.RecalculateBounds();

		mProperty = new MaterialPropertyBlock();

		mInitialized = true;

		if (mText != null)
			SetText(mText, mColor);
	}
Example #60
0
 public void SetDefaultCellData(string Css, HorizontalAlign HAlign, VerticalAlign VAlign, int CellSpan)
 {
     m_Css = Css;
     m_HAlign = HAlign;
     m_VAlign = VAlign;
     m_CellSpan = CellSpan;
 }