コード例 #1
0
        public int GetAngle()
        {
            float scrollPercent = _scrollable.GetScrollTop();

            int r                = 0;
            int splits           = Math.Abs(Chooser.Sensor.MaxElevationAngle) + Math.Abs(Chooser.Sensor.MinElevationAngle) + 1;
            int degreesOfFreedom = Math.Abs(Chooser.Sensor.MaxElevationAngle);

            float paginationSegment = 100.0f / (splits);

            /** 100% scrolled would always give you a page 1 if this wasn't implemented */
            if (scrollPercent == 50.0f)
            {
                r = 0;
            }
            else if (scrollPercent < 50.0f)
            {
                r = (int)((scrollPercent / 100.0) * degreesOfFreedom);
            }
            else if (scrollPercent > 50.0f)
            {
                r = (int)(-1 * (
                              ((scrollPercent - 50) / 100.0)
                              * degreesOfFreedom
                              ));
            }
            else
            {
                r = -27;
            }

            return(r);
        }
コード例 #2
0
        public override void Update(MouseState mouseState, MouseState oldMouseState, Rectangle mouseBoundingBox, GameTime gameTime)
        {
            if (mouseBoundingBox.Intersects(_scrollable.GraceArea))
            {
                _scrollable.Update(mouseState, oldMouseState, mouseBoundingBox, gameTime);
                float scrollPercent = _scrollable.GetScrollTop();

                float paginationSegment = 100.0f / (_pages);

                /** 100% scrolled would always give you a page 1 if this wasn't implemented */
                if (scrollPercent != 100.0f)
                {
                    _currentPage = (int)(scrollPercent / paginationSegment);
                }
                else
                {
                    /** Zero based paging system */
                    _currentPage = _pages - 1;
                }
                _pageBeginning = _viewableItems * _currentPage;
                _pageEnding    = _pageBeginning + _viewableItems;

                if (_pageEnding >= _collection.Count)
                {
                    _pageEnding = _collection.Count;
                }
            }
            else
            {
                if (_pageEnding >= _collection.Count)
                {
                    _pageEnding = _collection.Count;
                }
            }

            for (int i = _pageBeginning; i < _pageEnding; ++i)
            {
                _collection[i].Update(mouseState, oldMouseState, mouseBoundingBox, gameTime);
            }
        }