473,802 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw Line Over Pie Using GDI+

Hi

I am trying to draw a pie like shape on a form in the paint event. I am
then trying to draw a line running down the center of the pie. The code I
have attached at the bottom of this post does just this but there is
something wrong somewhere as when I resize the form, the line does not stay
over the center of the pie as expected.

I should imagine its just a case of something round the wrong way but I just
can't find what could be wrong.

Regards, Carl Gilbert
*************** ************ CODE *************** ************
Imports System.Math
Public Class Form2
Private Sub Form2_Paint(ByV al sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Me.Paint
Dim percentFromCent er As Integer = 80
Dim angle As Integer = 45
Dim span As Integer = 20
Dim cx As Double = Me.ClientRectan gle.Width / 2
Dim cy As Double = Me.ClientRectan gle.Height / 2
Dim theta, xMiddle, yMiddle As Double
'CENTRE LINE
theta = 45 * (PI / 180)
xMiddle = cx + cx * Cos(theta) * (percentFromCen ter / 100)
yMiddle = cy + cy * Sin(theta) * (percentFromCen ter / 100)
e.Graphics.Fill Pie(Brushes.Yel low, Me.ClientRectan gle, (angle - (span / 2)),
span)
e.Graphics.Draw Line(Pens.Black , New PointF(cx, cy), New PointF(xMiddle,
yMiddle))
End Sub
Private Sub Form1_Resize(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Resize
Me.Invalidate()
End Sub
End Class
*************** ************ CODE *************** ************
Nov 21 '05 #1
0 1069

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
3080
by: DraguVaso | last post by:
Hi, I have an inherited DataGrid, that does lots of extra stuff. For exemple drawing a backgroundimage in every cell. The problem is that it's taking too much time (using gdi+), so I want to do it using DirectX. I downloaded already the DSK etc, but I can't find how I need to draw an image on a given position. I don't need stuff to write advanced 3D-games, just painting that image. Can anybody help me with this? I'm already looking for...
4
734
by: Mathieu Chavoutier | last post by:
Hi. I would like to do something like paint. I try to draw a line. I want, like paint, that when I clickdown, it begins to draw the line, and then, when I move the mouse, the line follow the cursor. I have tried many things, and I have mysterious things appening. Here, I can't remove the lines I have drawed : http://img26.exs.cx/img26/4302/GRRRRRRRRRRRR.png
6
41892
by: redneon | last post by:
Is it possible to draw directly to the screen using the .net libraries? I thought that it might be possible with GDI+ but I can't find out how to do it anywhere. A part of me suspects I may have to look into using the Windows API. Any ideas, Darrell
6
3990
by: felix | last post by:
Hi, I have an Image that is drawn with Graphics.DrawImage(..). What I want to do is drawing it with a given transparency, e.g. at an alpha of only 180 instead of 255. How am I doing that?!?!? Regards, Felix
4
7373
by: Val | last post by:
When I am using Graphics.DrawString, I can only draw a string either horizontally or vertically. Is the a way to draw under arbitrary angle - parallel to some line? I would appreciate a code sample. Thanks, Val
6
1519
by: Carlos | last post by:
I need to have a picture loaded in a asp.net C# page and draw a line on top of it, using GDI.. any idea how to do it or sample page ? Thanks
3
15980
by: Steve | last post by:
Hi All, I am sure this is a simple question, but how do I draw a line onto a windows form in VB.NET, or any shape for that matter. VB6 had a line and shape control that you could use. Thanks, Steve
18
8574
by: Ed Bitzer | last post by:
Can draw a line on my form with a button click event but cannot upon the Load event when I wish. No more line object so used the following: Dim bit As Bitmap = New Bitmap(Me.Width, Me.Height) Dim g As Graphics = Graphics.FromImage(bit) Dim myPen As Pen = New Pen(Color.Blue, 1) Me.CreateGraphics.DrawLine(myPen, 0, 5, Me.Width, 5) Appreciate some help. Ed
2
12671
by: weird0 | last post by:
I wanted to draw an ellipse using c# with System.Drawing.Graphics. I tried out several tutorials and none of them worked and there seems to be something missing. One did execute without any errors but it did not render an ellipse on the form. I want to create an ellipse with just a new project with one form default, that is Form1. I want the draw ellipse function to be in some other class,say Shapes( user-defined) and then call it in the...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.