drawing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bad_Kid

    #1

    drawing

    How to make this:

    I have a panel and I draw something on it (some lines, a complex
    function...).
    I want this:
    When I move mouse over that panel to draw a vertical line from top of the
    panel to panel.height on the X position of the mouse? While I'm moving a
    mouse over a panel that vertical line is moving too aloong with the mouse
    cursor.
    Do I have to redraw a whole panel for every mouse movement??? That's not a
    good idea, ist' VERY slow...

    any suggestions, PLEASE??
    thanks!


  • dmdevel

    #2
    Re: drawing

    I have a few ideas, but am not totally sure if it will help solve your
    problem...

    First suggestion: By calling the Panel's Invalidate method, you can
    specificy the region that needs to be repainted via the use of the
    Rectangle Struct. This should only redraw part of the Panel rather
    than the entire thing.

    Another option is to set the style used on the Form. When I've had to
    do quick animations in .NET without using DirectX, I've managed to
    solve a lot of my problems with this approach (it can get rid of
    annoying flickering that can happen when your drawing requires a lot of
    repainting/refreshing).

    Here's a link to what MSDN has to say about it:

    http://msdn.microsoft.com/library/de...classtopic.asp

    Here's the bit of code that I found to be the most useful when dealing
    with any sort of animation:

    public class Form1: System.Windows. Forms.Form
    {
    public Form1()
    {
    SetStyle( ControlStyles.U serPaint, true );
    SetStyle( ControlStyles.A llPaintingInWmP aint, true );
    SetStyle( ControlStyles.D oubleBuffer, true );
    }
    }

    These SetStyle calls (all three of these together) will turn on double
    buffering for your form and should make things run a bit faster.

    Hope this helps...

    -- Dan

    Comment

    • Piotr Dobrowolski

      #3
      Re: drawing

      Dnia 19-02-2006 o 18:18:02 Bad_Kid <REMOVEzlocesto _dijete@yahoo.c o.uk>
      napisa³:
      [color=blue]
      > How to make this:
      >
      > I have a panel and I draw something on it (some lines, a complex
      > function...).
      > I want this:
      > When I move mouse over that panel to draw a vertical line from top of the
      > panel to panel.height on the X position of the mouse? While I'm moving a
      > mouse over a panel that vertical line is moving too aloong with the mouse
      > cursor.
      > Do I have to redraw a whole panel for every mouse movement??? That's not
      > a
      > good idea, ist' VERY slow...
      >
      > any suggestions, PLEASE??
      > thanks!
      >[/color]
      [PD] You can invalidate only parts of the control when you move the mouse.
      Look at the different overloads of the Control.Invalid ate method.



      --
      Piotr Dobrowolski
      Piotr.Dobrowols ki@_usun_gmail. com

      Comment

      Working...