Beispiel #1
0
 public OldScrollBar(XNAControl parent,
                     Vector2 locationRelativeToParent,
                     Vector2 size,
                     ScrollBarColors palette)
     : this(parent, locationRelativeToParent, size, palette, EOGame.Instance.GFXManager)
 {
 }
Beispiel #2
0
        public ScrollBar(Vector2 locationRelativeToParent,
                         Vector2 size,
                         ScrollBarColors palette,
                         INativeGraphicsManager nativeGraphicsManager)
        {
            scrollArea   = new Rectangle(0, 15, 0, (int)size.Y - 15);
            DrawPosition = locationRelativeToParent;
            SetSize((int)size.X, (int)size.Y);
            ScrollOffset = 0;

            var scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
            var upArrows          = new Rectangle[2];
            var downArrows        = new Rectangle[2];
            int vertOff;

            switch (palette)
            {
            case ScrollBarColors.LightOnLight: vertOff = 0; break;

            case ScrollBarColors.LightOnMed: vertOff = 105; break;

            case ScrollBarColors.LightOnDark: vertOff = 180; break;

            case ScrollBarColors.DarkOnDark: vertOff = 255; break;

            default: throw new ArgumentOutOfRangeException(nameof(palette));
            }

            //regions based on verticle offset (which is based on the chosen palette)
            upArrows[0]   = new Rectangle(0, vertOff + 15 * 3, 16, 15);
            upArrows[1]   = new Rectangle(0, vertOff + 15 * 4, 16, 15);
            downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
            downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
            var scrollBox = new Rectangle(0, vertOff, 16, 15);

            _upButton          = new XNAButton(scrollSpriteSheet, Vector2.Zero, upArrows[0], upArrows[1]);
            _upButton.OnClick += arrowClicked;
            _upButton.SetParentControl(this);

            _downButton          = new XNAButton(scrollSpriteSheet, new Vector2(0, size.Y - 15), downArrows[0], downArrows[1]);
            _downButton.OnClick += arrowClicked;
            _downButton.SetParentControl(this);

            _scrollButton               = new XNAButton(scrollSpriteSheet, new Vector2(0, 15), scrollBox, scrollBox);
            _scrollButton.OnClickDrag  += OnScrollButtonDragged;
            _scrollButton.OnMouseEnter += (o, e) => { SuppressParentClickDragEvent(true); };
            _scrollButton.OnMouseLeave += (o, e) => { SuppressParentClickDragEvent(false); };
            _scrollButton.SetParentControl(this);

            _totalHeight = DrawAreaWithParentOffset.Height;
        }
Beispiel #3
0
		public ScrollBar(XNAControl parent, Vector2 relativeLoc, Vector2 size, ScrollBarColors palette)
			: base(relativeLoc, new Rectangle((int)relativeLoc.X, (int)relativeLoc.Y, (int)size.X, (int)size.Y))
		{
			SetParent(parent);
			scrollArea = new Rectangle(0, 15, 0, (int)size.Y - 15);
			DrawLocation = relativeLoc;
			ScrollOffset = 0;

			Texture2D scrollSpriteSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
			Rectangle[] upArrows = new Rectangle[2];
			Rectangle[] downArrows = new Rectangle[2];
			int vertOff;
			switch (palette)
			{
				case ScrollBarColors.LightOnLight: vertOff = 0; break;
				case ScrollBarColors.LightOnMed: vertOff = 105; break;
				case ScrollBarColors.LightOnDark: vertOff = 180; break;
				case ScrollBarColors.DarkOnDark: vertOff = 255; break;
				default:
					throw new ArgumentOutOfRangeException("palette");
			}

			//regions based on verticle offset (which is based on the chosen palette)
			upArrows[0] = new Rectangle(0, vertOff + 15 * 3, 16, 15);
			upArrows[1] = new Rectangle(0, vertOff + 15 * 4, 16, 15);
			downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
			downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
			Rectangle scrollBox = new Rectangle(0, vertOff, 16, 15);

			Texture2D[] upButton = new Texture2D[2];
			Texture2D[] downButton = new Texture2D[2];
			Texture2D[] scrollButton = new Texture2D[2];
			for (int i = 0; i < 2; ++i)
			{
				upButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, upArrows[i].Width, upArrows[i].Height);
				Color[] upData = new Color[upArrows[i].Width * upArrows[i].Height];
				scrollSpriteSheet.GetData(0, upArrows[i], upData, 0, upData.Length);
				upButton[i].SetData(upData);

				downButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, downArrows[i].Width, downArrows[i].Height);
				Color[] downData = new Color[downArrows[i].Width * downArrows[i].Height];
				scrollSpriteSheet.GetData(0, downArrows[i], downData, 0, downData.Length);
				downButton[i].SetData(downData);

				//same texture for hover, AFAIK
				scrollButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, scrollBox.Width, scrollBox.Height);
				Color[] scrollData = new Color[scrollBox.Width * scrollBox.Height];
				scrollSpriteSheet.GetData(0, scrollBox, scrollData, 0, scrollData.Length);
				scrollButton[i].SetData(scrollData);
			}

			up = new XNAButton(upButton, new Vector2(0, 0));
			up.OnClick += arrowClicked;
			up.SetParent(this);
			down = new XNAButton(downButton, new Vector2(0, size.Y - 15)); //update coordinates!!!!
			down.OnClick += arrowClicked;
			down.SetParent(this);
			scroll = new XNAButton(scrollButton, new Vector2(0, 15)); //update coordinates!!!!
			scroll.OnClickDrag += scrollDragged;
			scroll.OnMouseEnter += (o, e) => { SuppressParentClickDrag(true); };
			scroll.OnMouseLeave += (o, e) => { SuppressParentClickDrag(false); };
			scroll.SetParent(this);

			_totalHeight = DrawAreaWithOffset.Height;
		}
Beispiel #4
0
        public OldScrollBar(XNAControl parent,
                            Vector2 locationRelaiveToParent,
                            Vector2 size,
                            ScrollBarColors palette,
                            INativeGraphicsManager nativeGraphicsManager)
            : base(locationRelaiveToParent,
                   new Rectangle((int)locationRelaiveToParent.X,
                                 (int)locationRelaiveToParent.Y,
                                 (int)size.X,
                                 (int)size.Y))
        {
            SetParent(parent);
            scrollArea   = new Rectangle(0, 15, 0, (int)size.Y - 15);
            DrawLocation = locationRelaiveToParent;
            ScrollOffset = 0;

            Texture2D scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29);

            Rectangle[] upArrows   = new Rectangle[2];
            Rectangle[] downArrows = new Rectangle[2];
            int         vertOff;

            switch (palette)
            {
            case ScrollBarColors.LightOnLight: vertOff = 0; break;

            case ScrollBarColors.LightOnMed: vertOff = 105; break;

            case ScrollBarColors.LightOnDark: vertOff = 180; break;

            case ScrollBarColors.DarkOnDark: vertOff = 255; break;

            default:
                throw new ArgumentOutOfRangeException(nameof(palette));
            }

            //regions based on verticle offset (which is based on the chosen palette)
            upArrows[0]   = new Rectangle(0, vertOff + 15 * 3, 16, 15);
            upArrows[1]   = new Rectangle(0, vertOff + 15 * 4, 16, 15);
            downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
            downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
            Rectangle scrollBox = new Rectangle(0, vertOff, 16, 15);

            Texture2D[] upButton     = new Texture2D[2];
            Texture2D[] downButton   = new Texture2D[2];
            Texture2D[] scrollButton = new Texture2D[2];
            for (int i = 0; i < 2; ++i)
            {
                upButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, upArrows[i].Width, upArrows[i].Height);
                Color[] upData = new Color[upArrows[i].Width * upArrows[i].Height];
                scrollSpriteSheet.GetData(0, upArrows[i], upData, 0, upData.Length);
                upButton[i].SetData(upData);

                downButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, downArrows[i].Width, downArrows[i].Height);
                Color[] downData = new Color[downArrows[i].Width * downArrows[i].Height];
                scrollSpriteSheet.GetData(0, downArrows[i], downData, 0, downData.Length);
                downButton[i].SetData(downData);

                //same texture for hover, AFAIK
                scrollButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, scrollBox.Width, scrollBox.Height);
                Color[] scrollData = new Color[scrollBox.Width * scrollBox.Height];
                scrollSpriteSheet.GetData(0, scrollBox, scrollData, 0, scrollData.Length);
                scrollButton[i].SetData(scrollData);
            }

            up          = new XNAButton(upButton, new Vector2(0, 0));
            up.OnClick += arrowClicked;
            up.SetParent(this);
            down          = new XNAButton(downButton, new Vector2(0, size.Y - 15)); //update coordinates!!!!
            down.OnClick += arrowClicked;
            down.SetParent(this);
            scroll               = new XNAButton(scrollButton, new Vector2(0, 15)); //update coordinates!!!!
            scroll.OnClickDrag  += scrollDragged;
            scroll.OnMouseEnter += (o, e) => { SuppressParentClickDrag(true); };
            scroll.OnMouseLeave += (o, e) => { SuppressParentClickDrag(false); };
            scroll.SetParent(this);

            _totalHeight = DrawAreaWithOffset.Height;
        }