C # winfrom Magnifier feature

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 usingSystem.Threading;Ten  One namespaceTest A { -      Public Partial classForm2:form -     { the         Private BOOLBlisdrawrectangle =true; -         PrivatePoint Ptbegin =NewPoint (); - Thread Thdraw; -         Delegate voidMydrawrectangel (); + Mydrawrectangel Mydraw; -          PublicForm2 () +         { A InitializeComponent (); at         } -  -         Private voidPicturebox1_paint (Objectsender, PaintEventArgs e) -         { -             if(Blisdrawrectangle) -             { inE.graphics.drawrectangle (NewPen (Brushes.black,1), ptbegin.x, PTBEGIN.Y, -, -); -             } to         } +  -         Private voidForm2_load (Objectsender, EventArgs e) the         { *Mydraw =NewMydrawrectangel (showdrawrectangle); $Thdraw =NewThread (Run);Panax Notoginseng Thdraw.start (); -         } the         Private voidRun () +         { A              while(true) the             { +                 if(pictureBox1.Image! =NULL) -                 { $                      This. BeginInvoke (Mydraw); $                 } -Thread.Sleep ( -); -             } the         } -         Private voidShowdrawrectangle ()Wuyi         { theRectangle rec =NewRectangle (ptbegin.x * pictureBox1.Image.Size.Width/460, -PTBEGIN.Y * PictureBox1.Image.Size.Height/ -, -* PictureBox1.Image.Size.Width/460, Wu                  -* PictureBox1.Image.Size.Height/ -); -Graphics g =picturebox2.creategraphics (); About g.drawimage (pictureBox1.Image, Picturebox2.clientrectangle, REC, graphicsunit.pixel); $ G.flush (); -         } -  -         Private voidPicturebox1_mouseleave (Objectsender, EventArgs e) A         { +Blisdrawrectangle =false; the Picturebox1.refresh (); -         } $  the         Private voidPicturebox1_mouseenter (Objectsender, EventArgs e) the         { theBlisdrawrectangle =true; the         } -  in         Private voidPicturebox1_mousemove (Objectsender, MouseEventArgs e) the         { the             if(E.x- -<=0) About             { thePtbegin.x =0; the             } the             Else if(Picturebox1.size.width-e.x <= -) +             { -ptbegin.x = PictureBox1.Size.Width- -; the             }Bayi             Else the             { theptbegin.x = e.x- -; -             } -  the             if(E.y- -<=0) the             { thePTBEGIN.Y =0; the             } -             Else if(picturebox1.size.height-e.y<= -) the             { thePTBEGIN.Y = PictureBox1.Size.Height- -; the             }94             Else the             { thePTBEGIN.Y = e.y- -; the             }98 Picturebox1.refresh (); About         } -     }101}
View Code

C # winfrom Magnifier feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.