内容へ移動
ユーザ用ツール
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
現在位置:
home
»
wiki
»
Windows Phone
»
7.1
»
Tips
»
009 タイマー処理
トレース:
wiki:windowsphone:7.1:tips:009
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== 009 タイマー処理 ====== {{:wiki:windowsphone:7.1:tips:w_phone_009_001.png?200|}} ===== 概要 ===== タイマーによるイメージの移動アニメーションを行います。 ==== MainPage.xaml ==== <code xml> <phone:PhoneApplicationPage x:Class="BaseApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True"> <!--LayoutRoot is the root grid where all page content is placed--> <Canvas x:Name="LayoutRoot" Background="Black"/> </phone:PhoneApplicationPage> </code> ==== MainPage.xaml.cs ==== <code csharp> using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Windows.Threading; using Microsoft.Phone.Controls; namespace BaseApp { // エントリーポイント public partial class MainPage : PhoneApplicationPage { private const int BASE_POS_X = 480 / 2; private const int BASE_POS_Y = 768 / 2; private Image image0 = null; private double radian = 0.0f; // コンストラクタ public MainPage() { // コンポーネントの初期化。 InitializeComponent(); // 初期化完了後に呼ばれるメソッドの登録。 Loaded += OnLoaded; } // 初期化完了後に呼ばれるメソッド。 void OnLoaded(object sender, RoutedEventArgs args) { // イメージを表示する。 { image0 = new Image(); image0.Source = new BitmapImage(new Uri("sample.png", UriKind.RelativeOrAbsolute)); Canvas.SetLeft(image0, BASE_POS_X - 64 ); Canvas.SetTop(image0, BASE_POS_Y - 64 ); LayoutRoot.Children.Add(image0); } // タイマーの生成と開始。 DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 17); timer.Tick += new EventHandler(OnTimerTick); timer.Start(); } // タイマーによる更新処理。 private void OnTimerTick(object sender, EventArgs e) { int px = BASE_POS_X - 64; int py = BASE_POS_Y + (int)(200.0f * Math.Sin(radian)); radian += 0.04f; Canvas.SetLeft(image0, px); Canvas.SetTop(image0, py); } } } </code>
Permalink
wiki/windowsphone/7.1/tips/009.txt
· 最終更新: 2014/11/08 03:24 (外部編集)
ページ用ツール
ログイン
文書の表示
文書の先頭へ
印刷
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
oeffentlich