Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: Funny location!! Pin
Muammar©5-Oct-09 10:38
Muammar©5-Oct-09 10:38 
GeneralRe: Funny location!! Pin
DaveyM695-Oct-09 10:40
professionalDaveyM695-Oct-09 10:40 
GeneralRe: Funny location!! Pin
Muammar©5-Oct-09 11:12
Muammar©5-Oct-09 11:12 
GeneralRe: Funny location!! Pin
Christian Graus5-Oct-09 12:50
protectorChristian Graus5-Oct-09 12:50 
GeneralRe: Funny location!! Pin
Muammar©5-Oct-09 23:19
Muammar©5-Oct-09 23:19 
GeneralRe: Funny location!! Pin
DaveyM695-Oct-09 12:55
professionalDaveyM695-Oct-09 12:55 
GeneralRe: Funny location!! Pin
Muammar©5-Oct-09 23:15
Muammar©5-Oct-09 23:15 
GeneralRe: Funny location!! Pin
DaveyM695-Oct-09 13:06
professionalDaveyM695-Oct-09 13:06 
This is an improved implementation that does what you want by creating a custom picture box. There's still some stuff to do, such as validating the value of LineWidth etc but should help.
C#
public class DrawablePictureBox : PictureBox
{
    private List<Rectangle> rectangles = new List<Rectangle>(100);

    public DrawablePictureBox()
    {
        LineWidth = 20;
        LineColor = Color.Red;
    }

    public int LineWidth
    {
        get;
        set;
    }
    public Color LineColor
    {
        get;
        set;
    }

    protected override void OnMouseMove(MouseEventArgs e)
    {
        base.OnMouseMove(e);
        if (e.Button == MouseButtons.Left)
        {
            Rectangle rectangle = new Rectangle(e.X - (LineWidth / 2),
                e.Y - (LineWidth / 2),
                LineWidth,
                LineWidth);
            rectangles.Add(rectangle);
            Invalidate(rectangle);
        }
    }

    protected override void OnPaint(PaintEventArgs pe)
    {
        base.OnPaint(pe);
        if (rectangles.Count > 0)
            using (Brush brush = new SolidBrush(LineColor))
            {
                foreach (Rectangle rectangle in rectangles)
                    pe.Graphics.FillEllipse(brush, rectangle);
            }
    }
}


Dave

Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: Funny location!! Pin
DaveyM695-Oct-09 13:55
professionalDaveyM695-Oct-09 13:55 
QuestionA control on the mainform doesn't update when others do Pin
teknolog1235-Oct-09 8:57
teknolog1235-Oct-09 8:57 
AnswerRe: A control on the mainform doesn't update when others do Pin
DaveyM695-Oct-09 10:33
professionalDaveyM695-Oct-09 10:33 
GeneralRe: A control on the mainform doesn't update when others do Pin
teknolog1236-Oct-09 2:45
teknolog1236-Oct-09 2:45 
GeneralRe: A control on the mainform doesn't update when others do Pin
DaveyM696-Oct-09 7:17
professionalDaveyM696-Oct-09 7:17 
GeneralRe: A control on the mainform doesn't update when others do Pin
teknolog1237-Oct-09 6:17
teknolog1237-Oct-09 6:17 
QuestionSilverlight Vertigo.Slideshow problem in C#/XAML Pin
Richard Hudson5-Oct-09 8:55
Richard Hudson5-Oct-09 8:55 
AnswerRepost to wrong forum Pin
Not Active5-Oct-09 9:43
mentorNot Active5-Oct-09 9:43 
Questionneed help with excel version problem Pin
jashimu5-Oct-09 7:53
jashimu5-Oct-09 7:53 
AnswerRe: need help with excel version problem Pin
Eddy Vluggen5-Oct-09 8:41
professionalEddy Vluggen5-Oct-09 8:41 
GeneralRe: need help with excel version problem Pin
jashimu5-Oct-09 9:13
jashimu5-Oct-09 9:13 
GeneralRe: need help with excel version problem Pin
Eddy Vluggen5-Oct-09 10:54
professionalEddy Vluggen5-Oct-09 10:54 
GeneralRe: need help with excel version problem Pin
jashimu6-Oct-09 5:28
jashimu6-Oct-09 5:28 
AnswerRe: need help with excel version problem Pin
Dave Kreskowiak5-Oct-09 8:51
mveDave Kreskowiak5-Oct-09 8:51 
Questionfind all possible combinations in a List &lt; List &lt; int &gt; &gt; [modified] Pin
cechode5-Oct-09 7:29
cechode5-Oct-09 7:29 
JokeRe: find all possible combinations in a List &lt; List &lt; int &gt; &gt; Pin
Luc Pattyn5-Oct-09 7:41
sitebuilderLuc Pattyn5-Oct-09 7:41 
GeneralRe: find all possible combinations in a List &lt; List &lt; int &gt; &gt; Pin
cechode5-Oct-09 7:58
cechode5-Oct-09 7:58 

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.