Silverlight Study Notes (1)-3.0 zoom in and out

Source: Internet
Author: User
Image. XAML

 
 
<Canvas X: Name = "layoutroot">
<Image cursor = "hand" mouseenter = "imglogo=mouseenter" canvas. zindex = "1" X: Name = "imglogo1" canvas. left = "100" canvas. top = "60" Source = "image/logo1.jpg">
<Image. rendertransform>
<Scaletransform X: Name = "logoscale" centerx = "90" centery = "96"> </scaletransform>
</Image. rendertransform>
</Image>
</Canvas> image. XAML. CS

Private system. Windows. Threading. dispatchertimer timer;
Private scaledirection;

Public page ()
{

Initializecomponent ();
Timer = new system. Windows. Threading. dispatchertimer ();
Timer. interval = timespan. frommilliseconds (50 );
Timer. Tick + = new eventhandler (timer_tick );
}

 

Void timer_tick (Object sender, eventargs E)
{
Adjustscale (scaledirection, logoscale );
}

 

Void adjustscale (scaledirection, scaletransform scale)
{
If (scaledirection = scaledirection. down)
{
If (scale. scalex <1.3)
{
Scale. scalex + = 0.05; scale. scaley + = 0.05;
}
Else
Timer. Stop ();
}
Else
{
If (scale. scalex> 1.0)
{
Scale. scalex-= 0.05; scale. scaley-= 0.05;
}
Else
Timer. Stop ();
}
}

Enum scaledirection
{
Up, down
}
Private void imglogo=mouseenter (Object sender, mouseeventargs E)
{
Scaledirection = scaledirection. down;
Timer. Start ();
}


 

Related Article

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.