コード例 #1
1
ファイル: RtfTableCell.cs プロジェクト: peterson1/ErrH
		internal RtfTableCell(float width, int rowIndex, int colIndex, RtfTable parentTable)
			: base(true, false)
		{
			_width = width;
			_halign = Align.None;
			_valign = AlignVertical.Top;
			_borders = new Borders();
			_mergeInfo = null;
			_rowIndex = rowIndex;
			_colIndex = colIndex;
			BackgroundColour = null;
			ParentTable = parentTable;
		}
コード例 #2
0
    public static void SetVerticalAlign(this IEnumerable <Transform> elements, AlignVertical alignVertical)
    {
        float target;

        switch (alignVertical)
        {
        case AlignVertical.Top:

            target = elements.Select(_ => _.position.y).Max();

            foreach (var el in elements)
            {
                el.position = new Vector3(el.position.x, target, el.position.z);
            }

            break;

        case AlignVertical.Center:

            target = (elements.Select(_ => _.position.y).Min() + elements.Select(_ => _.position.y).Max()) / 2F;

            foreach (var el in elements)
            {
                el.position = new Vector3(el.position.x, target, el.position.z);
            }

            break;

        case AlignVertical.Bottom:

            target = elements.Select(_ => _.position.y).Min();

            foreach (var el in elements)
            {
                el.position = new Vector3(el.position.x, target, el.position.z);
            }

            break;

        case AlignVertical.Average:

            if (elements.Count() <= 1)
            {
                throw new Exception("You have to select more than 1 object.");
            }

            float min = elements.Select(_ => _.position.y).Min();
            float max = elements.Select(_ => _.position.y).Max();

            List <Transform> elList = elements.OrderBy(_ => _.position.y).ToList();
            for (int i = 0; i < elList.Count; i++)
            {
                var item = elList[i];
                item.position = new Vector3(item.position.x, Mathf.Lerp(min, max, (float)i / (elList.Count - 1)), item.position.z);
            }

            break;
        }
    }
コード例 #3
0
		internal RtfTableCell(float width, int rowIndex, int colIndex)
			: base(true, true, false, true, false)
		{
			_width = width;
			_halign = Align.None;
			_valign = AlignVertical.Top;
			_borders = new Borders();
			_mergeInfo = null;
			_rowIndex = rowIndex;
			_colIndex = colIndex;
		}
コード例 #4
0
 public void AddChild(BaseRenderComponent child, AlignVertical alignment)
 {
     child.Width = Width;
     children.Add(new ComponentChild
     {
         alignment = alignment,
         component = child
     });
     child.SetParent(this);
     LayoutInvalidate();
 }
コード例 #5
0
 internal RtfTableCell(float width, int rowIndex, int colIndex)
     : base(true, true, false, true, false)
 {
     _width     = width;
     _halign    = Align.None;
     _valign    = AlignVertical.Top;
     _borders   = new Borders();
     _mergeInfo = null;
     _rowIndex  = rowIndex;
     _colIndex  = colIndex;
 }
コード例 #6
0
 internal RtfTableCell(float width, int rowIndex, int colIndex, RtfTable parentTable)
     : base(true, false)
 {
     _width           = width;
     _halign          = Align.None;
     _valign          = AlignVertical.Top;
     _borders         = new Borders();
     _mergeInfo       = null;
     _rowIndex        = rowIndex;
     _colIndex        = colIndex;
     BackgroundColour = null;
     ParentTable      = parentTable;
 }
コード例 #7
0
        public void setVerticalAlign(AlignVertical align)
        {
            switch (align)
            {
            case AlignVertical.Middle:
            default:
                vertical_align = Element.ALIGN_MIDDLE;
                break;

            case AlignVertical.Top:
                vertical_align = Element.ALIGN_TOP;
                break;

            case AlignVertical.Bottom:
                vertical_align = Element.ALIGN_BOTTOM;
                break;
            }
        }
コード例 #8
0
        /// <summary>
        /// 设置垂直对齐方式
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="align"></param>
        public static void setVerticalAlign(this PdfPCell cell, AlignVertical align)
        {
            switch (align)
            {
            case AlignVertical.Middle:
            default:
                cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                break;

            case AlignVertical.Top:
                cell.VerticalAlignment = Element.ALIGN_TOP;
                break;

            case AlignVertical.Bottom:
                cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                break;
            }
        }
コード例 #9
0
 public void AddChild(BaseRenderComponent child, AlignVertical alignment, int height)
 {
     child.Height = height;
     AddChild(child, alignment);
 }
コード例 #10
0
 public TextComponent(IDrawingContext parent, SdrFontPack font, string text, DisplayPixel color, AlignHorizontal horizontalTextAlign = AlignHorizontal.Left, AlignVertical verticalTextAlign = AlignVertical.Top) : base(parent)
 {
     this.font  = font;
     this.text  = text.ToCharArray();
     this.color = color;
     this.horizontalTextAlign = horizontalTextAlign;
     this.verticalTextAlign   = verticalTextAlign;
 }
コード例 #11
0
 public TextComponent SetTextVerticalAlign(AlignVertical align)
 {
     TextVerticalAlign = align;
     return(this);
 }
コード例 #12
0
 public void RenderPretty(IDrawingContext ctx, char[] text, DisplayPixel color, AlignHorizontal horizTextAlign, AlignVertical vertTextAlign, int boundsWidth, int boundsHeight)
 {
     char[][] lines = SplitLines(text, boundsWidth, boundsHeight);
     RenderPretty(ctx, lines, color, horizTextAlign, vertTextAlign, boundsWidth, boundsHeight);
 }
コード例 #13
0
        public void RenderPretty(IDrawingContext ctx, char[][] text, DisplayPixel color, AlignHorizontal horizTextAlign, AlignVertical vertTextAlign, int boundsWidth, int boundsHeight)
        {
            //Determine Y offset
            int offsetY;

            switch (vertTextAlign)
            {
            case AlignVertical.Top: offsetY = 0; break;

            case AlignVertical.Bottom: offsetY = boundsHeight - (text.Length * height); break;

            case AlignVertical.Center: offsetY = (boundsHeight - (text.Length * height)) / 2; break;

            default: throw new Exception("Unknown alignment.");
            }

            //Draw
            for (int ln = 0; ln < text.Length; ln++)
            {
                //Calculate X offset
                int offsetX;
                switch (horizTextAlign)
                {
                case AlignHorizontal.Left: offsetX = 0; break;

                case AlignHorizontal.Right: offsetX = boundsWidth - (text[ln].Length * width); break;

                case AlignHorizontal.Center: offsetX = (boundsWidth - (text[ln].Length * width)) / 2; break;

                default: throw new Exception("Unknown alignment.");
                }

                //Write
                RenderLine(ctx.GetOffsetContext(offsetX, offsetY + (height * ln)), text[ln], color);
            }
        }