1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

moving the panel inside a form (like photoshop hand tool)

Discussion in 'C#' started by Mr.President, Oct 26, 2010.

  1. Mr.President

    Mr.President New Member

    Joined:
    Apr 25, 2010
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    0
    Code:
            int x;
            int y;
            private void panel1_MouseMove(object sender, MouseEventArgs e)
            {
                    if (e.Button == MouseButtons.Left) 
                    {
                           panel1.Top += (e.Y - y); 
                           panel1.Left += (e.X - x);
                         } 
            }
    
            private void panel1_MouseDown(object sender, MouseEventArgs e)
            {
                     if (e.Button == MouseButtons.Left)
                    {
                           x = e.X;
                           y = e.Y;
                    }
            }
    
    

    I have added a picture in the panel and now its like google maps the panel is moving but the problem is it isn't smooth !

    when I move vertically no problem panel moves smoothly, horizontally also ok
    but wen it comes 2 angle wise move I mean 45 degree move the panel flikers it vibrates

    pls advice me on how to make this ryt i mean how to move smoothly ?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    The best way to solve this is not to move the entire picture but just the outline.
     
  3. Mr.President

    Mr.President New Member

    Joined:
    Apr 25, 2010
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    0
    i din get u ?
    do u mean I hav to drag only the border of the pictue ?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83

Share This Page