예제 #1
0
        public Component SetFont(string text, Color?textColor = null, Offset?textPadding = null)
        {
            textColor = textColor ?? Color.White;

            textPadding = textPadding ?? Offset.CreatePadding(OffsetValueType.Piksel, 0, 0, 0, 0);

            Font = new Font(text: text, fontColor: textColor);

            Font.IncreaseLayerDepth(baseDepth: LayerDepth);

            //SetPadding(textPadding.Value);

            Component_OnChangeRectangle();

            return(this);
        }
예제 #2
0
        public ScrollBar SetScrollBar()
        {
            //column = new Column();

            Column[] columns = new Column[125];


            for (int i = 0; i < columns.Length; i++)
            {
                var container = new Container();

                var row = new Row();
                row.SetTexture();
                container.AddRow(row, 70);

                var row2 = new Row();
                row2.SetTexture();
                container.AddRow(row2, 30);

                var row2Column1 = new Column();
                row2Column1.SetTexture(Color.Black);
                row2.AddColumn(row2Column1, 30);
                row2Column1.AddImage(Triangle.PlayButton(Color.Yellow).Texture);

                var row2Column2 = new Column();
                row2Column2.SetTexture();
                row2Column2.SetFont("Level : " + i);
                row2.AddColumn(row2Column2, 70);

                container.PrepareRows();
                row2Column1.SetPadding(Offset.CreatePadding(OffsetValueType.Ratio, 10, 10, 10, 10));

                var column1 = new Column();
                column1.AddChild(container);

                columns[i] = column1;

                column1.SetFrame(Color.Yellow);
            }


            var scrollBar = new ScrollBar(rowsCountToShow: 3, rowPadding: Offset.CreatePadding(OffsetValueType.Ratio, 5, 5, 5, 5), columns: columns);

            scrollBar.SetActive(true);

            return(scrollBar);
        }
예제 #3
0
        public MenuButton(string text, Color?textColor = null, Offset?textPadding = null, bool isPulsating = false)
            : base(isPulsating)
        {
            ThemeColor = textColor ?? Global.Theme.GetColor();

            OppositeColor = Global.Theme.Mode == ThemeMode.White ? Theme.GetDefaultColorByMode(ThemeMode.Dark) : Theme.GetDefaultColorByMode(ThemeMode.White);

            textPadding = textPadding ?? Offset.CreatePadding(OffsetValueType.Ratio, 10, 25, 0, 0);

            SetFont(text, OppositeColor, textPadding);

            var newSize = new Vector2(Font.TextMeasure.X + Padding.Left + Padding.Right, Font.TextMeasure.Y + Padding.Top + Padding.Bottom);

            newSize = new Vector2(MathHelper.Clamp(newSize.X, Size.X, newSize.X), MathHelper.Clamp(newSize.Y, Size.Y, newSize.Y));

            SetSize(newSize);

            InnerTextureLayerDepth = LayerDepth;
        }
예제 #4
0
        public ScrollBar(int rowsCountToShow = 4, int columnsCountPerRow = 3, float scrollContainerWidthRatio = 2.5f, Offset?rowPadding = null, params Column[] columns)
        {
            OnChangeRectangle += ScrollBar_OnChangeRectangle;

            MaxRowsCount = columns.Length != 0 ? Convert.ToInt32(Math.Ceiling((decimal)columns.Length / columnsCountPerRow)) : rowsCountToShow;

            RowsCountToShow = rowsCountToShow;

            ColumnsCountPerRow = columnsCountPerRow;

            ScrollContainerWidthRatio = scrollContainerWidthRatio;

            RowPadding = rowPadding ?? Offset.CreatePadding(OffsetValueType.Ratio, 2.5f, 2.5f, 2.5f, 2.5f);

            SetColumns(columns);

            LoadListContainer();

            LoadScrollContainer();
        }