Click here to Skip to main content
15,893,508 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem using Process.Start("notepad.exe") ... Process (notepad) is launched with no appearance of notepad! Pin
fulbright16-Dec-08 18:06
fulbright16-Dec-08 18:06 
GeneralRe: Problem using Process.Start("notepad.exe") ... Process (notepad) is launched with no appearance of notepad! Pin
Dave Kreskowiak17-Dec-08 2:06
mveDave Kreskowiak17-Dec-08 2:06 
QuestionDetecting a USB drive arrival/removal, whose Drive Letter has been removed Pin
G. Myers16-Dec-08 11:19
G. Myers16-Dec-08 11:19 
QuestionClass inference Pin
DwR16-Dec-08 9:28
DwR16-Dec-08 9:28 
AnswerRe: Class inference Pin
Christian Graus16-Dec-08 10:00
protectorChristian Graus16-Dec-08 10:00 
AnswerRe: Class inference Pin
Wendelius16-Dec-08 11:47
mentorWendelius16-Dec-08 11:47 
AnswerRe: Class inference Pin
Chamadness16-Dec-08 20:53
Chamadness16-Dec-08 20:53 
QuestionProblem drawing shapes when form is clicked Pin
SilentCodingOne16-Dec-08 8:42
SilentCodingOne16-Dec-08 8:42 
I'm working on some homework and need to create an application that draws 3 shapes when the form is clicked. The objects are suppose to be drawn on specified surface area within the form. I have the surface area being created but cannot seem to get a shape to be drawn onto it when clicked. I'm thinking that there is a problem with my event handling of the mouse click but I cannot seem to figure out how to fix it. I have included my code and would appreciate any help or direction that you guys could provide me.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace William_Cappoli_IT466_Unit_6_Project
{
    public partial class frmMain : Form
    {
        private DrawImage imgDraw;

       public frmMain()
        {
            imgDraw = new DrawImage();

            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs paintEvnt)
        {
            // Get the graphics object
            Graphics gfx = paintEvnt.Graphics;
            // calls draw method from DrawImage class and passes it the graphics object
            imgDraw.DrawBoundingBox(gfx);
        }
        
        private void frmMain_Click(PaintEventArgs e)
        {
            Graphics imgObj = e.Graphics;
            imgDraw.Draw(imgObj);

        }

    } // end partial class frmMain class
}


using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;

    class DrawImage
    {
        // private members that determine where drawing surface starts, how big it is and the color of it
        private float xCoordinate = 0;
        private float yCoordinate = 60;
        private float width = 521;
        private float height = 560;
        private Color backcolor = Color.White;

        // creates surface for drawing objects onto
        public void DrawBoundingBox(Graphics g)
        {
            // Create a new pen that we shall use for drawing the line
            Pen myPen = new Pen(Color.Black);
            SolidBrush myBrush = new SolidBrush(backcolor);

            g.DrawRectangle(myPen, xCoordinate, yCoordinate, width, height);
            g.FillRectangle(myBrush, xCoordinate, yCoordinate, width, height);


        } // end DrawBoundingBox method

        // draws rectangle when form is clicked
        public void Draw(Graphics o)
        {
            Pen imgPen = new Pen(Color.Black);
            o.DrawRectangle(imgPen, 90, 100, 45, 75);
        }

    } //  end DrawImage class


Thanks in advance
AnswerRe: Problem drawing shapes when form is clicked Pin
Christian Graus16-Dec-08 8:51
protectorChristian Graus16-Dec-08 8:51 
GeneralRe: Problem drawing shapes when form is clicked Pin
SilentCodingOne16-Dec-08 10:28
SilentCodingOne16-Dec-08 10:28 
GeneralRe: Problem drawing shapes when form is clicked Pin
Christian Graus16-Dec-08 12:55
protectorChristian Graus16-Dec-08 12:55 
QuestionThread.Sleep and WebBrowser... Okay to use together? Pin
Matthew Klein16-Dec-08 8:36
Matthew Klein16-Dec-08 8:36 
AnswerRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
Christian Graus16-Dec-08 8:52
protectorChristian Graus16-Dec-08 8:52 
GeneralRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
Matthew Klein16-Dec-08 11:48
Matthew Klein16-Dec-08 11:48 
GeneralRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
User 665816-Dec-08 11:57
User 665816-Dec-08 11:57 
GeneralRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
Christian Graus16-Dec-08 13:14
protectorChristian Graus16-Dec-08 13:14 
GeneralRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
Expert Coming16-Dec-08 16:26
Expert Coming16-Dec-08 16:26 
GeneralRe: Thread.Sleep and WebBrowser... Okay to use together? Pin
Christian Graus16-Dec-08 17:16
protectorChristian Graus16-Dec-08 17:16 
Questiontextbox validation Pin
Zeyad Jalil16-Dec-08 6:20
professionalZeyad Jalil16-Dec-08 6:20 
AnswerRe: textbox validation Pin
EliottA16-Dec-08 6:33
EliottA16-Dec-08 6:33 
AnswerRe: textbox validation Pin
Lev Danielyan16-Dec-08 6:52
Lev Danielyan16-Dec-08 6:52 
AnswerRe: textbox validation Pin
programmervb.netc++16-Dec-08 12:59
programmervb.netc++16-Dec-08 12:59 
AnswerRe: textbox validation Pin
DaveyM6916-Dec-08 13:35
professionalDaveyM6916-Dec-08 13:35 
QuestionWhere are the files?? Pin
Muammar©16-Dec-08 6:10
Muammar©16-Dec-08 6:10 
GeneralRe: Where are the files?? Pin
Luc Pattyn16-Dec-08 6:37
sitebuilderLuc Pattyn16-Dec-08 6:37 

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.