本文介绍了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.
推荐答案
这篇关于Bc30456,bc30496,bc30590的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!