自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Windows Phone開發(fā)中時(shí)鐘案例解析

移動(dòng)開發(fā)
Windows Phone開發(fā)有很多值得學(xué)習(xí)的地方,本文向大家簡單介紹一下Windows Phone開發(fā)中一個(gè)時(shí)鐘的例子,希望對你的學(xué)習(xí)有所幫助。

本文和大家重點(diǎn)討論一下Windows Phone開發(fā)中一個(gè)時(shí)鐘的例子,Expressblend工具是開發(fā)silverlightUi的重要工具,在這里有一個(gè)從silverlight移植過來的時(shí)鐘小例子可以看出在Phone7上這個(gè)工具一樣也很重要并且可以提高開發(fā)效率。

Windows Phone開發(fā)中一個(gè)時(shí)鐘的例子

Expressblend工具是開發(fā)silverlightUi的重要工具,在這里有一個(gè)從silverlight移植過來的時(shí)鐘小例子可以看出Windows Phone開發(fā)中在Phone7上這個(gè)工具一樣也很重要并且可以提高開發(fā)效率。

一.在blend工具中,可以用Ellipse繪制表盤,通過在property中使用漸變色來產(chǎn)生立體效果。還可以能過gradient工具來調(diào)整漸變色。

 

 

 

 

 

 

二.用Ellipse工具繪制表針軸,并設(shè)置圓的strokethickness來改變線的粗細(xì)。

 

 

三.用Rectangle工具來繪制三個(gè)表針,并放好位置。

 

 

四.增加動(dòng)畫效果

  1. <Storyboardx:NameStoryboardx:Name="clockStoryboard"> 
  2. <!--Thisanimationtargetsthehourhandtransform--> 
  3. <DoubleAnimationx:NameDoubleAnimationx:Name="hourAnimation" 
  4. Storyboard.TargetName="HourHandTransform" 
  5. Storyboard.TargetProperty="Angle" 
  6. Duration="12:0:0"RepeatBehavior="Forever"To="360"/> 
  7.  
  8. <!--Thisanimationtargetstheminutehandtransform--> 
  9. <DoubleAnimationx:NameDoubleAnimationx:Name="minuteAnimation" 
  10. Storyboard.TargetName="MinuteHandTransform" 
  11. Storyboard.TargetProperty="Angle" 
  12. Duration="1:0:0"RepeatBehavior="Forever"To="360"/> 
  13.  
  14. <!--Thisanimationtargetsthesecondhandtransform--> 
  15. <DoubleAnimationx:NameDoubleAnimationx:Name="secondAnimation" 
  16. Storyboard.TargetName="SecondHandTransform" 
  17. Storyboard.TargetProperty="Angle" 
  18. Duration="0:1:0"RepeatBehavior="Forever"To="360"/> 
  19. </Storyboard> 
  20.  

 

Windows Phone開發(fā)中這時(shí)運(yùn)行一下此程序,已經(jīng)可以看到時(shí)鐘的表針在走了。

五.控制表針行為語句

  1. voidMainPage_Loaded(objectsender,RoutedEventArgse)  
  2. {  
  3. //Thecurrentdateandtime.  
  4. System.DateTimecurrentDate=DateTime.Now;  
  5.  
  6. //Findtheappropriateangle(indegrees)forthehourhand  
  7. //basedonthecurrenttime.  
  8. doublehourangle=(((float)currentDate.Hour)/12)*360+currentDate.Minute/2;  
  9.  
  10. //Thesameasfortheminuteangle.  
  11. doubleminangle=(((float)currentDate.Minute)/60)*360;  
  12.  
  13. //Thesameforthesecondangle.  
  14. doublesecangle=(((float)currentDate.Second)/60)*360;  
  15.  
  16. //Setthebeginningoftheanimation(Fromproperty)totheangle  
  17. //correspongingtothecurrenttime.  
  18. hourAnimation.From=hourangle;  
  19.  
  20. //Settheendoftheanimation(Toproperty)totheangle  
  21. //correspondingtothecurrenttimePLUS360degrees.Thus,the  
  22. //animationwillendaftertheclockhandmovesaroundtheclock  
  23. //once.Note:TheRepeatBehaviorpropertyoftheanimationisset  
  24. //to"orever"sotheanimationwillbeginagainassoonasitcompletes.  
  25. hourAnimation.To=hourangle+360;  
  26.  
  27. //Sameaswiththehouranimation.  
  28. minuteAnimation.From=minangle;  
  29. minuteAnimation.To=minangle+360;  
  30.  
  31. //Sameaswiththehouranimation.  
  32. secondAnimation.From=secangle;  
  33. secondAnimation.To=secangle+360;  
  34.  
  35. this.clockStoryboard.Begin();  
  36. }  
  37.  

 

源代碼:

/Files/randylee/MyClock.rar

責(zé)任編輯:佚名 來源: cnblogs.com
相關(guān)推薦

2010-05-11 16:47:32

Windows Pho

2010-06-11 16:01:26

Windows Pho

2010-05-08 16:36:16

Windows Pho

2010-03-09 10:51:15

Windows Pho

2010-04-08 17:40:23

Windows Pho

2010-06-09 16:13:23

Windows Pho

2013-07-30 10:44:31

Windows PhoWindows Pho

2013-07-30 12:37:56

Windows PhoWindows Pho

2010-04-21 17:07:54

Windows Pho

2012-05-08 13:54:40

ToastPrompt

2012-05-25 09:09:25

Windows Pho

2010-07-21 15:46:25

Windows Pho

2011-06-07 12:42:15

Windows Pho

2013-04-17 14:00:06

Windows PhoWindows Pho

2013-04-16 17:02:50

Windows Pho概論

2013-04-19 16:34:56

Windows PhoWindows Pho

2013-07-30 11:18:37

Windows PhoWindows Pho

2010-11-01 14:49:20

Windows PhoWindows Pho

2010-12-21 10:02:48

SilverlightWindows Pho

2010-06-21 15:39:59

Windows Pho
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號