Bc30456,bc30496,bc30590 [英] Bc30456, bc30496, bc30590

查看:158
本文介绍了Bc30456,bc30496,bc30590的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目需要帮助,这里是我的代码:

i need help with my project here is my code:

<pre>Public Class Form1
    ''' <summary>
    ''' A condensed custom knob control that is made out of two images and rotates with a fairly consistent manner.
    ''' </summary>
    ''' <remarks></remarks>
    Public Class CustomKnobControl
        '-- our image objects
        Private _bitmapBack As Bitmap = Nothing
        Private _bitmapKnob As Bitmap = Nothing
        '-- the image top left location for easy reference.
        Private _pBack As Point
        Private _pknob As Point

        '-- how far to rotate teh image
        Private _sMaxAngle As Single = 156
        '-- the current angle rotoated so far.
        Private _sAngle As Single = 0

        '-- how many turns ot the right can the knob go?
        Private _lMax As Int32 = 11
        '-- the current knob
        Private _lCurrent As Int32 = 0

        '-- temp object track where the mouse location was when it was last polled
        Private _pointMouseDown As Point

        '-- increase or decreaase this to shorten the distance threshold to clicking the knob over one direction or the other.
        Private _lMouseSensitivity As Int32 = 0

        '-- if the knob rotates let the parent control know in case we want the value
        Public Event ValueChange()

        '-- Returns the current knob value
        Public Property Value As Int32
            Get
                Return _lCurrent
            End Get
            Set(value As Int32)

            End Set
        End Property

        '-- Property to the consistent angle to rotate.
        Public Property AngleMovement As Single
            Get
                Return _sMaxAngle
            End Get
            Set(value As Single)
                _sMaxAngle = value
            End Set
        End Property

        '-- When polling the mouse's location - how far must it have traveled before a knob is moved?
        Public Property MouseSensitivity As Int32
            Get
                Return _lMouseSensitivity
            End Get
            Set(value As Int32)
                _lMouseSensitivity = value
            End Set
        End Property

        '-- how many clicks can the knob go?
        Public Property MaxValue As Int32
            Get
                Return _lMax
            End Get
            Set(value As Int32)
                _lMax = value
            End Set
        End Property
        '-- constructor
        Public Sub New()

            ' This call is required by the designer.
            InitializeComponent()

            ' Add any initialization after the InitializeComponent() call.

            '-- I added the controls to my resource's image area.  Right click on your project -> properties -> resources -> add existing files.
            '_bitmapBack = New Bitmap("C:\Code\Test\sandbox\Tutorial\back.png")
            '_bitmapKnob = New Bitmap("C:\Code\Test\sandbox\Tutorial\knob2.png")
            _bitmapBack = New Bitmap(My.Resources.depthKnob)
            _bitmapKnob = New Bitmap(My.Resources.time)

            '-- default everything up
            _sMaxAngle = 15
            _sAngle = 0
            _lMax = 11
            _lCurrent = 0
            _lMouseSensitivity = 35

            '-- Determine how to center the images so they line up with each other.
            Dim x As Int32 = 0
            Dim y As Int32 = 0

            x = CInt(Me.Width / 2)
            x -= CInt(_bitmapBack.Width / 2)
            y = CInt(Me.Height / 2)
            y -= CInt(_bitmapBack.Height / 2)
            _pBack = New Point(x, y)

            x = CInt(Me.Width / 2)
            x -= CInt(_bitmapKnob.Width / 2)
            y = CInt(Me.Height / 2)
            y -= CInt(_bitmapKnob.Height / 2)
            _pknob = New Point(x, y)

            _sAngle = -75 '-- start the knob pointing off to the left
        End Sub

        ''' <summary>
        ''' Rotation routine. 
        ''' </summary>
        ''' <param name="incoming_bitmap"></param>
        ''' <param name="angle"></param>
        ''' <returns>Rotated bitmap</returns>
        ''' <remarks></remarks>
        Private Function MyRotate(ByVal incoming_bitmap As Bitmap, ByVal angle As Single) As Bitmap
            Dim bitmapReturn As Bitmap = New Bitmap(incoming_bitmap.Width, incoming_bitmap.Height) '-- rotated image to return.
            Dim tempGraphic As Graphics = Graphics.FromImage(bitmapReturn) '-- need hook to a graphics object.
            tempGraphic.TranslateTransform(CSng(incoming_bitmap.Width / 2), CSng(incoming_bitmap.Height / 2)) '-- get the center of the image-ish
            tempGraphic.RotateTransform(angle) '-- do the rotation.
            tempGraphic.TranslateTransform(-CSng(incoming_bitmap.Width / 2), -CSng(incoming_bitmap.Height / 2)) '-- make sure the image is back to where the center is
            tempGraphic.DrawImage(incoming_bitmap, New Point(0, 0)) '-- draw the translated image which is to the return bitmap.
            Return bitmapReturn
        End Function

        ''' <summary>
        ''' If a keyboard or mouse input is coming in move the knob to the appropriate angle.
        ''' </summary>
        ''' <param name="bRight"> true = right, false = left</param>
        ''' <remarks></remarks>
        Public Sub DoMove(ByVal bRight As Boolean)
            If bRight AndAlso _lCurrent < _lMax Then
                _lCurrent += 1
                _sAngle += _sMaxAngle
                Refresh()
                RaiseEvent ValueChange()
            ElseIf Not bRight AndAlso _lCurrent > 0 Then
                _lCurrent -= 1
                _sAngle -= _sMaxAngle
                Refresh()
                RaiseEvent ValueChange()
            End If
        End Sub

        ''' <summary>
        ''' Basic distance forumla
        ''' </summary>
        ''' <param name="point1"></param>
        ''' <param name="point2"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function Distance(ByVal point1 As Point, ByVal point2 As Point) As Int32
            Dim lReturn As Int32 = 0

            lReturn = CInt(Math.Sqrt((point2.X - point1.X) ^ 2 + (point2.Y - point1.Y) ^ 2))

            Return lReturn
        End Function

        '-- every refresh draw the base of the knob first, then rotate the picture as needed.
        Private Sub rotate_image_tutorial_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
            e.Graphics.DrawImage(_bitmapBack, _pBack)
            e.Graphics.DrawImage(MyRotate(_bitmapKnob, _sAngle), _pknob.X, _pknob.Y)
        End Sub

        '--When the user clicks the mouse down snag the location.  Important to determining if the mouse moved far enough to click the knob over a notch.
        Private Sub rotate_image_tutorial_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
            _pointMouseDown = e.Location
        End Sub

        '-- When the user is moving their mouse determine if the distance moved is great enough for the sensitivity to rotate the knob left or right.
        Private Sub rotate_image_tutorial_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
            If _pointMouseDown <> Nothing AndAlso (Distance(e.Location, _pointMouseDown) > _lMouseSensitivity) Then
                If e.X > _pointMouseDown.X Then
                    DoMove(True)
                    _pointMouseDown = e.Location
                ElseIf e.X < _pointMouseDown.X AndAlso (Distance(_pointMouseDown, e.Location) > _lMouseSensitivity) Then
                    DoMove(False)
                    _pointMouseDown = e.Location
                End If
            End If
        End Sub

        '-- When the user let's go clear the holder for the mouse location.
        Private Sub rotate_image_tutorial_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
            _pointMouseDown = Nothing
        End Sub

        '-- If the user uses the arrow keys or a/d keys move the knob in the appropriate direction.
        Private Sub rotate_image_tutorial_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            If e.KeyCode = Keys.Right OrElse e.KeyCode = Keys.D Then
                DoMove(True)
            ElseIf e.KeyCode = Keys.Left OrElse e.KeyCode = Keys.A Then
                DoMove(False)
            End If
        End Sub


    End Class

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click

    End Sub
End Class



但每次我都会收到错误bc30456(' width和height'不是'Form1.CustomKnobCintrol'的成员,bc30496(对非共享成员的引用需要非共享引用),并且bc30590(无法找到事件'paint,MouseDown,MouseMove,MouseUp和KeyDown') )



我的尝试:



我正在尝试拿别人的代码并使其成为我自己的代码。


but every time i get the errors bc30456('width and height' is not a member of 'Form1.CustomKnobCintrol), bc30496(reference to a non-shared member requires a non shared reference), and bc30590(Events 'paint, MouseDown, MouseMove, MouseUp, and KeyDown' cannot be found)

What I have tried:

I'm trying to take someone else's code and make it my own.

推荐答案

你可以从互联网上抓取代码并假设它会完全按照你的意愿行事 - 你需要坐下来,阅读它,并了解它是如何工作的。

猜测,你没有从任何东西继承你的控制,所以它没有获得任何标准控制属性,方法或事件 - 当你试图使用它时会出现错误。



顺便说一句:将参考文献保留在你得到鳕鱼的地方是礼貌的e,如果你自己的基础:自定义用户控件:旋钮 - VB.NET教程| Dream.In.Code [ ^ ]是我认为你找到它的地方。我怀疑该页面上的下载文件会为您提供所需的全部工作代码,而无需将其复制并粘贴到您的表单代码中...
You can;t just "grab code" from the internet and assume it will do exactly what you want - you need to sit down, read it, and understand how it works.
At a guess, you have not inherited your control from anything, so it doesn't get any of the "standard" Control properties, methods, or events - and you get errors when it tries to use it.

BTW: It's considered polite to keep a reference back to where you got the code from if you base your own from it: Custom User Controls: Knobs - VB.NET Tutorials | Dream.In.Code[^] is where I assume you found it. I suspect that the download file on that page would give you the entire, working code you need without having to copy and paste it into your form code...


为什么您的CustomKnobControl是一个类在Form1类中?这应该是它自己的项目!



但是,错误非常明显。



bc30456('width and height'不是'Form1.CustomKnobCintrol的成员)

您尚未向CustomKnobControl类添加Width或Height属性,或者你忘了从Control继承你的CustomKnobControl。



bc30496(对非共享成员的引用需要非共享引用)

您正在从Shared方法引用类的实例成员。这是不允许的。



bc30590(无法找到事件'paint,MouseDown,MouseMove,MouseUp和KeyDown')

再次,这可能是因为你忘了让你的CustomKnobControl类从Control继承。



下一次,仔细检查你的根据您在Dream.In.Code上的文章中提取的代码,并与他们联系以解决您在代码中遇到的任何问题。
Why is your CustomKnobControl a class inside the Form1 class? It should be it's own project!

But, the errors are pretty obvious.

bc30456('width and height' is not a member of 'Form1.CustomKnobCintrol)
You haven't added and Width or Height properties to your CustomKnobControl class, OR you forgot to inherit your CustomKnobControl from Control.

bc30496(reference to a non-shared member requires a non shared reference)
You're referencing an instance member of a class from a Shared method. That's not allowed.

bc30590(Events 'paint, MouseDown, MouseMove, MouseUp, and KeyDown' cannot be found)
Again, this is probably because you forgot to have your CustomKnobControl class inherit from Control.

Next time, double check your work against the code you're lifting from an article on Dream.In.Code and contact them for any problems you're having with their code.


这篇关于Bc30456,bc30496,bc30590的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆