View Applets in WPF

Source: Internet
Author: User

I have been working in Shenzhen for a month. I used to work in winform, but now I am working in WPF. I work overtime every day until AM, tired of me. There is also a process to learn new technologies, from the basic syntax and
Interface layout. This is a small piece of software I build.

Appreciation

On the basis of the original, a leaf fluttering effect is added.

The main code is as follows:

 1 <Canvas.Triggers> 2                 <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 3                     <BeginStoryboard> 4                         <Storyboard Storyboard.TargetName="img1" Storyboard.TargetProperty="(Canvas.Left)"> 5                             <DoubleAnimation From="0" To="514" Duration="0:0:20" RepeatBehavior="23:59:59" AutoReverse="True"/> 6                         </Storyboard> 7                     </BeginStoryboard> 8                     <BeginStoryboard Storyboard="{StaticResource StoryboardLeaf}"/> 9                 </EventTrigger>10             </Canvas.Triggers>
Baiyun mobile

Leaf float keytime = "0" value = "0" start position keytime = "0: 0" value = "20" rotation time and angle (clockwise) keytime = "" value = "0" Last
Status

1 <Storyboard x:Key="StoryboardLeaf" RepeatBehavior="Forever">2                 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)3 4 [1].(RotateTransform.Angle)" Storyboard.TargetName="bd">5                     <EasingDoubleKeyFrame KeyTime="0" Value="0"/>6                     <EasingDoubleKeyFrame KeyTime="0:0:2" Value="20"/>7                     <EasingDoubleKeyFrame KeyTime="0:0:4" Value="0"/>8                 </DoubleAnimationUsingKeyFrames>9             </Storyboard>
Float leaves
1 This. showintaskbar = false; // whether it is displayed on the taskbar
Display on the taskbar
1 timer = new dispatchertimer (); // Class 2 timer that is processed by time interval. interval = timespan. parse ("00:00:01"); // time interval of the time scale. The default value is timer. isenabled = true; 4 timer. tick + = new eventhandler (timer_tick); // dispatchertimer. occurs when the tick time interval is exceeded.
Set the interval
1 bitmapimage dayornight = new bitmapimage (); // create an image 2 dayornight. begininit (); 3 string uri = "pack: // application:,/wpftimezoneexample; component/images/"; 4 int nowhour = int32.parse (datetime. now. tostring ("hh"); 5 If (nowhour> = 6 & nowhour <= 18) 6 {7 URI ++ = "sun2.png"; 8 daymark. width = 105; 9 daymark. height = 53; 10} 11 else12 {13 URI + = "moon.png"; 14 daymark. width = 50; 15 daymark. height = 50; 16} 17 dayornight. urisource = new uri (URI); // set source 18 dayornight. endinit (); 19 daymark. source = dayornight;
Code to create an image
1         private void timer_Tick(object sender,EventArgs e)2         {3             CNT.Text = DateTime.Now.ToString("HH:mm:ss");4             UST.Text = DateTime.Now.AddHours(-12).ToString("HH:mm:ss");5             UKT.Text = DateTime.Now.AddHours(-7).ToString("HH:mm:ss");6             PRT.Text = DateTime.Now.AddHours(-6).ToString("HH:mm:ss");7             SNT.Text = DateTime.Now.AddHours(2).ToString("HH:mm:ss");8             BXT.Text = DateTime.Now.AddHours(-11).ToString("HH:mm:ss");9         }
Interval execution
1 private void grid_previewmouseleftbuttondown (Object sender, mousebuttoneventargs E) 2 {3 this. dragmove (); // drag 4}
Program drag

When the mouse is placed, the sun/moon changes

1 private void daymark_mouseenter (Object sender, mouseeventargs E) 2 {3 translatetransform trans = new translatetransform (); // transformgroup4 daymark. rendertransform = trans; // set the translation object to 5 doubleanimation animation = new doubleanimation (15, timespan. fromseconds (1); // 15 is the target value, and the last parameter is animation duration 6 animation. autoreverse = true; // whether to play 7 TRANS in reverse order. beginanimation (translatetransform. yproperty, animation); // translatet Ransform. yproperty: The property that moves along X and Y. Beginanimation application animation 8}
Mouse events

Finally, the development environment of this program: vs2013 running environment:. net4.5 source code download: browsing the applet at the time of the partition

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.