Esempio n. 1
0
 public void Update(int scrollIncrement, float trueScrollLength, ScrollPanel scrollPanel)
 {
     scrolling       = true;
     scrollPosition += scrollIncrement;
     scrollPosition  = (float)Math.Round(scrollPosition);
     if (scrollPosition <= 0)
     {
         scrollPosition = 0;
         scrollPanel.ScrollContainer.BuildContainerContinuous(0, scrollPanel.ScrollMask.Area.Top);
     }
     else if (scrollPosition > scrollIncrement * ((int)Math.Round(trueScrollLength / scrollIncrement)))
     {
         scrollPosition = scrollIncrement * ((int)Math.Round(trueScrollLength / scrollIncrement));
         scrollPanel.ScrollContainer.BuildContainerContinuous(0, (int)-scrollPosition + scrollPanel.ScrollMask.Area.Top);
     }
     // oldMax is the total value of each increment by 12 to scroll the container.
     HandleImage.Position = new Vector2(HandleImage.Position.X, (float)Math.Round(LinearConversion.Float(scrollPosition, handleMin.Y, scrollIncrement * ((int)Math.Round(trueScrollLength / scrollIncrement)), handleMin.Y, handleMax.Y - HandleImage.Height)));
 }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = 1366;
            graphics.PreferredBackBufferHeight = 768;
            graphics.IsFullScreen = false;
            //graphics.PreferredBackBufferWidth = 1920;
            //graphics.PreferredBackBufferHeight = 1080;
            //graphics.IsFullScreen = true;
            graphics.ApplyChanges();
            if (!graphics.IsFullScreen)
            {
                Window.Position = new Point((GraphicsDevice.DisplayMode.Width / 2) - graphics.PreferredBackBufferWidth / 2, (GraphicsDevice.DisplayMode.Height / 2) - graphics.PreferredBackBufferHeight / 2);
            }

            IsMouseVisible       = true;
            currMouseScrollValue = Mouse.GetState().ScrollWheelValue;
            prevMouseScrollValue = currMouseScrollValue;

            scrollbarA = new Scrollbar(new Rectangle(356, 100, 16, 256), new Image2D("scrollbar-handle", new Vector2(2, 0), Color.White, 0f), new Image2D("scrollbar", new Vector2(0, 0), Color.White, 0));
            scrollbarB = new Scrollbar(new Rectangle(696, 100, 16, 96), new Image2D("scrollbar-handle", new Vector2(2, 0), Color.White, 0f), new Image2D("scrollbar-96", new Vector2(0, 0), Color.White, 0));
            scrollbarC = new Scrollbar(new Rectangle(896, 200, 16, 96), new Image2D("scrollbar-handle", new Vector2(2, 0), Color.White, 0f), new Image2D("scrollbar-96", new Vector2(0, 0), Color.White, 0));

            scrollPanelA = new ScrollPanel(new ScrollMask(new Rectangle(100, 100, 256, 256), new Image2D("scroll-bg", new Vector2(0, 0), Color.White, 0f)), 12, null, scrollbarA);
            scrollPanelB = new ScrollPanel(new ScrollMask(new Rectangle(600, 100, 100, 100), new Image2D("scroll-bg-96", new Vector2(0, 0), Color.White, 0f)), 12, null, scrollbarB);
            scrollPanelC = new ScrollPanel(new ScrollMask(new Rectangle(800, 200, 100, 100), new Image2D("scroll-bg-96", new Vector2(0, 0), Color.White, 0f)), 12, null, scrollbarC);

            scrollPanels = new List <ScrollPanel>();
            scrollPanels.Add(scrollPanelA);
            scrollPanels.Add(scrollPanelB);
            scrollPanels.Add(scrollPanelC);

            textArea   = new TextArea(new Rectangle(0, 0, 200, 50), TextAlignment.Left, false, "Terminus", "The quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. 1234567890 . : , ; ' \" ( ! ? ) + - * / = \\", new Vector2(0, 0), Color.White);
            textInfo   = new TextArea(new Rectangle(350, 25, 200, 50), TextAlignment.Left, false, "Terminus", "These are scroll systems, you can click and drag the scroll bar or move mouse positions within the scroll area and use your mouse wheel to scroll.", new Vector2(0, 0), Color.White);
            buttonText = new TextArea(new Rectangle(14, 7, 200, 50), TextAlignment.Left, false, "Terminus", "This is a button\n\nYou can see the response in the console output", new Vector2(0, 0), Color.White);

            button        = new Button(new Image2D("scroll-btn", new Vector2(0, 0), Color.White, 0f), new Rectangle(0, 0, 128, 32), Color.White, Color.Red, Color.Green);
            button.Click += delegate(object s, EventArgs e) {
                ButtonTestPrintNum(s, e, new Random().Next(0, 1000));
            };

            base.Initialize();
        }