旋钮控制

时间:2014-03-21 12:29:56

标签: c# controls

我需要做一个旋钮控制,或使用一个有效的旋钮。我从该网站下载了一个:http://www.c-sharpcorner.com/uploadfile/desaijm/knobcontrolusingwindowsforms11182005004925am/knobcontrolusingwindowsforms.aspx但它并没有按照我的意愿工作。

当我移动它时,我需要这个旋钮控制器可以制作一个完整的圆圈。当你转到最大值时,如果你传递这个值,按钮会自动转到另一个值(即0)。

我想做的就是在没有最大值的情况下一直递增旋钮旋转值,并且在超过最大值时不要重新启动到0。

我发布了价值变化发生的代码,但我正在研究它3个小时而且我不知道如何改变......还有两个变量:最大值和最小值都有最大值旋钮的最小值。

protected override void OnMouseMove(MouseEventArgs e)
    {
        //--------------------------------------
        //  Following Handles Knob Rotating     
        //--------------------------------------
        if (this.isKnobRotating == true)
        {
            this.Cursor = Cursors.Hand;
            Point p = new Point(e.X, e.Y);
            int posVal = this.getValueFromPosition(p);
            Value = posVal;
        }       
    }

有没有想过这样做或任何可以帮助我的C#控件?

谢谢!

1 个答案:

答案 0 :(得分:0)

最后我找到了自己的解决方案,希望对其他人有所帮助!

if (this.isKnobRotating == true)
        {
            lastValue = Value;
            this.Cursor = Cursors.Hand;
            Point p = new Point(e.X, e.Y);
            int posVal = this.getValueFromPosition(p);
            Value = posVal;
            if ((lastValue >= Maximum + radiusLeft - 1) && Value == 0)
            {
                numRounds++;
            }
            else if (lastValue <= Minimum && (Value == Maximum + radiusLeft - 1))
            {
                numRounds--;
            }
            finalValue = (Maximum + radiusLeft) * numRounds;
            result = finalValue + Value;
        }       
相关问题