Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Ellipse Pin
Richard Andrew x6415-Oct-10 16:53
professionalRichard Andrew x6415-Oct-10 16:53 
GeneralRe: Ellipse Pin
WebMaster15-Oct-10 17:01
WebMaster15-Oct-10 17:01 
GeneralRe: Ellipse Pin
Richard Andrew x6415-Oct-10 17:03
professionalRichard Andrew x6415-Oct-10 17:03 
GeneralRe: Ellipse Pin
Richard Andrew x6415-Oct-10 17:36
professionalRichard Andrew x6415-Oct-10 17:36 
GeneralRe: Ellipse Pin
WebMaster16-Oct-10 8:24
WebMaster16-Oct-10 8:24 
AnswerRe: Ellipse Pin
Not Active16-Oct-10 8:47
mentorNot Active16-Oct-10 8:47 
GeneralRe: Ellipse Pin
WebMaster16-Oct-10 9:02
WebMaster16-Oct-10 9:02 
GeneralRe: Ellipse Pin
Lamrin17-Oct-10 0:09
Lamrin17-Oct-10 0:09 
Hi Friend!

Are you trying to draw an ellipse like this ?

public partial class Form1 : Form
   {
       Rectangle SelectionRectangle = new Rectangle();
       string SelectedShape = "None";

       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_MouseDown(object sender, MouseEventArgs e)
       {
           // If the current selected shape is 'Ellipse', then set the selection
           // rectangle's top-left position to mouse co-ordinates and set the width and
           // height to zero
           if (SelectedShape == "Ellipse")
           {
               SelectionRectangle.Width = 0;
               SelectionRectangle.Height = 0;
               SelectionRectangle.X = e.X;
               SelectionRectangle.Y = e.Y;
           }
       }

       private void Form1_MouseMove(object sender, MouseEventArgs e)
       {
           // If the mouse left button the pressed and the mouse is dragged, then capture
           // the mouse co-ordinates and resize the rectangle
           if (e.Button == MouseButtons.Left)
           {
               SelectionRectangle.Width = e.X - SelectionRectangle.Left; // EndPoint.X - StartPoint.Y;
               SelectionRectangle.Height = e.Y - SelectionRectangle.Top; // EndPoint.Y - StartPoint.Y;
               // ask Windows to redraw the form background
               Invalidate();
               Update();
           }
       }

       private void Form1_MouseUp(object sender, MouseEventArgs e)
       {
           // Capture the mouse position only if the current selected shape is 'Rectangle'
           // Else ignore
           if (SelectedShape == "Ellipse")
           {
               SelectionRectangle.Width = e.X - SelectionRectangle.Left; //EndPoint.X - StartPoint.X;
               SelectionRectangle.Height = e.Y - SelectionRectangle.Top; //EndPoint.Y - StartPoint.Y;
               Invalidate();
               Update();
           }

       }

       // Click 'Button2' to start drawing the ellipse
       private void button2_Click(object sender, EventArgs e)
       {
           SelectedShape = "Ellipse";
       }

       // Click 'Button2' to stop drawing the ellipse
       private void button1_Click(object sender, EventArgs e)
       {
           SelectedShape = "None";
       }

       private void Form1_Paint(object sender, PaintEventArgs e)
       {
           if ((SelectedShape == "Ellipse") && (SelectionRectangle != null))
           {
               Graphics g = e.Graphics;
               g.DrawEllipse(Pens.Black, SelectionRectangle);
               // If you do not want to draw the bounding rectangle, just comment out
               // the next line
               g.DrawRectangle(Pens.Gray, SelectionRectangle);
           }
       }

GeneralRe: Ellipse Pin
WebMaster17-Oct-10 7:57
WebMaster17-Oct-10 7:57 
GeneralRe: Ellipse Pin
WebMaster17-Oct-10 8:05
WebMaster17-Oct-10 8:05 
GeneralRe: Ellipse Pin
Lamrin17-Oct-10 15:46
Lamrin17-Oct-10 15:46 
GeneralRe: Ellipse Pin
WebMaster18-Oct-10 5:16
WebMaster18-Oct-10 5:16 
GeneralRe: Ellipse Pin
WebMaster20-Oct-10 8:21
WebMaster20-Oct-10 8:21 
GeneralRe: Ellipse Pin
Lamrin23-Oct-10 6:24
Lamrin23-Oct-10 6:24 
GeneralRe: Ellipse Pin
WebMaster24-Oct-10 8:10
WebMaster24-Oct-10 8:10 
GeneralRe: Ellipse Pin
Lamrin25-Oct-10 5:15
Lamrin25-Oct-10 5:15 
GeneralRe: Ellipse Pin
WebMaster25-Oct-10 9:27
WebMaster25-Oct-10 9:27 
QuestionOOB design - class fields Pin
Dell.Simmons15-Oct-10 13:41
Dell.Simmons15-Oct-10 13:41 
AnswerRe: OOB design - class fields Pin
ricmil4215-Oct-10 14:29
ricmil4215-Oct-10 14:29 
GeneralRe: OOB design - class fields Pin
Dell.Simmons15-Oct-10 14:34
Dell.Simmons15-Oct-10 14:34 
AnswerRe: OOB design - class fields Pin
Abhinav S15-Oct-10 22:25
Abhinav S15-Oct-10 22:25 
AnswerRe: OOB design - class fields Pin
Keith Barrow16-Oct-10 5:40
professionalKeith Barrow16-Oct-10 5:40 
AnswerRe: OOB design - class fields Pin
Nish Nishant16-Oct-10 6:27
sitebuilderNish Nishant16-Oct-10 6:27 
AnswerRe: OOB design - class fields Pin
Paul Michalik17-Oct-10 0:45
Paul Michalik17-Oct-10 0:45 
QuestionRead the 'raw' FileVersion and ProductVersion values from a file's version resource. Pin
Blake Miller15-Oct-10 13:02
Blake Miller15-Oct-10 13:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.