473,702 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw Line Over Pie Using GDI+


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
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)),
e.Graphics.Draw Line(Pens.Black , New PointF(cx, cy), New PointF(xMiddle,
End Sub
Private Sub Form1_Resize(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Resize
End Sub
End Class
*************** ************ CODE *************** ************
Nov 21 '05 #1
0 1066

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

Similar topics

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...
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
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
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
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
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
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
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
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...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.