Exemplo n.º 1
0
 private void Start()
 {
     m_InitialPosition = GetContentAnchoredPosition();
     m_PositionStop    = new Vector2(m_ScrollRect.content.anchoredPosition.x, m_InitialPosition - m_PullDistanceRequiredRefresh);
     m_ScrollView      = m_ScrollRect.GetComponent <IScrollable>();
     m_ScrollRect.onValueChanged.AddListener(OnScroll);
 }
Exemplo n.º 2
0
        public ScrollableRenderTarget(Game game, int width, int height, IScrollable scrollable, IScroll scroll)
            : base(game)
        {
            _Width      = width;
            _Height     = height;
            _scrollable = scrollable;
            _scroll     = scroll;
            if (_scroll != null)
            {
                _scroll.ScrollContainer = this;
            }
            Scale   = 1;
            Alpha   = 1;
            Color   = Color.White;
            Culling = true;
#if SILVERLIGHT
            BackgroundColor = Color.TransparentWhite;
#else
            BackgroundColor = Color.Transparent;
#endif

            PosDif         = 0;
            MatrixInternal = Matrix.Identity;
            Matrix         = Matrix.Identity;
        }
 protected override void OnControlRemoved(ControlEventArgs e)
 {
     base.OnControlRemoved(e);
     if (scrollable == e.Control)
     {
         scrollable.MouseWheel -= ScrollableWheel;
         scrollable             = null;
         UpdateEnabled();
     }
 }
Exemplo n.º 4
0
        private static void OnScrollablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IScrollable scrollable = (IScrollable)e.NewValue;
            var         behavior   = d as ScrollableBehaviorBase <T>;

            if (behavior != null && behavior.IsActive)
            {
                behavior.Scrollable = scrollable;
                behavior.Scroll();
            }
        }
Exemplo n.º 5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            colHeader = base.GetTemplateChild("PART_ColumnHeader") as IScrollable;
            addrBar   = base.GetTemplateChild("PART_AddrBar") as IScrollable;
            hexView   = base.GetTemplateChild("PART_HexView") as HexView;
            if (hexView != null)
            {
                hexView.Buffer = this.m_buffer;
            }
            ApplyScrollInfo();
        }
 protected override void OnControlAdded(ControlEventArgs e)
 {
     base.OnControlAdded(e);
     if (scrollable == null && !DesignMode)
     {
         scrollable = e.Control as IScrollable;
         if (scrollable != null)
         {
             scrollable.MouseWheel += ScrollableWheel;
             Controls.SetChildIndex(e.Control, 0);
             UpdateEnabled();
         }
     }
 }
Exemplo n.º 7
0
 public static void Initiate(int arrayLength, int lastLine)
 {
     if (ScrollingIsContinuous)
     {
         Scroll = new Continuous();
     }
     else
     {
         Scroll = new PageByPage();
     }
     Option          = 1; Page = -1; PagePlus = 1; Index = 1; Input = ConsoleKey.UpArrow;
     Left            = Console.CursorLeft; Top = Console.CursorTop + 1;
     MaxLines        = lastLine - Top;
     TotalOptions    = arrayLength;
     PossibleOptions = Math.Min(MaxLines, TotalOptions);
     Pages           = ScrollingIsContinuous ? TotalOptions : 1 + TotalOptions / MaxLines;
     ScrollIsEnabled = TotalOptions > MaxLines;
 }
Exemplo n.º 8
0
        public UIScrollbar(Transform transform, Texture2D backgroundSprite, Texture2D handleSprite, EventArg onValueChanged, IScrollable scrollable, Screen screen) : base(transform, backgroundSprite, screen)
        {
            this.scrollable     = scrollable;
            this.onValueChanged = onValueChanged;

            var handleElement = AddUIElement(new UIScrollbarHandle(
                                                 new Transform(transform.Position, new Vector2(transform.Width)),
                                                 handleSprite,
                                                 null,
                                                 this,
                                                 screen
                                                 ));

            handleElement.SetColor(new Color(66, 134, 244));

            //Get the handle group element:
            handle = GetGroupElement(handleElement);

            CalculateScrollbarHandlePosition();
        }
Exemplo n.º 9
0
        public ScrollingRelation(ScrollBar scBar, IScrollable scrollableSurface)
        {
            this.scBar             = scBar;
            this.scrollableSurface = scrollableSurface;
            switch (scBar.ScrollBarType)
            {
            case ScrollBarType.Vertical:
            {
                SetupVerticalScrollRelation();
            } break;

            case ScrollBarType.Horizontal:
            {
                SetupHorizontalScrollRelation();
            } break;

            default:
                throw new NotSupportedException();
            }
        }
 // Update is called once per frame
 void Update()
 {
     if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out currentHit, Mathf.Infinity, LayerMask.GetMask("Default")))
     {
         if (Input.GetMouseButtonDown(0))
         {
             IClickable clickedObj = currentHit.collider.GetComponent <IClickable>();
             if (clickedObj != null)
             {
                 clickedObj.OnClicked(0);
             }
         }
         float scrollWheelInput = Input.GetAxis("Mouse ScrollWheel");
         if (Mathf.Abs(scrollWheelInput) > 0f)
         {
             IScrollable scrolledObj = currentHit.collider.GetComponent <IScrollable>();
             if (scrolledObj != null)
             {
                 scrolledObj.OnScrolled(scrollWheelInput);
             }
         }
     }
     if (Input.GetKeyDown(KeyCode.A))
     {
         cam.MoveHorizontal(true);
     }
     else if (Input.GetKeyDown(KeyCode.D))
     {
         cam.MoveHorizontal(false);
     }
     else if (Input.GetKeyDown(KeyCode.W))
     {
         cam.MoveVertical(true);
     }
     else if (Input.GetKeyDown(KeyCode.S))
     {
         cam.MoveVertical(false);
     }
 }
Exemplo n.º 11
0
 public Scrollable(Generator g)
     : base(g, typeof(IScrollable))
 {
     inner = (IScrollable)Handler;
 }
Exemplo n.º 12
0
 public ScrollingRelation(ScrollBar scBar, IScrollable scrollableSurface)
 {
     this.scBar = scBar;
     this.scrollableSurface = scrollableSurface;
     switch (scBar.ScrollBarType)
     {
         case ScrollBarType.Vertical:
             {
                 SetupVerticalScrollRelation();
             }
             break;
         case ScrollBarType.Horizontal:
             {
                 SetupHorizontalScrollRelation();
             }
             break;
         default:
             throw new NotSupportedException();
     }
 }
		protected override void OnControlRemoved(ControlEventArgs e)
		{
			base.OnControlRemoved(e);
			if (scrollable == e.Control) {
				scrollable.MouseWheel -= ScrollableWheel;
				scrollable = null;
				UpdateEnabled();
			}
		}
		protected override void OnControlAdded(ControlEventArgs e)
		{
			base.OnControlAdded(e);
			if (scrollable == null && !DesignMode) {
				scrollable = e.Control as IScrollable;
				if (scrollable != null) {
					scrollable.MouseWheel += ScrollableWheel;
					Controls.SetChildIndex(e.Control, 0);
					UpdateEnabled();
				}
			}
		}
Exemplo n.º 15
0
 void Start()
 {
     view = GetComponent <IScrollable>();
 }
 protected override void OnControlAdded(ControlEventArgs e)
 {
     base.OnControlAdded(e);
     if ((this.scrollable == null) && !base.DesignMode)
     {
         this.scrollable = e.Control as IScrollable;
         if (this.scrollable != null)
         {
             this.scrollable.MouseWheel += new MouseEventHandler(this.ScrollableWheel);
             base.Controls.SetChildIndex(e.Control, 0);
             this.UpdateEnabled();
         }
     }
 }
 protected override void OnControlRemoved(ControlEventArgs e)
 {
     base.OnControlRemoved(e);
     if (this.scrollable == e.Control)
     {
         this.scrollable.MouseWheel -= new MouseEventHandler(this.ScrollableWheel);
         this.scrollable = null;
         this.UpdateEnabled();
     }
 }
Exemplo n.º 18
0
 private void UpdateFromScrollable(IScrollable scrollable)
 {
     Viewport = scrollable.Viewport;
     Extent   = scrollable.Extent;
     Offset   = scrollable.Offset;
 }
Exemplo n.º 19
0
 public ScrollableRenderTarget(Game game, int width, int height, IScrollable scrollable)
     : this(game, width, height, scrollable, null)
 {
 }
Exemplo n.º 20
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            colHeader = base.GetTemplateChild("PART_ColumnHeader") as IScrollable;
            addrBar = base.GetTemplateChild("PART_AddrBar") as IScrollable;
            hexView = base.GetTemplateChild("PART_HexView") as HexView;
            if (hexView != null)
            {
                hexView.Buffer = this.m_buffer;
            }
            ApplyScrollInfo();
        }
Exemplo n.º 21
0
        public override void Update(GameTime gameTime)
        {
            _itemsContainer.Position = new Point(Left, Top);
            //MultiTextBox mtb = Parent as MultiTextBox;

            Point lastPosition      = SliderButton.Position;
            Point lastMousePosition = MouseGUI.Position;

            _itemsContainer.Update(gameTime);
            if (MouseGUI.Focus == SliderButton)
            {
                Point delta = MouseGUI.Position - SliderButton.Center;

                direction = delta.Y > 0 ? ScrollDirection.DOWN : delta.Y < 0 ? ScrollDirection.UP : ScrollDirection.NONE;

                if (direction == ScrollDirection.DOWN)
                {
                    if (GetBounds(delta.Y) == 0)
                    {
                        var slider = _itemsContainer[SliderButton].Position;
                        _itemsContainer.UpdateSlot(SliderButton, new Point(slider.X, slider.Y + delta.Y));

                        _scrollEvent.OnScroll(Parent, ScrollDirection.DOWN, delta.Y);
                    }
                    else
                    {
                        var down = _itemsContainer[DownButton].Position;
                        _itemsContainer.UpdateSlot(SliderButton, new Point(down.X, down.Y - SliderButton.Height));
                    }
                }
                else
                {
                    if (direction == ScrollDirection.UP)
                    {
                        if (GetBounds(delta.Y) == 0)
                        {
                            var slider = _itemsContainer[SliderButton].Position;
                            _itemsContainer.UpdateSlot(SliderButton, new Point(slider.X, slider.Y + delta.Y));

                            _scrollEvent.OnScroll(Parent, ScrollDirection.UP, delta.Y);
                        }
                        else
                        {
                            var up = _itemsContainer[UpButton].Position;
                            _itemsContainer.UpdateSlot(SliderButton, new Point(up.X, up.Y + UpButton.Height));
                        }
                    }
                }
            }
            else
            {
                IScrollable parent = (Parent as IScrollable);
                if (parent.NumberOfLines > parent.MaxLinesLength)
                {
                    var slot  = _itemsContainer[SliderButton];
                    int delta = (slot.Position.Y + CurrentScrollValue) - slot.Position.Y;

                    if (delta > 0)
                    {
                        _itemsContainer.UpdateSlot(SliderButton, new Point(slot.Position.X, DownButton.Height + CurrentScrollValue));
                    }
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 22
0
 private void UpdateFromScrollable(IScrollable scrollable)
 {
     Viewport = scrollable.Viewport;
     Extent = scrollable.Extent;
     Offset = scrollable.Offset;
 }
Exemplo n.º 23
0
 protected Scrollable(Generator generator, Type type, bool initialize = true)
     : base(generator, type, initialize)
 {
     handler = (IScrollable)Handler;
 }