Ejemplo n.º 1
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value

            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition() + minmax_boxHeight;

            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...

                Point pos = scroll_button.Position;

                //if vscroll bar then move only y axis
                int newXPos = (int)(pos.X + e.DiffCapturedX);

                //clamp!
                if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
                {
                    newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
                }
                else if (newXPos < minmax_boxHeight)
                {
                    newXPos = minmax_boxHeight;
                }

                //calculate value from position

                int currentMarkAt = (newXPos - minmax_boxHeight);
                this.scrollValue = (float)(onePixelFor * currentMarkAt);
                newXPos          = CalculateThumbPosition() + minmax_boxHeight;
                scroll_button.SetLocation(newXPos, pos.Y);

                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }

                e.StopPropagation();
            };
        }
Ejemplo n.º 2
0
        void UpdateScrollButtonPosition()
        {
            switch (this.ScrollBarType)
            {
            default:
            case ScrollBarType.Vertical:
            {
                int thumbPosY = CalculateThumbPosition() + minmax_boxHeight;
                scrollButton.SetLocation(0, thumbPosY);
            } break;

            case ScrollBarType.Horizontal:
            {
                int thumbPosX = CalculateThumbPosition() + minmax_boxHeight;
                scrollButton.SetLocation(thumbPosX, 0);
            } break;
            }
        }
Ejemplo n.º 3
0
        void UpdateScrollButtonPosition()
        {
            if (scrollButton == null)
            {
                return;
            }
            switch (this.ScrollBarType)
            {
            default:
            case ScrollBarType.Vertical:
            {
                int thumbPosY = CalculateThumbPosition();
                scrollButton.SetLocation(0, thumbPosY);
            }
            break;

            case ScrollBarType.Horizontal:
            {
                int thumbPosX = CalculateThumbPosition();
                scrollButton.SetLocation(thumbPosX, 0);
            }
            break;
            }
        }
Ejemplo n.º 4
0
        void SetupMaxButtonProperties(RenderElement container)
        {
            ScrollBarButton max_button;

            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                max_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
                max_button.SetLocation(this.Width - minmax_boxHeight, 0);
            }
            else
            {
                max_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
                max_button.SetLocation(0, this.Height - minmax_boxHeight);
            }


            max_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray);
            max_button.MouseUp  += (s, e) => this.StepSmallToMax();
            container.AddChild(max_button);
            this.maxButton = max_button;
        }
Ejemplo n.º 5
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            //TODO: use 'theme-concept' eg. css

            var scroll_button = new ScrollBarButton(SCROLL_BOX_SIZE_LIMIT, this.Height, this); //create with default value

            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition();

            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...

                Point pos = scroll_button.Position;

                int newXPos = (int)(pos.X + e.DiffCapturedX);
                //clamp!
                if (newXPos >= this.Width - (scrollButton.Width))
                {
                    newXPos = this.Width - (scrollButton.Width);
                }
                else if (newXPos < 0)
                {
                    newXPos = 0;
                }

                //calculate value from position

                int currentMarkAt = newXPos;
                this.scrollRangeLogic.SetValue((float)(onePixelFor * currentMarkAt));

                newXPos = CalculateThumbPosition();
                scroll_button.SetLocation(newXPos, pos.Y);
                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }
                e.StopPropagation();
            };
            ////-------------------------------------------
            ////4.
            //scroll_button.MouseLeave += (s, e) =>
            //{
            //    if (e.IsDragging)
            //    {
            //        Point pos = scroll_button.Position;
            //        //if vscroll bar then move only y axis
            //        int newXPos = (int)(pos.X + e.XDiff);
            //        //clamp!
            //        if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
            //        {
            //            newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
            //        }
            //        else if (newXPos < minmax_boxHeight)
            //        {
            //            newXPos = minmax_boxHeight;
            //        }

            //        //calculate value from position

            //        int currentMarkAt = (newXPos - minmax_boxHeight);
            //        this.scrollValue = (float)(onePixelFor * currentMarkAt);
            //        newXPos = CalculateThumbPosition() + minmax_boxHeight;
            //        scroll_button.SetLocation(newXPos, pos.Y);
            //        if (this.UserScroll != null)
            //        {
            //            this.UserScroll(this, EventArgs.Empty);
            //        }
            //        e.StopPropagation();
            //    }
            //};
        }
Ejemplo n.º 6
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value
            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition() + minmax_boxHeight;
            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...

                Point pos = scroll_button.Position;
                //if vscroll bar then move only y axis 
                int newXPos = (int)(pos.X + e.DiffCapturedX);
                //clamp!
                if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
                {
                    newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
                }
                else if (newXPos < minmax_boxHeight)
                {
                    newXPos = minmax_boxHeight;
                }

                //calculate value from position 

                int currentMarkAt = (newXPos - minmax_boxHeight);
                this.scrollValue = (float)(onePixelFor * currentMarkAt);
                newXPos = CalculateThumbPosition() + minmax_boxHeight;
                scroll_button.SetLocation(newXPos, pos.Y);
                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }

                e.StopPropagation();
            };
        }
Ejemplo n.º 7
0
        void SetupMaxButtonProperties(RenderElement container)
        {
            ScrollBarButton max_button;
            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                max_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
                max_button.SetLocation(this.Width - minmax_boxHeight, 0);
            }
            else
            {
                max_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
                max_button.SetLocation(0, this.Height - minmax_boxHeight);
            }


            max_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray);
            max_button.MouseUp += (s, e) => this.StepSmallToMax();
            container.AddChild(max_button);
            this.maxButton = max_button;
        }