Drawing a rectangle with a mouse.........

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • A2K
    New Member
    • Mar 2007
    • 3

    Drawing a rectangle with a mouse.........

    Hi,

    I have made an applicationa in C#(VS 2005), which allows the user to plot and zoom a graph.

    while zooming, the user drags the mouse to specify a rectangular area, which is then magnified.

    I would like to show this rectangle actually being created.

    The problem is, the apllication creates a rectangle with every drag of the mouse,
    thereby creating nearly 100-200 rectangles. I want only the last rectangle to be visible and erase the previos rectangles.


    Any help is appreciated.
    Thnx.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    This is an advanced topic and we will need to see your rectangle drawing code. I suspect you will be detecting a mouse LBUTTONDOWN event and then starting to draw your rectangle from the X,Y coords of that point. But I would need to see that block of your code to tell you what is going on.

    Comment

    • A2K
      New Member
      • Mar 2007
      • 3

      #3
      Hi,
      I got the solution for it from the net.

      The DrawReversibleF rame method automatically erases the previous rectangles.

      ControlPaint.Dr awReversibleFra me(thisform.Rec tangleToScreen( SelectRect), Color.Black, FrameStyle.Dash ed);

      If it could help you, I can send you the complete code.

      bye.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        No need I was just curious.

        Comment

        • mallyajiggs
          New Member
          • Aug 2006
          • 5

          #5
          On Similar Grounds... i am drawing a rectangle ..with mouse dynamically using mouse events ..

          I want it to display the rectangle as i draw it .. something like in paint/ photoshop !! how do i do it ..>!!


          thnx ;)

          Comment

          • dotnetmaster
            New Member
            • Jan 2008
            • 1

            #6
            Originally posted by mallyajiggs
            On Similar Grounds... i am drawing a rectangle ..with mouse dynamically using mouse events ..

            I want it to display the rectangle as i draw it .. something like in paint/ photoshop !! how do i do it ..>!!


            thnx ;)


            Hi friend, i m working on the GIS using .Net platform.
            I like to do zoom on image by using rectangle zoom.

            so please if u have code for the same, please reply me.

            thanx

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Originally posted by dotnetmaster
              Hi friend, i m working on the GIS using .Net platform.
              I like to do zoom on image by using rectangle zoom.

              so please if u have code for the same, please reply me.

              thanx
              Using the above posts as references, you should be able to figure out how to draw the "rectangles ".
              Once you have the rectangle, you can use Bitmap's CreateThumbnail () function to create a thumbnail with the coordinates of the rectangle.
              You would then set that thumbnail image back to the picture displaying control and setting it's mode to stretch.

              Comment

              Working...