Initialize() публичный Метод

public Initialize ( int x, int y, int width, int height, StretchableImageType type, Random r, string &reason ) : bool
x int
y int
width int
height int
type StretchableImageType
r System.Random
reason string
Результат bool
Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="items"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="maxVisible"></param>
        /// <param name="r"></param>
        /// <param name="reason"></param>
        public bool Initialize(List<string> items, int xPos, int yPos, int width, int height, int maxVisible, Random r, out string reason)
        {
            _items = items;
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;

            _selectedIndex = 0;
            Dropped = false;
            _downArrowSprite = SpriteManager.GetSprite("ScrollDownBGButton", r);

            if (items.Count < maxVisible)
            {
                _haveScroll = false;
                maxVisible = items.Count;
            }
            else if (items.Count > maxVisible)
            {
                _haveScroll = true;
            }

            Enabled = true;

            _buttons = new List<BBInvisibleStretchButton>();
            _dropBackground = new BBStretchableImage();
            _scrollBar = new BBScrollBar();

            for (int i = 0; i <= maxVisible; i++)
            {
                BBInvisibleStretchButton button = new BBInvisibleStretchButton();
                if (!button.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos, _yPos + (i * height), _width, _height, r, out reason))
                {
                    return false;
                }
                _buttons.Add(button);
            }
            if (!_dropBackground.Initialize(_xPos, _yPos, width, height, StretchableImageType.ThinBorderBG, r, out reason))
            {
                return false;
            }
            if (!_scrollBar.Initialize(_xPos + _width, _yPos + _height, maxVisible * _height, maxVisible, items.Count, false, false, r, out reason))
            {
                return false;
            }
            RefreshSelection();
            RefreshLabels();
            return true;
        }
Пример #2
0
        public bool Initialize(string buttonText, ButtonTextAlignment alignment, StretchableImageType background, StretchableImageType foreground, int xPos, int yPos, int width, int height, Random r, out string reason)
        {
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _alignment = alignment;

            _backgroundImage = new BBStretchableImage();
            _foregroundImage = new BBStretchableImage();

            if (!_backgroundImage.Initialize(xPos, yPos, width, height, background, r, out reason))
            {
                return false;
            }
            if (!_foregroundImage.Initialize(xPos, yPos, width, height, foreground, r, out reason))
            {
                return false;
            }

            _label = new BBLabel();
            if (!_label.Initialize(0, 0, string.Empty, Color.White, out reason))
            {
                return false;
            }
            SetText(buttonText);

            Reset();
            _timeSinceClick = 10; //10 seconds will exceed any double-click max interval
            _doubleClicked = false;

            reason = null;
            return true;
        }
Пример #3
0
        public bool Initialize(string name, string text, int screenWidth, int screenHeight, Random r, out string reason)
        {
            _text = new BBTextBox();
            if (!_text.Initialize(0, 0, WIDTH - 30, 0, true, false, name, r, out reason))
            {
                return false;
            }
            _text.SetText(text);
            if (_text.Width < WIDTH - 30)
            {
                _actualWidth = _text.Width + 30;
            }
            else
            {
                _actualWidth = WIDTH;
            }

            _totalHeight = _text.Height + 15;

            _background = new BBStretchableImage();
            if (!_background.Initialize(0, 0, _actualWidth, _totalHeight, StretchableImageType.ThinBorderBG, r, out reason))
            {
                return false;
            }

            _showing = false;
            _delayBeforeShowing = 0; //1 second will turn on showing

            _screenWidth = screenWidth;
            _screenHeight = screenHeight;

            reason = null;
            return true;
        }
Пример #4
0
        public bool Initialize(string text, int x, int y, int width, int height, bool isReadOnly, Random r, out string reason)
        {
            xPos = x;
            yPos = y;
            this.width = width;
            this.height = height;
            HighlightColor = Color.FromArgb(125, 0, 125, 125);

            //Allows us to have transparency on our highlight rectangle
            Gorgon.Screen.BlendingMode = BlendingModes.Modulated;

            background = new BBStretchableImage();
            if (!background.Initialize(x, y, width, height, StretchableImageType.TextBox, r, out reason))
            {
                return false;
            }

            Text = string.Empty;
            this.text = new BBLabel();
            if (!this.text.Initialize(x + 6, y + 7, text, Color.White, out reason))
            {
                return false;
            }
            pressed = false;
            isSelected = false;
            blink = true;
            this.isReadOnly = isReadOnly;

            reason = null;
            return true;
        }