和之前一樣首先看一下WPF鐘表效果圖
發(fā)展壯大離不開(kāi)廣大客戶長(zhǎng)期以來(lái)的信賴與支持,我們將始終秉承“誠(chéng)信為本、服務(wù)至上”的服務(wù)理念,堅(jiān)持“二合一”的優(yōu)良服務(wù)模式,真誠(chéng)服務(wù)每家企業(yè),認(rèn)真做好每個(gè)細(xì)節(jié),不斷完善自我,成就企業(yè),實(shí)現(xiàn)共贏。行業(yè)涉及鑿毛機(jī)等,在重慶網(wǎng)站建設(shè)公司、營(yíng)銷型網(wǎng)站、WAP手機(jī)網(wǎng)站、VI設(shè)計(jì)、軟件開(kāi)發(fā)等項(xiàng)目上具有豐富的設(shè)計(jì)經(jīng)驗(yàn)。
是不是很炫酷,上面的那個(gè)花都是帶有動(dòng)畫(huà)效果的圖片 。
接下來(lái)就是代碼了。
首先看一下整個(gè)場(chǎng)景的布局搭建
<Window x:Class="QQDemo1.DateTimew" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="DateTimew" Height="700" Width="800" Loaded="Window_Loaded" Name="datatime"> <Window.Resources> <Storyboard x:Key="zhuanRote"> <DoubleAnimation RepeatBehavior="Forever" From="0" To="360" Duration="1:0:0" Storyboard.TargetName="fenImg" Storyboard.TargetProperty="RenderTransform.Angle"></DoubleAnimation> <DoubleAnimation RepeatBehavior="Forever" From="0" To="360" Duration="0:1:0" Storyboard.TargetName="xiaoshiImg" Storyboard.TargetProperty="RenderTransform.Angle"></DoubleAnimation> <DoubleAnimation RepeatBehavior="Forever" From="0" To="360" Duration="0:0:5" Storyboard.TargetName="zhImg" Storyboard.TargetProperty="RenderTransform.Angle"></DoubleAnimation> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="huaImg" RepeatBehavior="Forever" Storyboard.TargetProperty="RenderTransform.Angle"> <EasingDoubleKeyFrame Value="10" KeyTime="0:0:2"></EasingDoubleKeyFrame> <EasingDoubleKeyFrame Value="30" KeyTime="0:0:4"></EasingDoubleKeyFrame> <EasingDoubleKeyFrame Value="0" KeyTime="0:0:6"></EasingDoubleKeyFrame> <EasingDoubleKeyFrame Value="-10" KeyTime="0:0:8"></EasingDoubleKeyFrame> <EasingDoubleKeyFrame Value="-30" KeyTime="0:0:10"></EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Window.Triggers> <EventTrigger RoutedEvent="Loaded"> <BeginStoryboard Storyboard="{StaticResource zhuanRote}"></BeginStoryboard> </EventTrigger> </Window.Triggers> <Canvas> <Button Width="40" Height="20" Margin="560,113" Panel.ZIndex="1" Background="#72532E" Foreground="White" Content="Min" FontWeight="SemiBold" Click="Button_Click"></Button> <Button Width="40" Height="20" Margin="610,113" Panel.ZIndex="1" Background="#72532E" Foreground="White" Content="Tchu" FontWeight="SemiBold" Click="Button_Click_1"></Button> <Border Width="529" Height="330" Margin="145,138" Background="#FAC178"></Border> <Label Width="236" Height="40" Margin="480,150" Name="time" FontSize="24" Canvas.Left="-66"></Label> <Image Width="120" Height="140" RenderTransformOrigin="0.5,0.5" Name="huaImg" Margin="510,200" Source="/QQDemo1;component/TimeImage/2224.png"> <Image.RenderTransform> <RotateTransform></RotateTransform> </Image.RenderTransform> </Image> <Image Width="90" Name="fenImg" Height="40" RenderTransformOrigin="0,0.8" Margin="251,306" Source="/QQDemo1;component/TimeImage/wwww.png"> <Image.RenderTransform> <RotateTransform></RotateTransform> </Image.RenderTransform> </Image> <Image Name="xiaoshiImg" Width="48" Height="134" Margin="300,242" RenderTransformOrigin="0.5,0.8" Source="/QQDemo1;component/TimeImage/www.png" Canvas.Top="-26"> <Image.RenderTransform> <RotateTransform></RotateTransform> </Image.RenderTransform> </Image> <Image Width="867" Height="700" Source="/QQDemo1;component/TimeImage/3.png"></Image> <Image Width="30" Height="30" Margin="300,160" Source="TimeImage/11.png"></Image> <Image Width="30" Height="30" Margin="314,160" Source="TimeImage/12.png"></Image> <Image Name="zhImg" RenderTransformOrigin="0.5,0.5" Width="376" Margin="0,0" Height="356" Source="TimeImage/22230.png" Canvas.Left="-59" Canvas.Top="-44"> <Image.RenderTransform> <RotateTransform></RotateTransform> </Image.RenderTransform> </Image> <Image Width="30" Height="30" Margin="310,430" Source="TimeImage/16.png"></Image> <Image Width="30" Height="30" Margin="430,305" Source="TimeImage/13.png"></Image> <Image Width="30" Height="30" Margin="180,305" Source="TimeImage/19.png"></Image> <Image Width="30" Height="30" Margin="390,200" Source="TimeImage/11.png" Canvas.Left="-10" Canvas.Top="-12"></Image> <Image Width="30" Height="30" Margin="420,255" Source="TimeImage/12.png" Canvas.Left="-6" Canvas.Top="-14" ImageFailed="Image_ImageFailed"></Image> <Image Width="30" Height="30" Margin="380,190" Source="TimeImage/14.png" Canvas.Left="34" Canvas.Top="174"></Image> <Image Width="30" Height="30" Margin="390,190" Source="TimeImage/15.png" Canvas.Left="-10" Canvas.Top="216"></Image> <Image Width="30" Height="30" Margin="390,190" Source="TimeImage/17.png" Canvas.Left="-148" Canvas.Top="216"></Image> <Image Width="30" Height="30" Margin="400,190" Source="TimeImage/18.png" Canvas.Left="-193" Canvas.Top="174"></Image> <Image Width="30" Height="30" Margin="400,200" Source="TimeImage/10.png" Canvas.Left="-193" Canvas.Top="41"></Image> <Image Width="30" Height="30" Margin="400,200" Source="TimeImage/11.png" Canvas.Left="-208" Canvas.Top="41"></Image> <Image Width="30" Height="30" Margin="370,200" Source="TimeImage/11.png" Canvas.Left="-148" Canvas.Top="-12"></Image> <Image Width="30" Height="30" Margin="320,160" Source="TimeImage/11.png" Canvas.Left="-84" Canvas.Top="28"></Image> </Canvas> </Window>
場(chǎng)景的搭建比較死板,沒(méi)有用代碼去創(chuàng)建整個(gè)場(chǎng)景,位置都是自己一個(gè)一個(gè)的慢慢的擺放的比較隨意。
下面就是程序的代碼了。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Timers; using System.Windows.Navigation; using System.Windows.Threading; namespace QQDemo1 { /// <summary> /// DateTime.xaml 的交互邏輯 /// </summary> public partial class DateTimew : Window { public DateTimew() { DispatcherTimer timer = new DispatcherTimer(); //時(shí)間相當(dāng)于Timer timer.Tick += new EventHandler(timer_Tick); //timer.Interval = TimeSpan.FromSeconds(0.1); timer.Start(); InitializeComponent(); this.datatime.WindowStyle = System.Windows.WindowStyle.None; //this.datatime.WindowState = System.Windows.WindowState.Normal; this.datatime.AllowsTransparency = true;//透明 this.Background = Brushes.Transparent;//背景透明5 this.datatime.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; //this.time.Content = ; // DateTime d = new DateTime(); // this.xiaoshiImg.RenderTransformOrigin = new Point(0.85,0.85); } void timer_Tick(object sender, EventArgs e) { this.time.Content = DateTime.Now.ToString(); //Tick 事件 } private void Window_Loaded(object sender, RoutedEventArgs e) { } private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e) { } private void Button_Click(object sender, RoutedEventArgs e) { this.WindowState = System.Windows.WindowState.Minimized; } private void Button_Click_1(object sender, RoutedEventArgs e) { this.Close(); } } }
這個(gè)動(dòng)畫(huà)的實(shí)現(xiàn)實(shí)在場(chǎng)景里面去實(shí)現(xiàn)的。下一節(jié),會(huì)說(shuō)到在代碼里面如何去控制整個(gè)動(dòng)畫(huà)的實(shí)現(xiàn)!
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
新聞標(biāo)題:WPF實(shí)現(xiàn)鐘表效果
標(biāo)題URL:http://chinadenli.net/article0/ppscoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站收錄、全網(wǎng)營(yíng)銷推廣、建站公司、軟件開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)