[Message Deleted]
-
[Message Deleted]
-
[Message Deleted]
What question?
All you've done is copy/paste in your homework assignment. This is a great way to your "question" ignored. Ask something specific and we can help with that. The whole point of you getting a homework assignmnet is to see if you're understanding the what's being taught in the class and if you understand how to apply it to problems. If all you're doing is copying/pasting the assignment into a forum, ... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
What question?
All you've done is copy/paste in your homework assignment. This is a great way to your "question" ignored. Ask something specific and we can help with that. The whole point of you getting a homework assignmnet is to see if you're understanding the what's being taught in the class and if you understand how to apply it to problems. If all you're doing is copying/pasting the assignment into a forum, ... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
this is the code I have been trying for hrs. Trackbar control only Vertical and horizontal. :laugh:Now how do I control the diameter? Public Class Form1 Inherits System.Windows.Forms.Form Private paper As Graphics #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call paper = Me.PictureBox1.CreateGraphics Me.VertTrackBar.Minimum = 0 Me.VertTrackBar.Maximum = Me.PictureBox1.Height Me.Label1.Text = CStr(Me.VertTrackBar.Value) Me.HoriTrackBar.Minimum = 0 Me.HoriTrackBar.Maximum = Me.PictureBox1.Width Me.Label2.Text = CStr(Me.HoriTrackBar.Value) Me.HoriDiaTrackbar.Minimum = 0 Me.HoriDiaTrackbar.Maximum = Me.PictureBox1.Width End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox Friend WithEvents VertTrackBar As System.Windows.Forms.TrackBar Friend WithEvents HoriTrackBar As System.Windows.Forms.TrackBar Friend WithEvents HoriDiaTrackbar As System.Windows.Forms.TrackBar Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents btnDraw As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.VertTrackBar = New System.Windows.Forms.TrackBar Me.HoriTrackBar = New System.Windows.Forms.TrackBar Me.PictureBox1 = New System.Windows.Forms.PictureBox Me.HoriDiaTrackbar = New System.Windows.Forms.TrackBar Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label
-
this is the code I have been trying for hrs. Trackbar control only Vertical and horizontal. :laugh:Now how do I control the diameter? Public Class Form1 Inherits System.Windows.Forms.Form Private paper As Graphics #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call paper = Me.PictureBox1.CreateGraphics Me.VertTrackBar.Minimum = 0 Me.VertTrackBar.Maximum = Me.PictureBox1.Height Me.Label1.Text = CStr(Me.VertTrackBar.Value) Me.HoriTrackBar.Minimum = 0 Me.HoriTrackBar.Maximum = Me.PictureBox1.Width Me.Label2.Text = CStr(Me.HoriTrackBar.Value) Me.HoriDiaTrackbar.Minimum = 0 Me.HoriDiaTrackbar.Maximum = Me.PictureBox1.Width End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox Friend WithEvents VertTrackBar As System.Windows.Forms.TrackBar Friend WithEvents HoriTrackBar As System.Windows.Forms.TrackBar Friend WithEvents HoriDiaTrackbar As System.Windows.Forms.TrackBar Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents btnDraw As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.VertTrackBar = New System.Windows.Forms.TrackBar Me.HoriTrackBar = New System.Windows.Forms.TrackBar Me.PictureBox1 = New System.Windows.Forms.PictureBox Me.HoriDiaTrackbar = New System.Windows.Forms.TrackBar Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label
You still haven't supplied much information. I take it you have to control both the position and the size of the circle. You're drawing a cicle from the top/left corner of the picture box ALL THE TIME. You're not tracking the position of the circle at at all. You have to track the center of the circle with the two trackbars. Easy enough, you already have them in place. Eliminate all the drawing code from the trackbars, you don't need any of it. The trackbar code will just alter the position and size of the circle. Then call the Invalidate method of the PictureBox control your painting on. You only need a single Draw statement, inside the Paint event handler for the PictureBox control. Here is where you'll calculate the top/left and bottom/right corners of the box that will be used to draw your circle. It's simple math. The top/left will be the position of the circle minus hald the diameter. The bottom/right will be the position plus half the diameter. Don't even thnik of asking for the code. You're in a class to learn to write it yourself. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
You still haven't supplied much information. I take it you have to control both the position and the size of the circle. You're drawing a cicle from the top/left corner of the picture box ALL THE TIME. You're not tracking the position of the circle at at all. You have to track the center of the circle with the two trackbars. Easy enough, you already have them in place. Eliminate all the drawing code from the trackbars, you don't need any of it. The trackbar code will just alter the position and size of the circle. Then call the Invalidate method of the PictureBox control your painting on. You only need a single Draw statement, inside the Paint event handler for the PictureBox control. Here is where you'll calculate the top/left and bottom/right corners of the box that will be used to draw your circle. It's simple math. The top/left will be the position of the circle minus hald the diameter. The bottom/right will be the position plus half the diameter. Don't even thnik of asking for the code. You're in a class to learn to write it yourself. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
thank you so much Master.:laugh:
-
You still haven't supplied much information. I take it you have to control both the position and the size of the circle. You're drawing a cicle from the top/left corner of the picture box ALL THE TIME. You're not tracking the position of the circle at at all. You have to track the center of the circle with the two trackbars. Easy enough, you already have them in place. Eliminate all the drawing code from the trackbars, you don't need any of it. The trackbar code will just alter the position and size of the circle. Then call the Invalidate method of the PictureBox control your painting on. You only need a single Draw statement, inside the Paint event handler for the PictureBox control. Here is where you'll calculate the top/left and bottom/right corners of the box that will be used to draw your circle. It's simple math. The top/left will be the position of the circle minus hald the diameter. The bottom/right will be the position plus half the diameter. Don't even thnik of asking for the code. You're in a class to learn to write it yourself. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Dave I took this challenge and found I'm having a tough time understang the logic flow of the object model. I get the circle to draw in the center of the PictureBox, but it is fleeting - it disappears as soon as it is drawn. I debugged only to find the circle vanishes as soon as I exit the Paint event on the PictureBox. Where am I failing?
Public Class Form1 Private _paper As Graphics Private _pen As Pen = New Pen(Color.Black, 3) Private Sub Form1_Load(....) Handles MyBase.Load _paper = Me.uxCanvasPicbx.CreateGraphics() End Sub Private Sub uxDiameterTrkbar_Scroll(....) Handles uxDiameterTrkbar.Scroll uxDiameterLbl.Text = uxDiameterTrkbar.Value.ToString uxCanvasPicbx.Invalidate() End Sub Private Sub uxCanvasPicbx_Paint(....) Handles uxCanvasPicbx.Paint Dim ul, lr As Integer lr = Me.uxDiameterTrkbar.Value ul = ((200 - lr) / 2) _paper.Clear(Color.White) _paper.DrawEllipse(_pen, ul, ul, lr, lr) End Sub End Class
Thanks, Karen Nooobie to OOP and VB.Net 2005 -
Dave I took this challenge and found I'm having a tough time understang the logic flow of the object model. I get the circle to draw in the center of the PictureBox, but it is fleeting - it disappears as soon as it is drawn. I debugged only to find the circle vanishes as soon as I exit the Paint event on the PictureBox. Where am I failing?
Public Class Form1 Private _paper As Graphics Private _pen As Pen = New Pen(Color.Black, 3) Private Sub Form1_Load(....) Handles MyBase.Load _paper = Me.uxCanvasPicbx.CreateGraphics() End Sub Private Sub uxDiameterTrkbar_Scroll(....) Handles uxDiameterTrkbar.Scroll uxDiameterLbl.Text = uxDiameterTrkbar.Value.ToString uxCanvasPicbx.Invalidate() End Sub Private Sub uxCanvasPicbx_Paint(....) Handles uxCanvasPicbx.Paint Dim ul, lr As Integer lr = Me.uxDiameterTrkbar.Value ul = ((200 - lr) / 2) _paper.Clear(Color.White) _paper.DrawEllipse(_pen, ul, ul, lr, lr) End Sub End Class
Thanks, Karen Nooobie to OOP and VB.Net 2005 -
Dave I took this challenge and found I'm having a tough time understang the logic flow of the object model. I get the circle to draw in the center of the PictureBox, but it is fleeting - it disappears as soon as it is drawn. I debugged only to find the circle vanishes as soon as I exit the Paint event on the PictureBox. Where am I failing?
Public Class Form1 Private _paper As Graphics Private _pen As Pen = New Pen(Color.Black, 3) Private Sub Form1_Load(....) Handles MyBase.Load _paper = Me.uxCanvasPicbx.CreateGraphics() End Sub Private Sub uxDiameterTrkbar_Scroll(....) Handles uxDiameterTrkbar.Scroll uxDiameterLbl.Text = uxDiameterTrkbar.Value.ToString uxCanvasPicbx.Invalidate() End Sub Private Sub uxCanvasPicbx_Paint(....) Handles uxCanvasPicbx.Paint Dim ul, lr As Integer lr = Me.uxDiameterTrkbar.Value ul = ((200 - lr) / 2) _paper.Clear(Color.White) _paper.DrawEllipse(_pen, ul, ul, lr, lr) End Sub End Class
Thanks, Karen Nooobie to OOP and VB.Net 2005The problem is because your using your own Graphics object and you don't need to. The Graphics object is supplied to you in the args for the Paint event. If you use your's, everything you paint will be overlayed by the Graphics object in the Paint event args. Sooooo....
Public Class Form1
Private _pen As Pen = New Pen(Color.Black, 3)Private Sub uxDiameterTrkbar\_Scroll(....) Handles uxDiameterTrkbar.Scroll uxDiameterLbl.Text = uxDiameterTrkbar.Value.ToString uxCanvasPicbx.Invalidate() End Sub Private Sub uxCanvasPicbx\_Paint(....) Handles uxCanvasPicbx.Paint Dim g As Graphics = e.Graphics Dim ul, lr As Integer lr = uxDiameterTrkbar.Value ul = ((200 - lr) / 2) g.Clear(Color.White) g.DrawEllipse(\_pen, ul, ul, lr, lr) End Sub
End Class
RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome