<Question@aol.c omwrote in message
news:oller29u91 pa3qhtgh79miuhj nfpt3icqv@4ax.c om...
Is there a way to display 4 quarter circles (half a semi circle) in
different colors? Is there a way to make quarter circle radiobutton?
Not sure if this is what you meant, but I'll post it just in case...
Create a new form and add the following:
Private mPen1 As Pen
Private mPen2 As Pen
Private mPen3 As Pen
Private mPen4 As Pen
Private mPenWidth As Integer
Private mBackBuffer As Bitmap
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
If mBackBuffer Is Nothing
mBackBuffer = _
New Bitmap(Me.Clien tSize.Width, Me.ClientSize.H eight)
End If
Dim canvas As Graphics = Graphics.FromIm age(mBackBuffer )
' Draw the background.
canvas.Clear(Me .BackColor)
Dim rect As Rectangle = Me.ClientRectan gle
' Draw the top-left quarter-circle.
canvas.DrawArc( mPen1, rect, 180, 90)
' Draw the top-right quarter-circle.
canvas.DrawArc( mPen2, rect, 270, 90)
' Draw the bottom-right quarter-circle.
canvas.DrawArc( mPen3, rect, 0, 90)
' Draw the bottom-left quarter-circle.
canvas.DrawArc( mPen4, rect, 90, 90)
' Cleanup.
canvas.Dispose( )
' Copy the back buffer to the screen.
e.Graphics.Draw ImageUnscaled(m BackBuffer, 0, 0)
End Sub
Protected Overrides Sub OnPaintBackgrou nd( _
ByVal pevent As System.Windows. Forms.PaintEven tArgs _
)
' Don't paint the background.
End Sub
Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
Me.Invalidate()
If Not mBackBuffer Is Nothing
mBackBuffer.Dis pose()
mBackBuffer = Nothing
End If
MyBase.OnResize (e)
End Sub
Private Sub Form_Load( _
ByVal sender As Object, _
ByVal e As System.EventArg s _
) Handles MyBase.Load
mPenWidth = 5
mPen1 = New Pen(Color.Red, mPenWidth)
mPen2 = New Pen(Color.Blue, mPenWidth)
mPen3 = New Pen(Color.Green , mPenWidth)
mPen4 = New Pen(Color.Yello w, mPenWidth)
End Sub
This will draw a full circle on the form, each quarter circle is a different
color and are each drawn separately...th is also follows powell's
double-buffering example as well for a smoother drawing experience :)
Definitely a start...Thanks I would like the quarters solid not as
arc. Any ideas?
On Wed, 24 Jan 2007 11:09:58 -0800, "Mythran" <kip_potter@hot mail.com>
wrote:
>Private mPen1 As Pen
>Private mPen2 As Pen
>Private mPen3 As Pen
>Private mPen4 As Pen
>Private mPenWidth As Integer
>Private mBackBuffer As Bitmap
>Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
If mBackBuffer Is Nothing
mBackBuffer = _
New Bitmap(Me.Clien tSize.Width, Me.ClientSize.H eight)
End If
>
Dim canvas As Graphics = Graphics.FromIm age(mBackBuffer )
>
' Draw the background.
canvas.Clear(Me .BackColor)
>
Dim rect As Rectangle = Me.ClientRectan gle
>
' Draw the top-left quarter-circle.
canvas.DrawArc( mPen1, rect, 180, 90)
>
' Draw the top-right quarter-circle.
canvas.DrawArc( mPen2, rect, 270, 90)
>
' Draw the bottom-right quarter-circle.
canvas.DrawArc( mPen3, rect, 0, 90)
>
' Draw the bottom-left quarter-circle.
canvas.DrawArc( mPen4, rect, 90, 90)
>
' Cleanup.
canvas.Dispose( )
>
' Copy the back buffer to the screen.
e.Graphics.Draw ImageUnscaled(m BackBuffer, 0, 0)
>End Sub
>
>Protected Overrides Sub OnPaintBackgrou nd( _
ByVal pevent As System.Windows. Forms.PaintEven tArgs _
>)
' Don't paint the background.
>End Sub
>
>Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
Me.Invalidate()
If Not mBackBuffer Is Nothing
mBackBuffer.Dis pose()
mBackBuffer = Nothing
End If
>
MyBase.OnResize (e)
>End Sub
>
>Private Sub Form_Load( _
ByVal sender As Object, _
ByVal e As System.EventArg s _
>) Handles MyBase.Load
mPenWidth = 5
mPen1 = New Pen(Color.Red, mPenWidth)
mPen2 = New Pen(Color.Blue, mPenWidth)
mPen3 = New Pen(Color.Green , mPenWidth)
mPen4 = New Pen(Color.Yello w, mPenWidth)
>End Sub
Definitely a start...Thanks I would like the quarters solid not as
arc. Any ideas?
I would have thought you would have gone straight to the search in VS.NET
help, looked up DrawArc, found the Graphics.DrawAr c method in the results
pane (you're looking for things in the .NET framework Location) and
double-clicked it, then clicked the "Sync Contents" button (looks like a
blue left-right arrow in the Web toolbar) and looked at the other methods in
the Graphics section, where you would have found the DrawPie method.
I did. I used the draw arc but again it was hollow. I tired to
increase the width of of the pen but it created a funny shape Then I
tired to create a loop that would keep making the arc smaller and
that created smaller pies but I could not postion the correctly so
that the filled the hole so i am stuck
On Thu, 25 Jan 2007 10:43:16 -0000, "Andrew Morton"
<akm@in-press.co.uk.inv alidwrote:
>Definitely a start...Thanks I would like the quarters solid not as
>arc. Any ideas?
>
>I would have thought you would have gone straight to the search in VS.NET
>help, looked up DrawArc, found the Graphics.DrawAr c method in the results
>pane (you're looking for things in the .NET framework Location) and
>double-clicked it, then clicked the "Sync Contents" button (looks like a
>blue left-right arrow in the Web toolbar) and looked at the other methods in
>the Graphics section, where you would have found the DrawPie method.
>
>HTH
>
>Andrew
>
>Definitely a start...Thanks I would like the quarters solid not as
>arc. Any ideas?
>
>I would have thought you would have gone straight to the search in VS.NET
>help, looked up DrawArc, found the Graphics.DrawAr c method in the results
>pane (you're looking for things in the .NET framework Location) and
>double-clicked it, then clicked the "Sync Contents" button (looks like a
>blue left-right arrow in the Web toolbar) and looked at the other methods in
>the Graphics section, where you would have found the DrawPie method.
>
>HTH
>
>Andrew
>
In previous post I meant to say drawpie not drawarc
Pah! Why do MS think that a pie should be empty? What point is there in an
empty pie? :-)
I see the help does not have Filling.AppleAn dBlackberry or anything similar.
Did you look further down in the help (like I should have ;-) and find
FillPie?
Find the line:
canvas.DrawPie( mPen1, rect, 180, 90)
and after it put in:
canvas.FillPie( Brushes.Red, rect, 180, 90)
How to I clear the pie chart so that I cann replace it with an updated
pie chart
(BTW I am a Newbie)
On Thu, 25 Jan 2007 11:52:15 -0000, "Andrew Morton"
<akm@in-press.co.uk.inv alidwrote:
>Question@aol.c om wrote:
>In previous post I meant to say drawpie not drawarc
>
>Pah! Why do MS think that a pie should be empty? What point is there in an
>empty pie? :-)
>I see the help does not have Filling.AppleAn dBlackberry or anything similar.
>
>Did you look further down in the help (like I should have ;-) and find
>FillPie?
>
>Find the line:
>canvas.DrawPie (mPen1, rect, 180, 90)
>
>and after it put in:
>canvas.FillPie (Brushes.Red, rect, 180, 90)
>
>to see it work.
>
>Andrew
>
How to I clear the pie chart so that I cann replace it with an updated
pie chart
Are you working with Mythran's example or do you have some other code
producing the pie chart?
If the former, then I think you would want a different place to put the
image, like a..., ooh, let me look in the Toolbox window.... ah: PictureBox.
I /think/ the OnPaint event happens automatically when Windows decides the
window needs to be re-drawn.
(BTW I am a Newbie)
And what makes you think I /really/ know what I'm going on about? ;-) Just
about all my VB.NET has been as ASP.NET, so I haven't had to learn/worry
about forms other than for making little utilities with simple buttons and
text for the UI.
I'm sure someone in this ng will have good suggestions for a beginning
VB.NET book (hint, hint! to anyone else reading this :-).
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows. Forms.Form
Private mBrush1 As Brush
Private mBrush2 As Brush
Private mBrush3 As Brush
Private mBrush4 As Brush
Private Sub Form_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
mBrush1 = Brushes.Red
mBrush2 = Brushes.Blue
mBrush3 = Brushes.Green
mBrush4 = Brushes.Yellow
PictureBox1.Bac kColor = Color.Transpare nt
AddHandler PictureBox1.Pai nt, AddressOf Me.pictureBox1_ Paint
Me.Controls.Add (PictureBox1)
End Sub
Private Sub pictureBox1_Pai nt(ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim g As Graphics = e.Graphics
g.Clear(Me.Back Color)
Dim rect As Rectangle
rect.Size = PictureBox1.Siz e
g.FillPie(mBrus h1, rect, 45, 90)
g.FillPie(mBrus h2, rect, 135, 90)
g.FillPie(mBrus h3, rect, 225, 90)
g.FillPie(mBrus h4, rect, 315, 90)
End Sub 'pictureBox1_Pa int
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
PictureBox1.Dis pose()
End Sub
End Class
The dispose command clears it but then I cannot redraw it in
picturebox1
On Thu, 25 Jan 2007 13:15:53 -0000, "Andrew Morton"
<akm@in-press.co.uk.inv alidwrote:
>Question@aol.c om wrote:
>How to I clear the pie chart so that I cann replace it with an updated
>pie chart
>
>Are you working with Mythran's example or do you have some other code
>producing the pie chart?
>
>If the former, then I think you would want a different place to put the
>image, like a..., ooh, let me look in the Toolbox window.... ah: PictureBox.
>I /think/ the OnPaint event happens automatically when Windows decides the
>window needs to be re-drawn.
>
>(BTW I am a Newbie)
>
>And what makes you think I /really/ know what I'm going on about? ;-) Just
>about all my VB.NET has been as ASP.NET, so I haven't had to learn/worry
>about forms other than for making little utilities with simple buttons and
>text for the UI.
>
>I'm sure someone in this ng will have good suggestions for a beginning
>VB.NET book (hint, hint! to anyone else reading this :-).
>
>Andrew
>
ACK! Why is this turned off? I don't see any latebinding in your code,
so you definately should turn this on. I realize it's annoying, and
narrowing conversions won't cause problems in a lot of projects, but it
is a super good idea to always leave Option Strict On, particularly
when you're just starting out.
Thanks,
Seth Rowe
On Jan 25, 8:38 am, Quest...@aol.co m wrote:
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows. Forms.Form
Private mBrush1 As Brush
Private mBrush2 As Brush
Private mBrush3 As Brush
Private mBrush4 As Brush
>
Private Sub Form_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
mBrush1 = Brushes.Red
mBrush2 = Brushes.Blue
mBrush3 = Brushes.Green
mBrush4 = Brushes.Yellow
PictureBox1.Bac kColor = Color.Transpare nt
AddHandler PictureBox1.Pai nt, AddressOf Me.pictureBox1_ Paint
Me.Controls.Add (PictureBox1)
End Sub
>
Private Sub pictureBox1_Pai nt(ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim g As Graphics = e.Graphics
g.Clear(Me.Back Color)
Dim rect As Rectangle
rect.Size = PictureBox1.Siz e
g.FillPie(mBrus h1, rect, 45, 90)
g.FillPie(mBrus h2, rect, 135, 90)
g.FillPie(mBrus h3, rect, 225, 90)
g.FillPie(mBrus h4, rect, 315, 90)
End Sub 'pictureBox1_Pa int
>
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
PictureBox1.Dis pose()
End Sub
End Class
>
The dispose command clears it but then I cannot redraw it in
picturebox1
>
On Thu, 25 Jan 2007 13:15:53 -0000, "Andrew Morton"
>
<a...@in-press.co.uk.inv alidwrote:
Quest...@aol.co m wrote:
How to I clear the pie chart so that I cann replace it with an updated
pie chart
>
Are you working with Mythran's example or do you have some other code
producing the pie chart?
>
If the former, then I think you would want a different place to put the
image, like a..., ooh, let me look in the Toolbox window.... ah: PictureBox.
I /think/ the OnPaint event happens automatically when Windows decides the
window needs to be re-drawn.
>
(BTW I am a Newbie)
>
And what makes you think I /really/ know what I'm going on about? ;-) Just
about all my VB.NET has been as ASP.NET, so I haven't had to learn/worry
about forms other than for making little utilities with simple buttons and
text for the UI.
>
I'm sure someone in this ng will have good suggestions for a beginning
VB.NET book (hint, hint! to anyone else reading this :-).
I believe using
PictureBox1.Cre ateGraphics().C lear(PictureBox 1.BackColor) instead of
..Dispose() will do the trick.
Thanks,
Seth Rowe
On Jan 25, 8:38 am, Quest...@aol.co m wrote:
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows. Forms.Form
Private mBrush1 As Brush
Private mBrush2 As Brush
Private mBrush3 As Brush
Private mBrush4 As Brush
>
Private Sub Form_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
mBrush1 = Brushes.Red
mBrush2 = Brushes.Blue
mBrush3 = Brushes.Green
mBrush4 = Brushes.Yellow
PictureBox1.Bac kColor = Color.Transpare nt
AddHandler PictureBox1.Pai nt, AddressOf Me.pictureBox1_ Paint
Me.Controls.Add (PictureBox1)
End Sub
>
Private Sub pictureBox1_Pai nt(ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim g As Graphics = e.Graphics
g.Clear(Me.Back Color)
Dim rect As Rectangle
rect.Size = PictureBox1.Siz e
g.FillPie(mBrus h1, rect, 45, 90)
g.FillPie(mBrus h2, rect, 135, 90)
g.FillPie(mBrus h3, rect, 225, 90)
g.FillPie(mBrus h4, rect, 315, 90)
End Sub 'pictureBox1_Pa int
>
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
PictureBox1.Dis pose()
End Sub
End Class
>
The dispose command clears it but then I cannot redraw it in
picturebox1
>
On Thu, 25 Jan 2007 13:15:53 -0000, "Andrew Morton"
>
<a...@in-press.co.uk.inv alidwrote:
Quest...@aol.co m wrote:
How to I clear the pie chart so that I cann replace it with an updated
pie chart
>
Are you working with Mythran's example or do you have some other code
producing the pie chart?
>
If the former, then I think you would want a different place to put the
image, like a..., ooh, let me look in the Toolbox window.... ah: PictureBox.
I /think/ the OnPaint event happens automatically when Windows decides the
window needs to be re-drawn.
>
(BTW I am a Newbie)
>
And what makes you think I /really/ know what I'm going on about? ;-) Just
about all my VB.NET has been as ASP.NET, so I haven't had to learn/worry
about forms other than for making little utilities with simple buttons and
text for the UI.
>
I'm sure someone in this ng will have good suggestions for a beginning
VB.NET book (hint, hint! to anyone else reading this :-).
I'm sure someone in this ng will have good suggestions for a beginning
VB.NET book (hint, hint! to anyone else reading this :-).
Although I've never read it, Tim Patrick (a contributer here) has a
book called "Start-to-Finish Visual Basic 2005" you might check out. Do
you (the OP) have experience in any other programming language or are
you a complete newbie to vb.net?
Thanks,
Seth Rowe
On Jan 25, 8:15 am, "Andrew Morton" <a...@in-press.co.uk.inv alid>
wrote:
Quest...@aol.co m wrote:
How to I clear the pie chart so that I cann replace it with an updated
pie chartAre you working with Mythran's example or do you have some other code
producing the pie chart?
>
If the former, then I think you would want a different place to put the
image, like a..., ooh, let me look in the Toolbox window.... ah: PictureBox.
I /think/ the OnPaint event happens automatically when Windows decides the
window needs to be re-drawn.
>
(BTW I am a Newbie)And what makes you think I /really/ know what I'm going on about? ;-) Just
about all my VB.NET has been as ASP.NET, so I haven't had to learn/worry
about forms other than for making little utilities with simple buttons and
text for the UI.
>
I'm sure someone in this ng will have good suggestions for a beginning
VB.NET book (hint, hint! to anyone else reading this :-).
>
Andrew
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
PictureBox1.Dis pose()
End Sub
End Class
>
The dispose command clears it but then I cannot redraw it in
picturebox1
Comment