Example #1
0
        public void Update()
        {
            if (ScrollEvent != null)
            {
                ScrollEvent();
            }

            //마우스 입력 처리
            if (Cursor.IsDragging(Bar) || (Cursor.JustdidLeftClick() && Cursor.IsOn(Frame)))
            {
                if (isVertical)
                {
                    Bar.SetCenter(new Point(Bar.GetPos().X, Cursor.GetPos().Y));
                }
                else
                {
                    Bar.SetCenter(new Point(Cursor.GetPos().X, Bar.GetPos().Y));
                }
            }

            //바가 범위를 벗어나지 않도록 조정.
            if (isVertical)
            {
                if (Bar.GetPos().Y < Frame.GetPos().Y)
                {
                    Bar.SetPos(Frame.GetPos());
                }
                if (Bar.GetPos().Y > Frame.GetPos().Y + Interval)
                {
                    Bar.SetPos(Bar.GetPos().X, Frame.GetPos().Y + Interval);
                }
                Bar.SetPos(Frame.GetPos().X, Bar.GetPos().Y);
            }
            else
            {
                if (Bar.GetPos().X < Frame.GetPos().X)
                {
                    Bar.SetPos(Frame.GetPos());
                }
                if (Bar.GetPos().X > Frame.GetPos().X + Interval)
                {
                    Bar.SetPos(Frame.GetPos().X + Interval, Bar.GetPos().Y);
                }
                Bar.SetPos(Bar.GetPos().X, Frame.GetPos().Y);
            }

            //계수조정.
            if (isVertical)
            {
                Coefficient = 1 - (Bar.GetPos().Y - Frame.GetPos().Y) / (float)Interval;
            }
            else
            {
                Coefficient = (Bar.GetPos().X - Frame.GetPos().X) / (float)Interval;
            }
        }