Example #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();
            };
        }
Example #2
0
        void SetupMinButtonProperties(RenderElement container)
        {
            ScrollBarButton min_button;

            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                min_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
            }
            else
            {
                min_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
            }
            min_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray);
            min_button.MouseUp  += (s, e) => this.StepSmallToMin();
            container.AddChild(min_button);
            this.minButton = min_button;
        }
Example #3
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();
            //    }
            //};
        }
Example #4
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();
            };
        }
Example #5
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;
        }