Exemple #1
0
 /// <summary>
 /// Creates a ScrollBar HUD element with the specified parameters.
 /// </summary>
 public ScrollBar(Game game, UIController controller, Vector2? position, float length,
                  ListBoxStateMachine listBox,
                  ScrollBarStateMachine scrollBar, UIElement parent)
     : base(game, controller, null, position,
            scrollBar.NumberOfPixelsInHorizontalAxis,
            scrollBar.NumberOfPixelsInVerticalAxis,
            parent)
 {
     if (scrollBar.Orientation != Orientation.Horizontal)
     {
         throw new InvalidOperationException(Properties.Resources.ScrollBarStateMachineShouldBeHorizontal);
     }
     this.listBox = listBox;
     StateMachine = scrollBar;
     StateMachine.Tag = this;
     StateMachine.MaximumFlickVelocity = MaximumFlickVelocity;
     scrollBarLength = length;
 }
        /// <summary>
        /// Creates a new ScrollViewerStateMachine.
        /// </summary>
        /// <param name="controller">The UIController which dispatches hit testing.</param>
        /// <param name="elementToScroll">The element which is scrolling.</param>
        public ScrollAdapter(UIController controller, UIElementStateMachine elementToScroll)
        {
            // By default scrolling should be allowed in both directions.
            Orientation = Orientation.Both;

            this.elementToScroll = elementToScroll;

            // Handle the ScrollBars for this ScrollViewer.
            horizontalScrollBarStateMachine = 
                new ScrollBarStateMachine(controller, elementToScroll.NumberOfPixelsInHorizontalAxis, 0);
            horizontalScrollBarStateMachine.Orientation = Orientation.Horizontal;

            verticalScrollBarStateMachine = 
                new ScrollBarStateMachine(controller, 0, elementToScroll.NumberOfPixelsInVerticalAxis);
            verticalScrollBarStateMachine.Orientation = Orientation.Vertical;

            // Default to 1 (full size).
            HorizontalViewportSize = 1;
            VerticalViewportSize = 1;
          
            horizontalScrollBarStateMachine.ValueChanged += OnHorizontalScrollBarStateMachineValueChanged;
            horizontalScrollBarStateMachine.ThumbChanged += OnHorizontalScrollBarStateMachineThumbChanged;
            horizontalScrollBarStateMachine.NumberOfPixelsInHorizontalAxisChanged +=
                HorizontalScrollBarStateMachineNumberOfPixelsInHorizontalAxisChanged;

            verticalScrollBarStateMachine.ValueChanged += OnVerticalScrollBarStateMachineValueChanged;
            verticalScrollBarStateMachine.ThumbChanged += OnVerticalScrollBarStateMachineThumbChanged;
            verticalScrollBarStateMachine.NumberOfPixelsInVerticalAxisChanged +=
                VerticalScrollBarStateMachineNumberOfPixelsInVerticalAxisChanged;

            // Manipulations should only cause translations, not rotations or scaling.
            manipulationProcessor =
                new ManipulationProcessor2D(Manipulations2D.TranslateX | Manipulations2D.TranslateY);
            manipulationProcessor.Completed += OnAffine2DManipulationCompleted;
            stopwatch = Stopwatch.StartNew();
        }
Exemple #3
0
 /// <summary>
 /// Creates a ScrollBar HUD element with the specified parent UIElement.
 /// </summary>
 public ScrollBar(UIElement parent,  Vector2? position, float length,
                  ListBoxStateMachine listBox, ScrollBarStateMachine scrollBar)
     : this(parent.Game, parent.Controller, position, length, listBox, scrollBar, parent)
 {
     // Empty.
 }