Beispiel #1
0
    public static void SetHorizontalAlign(this IEnumerable <Transform> elements, AlignHorizontal alignHorizontal)
    {
        float target;

        switch (alignHorizontal)
        {
        case AlignHorizontal.Left:

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

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

            break;

        case AlignHorizontal.Center:

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

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

            break;

        case AlignHorizontal.Right:

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

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

            break;


        case AlignHorizontal.Average:

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

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

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

            break;
        }
    }
    /// <summary>
    /// Change opacity (float, NOT int) of 3 Objective stars at top centre
    /// </summary>
    /// <param name="opacity"></param>
    /// <param name="uiPosition"></param>
    public void SetStar(float opacity, AlignHorizontal uiPosition)
    {
        Debug.Assert(opacity >= 0 && opacity <= 100f, string.Format("Invalid opacity \"{0}\"", opacity));
        //convert opacity to 0 to 1.0
        opacity *= 0.01f;
        //change opacity of relevant star
        switch (uiPosition)
        {
        case AlignHorizontal.Left:
            Color tempLeftColor = starLeft.color;
            tempLeftColor.a = opacity;
            starLeft.color  = tempLeftColor;
            break;

        case AlignHorizontal.Centre:
            Color tempMiddleColor = starMiddle.color;
            tempMiddleColor.a = opacity;
            starMiddle.color  = tempMiddleColor;
            break;

        case AlignHorizontal.Right:
            Color tempRightColor = starRight.color;
            tempRightColor.a = opacity;
            starRight.color  = tempRightColor;
            break;

        default:
            Debug.LogWarningFormat("Invalid UIPosition \"{0}\"", uiPosition);
            break;
        }
    }
Beispiel #3
0
        public static PdfPCell instance(Image image, AlignHorizontal align, UIPadding padding)
        {
            var cell = new PdfPCell(image);

            cell.setNoBorder();
            cell.setPadding(padding);
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;
            cell.setHorizontalAlign(align);
            cell.BackgroundColor = BaseColor.White;
            return(cell);
        }
Beispiel #4
0
 public BaseRenderComponent AddChild(BaseRenderComponent child, AlignHorizontal alignment)
 {
     child.Height = Height;
     children.Add(new ComponentChild
     {
         alignment = alignment,
         component = child
     });
     child.SetParent(this);
     LayoutInvalidate();
     return(child);
 }
Beispiel #5
0
        public void setHorizontalAlign(AlignHorizontal align)
        {
            switch (align)
            {
            case AlignHorizontal.Left:
            default:
                horizontal_align = Element.ALIGN_LEFT;
                break;

            case AlignHorizontal.Center:
                horizontal_align = Element.ALIGN_CENTER;
                break;

            case AlignHorizontal.Right:
                horizontal_align = Element.ALIGN_RIGHT;
                break;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 设置水平对齐方式
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="align"></param>
        public static void setHorizontalAlign(this PdfPCell cell, AlignHorizontal align)
        {
            switch (align)
            {
            case AlignHorizontal.Left:
            default:
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                break;

            case AlignHorizontal.Center:
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                break;

            case AlignHorizontal.Right:
                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                break;
            }
        }
        public bool isExit;                                             //exit to desktop

        public ModalMainMenuDetails()
        {
            alignHorizontal = AlignHorizontal.Centre;
            background      = Background.None;
            header          = "Unknown";
            isResume        = true;
            isTutorial      = true;
            isNewGame       = true;
            isLoadGame      = true;
            isSaveGame      = true;
            isOptions       = true;
            isFeedback      = true;
            isCustomise     = true;
            isCredits       = true;
            isInformation   = true;
            isMainMenu      = false;
            isExit          = true;
        }
Beispiel #8
0
 public BaseRenderComponent AddChild(BaseRenderComponent child, AlignHorizontal alignment, int width)
 {
     child.Width = width;
     return(AddChild(child, alignment));
 }
 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;
 }
 public TextComponent SetTextHorizontalAlign(AlignHorizontal align)
 {
     TextHorizontalAlign = align;
     return(this);
 }
Beispiel #11
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);
 }
Beispiel #12
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);
            }
        }